MuxWrapper.LiveStreams (Mux Wrapper v0.1.1) View Source
Provides a wrapper of live streaming to manipulate Mux API
Link to this section Summary
Functions
Provide a function to singal a live stream finished
Provide a function to send a create a live streming to Mux
Provide a function to create a praivate playback id in Mux
Provide a function to create simulcast target, strongly suggest read Mux doc first
Provide a function to delete a live stream
Provide a function to delete specfic playback asset from Mux
Provide a function to delete simulcast targets
Provide a function to disable a live stream
Provide a function to enable a live stream
Provide a function to get a specific live streaming from Mux
Provide a function to get simulcast target, strongly suggest read Mux doc first
Provide a function to list all live streams in Mux, support pagnation see Mux doc
Provide a function to reset stream key
Link to this section Functions
Specs
complete_live_stream( %Tesla.Client{adapter: term(), fun: term(), post: term(), pre: term()}, String.t() ) :: atom()
Provide a function to singal a live stream finished
Parameters
- client: provide by
client/0
- live_stream_id: live stream id
Examples
iex> MuxWrapper.client() |> MuxWrapper.LiveStreams.complete_live_stream("live_stream_id_very_long")
:ok
Specs
create_live_stream(%Tesla.Client{ adapter: term(), fun: term(), post: term(), pre: term() }) :: %MuxWrapper.EmbeddedSchema.LiveStream{ created_at: term(), id: term(), new_asset_settings: term(), playback_ids: term(), reconnect_window: term(), status: term(), stream_key: term() }
Provide a function to send a create a live streming to Mux
Parameters
- client: provide by
MuxWrapper.client/0
Examples
iex> MuxWrapper.client() |> MuxWrapper.LiveStreams.create_live_stream()
%MuxWrapper.EmbeddedSchema.LiveStream{
created_at: ~N[2021-03-16 09:59:26],
id: "livestream_id_very_long",
new_asset_settings: %{"playback_policies" => ["public"]},
playback_ids: [
%MuxWrapper.EmbeddedSchema.Playback{
id: "playback_id_very_long",
policy: "public"
}
],
reconnect_window: 60,
status: "idle",
stream_key: "stream_key_very_long"
}
Specs
create_playback_id( %Tesla.Client{adapter: term(), fun: term(), post: term(), pre: term()}, String.t(), atom() ) :: %MuxWrapper.EmbeddedSchema.Playback{id: term(), policy: term()}
Provide a function to create a praivate playback id in Mux
## Parameters
- client: provide by
client/0
- live_stream_id: live stream id
- pramas - provide by
MuxWrapper.EmbeddedSchema.Playback.policy_public/0
orMuxWrapper.EmbeddedSchema.Playback.policy_private/0
## Example
iex> client = MuxWrapper.client()
%Tesla.Client{
adapter: nil,
fun: nil,
post: [],
pre: [
{Tesla.Middleware.BaseUrl, :call, ["https://api.mux.com"]},
{Tesla.Middleware.BasicAuth, :call,
[
%{
password: "your_password",
username: "your_username"
}
]}
]
}
iex> MuxWrapper.LiveStreams.create_playback_id(client, "stream_id_very_long", :signed)
%MuxWrapper.EmbeddedSchema.Playback{
id: "FRDDXsjcNgD013rx1M4CDunZ86xkq8A02hfF3b6XAa7iE",
policy: "singed"
}
Specs
create_simulcast_target( %Tesla.Client{adapter: term(), fun: term(), post: term(), pre: term()}, String.t(), %MuxWrapper.EmbeddedSchema.Simulcast{ id: term(), passthrough: term(), stream_key: term(), url: term() } ) :: %MuxWrapper.EmbeddedSchema.Simulcast{ id: term(), passthrough: term(), stream_key: term(), url: term() }
Provide a function to create simulcast target, strongly suggest read Mux doc first
Parameters
- client: provide by
client/0
- live_stream_id: live stream id
- params: request body,
MuxWrapper.EmbeddedSchema.Simulcast
Example
iex> params = %MuxWrapper.EmbeddedSchema.Simulcast{url: "rtmp://live.example.com/app", stream_key: "abcdefgh"}
%MuxWrapper.EmbeddedSchema.Simulcast{
id: nil,
passthrough: nil,
stream_key: "abcdefgh",
url: "rtmp://live.example.com/app"
}
iex> MuxWrapper.clinet() |> MuxWrapper.LiveStreams.create_simulcast_target("live_stream_id_very_long", params)
%MuxWrapper.EmbeddedSchema.Simulcast{
id: "vuOfW021mz5QA500wYEQ9SeUYvuYnpFz011mqSvski5T8claN02JN9ve2g",
passthrough: "Example 1",
stream_key: "abcdefgh",
url: "rtmp://live.example1.com/app"
}
Specs
delete_live_stream( %Tesla.Client{adapter: term(), fun: term(), post: term(), pre: term()}, String.t() ) :: atom()
Provide a function to delete a live stream
Parameters
- client: provide by
client/0
- live_stream_id: live stream id
Examples
iex> MuxWrapper.client |> MuxWrapper.LiveStreams.delete_live_stream("live_stream_id_very_long")
:ok
Specs
delete_playback_id( %Tesla.Client{adapter: term(), fun: term(), post: term(), pre: term()}, String.t(), String.t() ) :: atom()
Provide a function to delete specfic playback asset from Mux
Parameters
- client: provide by
client/0
- live_stream_id: live stream id
- playback_id: play back id
Example
iex> client = MuxWrapper.client()
%Tesla.Client{
adapter: nil,
fun: nil,
post: [],
pre: [
{Tesla.Middleware.BaseUrl, :call, ["https://api.mux.com"]},
{Tesla.Middleware.BasicAuth, :call,
[
%{
password: "your_password",
username: "your_username"
}
]}
]
}
iex> MuxWrapper.LiveStreams.delete_playback_id(client, "stream_id_very_long", "playback_id_very_long")
:ok
delete_simulcast_target(client, live_stream_id, simulcast_target_id)
View SourceSpecs
delete_simulcast_target( %Tesla.Client{adapter: term(), fun: term(), post: term(), pre: term()}, String.t(), String.t() ) :: atom()
Provide a function to delete simulcast targets
Parameters
- client: provide by
client/0
- live_stream_id: live stream id
- simulcast_target_id: simulcast target id
Example
iex> client = MuxWrapper.client()
%Tesla.Client{
adapter: nil,
fun: nil,
post: [],
pre: [
{Tesla.Middleware.BaseUrl, :call, ["https://api.mux.com"]},
{Tesla.Middleware.BasicAuth, :call,
[
%{
password: "your_password",
username: "your_username"
}
]}
]
}
iex> MuxWrapper.LiveStreams.delete_simulcast_target(client, "stream_id_very_long", "simulcast_target_id")
:ok
Specs
disable_live_stream( %Tesla.Client{adapter: term(), fun: term(), post: term(), pre: term()}, String.t() ) :: atom()
Provide a function to disable a live stream
Parameters
- client: provide by
client/0
- live_stream_id: live stream id
Examples
iex> MuxWrapper.client() |> MuxWrapper.LiveStreams.disable_live_stream("live_stream_id_very_long")
:ok
Specs
enable_live_stream( %Tesla.Client{adapter: term(), fun: term(), post: term(), pre: term()}, String.t() ) :: atom()
Provide a function to enable a live stream
Parameters
- client: provide by
client/1
- live_stream_id: live stream id
Examples
iex> MuxWrapper.client() |> MuxWrapper.LiveStreams.enable_live_stream("live_stream_id_very_long")
:ok
Specs
get_live_stream( %Tesla.Client{adapter: term(), fun: term(), post: term(), pre: term()}, String.t() ) :: %MuxWrapper.EmbeddedSchema.LiveStream{ created_at: term(), id: term(), new_asset_settings: term(), playback_ids: term(), reconnect_window: term(), status: term(), stream_key: term() }
Provide a function to get a specific live streaming from Mux
Parameters
- client: provide by
client/0
- live_stream_id: stream id
Examples
iex> MuxWrapper.client() |> MuxWrapper.LiveStreams.get_live_stream("stream_id_very_long")
%MuxWrapper.EmbeddedSchema.LiveStream{
created_at: ~N[2021-03-16 09:59:26],
id: "stream_id_very_long",
new_asset_settings: %{"playback_policies" => ["public"]},
playback_ids: [
%MuxWrapper.EmbeddedSchema.Playback{
id: "playback_id_very_long",
policy: "public"
}
],
reconnect_window: 60,
status: "idle",
stream_key: "stream_key_very_long"
}
Specs
get_simulcast_target( %Tesla.Client{adapter: term(), fun: term(), post: term(), pre: term()}, String.t(), String.t() ) :: %MuxWrapper.EmbeddedSchema.Simulcast{ id: term(), passthrough: term(), stream_key: term(), url: term() }
Provide a function to get simulcast target, strongly suggest read Mux doc first
Parameters
- client: provide by
client/0
- live_stream_id: live stream id
- simulcast_target_id: simulcast target id
Examples
iex> client = MuxWrapper.client()
%Tesla.Client{
adapter: nil,
fun: nil,
post: [],
pre: [
{Tesla.Middleware.BaseUrl, :call, ["https://api.mux.com"]},
{Tesla.Middleware.BasicAuth, :call,
[
%{
password: "your_password",
username: "your_username"
}
]}
]
}
iex> MuxWrapper.LiveStreams.get_simulcast_target(client, "stream_id_very_long", "simulcast_target_id")
%MuxWrapper.EmbeddedSchema.Simulcast{
id: "vuOfW021mz5QA500wYEQ9SeUYvuYnpFz011mqSvski5T8claN02JN9ve2g",
passthrough: "Example 1",
stream_key: "abcdefgh",
url: "rtmp://live.example1.com/app"
}
Specs
list_all_live_stream( %Tesla.Client{adapter: term(), fun: term(), post: term(), pre: term()}, Enum.t() ) :: Enum.t()
Provide a function to list all live streams in Mux, support pagnation see Mux doc
## Parameters
- client: provide by
client/0
- opt: pagnation query params, can pass a Map like this
%{limit: 10, page: 3}
. If don't pass, the default value from Mux is limit: 25 and page: 1
## Example
iex> client = MuxWrapper.client()
%Tesla.Client{
adapter: nil,
fun: nil,
post: [],
pre: [
{Tesla.Middleware.BaseUrl, :call, ["https://api.mux.com"]},
{Tesla.Middleware.BasicAuth, :call,
[
%{
password: "your_password",
username: "your_username"
}
]}
]
}
iex> MuxWrapper.LiveStreams.list_all_live_stream(client, %{limit: 1, page: 1})
[
%MuxWrapper.EmbeddedSchema.LiveStream{
created_at: ~N[2021-03-17 16:49:36],
id: "ABYT7nZXRKXLz02rMeWo00bhzLgw34sby6ZcZWR7vboFI",
new_asset_settings: %{"playback_policies" => ["public"]},
playback_ids: [
%MuxWrapper.EmbeddedSchema.Playback{
id: "NbUxpgpd02V00g02JNScdJwCxB9LUzPlvUmcnGHadG1V700",
policy: "public"
},
%MuxWrapper.EmbeddedSchema.Playback{
id: "Lg2lOeX9dmuzGOZBRVPYhcng9008MPUcCxwWA8002brlw",
policy: "signed"
},
%MuxWrapper.EmbeddedSchema.Playback{
id: "cnIcHj02pOmG01aTAE7t2B5iDWjWgQgLUbz8YHkJElBcs",
policy: "public"
}
],
reconnect_window: 60,
status: "idle",
stream_key: "stream_key_very_long"
}
]
Specs
reset_stream_key( %Tesla.Client{adapter: term(), fun: term(), post: term(), pre: term()}, String.t() ) :: %MuxWrapper.EmbeddedSchema.LiveStream{ created_at: term(), id: term(), new_asset_settings: term(), playback_ids: term(), reconnect_window: term(), status: term(), stream_key: term() }
Provide a function to reset stream key
Parameters
- client: provide by
client/0
- live_stream_id: live stream id
Examples
iex> MuxWrapper.client() |> MuxWrapper.LiveStreams.reset_stream_key("stream_id_very_long")
%MuxWrapper.EmbeddedSchema.LiveStream{
created_at: ~N[2021-03-17 09:27:39],
id: "009cUTpAr01fQgGQdLHnoy62naafkNhYRGQGTqG6O54kE",
new_asset_settings: %{"playback_policies" => ["public"]},
playback_ids: [
%MuxWrapper.EmbeddedSchema.Playback{
id: "004iSQFtzMHEPnftHqeU8w6UMwUocP1i8nKXtKlHcjI8",
policy: "public"
}
],
reconnect_window: 60,
status: "disabled",
stream_key: "d0c30be3-7e80-de52-5676-53a87a02c54f"
}