public function __construct(KalturaDistributionJobData $distributionJobData = null)
 {
     parent::__construct($distributionJobData);
     if (!$distributionJobData || !$distributionJobData->distributionProfile instanceof KalturaTvinciDistributionProfile || !$distributionJobData->entryDistribution) {
         return;
     }
     $entry = null;
     if ($distributionJobData->entryDistribution->entryId) {
         $entry = entryPeer::retrieveByPK($distributionJobData->entryDistribution->entryId);
     }
     if (!$entry) {
         KalturaLog::err("Can't find entry with id: {$distributionJobData->entryDistribution->entryId}");
         return;
     }
     $feedHelper = new TvinciDistributionFeedHelper($distributionJobData->distributionProfile);
     $feedHelper->setEntryId($entry->getId());
     $feedHelper->setReferenceId($entry->getReferenceID());
     $feedHelper->setDescription($entry->getDescription());
     $feedHelper->setTitleName($entry->getName());
     $feedHelper->setSunrise($distributionJobData->entryDistribution->sunrise);
     $feedHelper->setSunset($distributionJobData->entryDistribution->sunset);
     $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds));
     $picRatios = array();
     $defaultThumbUrl = null;
     foreach ($thumbAssets as $thumbAsset) {
         $thumbDownloadUrl = $this->getAssetDownloadUrl($thumbAsset);
         $ratio = KDLVideoAspectRatio::ConvertFrameSize($thumbAsset->getWidth(), $thumbAsset->getHeight());
         $picRatios[] = array('url' => $thumbDownloadUrl, 'ratio' => $ratio);
         if ($thumbAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
             $defaultThumbUrl = $thumbDownloadUrl;
         }
     }
     $feedHelper->setPicRatiosArray($picRatios);
     if (!$defaultThumbUrl && count($picRatios)) {
         // Choose the URL of the first resource in the array
         $defaultThumbUrl = $picRatios[0]['url'];
     }
     $feedHelper->setDefaultThumbnailUrl($defaultThumbUrl);
     $this->createPlayManifestURLs($distributionJobData->entryDistribution, $entry, $feedHelper);
     $metadatas = MetadataPeer::retrieveAllByObject(MetadataObjectType::ENTRY, $distributionJobData->entryDistribution->entryId);
     $fullMetadataXML = '';
     foreach ($metadatas as $metadataField) {
         $syncKey = $metadataField->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA);
         $currMetaXML = kFileSyncUtils::file_get_contents($syncKey, true, false);
         $fullMetadataXML .= $currMetaXML;
     }
     $feedHelper->setMetasXML($fullMetadataXML);
     if ($distributionJobData instanceof KalturaDistributionSubmitJobData) {
         $this->xml = $feedHelper->buildSubmitFeed();
     } elseif ($distributionJobData instanceof KalturaDistributionUpdateJobData) {
         $this->xml = $feedHelper->buildUpdateFeed();
     } elseif ($distributionJobData instanceof KalturaDistributionDeleteJobData) {
         $this->xml = $feedHelper->buildDeleteFeed();
     }
     KalturaLog::debug("XML Constructed by the Tvinci feed helper :{$this->xml}");
 }
 public function __construct(KalturaDistributionJobData $distributionJobData = null)
 {
     parent::__construct($distributionJobData);
     if (!$distributionJobData) {
         return;
     }
     if (!$distributionJobData->distributionProfile instanceof KalturaTvinciDistributionProfile) {
         return;
     }
     $fieldValues = unserialize($this->fieldValues);
     $entry = null;
     if ($distributionJobData->entryDistribution->entryId) {
         $entry = entryPeer::retrieveByPK($distributionJobData->entryDistribution->entryId);
     }
     if (!$entry) {
         KalturaLog::err("Can't find entry with id: {$distributionJobData->entryDistribution->entryId}");
         return;
     }
     $feedHelper = new TvinciDistributionFeedHelper($distributionJobData->distributionProfile, $fieldValues);
     $feedHelper->setEntryId($entry->getId());
     $feedHelper->setCreatedAt($entry->getCreatedAtAsInt());
     $broadcasterName = 'Kaltura-' . $entry->getPartnerId();
     $feedHelper->setBroadcasterName($broadcasterName);
     $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds));
     $picRatios = array();
     $defaultThumbUrl = null;
     foreach ($thumbAssets as $thumbAsset) {
         $thumbDownloadUrl = $this->getAssetDownloadUrl($thumbAsset);
         $ratio = KDLVideoAspectRatio::ConvertFrameSize($thumbAsset->getWidth(), $thumbAsset->getHeight());
         $picRatios[] = array('url' => $thumbDownloadUrl, 'ratio' => $ratio);
         if ($thumbAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
             $defaultThumbUrl = $thumbDownloadUrl;
         }
     }
     $feedHelper->setPicRatiosArray($picRatios);
     if (!$defaultThumbUrl && count($picRatios)) {
         // Choose the URL of the first resource in the array
         $defaultThumbUrl = $picRatios[0]['url'];
     }
     $feedHelper->setDefaultThumbnailUrl($defaultThumbUrl);
     $this->initPlayManifestUrls($entry, $feedHelper);
     if ($distributionJobData instanceof KalturaDistributionSubmitJobData) {
         $this->xml = $feedHelper->buildSubmitFeed();
     } elseif ($distributionJobData instanceof KalturaDistributionUpdateJobData) {
         $this->xml = $feedHelper->buildUpdateFeed();
     } elseif ($distributionJobData instanceof KalturaDistributionDeleteJobData) {
         $this->xml = $feedHelper->buildDeleteFeed();
     }
 }