/** * @param flavorAsset $flavorAsset * @param SimpleXMLElement $mrss * @return SimpleXMLElement */ protected static function appendFlavorAssetMrss(flavorAsset $flavorAsset, SimpleXMLElement $mrss = null, kMrssParameters $mrssParams = null) { if (!$mrss) { $mrss = new SimpleXMLElement('<item/>'); } $servePlayManifest = false; $playManifestClientTag = null; $storageId = null; if ($mrssParams) { $servePlayManifest = $mrssParams->getServePlayManifest(); $playManifestClientTag = $mrssParams->getPlayManifestClientTag(); $storageId = $mrssParams->getStorageId(); } $content = $mrss->addChild('content'); $content->addAttribute('url', kAssetUtils::getAssetUrl($flavorAsset, $servePlayManifest, $playManifestClientTag, $storageId)); $content->addAttribute('flavorAssetId', $flavorAsset->getId()); $content->addAttribute('isSource', $flavorAsset->getIsOriginal() ? 'true' : 'false'); $content->addAttribute('containerFormat', $flavorAsset->getContainerFormat()); $content->addAttribute('extension', $flavorAsset->getFileExt()); $content->addAttribute('createdAt', $flavorAsset->getCreatedAt()); // get the file size $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false); $fileSize = $fileSync && $fileSync->getFileSize() > 0 ? $fileSync->getFileSize() : $flavorAsset->getSize() * 1024; $mediaParams = array('format' => $flavorAsset->getContainerFormat(), 'videoBitrate' => $flavorAsset->getBitrate(), 'fileSize' => $fileSize, 'videoCodec' => $flavorAsset->getVideoCodecId(), 'audioBitrate' => 0, 'audioCodec' => '', 'frameRate' => $flavorAsset->getFrameRate(), 'height' => $flavorAsset->getHeight(), 'width' => $flavorAsset->getWidth()); if (!is_null($flavorAsset->getFlavorParamsId())) { $content->addAttribute('flavorParamsId', $flavorAsset->getFlavorParamsId()); $flavorParams = assetParamsPeer::retrieveByPK($flavorAsset->getFlavorParamsId()); if ($flavorParams) { $content->addAttribute('flavorParamsName', $flavorParams->getName()); $flavorParamsDetails = array('format' => $flavorParams->getFormat(), 'videoBitrate' => $flavorParams->getVideoBitrate(), 'videoCodec' => $flavorParams->getVideoCodec(), 'audioBitrate' => $flavorParams->getAudioBitrate(), 'audioCodec' => $flavorParams->getAudioCodec(), 'frameRate' => $flavorParams->getFrameRate(), 'height' => $flavorParams->getHeight(), 'width' => $flavorParams->getWidth()); // merge the flavar param details with the flavor asset details // the flavor asset details take precedence whenever they exist $mediaParams = array_merge($flavorParamsDetails, array_filter($mediaParams)); } } foreach ($mediaParams as $key => $value) { $content->addAttribute($key, $value); } $tags = $content->addChild('tags'); foreach (explode(',', $flavorAsset->getTags()) as $tag) { $tags->addChild('tag', self::stringToSafeXml($tag)); } if ($flavorAsset->hasTag(assetParams::TAG_SLWEB)) { self::addIsmLink($flavorAsset->getentry(), $mrss); } }
/** * @param flavorAsset $flavorAsset * @param SimpleXMLElement $mrss * @return SimpleXMLElement */ protected static function appendFlavorAssetMrss(flavorAsset $flavorAsset, SimpleXMLElement $mrss = null, kMrssParameters $mrssParams = null) { if (!$mrss) { $mrss = new SimpleXMLElement('<item/>'); } $content = $mrss->addChild('content'); $content->addAttribute('url', self::getAssetUrl($flavorAsset, $mrssParams ? $mrssParams->getStorageId() : null)); $content->addAttribute('flavorAssetId', $flavorAsset->getId()); $content->addAttribute('isSource', $flavorAsset->getIsOriginal() ? 'true' : 'false'); $content->addAttribute('containerFormat', $flavorAsset->getContainerFormat()); $content->addAttribute('extension', $flavorAsset->getFileExt()); $content->addAttribute('createdAt', $flavorAsset->getCreatedAt()); $mediaParams = array('format' => $flavorAsset->getContainerFormat(), 'videoBitrate' => $flavorAsset->getBitrate(), 'fileSize' => $flavorAsset->getSize() * 1024, 'videoCodec' => $flavorAsset->getVideoCodecId(), 'audioBitrate' => 0, 'audioCodec' => '', 'frameRate' => $flavorAsset->getFrameRate(), 'height' => $flavorAsset->getHeight(), 'width' => $flavorAsset->getWidth()); if (!is_null($flavorAsset->getFlavorParamsId())) { $content->addAttribute('flavorParamsId', $flavorAsset->getFlavorParamsId()); $flavorParams = assetParamsPeer::retrieveByPK($flavorAsset->getFlavorParamsId()); if ($flavorParams) { $content->addAttribute('flavorParamsName', $flavorParams->getName()); $flavorParamsDetails = array('format' => $flavorParams->getFormat(), 'videoBitrate' => $flavorParams->getVideoBitrate(), 'videoCodec' => $flavorParams->getVideoCodec(), 'audioBitrate' => $flavorParams->getAudioBitrate(), 'audioCodec' => $flavorParams->getAudioCodec(), 'frameRate' => $flavorParams->getFrameRate(), 'height' => $flavorParams->getHeight(), 'width' => $flavorParams->getWidth()); // merge the flavar param details with the flavor asset details // the flavor asset details take precedence whenever they exist $mediaParams = array_merge($flavorParamsDetails, array_filter($mediaParams)); } } foreach ($mediaParams as $key => $value) { $content->addAttribute($key, $value); } $tags = $content->addChild('tags'); foreach (explode(',', $flavorAsset->getTags()) as $tag) { $tags->addChild('tag', self::stringToSafeXml($tag)); } if ($flavorAsset->hasTag(assetParams::TAG_SLWEB)) { self::addIsmLink($flavorAsset->getentry(), $mrss); } }