/**
  * Fill ChannelInput from array.
  *
  * @param array $options Array containing values for object properties
  */
 public function fromArray($options)
 {
     if (!empty($options['KeyFrameInterval'])) {
         Validate::isString($options['KeyFrameInterval'], 'options[KeyFrameInterval]');
         $this->_keyFrameInterval = $options['KeyFrameInterval'];
     }
     if (isset($options['StreamingProtocol'])) {
         Validate::isString($options['StreamingProtocol'], 'options[StreamingProtocol]');
         $this->_streamingProtocol = $options['StreamingProtocol'];
     }
     if (isset($options['AccessControl'])) {
         Validate::isArray($options['AccessControl'], 'options[AccessControl]');
         $this->_accessControl = ChannelInputAccessControl::createFromOptions($options['AccessControl']);
     }
     if (!empty($options['Endpoints'])) {
         Validate::isArray($options['Endpoints'], 'options[Endpoints]');
         foreach ($options['Endpoints'] as $endpoint) {
             $this->_endpoints[] = ChannelEndpoint::createFromOptions($endpoint);
         }
     }
 }
 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;
}