-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb8f8cf
commit 8ff611e
Showing
17 changed files
with
908 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
export OSS_ACCESS_KEY_ID=mFuuivpsrtPlLPcT | ||
export OSS_ACCESS_KEY_SECRET=AiiUWXVcAf2I92vkhZg31K9Cx2TTeH | ||
export OSS_ENDPOINT=oss-cn-shenzhen.aliyuncs.com | ||
export OSS_BUCKET=php-sdk-test-bucket-6 | ||
echo "done..." |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
require_once __DIR__ . '/Common.php'; | ||
|
||
use OSS\OssClient; | ||
use OSS\Core\OssException; | ||
use OSS\Model\LiveChannelConfig; | ||
|
||
$bucket = Common::getBucketName(); | ||
$ossClient = Common::getOssClient(); | ||
if (is_null($ossClient)) exit(1); | ||
|
||
//******************************* 简单使用 ******************************************************* | ||
|
||
//putLiveChannel | ||
$config = new LiveChannelConfig(array( | ||
'name' => 'live-1', | ||
'description' => 'live channel 1', | ||
'type' => 'HLS', | ||
'fragDuration' => 10, | ||
'fragCount' => 5, | ||
'playListName' => 'hello' | ||
)); | ||
$info = $ossClient->putBucketLiveChannel($bucket, $config); | ||
Common::println("bucket $bucket liveChannel created:\n" . | ||
"live channel name: ". $info->getName() . "\n" . | ||
"live channel description: ". $info->getDescription() . "\n" . | ||
"publishurls: ". $info->getPublishUrls()[0] . "\n" . | ||
"playurls: ". $info->getPlayUrls()[0] . "\n"); | ||
|
||
//listLiveChannel | ||
$list = $ossClient->listBucketLiveChannels($bucket); | ||
Common::println("bucket $bucket listLiveChannel:\n" . | ||
"list live channel prefix: ". $list->getPrefix() . "\n" . | ||
"list live channel marker: ". $list->getMarker() . "\n" . | ||
"list live channel maxkey: ". $list->getMaxKeys() . "\n" . | ||
"list live channel IsTruncated: ". $list->getIsTruncated() . "\n" . | ||
"list live channel getNextMarker: ". $list->getNextMarker() . "\n" . | ||
"list live channel list: ". $list->getChannelList()[0]->getName() . "\n"); | ||
|
||
//getLiveChannelUrl | ||
$url = $ossClient->getLiveChannelUrl($bucket, "live-1"); | ||
Common::println("bucket $bucket rtmp url: \n" . $url); | ||
|
||
//putLiveChannelStatus | ||
$resp = $ossClient->putLiveChannelStatus($bucket, "live-1", "enabled"); | ||
|
||
//getLiveChannelInfo | ||
$info = $ossClient->getLiveChannelInfo($bucket, 'live-1'); | ||
Common::println("bucket $bucket listLiveChannel:\n" . | ||
"live channel info description: ". $info->getDescription() . "\n" . | ||
"live channel info status: ". $info->getStatus() . "\n" . | ||
"live channel info type: ". $info->getType() . "\n" . | ||
"live channel info fragDuration: ". $info->getFragDuration() . "\n" . | ||
"live channel info fragCount: ". $info->getFragCount() . "\n" . | ||
"live channel info playListName: ". $info->getPlayListName() . "\n"); | ||
|
||
//getLiveChannelHistory | ||
$history = $ossClient->getLiveChannelHistory($bucket, "live-1"); | ||
if (count($history->getLiveRecordList()) != 0) | ||
{ | ||
Common::println("bucket $bucket liveChannelHistory:\n" . | ||
"live channel history startTime: ". $history->getLiveRecordList()[0]->getStartTime() . "\n" . | ||
"live channel history endTime: ". $history->getLiveRecordList()[0]->getEndTime() . "\n" . | ||
"live channel history remoteAddr: ". $history->getLiveRecordList()[0]->getRemoteAddr() . "\n"); | ||
} | ||
|
||
//getLiveChannelStatus | ||
$status = $ossClient->getLiveChannelStatus($bucket, "live-1"); | ||
Common::println("bucket $bucket listLiveChannel:\n" . | ||
"live channel status status: ". $status->getStatus() . "\n" . | ||
"live channel status ConnectedTime: ". $status->getConnectedTime() . "\n" . | ||
"live channel status VideoWidth: ". $status->getVideoWidth() . "\n" . | ||
"live channel status VideoHeight: ". $status->getVideoHeight() . "\n" . | ||
"live channel status VideoFrameRate: ". $status->getVideoFrameRate() . "\n" . | ||
"live channel status VideoBandwidth: ". $status->getVideoBandwidth() . "\n" . | ||
"live channel status VideoCodec: ". $status->getVideoCodec() . "\n" . | ||
"live channel status AudioBandwidth: ". $status->getAudioBandwidth() . "\n" . | ||
"live channel status AudioSampleRate: ". $status->getAudioSampleRate() . "\n" . | ||
"live channel status AdioCodec: ". $status->getAudioCodec() . "\n"); | ||
|
||
//postVodPlaylist | ||
$info = $ossClient->postVodPlaylist($bucket, | ||
"live-1", "playback.m3u8", | ||
array('StartTime' => '1476844172', | ||
'EndTime' => '1476864172') | ||
); | ||
|
||
//deleteLiveChannel | ||
$info = $ossClient->deleteBucketLiveChannel($bucket, "live-1"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
require_once __DIR__ . '/Common.php'; | ||
|
||
use OSS\OssClient; | ||
use OSS\Core\OssException; | ||
use OSS\Model\LiveChannelConfig; | ||
|
||
$bucket = Common::getBucketName(); | ||
$ossClient = Common::getOssClient(); | ||
if (is_null($ossClient)) exit(1); | ||
|
||
//******************************* 简单使用 ******************************************************* | ||
|
||
//putLiveChannel | ||
$config = new LiveChannelConfig(array( | ||
'name' => 'live-1', | ||
'description' => 'live channel 1', | ||
'type' => 'HLS', | ||
'fragDuration' => 10, | ||
'fragCount' => 5, | ||
'playListName' => 'hello' | ||
)); | ||
$info = $ossClient->putBucketLiveChannel($bucket, $config); | ||
Common::println("bucket $bucket liveChannel created:\n" . | ||
"live channel name: ". $info->getName() . "\n" . | ||
"live channel description: ". $info->getDescription() . "\n" . | ||
"publishurls: ". $info->getPublishUrls()[0] . "\n" . | ||
"playurls: ". $info->getPlayUrls()[0] . "\n"); | ||
|
||
//listLiveChannel | ||
$list = $ossClient->listBucketLiveChannels($bucket); | ||
Common::println("bucket $bucket listLiveChannel:\n" . | ||
"list live channel prefix: ". $list->getPrefix() . "\n" . | ||
"list live channel marker: ". $list->getMarker() . "\n" . | ||
"list live channel maxkey: ". $list->getMaxKeys() . "\n" . | ||
"list live channel IsTruncated: ". $list->getIsTruncated() . "\n" . | ||
"list live channel getNextMarker: ". $list->getNextMarker() . "\n" . | ||
"list live channel count: ". count($list->getChannelList()) . "\n" . | ||
"list live channel list: ". $list->getChannelList()[0]->getName() . "\n"); | ||
|
||
//getLiveChannelUrl | ||
$url = $ossClient->getLiveChannelUrl($bucket, "live-1"); | ||
Common::println("bucket $bucket rtmp url: \n" . $url); | ||
|
||
system(" sudo ffmpeg \-re \-i ./allstar.flv \-c copy \-f flv \"$url\" "); | ||
|
||
//deleteLiveChannel | ||
$info = $ossClient->deleteBucketLiveChannel($bucket, "live-1"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace OSS\Model; | ||
/** | ||
* Class GetLiveChannelHistory | ||
* @package OSS\Model | ||
* | ||
*/ | ||
class GetLiveChannelHistory implements XmlConfig | ||
{ | ||
private $liveRecordList = array(); | ||
|
||
public function getLiveRecordList() | ||
{ | ||
return $this->liveRecordList; | ||
} | ||
|
||
public function parseFromXml($strXml) | ||
{ | ||
$xml = simplexml_load_string($strXml); | ||
|
||
if (isset($xml->LiveRecord)) { | ||
foreach ($xml->LiveRecord as $record) { | ||
$liveRecord = new LiveChannelHistory(); | ||
$liveRecord->parseFromXmlNode($record); | ||
$this->liveRecordList[] = $liveRecord; | ||
} | ||
} | ||
} | ||
|
||
public function serializeToXml() | ||
{ | ||
throw new OssException("Not implemented."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
namespace OSS\Model; | ||
/** | ||
* Class GetLiveChannelInfo | ||
* @package OSS\Model | ||
* | ||
*/ | ||
class GetLiveChannelInfo implements XmlConfig | ||
{ | ||
private $description; | ||
private $status; | ||
private $type; | ||
private $fragDuration; | ||
private $fragCount; | ||
private $playlistName; | ||
|
||
public function getDescription() | ||
{ | ||
return $this->description; | ||
} | ||
|
||
public function getStatus() | ||
{ | ||
return $this->status; | ||
} | ||
|
||
public function getType() | ||
{ | ||
return $this->type; | ||
} | ||
|
||
public function getFragDuration() | ||
{ | ||
return $this->fragDuration; | ||
} | ||
|
||
public function getFragCount() | ||
{ | ||
return $this->fragCount; | ||
} | ||
|
||
public function getPlayListName() | ||
{ | ||
return $this->playlistName; | ||
} | ||
|
||
public function parseFromXml($strXml) | ||
{ | ||
$xml = simplexml_load_string($strXml); | ||
|
||
$this->description = strval($xml->Description); | ||
$this->status = strval($xml->Status); | ||
|
||
if (isset($xml->Target)) { | ||
foreach ($xml->Target as $target) { | ||
$this->type = strval($target->Type); | ||
$this->fragDuration = strval($target->FragDuration); | ||
$this->fragCount = strval($target->FragCount); | ||
$this->playlistName = strval($target->PlaylistName); | ||
} | ||
} | ||
} | ||
|
||
public function serializeToXml() | ||
{ | ||
throw new OssException("Not implemented."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?php | ||
|
||
namespace OSS\Model; | ||
/** | ||
* Class GetLiveChannelStatus | ||
* @package OSS\Model | ||
* | ||
*/ | ||
class GetLiveChannelStatus implements XmlConfig | ||
{ | ||
private $status; | ||
private $connectedTime; | ||
private $remoteAddr; | ||
|
||
|
||
private $videoWidth; | ||
private $videoHeight; | ||
private $videoFrameRate; | ||
private $videoBandwidth; | ||
private $videoCodec; | ||
|
||
private $audioBandwidth; | ||
private $audioSampleRate; | ||
private $audioCodec; | ||
|
||
public function getStatus() | ||
{ | ||
return $this->status; | ||
} | ||
|
||
public function getConnectedTime() | ||
{ | ||
return $this->connectedTime; | ||
} | ||
|
||
public function getRemoteAddr() | ||
{ | ||
return $this->remoteAddr; | ||
} | ||
|
||
public function getVideoWidth() | ||
{ | ||
return $this->videoWidth; | ||
} | ||
public function getVideoHeight() | ||
{ | ||
return $this->videoHeight; | ||
} | ||
public function getVideoFrameRate() | ||
{ | ||
return $this->videoFrameRate; | ||
} | ||
public function getVideoBandwidth() | ||
{ | ||
return $this->videoBandwidth; | ||
} | ||
public function getVideoCodec() | ||
{ | ||
return $this->videoCodec; | ||
} | ||
|
||
public function getAudioBandwidth() | ||
{ | ||
return $this->audioBandwidth; | ||
} | ||
public function getAudioSampleRate() | ||
{ | ||
return $this->audioSampleRate; | ||
} | ||
public function getAudioCodec() | ||
{ | ||
return $this->audioCodec; | ||
} | ||
|
||
|
||
public function parseFromXml($strXml) | ||
{ | ||
$xml = simplexml_load_string($strXml); | ||
$this->status = strval($xml->Status); | ||
$this->connectedTime = strval($xml->ConnectedTime); | ||
$this->remoteAddr = strval($xml->RemoteAddr); | ||
|
||
if (isset($xml->Video)) { | ||
foreach ($xml->Video as $video) { | ||
$this->videoWidth = intval($video->Width); | ||
$this->videoHeight = intval($video->Height); | ||
$this->videoFrameRate = intval($video->FrameRate); | ||
$this->videoBandwidth = intval($video->Bandwidth); | ||
$this->videoCodec = strval($video->Codec); | ||
} | ||
} | ||
|
||
if (isset($xml->Video)) { | ||
foreach ($xml->Audio as $audio) { | ||
$this->audioBandwidth = intval($audio->Bandwidth); | ||
$this->audioSampleRate = intval($audio->SampleRate); | ||
$this->audioCodec = strval($audio->Codec); | ||
} | ||
} | ||
|
||
} | ||
|
||
public function serializeToXml() | ||
{ | ||
throw new OssException("Not implemented."); | ||
} | ||
} |
Oops, something went wrong.