Aliyun.Oss.LiveChannel (aliyun_oss v1.0.0)
LiveChannel 相关操作:
Aliyun.Oss.LiveChannel
: LiveChannel 基本操作
Link to this section Summary
Functions
DeleteLiveChannel接口用于删除指定的LiveChannel。
GetLiveChannelHistory接口用于获取指定LiveChannel的推流记录。使用GetLiveChannelHistory接口最多会返回指定LiveChannel最近的10次推流记录。
GetLiveChannelInfo接口用于获取指定LiveChannel的配置信息。
GetVodPlaylist接口用于查看指定LiveChannel在指定时间段内推流生成的播放列表。
GetLiveChannelStat接口用于获取指定LiveChannel的推流状态信息。
ListLiveChannel接口用于列举指定的LiveChannel。
PostVodPlaylist接口用于为指定的LiveChannel生成一个点播用的播放列表。OSS会查询指定时间范围内由该LiveChannel推流生成的ts文件,并将其拼装为一个m3u8播放列表。
通过RTMP协议上传音视频数据前,必须先调用该接口创建一个LiveChannel。调用PutLiveChannel接口会返回RTMP推流地址,以及对应的播放地址。
LiveChannel分为启用(enabled)和禁用(disabled)两种状态。您可以使用PutLiveChannelStatus接口在两种状态之间进行切换。
Link to this section Types
error()
Specs
Link to this section Functions
delete(bucket, channel_name)
Specs
DeleteLiveChannel接口用于删除指定的LiveChannel。
Examples
iex> Aliyun.Oss.LiveChannel.delete("some-bucket", "channel-name")
{:ok, %Aliyun.Oss.Client.Response{
data: "",
headers: [
{"Server", "AliyunOSS"},
{"Date", "Wed, 05 Dec 2018 02:34:57 GMT"},
...
]
}
}
get_history(bucket, channel_name)
Specs
GetLiveChannelHistory接口用于获取指定LiveChannel的推流记录。使用GetLiveChannelHistory接口最多会返回指定LiveChannel最近的10次推流记录。
Examples
iex> Aliyun.Oss.LiveChannel.get_history("some-bucket", "channe-name")
{:ok, %Aliyun.Oss.Client.Response{
data: %{"LiveChannelHistory" => %{
"LiveRecord" => [
# ...
]
}},
headers: [
{"Server", "AliyunOSS"},
{"Date", "Wed, 05 Dec 2018 02:34:57 GMT"},
...
]
}
}
get_info(bucket, channel_name)
Specs
GetLiveChannelInfo接口用于获取指定LiveChannel的配置信息。
Examples
iex> Aliyun.Oss.LiveChannel.get_info("some-bucket", "channe-name")
{:ok, %Aliyun.Oss.Client.Response{
data: %{
"LiveChannelConfiguration" => %{
"Description" => nil,
"Status" => "enabled",
"Target" => %{
"FragCount" => "3",
"FragDuration" => "2",
"PlaylistName" => "playlist.m3u8",
"Type" => "HLS"
}
}
},
headers: [
{"Server", "AliyunOSS"},
{"Date", "Wed, 05 Dec 2018 02:34:57 GMT"},
...
]
}
}
get_playlist(bucket, channel_name, start_time, end_time)
Specs
get_playlist(String.t(), String.t(), integer(), integer()) :: {:error, error()} | {:ok, Aliyun.Oss.Client.Response.t()}
GetVodPlaylist接口用于查看指定LiveChannel在指定时间段内推流生成的播放列表。
Examples
iex> Aliyun.Oss.LiveChannel.get_playlist("some-bucket", "channe-name", 1472020031, 1472020226)
{:ok, %Aliyun.Oss.Client.Response{
data: "#EXTM3u...",
headers: [
{"Server", "AliyunOSS"},
{"Date", "Wed, 05 Dec 2018 02:34:57 GMT"},
...
]
}
}
get_stat(bucket, channel_name)
Specs
GetLiveChannelStat接口用于获取指定LiveChannel的推流状态信息。
Examples
iex> Aliyun.Oss.LiveChannel.get_stat("some-bucket", "channe-name")
{:ok, %Aliyun.Oss.Client.Response{
data: %{"LiveChannelStat" => %{"Status" => "Idle"}},
headers: [
{"Server", "AliyunOSS"},
{"Date", "Wed, 05 Dec 2018 02:34:57 GMT"},
...
]
}
}
list(bucket, query_params \\ %{})
Specs
ListLiveChannel接口用于列举指定的LiveChannel。
Examples
iex> Aliyun.Oss.LiveChannel.list("some-bucket")
{:ok, %Aliyun.Oss.Client.Response{
data: %{
"ListLiveChannelResult" => %{
"IsTruncated" => false,
"LiveChannel" => [
%{
"Description" => nil,
"LastModified" => "2021-01-20T03:18:06.000Z",
"Name" => "channel1",
"PlayUrls" => %{
"Url" => "http://some-bucket.oss-cn-shenzhen.aliyuncs.com/channel1/playlist.m3u8"
},
"PublishUrls" => %{
"Url" => "rtmp://some-bucket.oss-cn-shenzhen.aliyuncs.com/live/channel1"
},
"Status" => "enabled"
},
# ..
],
"Marker" => nil,
"MaxKeys" => 2,
"NextMarker" => nil,
"Prefix" => nil
}
},
headers: [
{"Server", "AliyunOSS"},
{"Date", "Wed, 05 Dec 2018 02:34:57 GMT"},
...
]
}
}
post_playlist(bucket, channel_name, list_name, start_time, end_time)
Specs
post_playlist(String.t(), String.t(), String.t(), integer(), integer()) :: {:error, error()} | {:ok, Aliyun.Oss.Client.Response.t()}
PostVodPlaylist接口用于为指定的LiveChannel生成一个点播用的播放列表。OSS会查询指定时间范围内由该LiveChannel推流生成的ts文件,并将其拼装为一个m3u8播放列表。
Examples
iex> Aliyun.Oss.LiveChannel.post_playlist("some-bucket", "channe-name", "list.m3u8", 1472020031, 1472020226)
{:ok, %Aliyun.Oss.Client.Response{
data: "",
headers: [
{"Server", "AliyunOSS"},
{"Date", "Wed, 05 Dec 2018 02:34:57 GMT"},
...
]
}
}
put(bucket, channel_name, config)
Specs
put(String.t(), String.t(), map() | String.t()) :: {:error, error()} | {:ok, Aliyun.Oss.Client.Response.t()}
通过RTMP协议上传音视频数据前,必须先调用该接口创建一个LiveChannel。调用PutLiveChannel接口会返回RTMP推流地址,以及对应的播放地址。
Examples
iex> config_json = %{
"LiveChannelConfiguration" => %{
"Description" => nil,
"Status" => "enabled",
"Target" => %{"FragCount" => "3", "FragDuration" => "2", "Type" => "HLS"}
}
}
iex> Aliyun.Oss.LiveChannel.put("some-bucket", "channe-name", config_json)
{:ok, %Aliyun.Oss.Client.Response{
data: %{
"CreateLiveChannelResult" => %{
"PlayUrls" => %{
"Url" => "http://some-bucket.oss-cn-shenzhen.aliyuncs.com/channel-name/playlist.m3u8"
},
"PublishUrls" => %{
"Url" => "rtmp://some-bucket.oss-cn-shenzhen.aliyuncs.com/live/channel-name"
}
}
},
headers: [
{"Server", "AliyunOSS"},
{"Date", "Wed, 05 Dec 2018 02:34:57 GMT"},
...
]
}
}
iex> config_xml = ~S[
<?xml version="1.0" encoding="UTF-8"?>
<LiveChannelConfiguration>
<Description></Description>
<Status>enabled</Status>
<Target>
<FragCount>3</FragCount>
<FragDuration>2</FragDuration>
<Type>HLS</Type>
</Target>
</LiveChannelConfiguration>
]
iex> Aliyun.Oss.LiveChannel.put("some-bucket", "channe-name", config_xml)
{:ok, %Aliyun.Oss.Client.Response{
data: %{
"CreateLiveChannelResult" => %{
"PlayUrls" => %{
"Url" => "http://some-bucket.oss-cn-shenzhen.aliyuncs.com/channel-name/playlist.m3u8"
},
"PublishUrls" => %{
"Url" => "rtmp://some-bucket.oss-cn-shenzhen.aliyuncs.com/live/channel-name"
}
}
},
headers: [
{"Server", "AliyunOSS"},
{"Date", "Wed, 05 Dec 2018 02:34:57 GMT"},
...
]
}
}
put_status(bucket, channel_name, status)
Specs
put_status(String.t(), String.t(), String.t()) :: {:error, error()} | {:ok, Aliyun.Oss.Client.Response.t()}
LiveChannel分为启用(enabled)和禁用(disabled)两种状态。您可以使用PutLiveChannelStatus接口在两种状态之间进行切换。
Examples
iex> Aliyun.Oss.LiveChannel.put_status("some-bucket", "channe-name", "disabled)
{:ok, %Aliyun.Oss.Client.Response{
data: "",
headers: [
{"Server", "AliyunOSS"},
{"Date", "Wed, 05 Dec 2018 02:34:57 GMT"},
...
]
}
}
signed_publish_url(bucket, channel, expires, query_params \\ %{"playlistName" => "playlist.m3u8"})
Specs
生成包含签名的 RTMP 推流地址
Examples
iex> expires = Timex.now() |> Timex.shift(days: 1) |> Timex.to_unix()
iex> Aliyun.Oss.Object.signed_url("some-bucket", "some-object", expires, "GET", %{"Content-Type" -> ""})
"http://some-bucket.oss-cn-hangzhou.aliyuncs.com/oss-api.pdf?OSSAccessKeyId=nz2pc5*******9l&Expires=1141889120&Signature=vjbyPxybdZ*****************v4%3D"