/** * @return int */ private function initEntryDuration() { $this->duration = $this->entry->getDurationInt(); $flavors = $this->deliveryAttributes->getFlavorAssets(); foreach ($flavors as $flavorAsset) { /* @var $flavorAsset flavorAsset */ $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($flavorAsset->getId()); if ($mediaInfo && ($mediaInfo->getVideoDuration() || $mediaInfo->getAudioDuration() || $mediaInfo->getContainerDuration())) { $duration = $mediaInfo->getVideoDuration() ? $mediaInfo->getVideoDuration() : ($mediaInfo->getAudioDuration() ? $mediaInfo->getAudioDuration() : $mediaInfo->getContainerDuration()); $this->duration = $duration / 1000; break; } } }
/** * @return kManifestRenderer */ private function serveHDNetworkManifest() { $flavor = $this->getSecureHdUrl(); if (!$flavor) { return null; } $duration = $this->entry->getDurationInt(); $renderer = new kF4MManifestRenderer(); $renderer->entryId = $this->entryId; $renderer->duration = $duration; $renderer->flavors = array($flavor); $renderer->tokenizer = $this->tokenizer; return $renderer; }
public function execute() { $this->entryId = $this->getRequestParameter("entryId", null); $this->flavorId = $this->getRequestParameter("flavorId", null); $this->storageId = $this->getRequestParameter("storageId", null); $this->maxBitrate = $this->getRequestParameter("maxBitrate", null); $flavorIdsStr = $this->getRequestParameter("flavorIds", null); if ($flavorIdsStr) { $this->flavorIds = explode(",", $flavorIdsStr); } $this->entry = entryPeer::retrieveByPKNoFilter($this->entryId); if (!$this->entry) { KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND); } if (!$this->flavorId) { $flavorParamId = $this->getRequestParameter("flavorParamId", null); if ($flavorParamId) { $flavorAsset = flavorAssetPeer::retrieveByEntryIdAndFlavorParams($entry->getId(), $flavorParamId); if (!$flavorAsset) { KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND); } $this->flavorId = $flavorAsset->getId(); } } $this->validateStorageId(); $this->protocol = $this->getRequestParameter("protocol", null); if (!$this->protocol) { $this->protocol = StorageProfile::PLAY_FORMAT_HTTP; } $this->format = $this->getRequestParameter("format"); if (!$this->format) { $this->format = StorageProfile::PLAY_FORMAT_HTTP; } $this->cdnHost = $this->getRequestParameter("cdnHost", null); $partner = $this->entry->getPartner(); if (!$this->cdnHost || $partner->getForceCdnHost()) { $this->cdnHost = myPartnerUtils::getCdnHost($this->entry->getPartnerId(), $this->protocol); } if ($this->maxBitrate && (!is_numeric($this->maxBitrate) || $this->maxBitrate <= 0)) { KExternalErrors::dieError(KExternalErrors::INVALID_MAX_BITRATE); } $ksStr = $this->getRequestParameter("ks"); $base64Referrer = $this->getRequestParameter("referrer"); $referrer = base64_decode($base64Referrer); if (!is_string($referrer)) { $referrer = ""; } // base64_decode can return binary data $securyEntryHelper = new KSecureEntryHelper($this->entry, $ksStr, $referrer); if ($securyEntryHelper->shouldPreview()) { $this->clipTo = $securyEntryHelper->getPreviewLength() * 1000; } else { $securyEntryHelper->validateForPlay($this->entry, $ksStr); } // grab seekFrom parameter and normalize url $this->seekFrom = $this->getRequestParameter("seekFrom", -1); if ($this->seekFrom <= 0) { $this->seekFrom = -1; } if ($this->entry->getStatus() == entryStatus::DELETED) { // because the fiter was turned off - a manual check for deleted entries must be done. die; } $xml = null; switch ($this->format) { case StorageProfile::PLAY_FORMAT_HTTP: $xml = $this->serveHttp(); break; case StorageProfile::PLAY_FORMAT_RTMP: $xml = $this->serveRtmp(); break; case StorageProfile::PLAY_FORMAT_SILVER_LIGHT: $xml = $this->serveSilverLight(); break; case StorageProfile::PLAY_FORMAT_APPLE_HTTP: $xml = $this->serveAppleHttp(); break; case "url": return $this->serveUrl(); break; case "hdnetworksmil": $xml = $this->serveHDNetwork(); break; case "hdnetwork": $duration = $this->entry->getDurationInt(); $mediaUrl = "<media url=\"" . requestUtils::getHost() . str_replace("f4m", "smil", str_replace("hdnetwork", "hdnetworksmil", $_SERVER["REQUEST_URI"])) . "\"/>"; $xml = $this->buildXml(self::PLAY_STREAM_TYPE_RECORDED, array(), 'video/x-flv', $duration, null, $mediaUrl); break; } if ($this->format == StorageProfile::PLAY_FORMAT_APPLE_HTTP) { header("Content-Type: text/plain; charset=UTF-8"); } else { header("Content-Type: text/xml; charset=UTF-8"); header("Content-Disposition: inline; filename=manifest.xml"); } echo $xml; die; }
public static function setSearchTextDiscreteForEntry(entry $obj) { $searchText = array(); // categories if ($obj->getCategoriesIds()) { $categories = explode(entry::ENTRY_CATEGORY_SEPARATOR, $obj->getCategoriesIds()); foreach ($categories as $category) { $searchText[] = self::ENTRY_CATEGORY_ID_PREFIX . $category; } } // duration type $duration = $obj->getDurationInt(); $searchText[] = self::ENTRY_DURATION_TYPE_PREFIX . entryPeer::getDurationType($duration); // flavor params ids $getFlavorParamsIds = explode(",", $obj->getFlavorParamsIds()); foreach ($getFlavorParamsIds as $getFlavorParamsIds) { $searchText[] = self::ENTRY_FLAVOR_PARAMS_PREFIX . $getFlavorParamsIds; } $obj->setSearchTextDiscrete(implode(" ", $searchText)); }