Aliyun.Oss.LiveChannel (aliyun_oss v3.2.0)

LiveChannel-related operations.

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.

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

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

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.

Types

error()

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

Functions

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

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

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

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(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

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(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

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(config, bucket, channel_name, start_time, end_time)

@spec get_vod_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

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(config, bucket, options \\ [])

@spec list(Aliyun.Oss.Config.t(), String.t(), keyword()) ::
  {:error, error()} | {: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(config, bucket, channel_name, list_name, start_time, end_time)

@spec post_vod_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

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(config, bucket, channel_name, config_xml)

@spec put(Aliyun.Oss.Config.t(), String.t(), String.t(), String.t()) ::
  {:error, error()} | {: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(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

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(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

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=..."