Aliyun.Oss.LiveChannel (aliyun_oss v2.0.0)

LiveChannel-related operations.

Link to this section Summary

Functions

DeleteLiveChannel - deletes a specified LiveChannel.

GetLiveChannelHistory - gets the stream pushing record of a LiveChannel.

GetLiveChannelInfo - gets the configuration information about a specified LiveChannel.

GetVodPlaylist - gets the playlist generated by the streams pushed to a specified LiveChannel in a specified time period.

GetLiveChannelStat - gets the stream ingestion status of a specified LiveChannel.

ListLiveChannel - lists specified LiveChannels.

PostVodPlaylist - generates a VOD playlist for the specified LiveChannel.

PutLiveChannel - creates a LiveChannel.

PutLiveChannelStatus - sets a LiveChannel to one of the states - enabled or disabled.

Link to this section Types

@type error() ::
  %Aliyun.Oss.Client.Error{
    body: String.t(),
    parsed_details: map(),
    status_code: integer()
  }
  | atom()

Link to this section Functions

Link to this function

delete(config, bucket, channel_name)

@spec delete(Aliyun.Oss.Config.t(), String.t(), String.t()) ::
  {:error, error()} | {:ok, Aliyun.Oss.Client.Response.t()}

DeleteLiveChannel - deletes a specified LiveChannel.

examples

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"},
      ...
    ]
  }
}
Link to this function

get_history(config, bucket, channel_name)

@spec get_history(Aliyun.Oss.Config.t(), String.t(), String.t()) ::
  {:error, error()} | {:ok, Aliyun.Oss.Client.Response.t()}

GetLiveChannelHistory - gets the stream pushing record of a LiveChannel.

examples

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"},
      ...
    ]
  }
}
Link to this function

get_info(config, bucket, channel_name)

@spec get_info(Aliyun.Oss.Config.t(), String.t(), String.t()) ::
  {:error, error()} | {:ok, Aliyun.Oss.Client.Response.t()}

GetLiveChannelInfo - gets the configuration information about a specified LiveChannel.

examples

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"},
      ...
    ]
  }
}
Link to this function

get_playlist(config, bucket, channel_name, start_time, end_time)

@spec get_playlist(
  Aliyun.Oss.Config.t(),
  String.t(),
  String.t(),
  integer(),
  integer()
) ::
  {:error, error()} | {:ok, Aliyun.Oss.Client.Response.t()}

GetVodPlaylist - gets the playlist generated by the streams pushed to a specified LiveChannel in a specified time period.

examples

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"},
      ...
    ]
  }
}
Link to this function

get_stat(config, bucket, channel_name)

@spec get_stat(Aliyun.Oss.Config.t(), String.t(), String.t()) ::
  {:error, error()} | {:ok, Aliyun.Oss.Client.Response.t()}

GetLiveChannelStat - gets the stream ingestion status of a specified LiveChannel.

examples

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"},
      ...
    ]
  }
}
Link to this function

list(config, bucket, query_params \\ %{})

@spec list(Aliyun.Oss.Config.t(), String.t(), map()) ::
  {:error, error()} | {:ok, Aliyun.Oss.Client.Response.t()}

ListLiveChannel - lists specified LiveChannels.

examples

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"},
      ...
    ]
  }
}
Link to this function

post_playlist(config, bucket, channel_name, list_name, start_time, end_time)

@spec post_playlist(
  Aliyun.Oss.Config.t(),
  String.t(),
  String.t(),
  String.t(),
  integer(),
  integer()
) ::
  {:error, error()} | {:ok, Aliyun.Oss.Client.Response.t()}

PostVodPlaylist - generates a VOD playlist for the specified LiveChannel.

examples

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"},
      ...
    ]
  }
}
Link to this function

put(config, bucket, channel_name, config)

@spec put(Aliyun.Oss.Config.t(), String.t(), String.t(), map() | String.t()) ::
  {:error, error()} | {:ok, Aliyun.Oss.Client.Response.t()}

PutLiveChannel - creates a LiveChannel.

examples

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"},
      ...
    ]
  }
}
Link to this function

put_status(config, bucket, channel_name, status)

@spec put_status(Aliyun.Oss.Config.t(), String.t(), String.t(), String.t()) ::
  {:error, error()} | {:ok, Aliyun.Oss.Client.Response.t()}

PutLiveChannelStatus - sets a LiveChannel to one of the states - enabled or disabled.

examples

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"},
      ...
    ]
  }
}
Link to this function

signed_publish_url(config, bucket, channel, expires, query_params \\ %{"playlistName" => "playlist.m3u8"})

@spec signed_publish_url(
  Aliyun.Oss.Config.t(),
  String.t(),
  String.t(),
  integer(),
  map()
) :: String.t()

Creates a signed RTMP ingest URL.

examples

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"