Live Channels

Live Channels allow you to use OSS as an ingest point for RTMP streams and distribute them via HLS (m3u8).

Creating a Live Channel

use OSS\Model\LiveChannelConfig;

$config = new LiveChannelConfig([
    'description' => 'My live stream',
    'type' => 'HLS',
    'fragDuration' => 10, // Fragment duration in seconds
    'fragCount' => 5,    // Number of fragments in the playlist
    'playListName' => 'live.m3u8'
]);

$info = $ossClient->putBucketLiveChannel($bucket, 'my-channel', $config);

echo "Publish URL: " . $info->getPublishUrls()[0];
echo "Play URL: " . $info->getPlayUrls()[0];

Managing Status

You can enable or disable a channel at any time:

$ossClient->putLiveChannelStatus($bucket, 'my-channel', 'enabled');
// or 'disabled'

Signing RTMP URLs

If your bucket is private, you must sign the RTMP URL used for pushing the stream:

$expires = 3600;
$rtmpUrl = $ossClient->signRtmpUrl($bucket, 'my-channel', $expires);

Recording & History

You can retrieve the history of stream pushes:

$history = $ossClient->getLiveChannelHistory($bucket, 'my-channel');
foreach ($history->getLiveRecordList() as $record) {
    echo "Start: " . $record->getStartTime() . " End: " . $record->getEndTime();
}