public function testLiveChannelConfig() { $config = new LiveChannelConfig(array('name' => 'live-1')); $config->parseFromXml($this->config); $this->assertEquals('xxx', $config->getDescription()); $this->assertEquals('enabled', $config->getStatus()); $this->assertEquals('hls', $config->getType()); $this->assertEquals(1000, $config->getFragDuration()); $this->assertEquals(5, $config->getFragCount()); $this->assertEquals('hello.m3u8', $config->getPlayListName()); $xml = $config->serializeToXml(); $config2 = new LiveChannelConfig(array('name' => 'live-2')); $config2->parseFromXml($xml); $this->assertEquals('xxx', $config2->getDescription()); $this->assertEquals('enabled', $config2->getStatus()); $this->assertEquals('hls', $config2->getType()); $this->assertEquals(1000, $config2->getFragDuration()); $this->assertEquals(5, $config2->getFragCount()); $this->assertEquals('hello.m3u8', $config2->getPlayListName()); }
/** * 为指定Bucket创建LiveChannel * * @param string $bucket bucket名称 * @param string channelName $channelName * @param LiveChannelConfig $channelConfig * @param array $options * @throws OssException * @return LiveChannelInfo */ public function putBucketLiveChannel($bucket, $channelName, $channelConfig, $options = NULL) { $this->precheckCommon($bucket, NULL, $options, false); $options[self::OSS_BUCKET] = $bucket; $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; $options[self::OSS_OBJECT] = $channelName; $options[self::OSS_SUB_RESOURCE] = 'live'; $options[self::OSS_CONTENT_TYPE] = 'application/xml'; $options[self::OSS_CONTENT] = $channelConfig->serializeToXml(); $response = $this->auth($options); $result = new PutLiveChannelResult($response); $info = $result->getData(); $info->setName($channelName); $info->setDescription($channelConfig->getDescription()); return $info; }