# `Aliyun.Oss.LiveChannel`

LiveChannel-related operations.

# `delete`

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

DeleteLiveChannel - deletes a specified LiveChannel.

## Examples

    iex> Aliyun.Oss.LiveChannel.delete(config, "some-bucket", "channel-name")
    {:ok, %Aliyun.Oss.Client.Response{
        data: "",
        headers: %{
          "connection" => ["keep-alive"],
          ...
        }
      }
    }

# `get_history`

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

GetLiveChannelHistory - gets the stream pushing record of a LiveChannel.

## Examples

    iex> Aliyun.Oss.LiveChannel.get_history(config, "some-bucket", "channel-name")
    {:ok, %Aliyun.Oss.Client.Response{
        data: %{"LiveChannelHistory" => %{
          "LiveRecord" => [
            %{
              "EndTime" => "2021-01-20T09:18:28.000Z",
              "RemoteAddr" => "1**.1**.1**.1**:****",
              "StartTime" => "2021-01-20T09:18:25.000Z"
            },
            ...
          ]
        }},
        headers: %{
          "connection" => ["keep-alive"],
          ...
        }
      }
    }

# `get_info`

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

GetLiveChannelInfo - gets the configuration information about a specified LiveChannel.

## Examples

    iex> Aliyun.Oss.LiveChannel.get_info(config, "some-bucket", "channel-name")
    {:ok, %Aliyun.Oss.Client.Response{
        data: %{
          "LiveChannelConfiguration" => %{
            "Description" => nil,
            "Status" => "enabled",
            "Target" => %{
              "FragCount" => "3",
              "FragDuration" => "2",
              "PlaylistName" => "playlist.m3u8",
              "Type" => "HLS"
            }
          }
        },
        headers: %{
          "connection" => ["keep-alive"],
          ...
        }
      }
    }

# `get_stat`

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

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

## Examples

    iex> Aliyun.Oss.LiveChannel.get_stat(config, "some-bucket", "channel-name")
    {:ok, %Aliyun.Oss.Client.Response{
        data: %{"LiveChannelStat" => %{"Status" => "Idle"}},
        headers: %{
          "connection" => ["keep-alive"],
          ...
        }
      }
    }

# `get_vod_playlist`

```elixir
@spec get_vod_playlist(
  Aliyun.Oss.Config.t(),
  String.t(),
  String.t(),
  integer(),
  integer()
) ::
  {:error, Exception.t()} | {: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

    iex> Aliyun.Oss.LiveChannel.get_vod_playlist(config, "some-bucket", "channel-name", 1472020031, 1472020226)
    {:ok, %Aliyun.Oss.Client.Response{
        data: "#EXTM3u...",
        headers: %{
          "connection" => ["keep-alive"],
          ...
        }
      }
    }

# `list`

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

ListLiveChannel - lists specified LiveChannels.

## Options

- `:query_params` - Defaults to `%{}`

## Examples

    iex> Aliyun.Oss.LiveChannel.list(config, "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: %{
          "connection" => ["keep-alive"],
          ...
        }
      }
    }

# `post_vod_playlist`

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

PostVodPlaylist - generates a VOD playlist for the specified LiveChannel.

## Examples

    iex> Aliyun.Oss.LiveChannel.post_vod_playlist(config, "some-bucket", "channel-name", "list.m3u8", 1472020031, 1472020226)
    {:ok, %Aliyun.Oss.Client.Response{
        data: "",
        headers: %{
          "connection" => ["keep-alive"],
          ...
        }
      }
    }

# `put`

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

PutLiveChannel - creates a LiveChannel.

## Examples

    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(config, "some-bucket", "channel-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: %{
          "connection" => ["keep-alive"],
          ...
        }
      }
    }

# `put_status`

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

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

## Examples

    iex> Aliyun.Oss.LiveChannel.put_status(config, "some-bucket", "channel-name", "disabled")
    {:ok, %Aliyun.Oss.Client.Response{
        data: "",
        headers: %{
          "connection" => ["keep-alive"],
          ...
        }
      }
    }

# `signed_publish_url`

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

Creates a signed RTMP ingest URL.

## Examples

    iex> expires = DateTime.utc_now |> DateTime.shift(day: 1) |> DateTime.to_unix()
    iex> Aliyun.Oss.LiveChannel.signed_url(config, "some-bucket", "some-object", expires, "GET", %{"Content-Type" -> ""})
    "rtmp://some-bucket.oss-cn-hangzhou.aliyuncs.com/live/channel-name?OSSAccessKeyId=...&Expires=...&playlistName=playlist.m3u8&Signature=..."

---

*Consult [api-reference.md](api-reference.md) for complete listing*
