Exemplo n.º 1
0
 /**
  * Fill Channel from array.
  *
  * @param array $options Array containing values for object properties
  */
 public function fromArray($options)
 {
     if (isset($options['Id'])) {
         Validate::isString($options['Id'], 'options[Id]');
         $this->_id = $options['Id'];
     }
     if (isset($options['Name'])) {
         Validate::isString($options['Name'], 'options[Name]');
         $this->_name = $options['Name'];
     }
     if (isset($options['Created'])) {
         Validate::isDateString($options['Created'], 'options[Created]');
         $this->_created = new \DateTime($options['Created']);
     }
     if (isset($options['Description'])) {
         Validate::isString($options['Description'], 'options[Description]');
         $this->_description = $options['Description'];
     }
     if (isset($options['LastModified'])) {
         Validate::isDateString($options['LastModified'], 'options[LastModified]');
         $this->_lastModified = new \DateTime($options['LastModified']);
     }
     if (isset($options['State'])) {
         Validate::isString($options['State'], 'options[State]');
         $this->_state = $options['State'];
     }
     if (!empty($options['Input'])) {
         Validate::isArray($options['Input'], 'options[Input]');
         $this->_input = ChannelInput::createFromOptions($options['Input']);
     }
     if (!empty($options['Output'])) {
         Validate::isArray($options['Output'], 'options[Output]');
         $this->_output = ChannelOutput::createFromOptions($options['Output']);
     }
     if (!empty($options['Preview'])) {
         Validate::isArray($options['Preview'], 'options[Preview]');
         $this->_preview = ChannelPreview::createFromOptions($options['Preview']);
     }
     if (!empty($options['CrossSiteAccessPolicies'])) {
         Validate::isArray($options['CrossSiteAccessPolicies'], 'options[CrossSiteAccessPolicies]');
         $this->_crossSiteAccessPolicies = CrossSiteAccessPolicies::createFromOptions($options['CrossSiteAccessPolicies']);
     }
     if (isset($options['EncodingType'])) {
         Validate::isString($options['EncodingType'], 'options[EncodingType]');
         $this->_encodingType = $options['EncodingType'];
     }
     if (!empty($options['Encoding'])) {
         Validate::isArray($options['Encoding'], 'options[Encoding]');
         $this->_encoding = ChannelEncoding::createFromOptions($options['Encoding']);
     }
     if (!empty($options['Slate'])) {
         Validate::isArray($options['Slate'], 'options[Slate]');
         $this->_slate = ChannelSlate::createFromOptions($options['Slate']);
     }
 }
 private function makeChannelEncodingTypeStandard($name)
 {
     $channel = new Channel();
     $channel->setName($name);
     $channel->setDescription("Description of channel {$name}");
     // channel Input
     $channelInput = new ChannelInput();
     $channelInput->setStreamingProtocol(StreamingProtocol::RTPMPEG2TS);
     // channel Input\ChannelInputAccessControl
     $channelInputAccessControl = new ChannelInputAccessControl();
     $ciacIPAccessControl = new IPAccessControl();
     $ciacIPRange = new IPRange();
     $ciacIPRange->setName("default");
     $ciacIPRange->setAddress("0.0.0.0");
     $ciacIPRange->setSubnetPrefixLength("0");
     $ciacIPAccessControl->setAllow(array($ciacIPRange));
     $channelInputAccessControl->setIP($ciacIPAccessControl);
     $channelInput->setAccessControl($channelInputAccessControl);
     $channel->setInput($channelInput);
     // channel Preview
     $channelPreview = new ChannelPreview();
     // channel Preview\ChannelPreviewAccessControl
     $channelPreviewAccessControl = new ChannelPreviewAccessControl();
     $cpacIPAccessControl = new IPAccessControl();
     $cpacIPRange = new IPRange();
     $cpacIPRange->setName("default");
     $cpacIPRange->setAddress("0.0.0.0");
     $cpacIPRange->setSubnetPrefixLength("0");
     $cpacIPAccessControl->setAllow(array($cpacIPRange));
     $channelPreviewAccessControl->setIP($cpacIPAccessControl);
     $channelPreview->setAccessControl($channelPreviewAccessControl);
     $channel->setPreview($channelPreview);
     // encoding type
     $channel->setEncodingType(EncodingType::Standard);
     $channelEncoding = new ChannelEncoding();
     $channelEncoding->setSystemPreset(ChannelEncodingPresets::Default720p);
     $channelEncoding->setAdMarkerSource(AdMarkerSources::Scte35);
     $channelEncoding->setIgnoreCea708ClosedCaptions(true);
     $vs = new VideoStream();
     $vs->setIndex(0);
     $channelEncoding->setVideoStreams(array($vs));
     $as = new AudioStream();
     $as->setIndex(0);
     $as->setLanguage("eng");
     $channelEncoding->setAudioStreams(array($as));
     $channel->setEncoding($channelEncoding);
     // cors rules
     $channel->setCrossSiteAccessPolicies(new CrossSiteAccessPolicies());
     return $channel;
 }
function createChannelData($options)
{
    $channel = new Channel();
    $channel->setName($options->channelName);
    // 1 - Channel Input
    $channelInput = new ChannelInput();
    $channelAccessControl = new ChannelInputAccessControl();
    $channelAccessControl->setIP(createOpenIPAccessControl());
    $channelInput->setAccessControl($channelAccessControl);
    $channelInput->setStreamingProtocol($options->ingestProtocol);
    $channel->setInput($channelInput);
    // 2 - Channel Preview
    $channelPreview = new ChannelPreview();
    $channelAccessControl = new ChannelPreviewAccessControl();
    $channelAccessControl->setIP(createOpenIPAccessControl());
    $channelPreview->setAccessControl($channelAccessControl);
    $channel->setPreview($channelPreview);
    // 3 - Channel Encoding
    if ($options->encodingType == EncodingType::Standard) {
        $channel->setEncodingType(EncodingType::Standard);
        $channelEncoding = new ChannelEncoding();
        $channelEncoding->setSystemPreset(ChannelEncodingPresets::Default720p);
        $channel->setEncoding($channelEncoding);
    } else {
        $channel->setEncodingType(EncodingType::None);
    }
    // 4 - cors rules
    $channel->setCrossSiteAccessPolicies(new CrossSiteAccessPolicies());
    return $channel;
}