/** * @param flavorAsset $flavorAsset * @return string */ protected function doGetFlavorAssetUrl(flavorAsset $flavorAsset) { $entry = $flavorAsset->getentry(); $partnerId = $entry->getPartnerId(); $subpId = $entry->getSubpId(); $flavorAssetId = $flavorAsset->getId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId); $this->setFileExtension($flavorAsset->getFileExt()); $versionString = $this->getFlavorVersionString($flavorAsset); $url = "/s{$partnerPath}/serveFlavor/entryId/" . $flavorAsset->getEntryId() . "{$versionString}/flavorId/{$flavorAssetId}"; if ($this->clipTo) { $url .= "/clipTo/{$this->clipTo}"; } if ($this->extention) { $url .= "/name/a.{$this->extention}"; } $url = str_replace('\\', '/', $url); if ($this->protocol != StorageProfile::PLAY_FORMAT_RTMP) { $url .= '?novar=0'; $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $seekFromBytes = $this->getSeekFromBytes(kFileSyncUtils::getLocalFilePathForKey($syncKey)); if ($seekFromBytes) { $url .= '&fs=' . $seekFromBytes; } } else { if ($this->extention && strtolower($this->extention) != 'flv' || $this->containerFormat && strtolower($this->containerFormat) != 'flash video') { $url = "mp4:{$url}"; } } return $url; }
/** * @param flavorAsset $flavorAsset * @return string */ public function getFlavorAssetUrl(flavorAsset $flavorAsset) { $entry = $flavorAsset->getentry(); $partnerId = $entry->getPartnerId(); $subpId = $entry->getSubpId(); $flavorAssetId = $flavorAsset->getId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId); $this->setFileExtension($flavorAsset->getFileExt()); $url = "/s{$partnerPath}/serveFlavor/flavorId/{$flavorAssetId}"; if ($this->clipTo) { $url .= "/clipTo/{$this->clipTo}"; } if ($this->extention) { $url .= "/name/{$flavorAssetId}.{$this->extention}"; } $url = str_replace('\\', '/', $url); if ($this->protocol != StorageProfile::PLAY_FORMAT_RTMP) { $url .= '?novar=0'; $url .= '&e=' . (time() + 120); $secret = $this->getMediaVault(); $fullUrl = $this->protocol . '://' . $this->domain . $url; $url .= '&h=' . md5($secret . $fullUrl); $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $seekFromBytes = $this->getSeekFromBytes(kFileSyncUtils::getLocalFilePathForKey($syncKey)); if ($seekFromBytes) { $url .= '&fs=' . $seekFromBytes; } } else { $url .= '/forceproxy/true'; } return $url; }
/** * @param flavorAsset $flavorAsset * @return string */ protected function doGetFlavorAssetUrl(flavorAsset $flavorAsset) { $partnerId = $flavorAsset->getPartnerId(); $subpId = $flavorAsset->getentry()->getSubpId(); $flavorAssetId = $flavorAsset->getId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId); $this->setFileExtension($flavorAsset->getFileExt()); $this->setContainerFormat($flavorAsset->getContainerFormat()); $versionString = $this->getFlavorVersionString($flavorAsset); $url = "{$partnerPath}/serveFlavor/entryId/" . $flavorAsset->getEntryId() . "{$versionString}/flavorId/{$flavorAssetId}"; if ($this->protocol == StorageProfile::PLAY_FORMAT_RTSP) { return $url; } if ($this->protocol == StorageProfile::PLAY_FORMAT_APPLE_HTTP) { if (strpos($flavorAsset->getTags(), flavorParams::TAG_APPLEMBR) === FALSE) { // we use index_0_av.m3u8 instead of master.m3u8 as temporary solution to overcome // an extra "redirection" done on the part of akamai. // the auto created master.m3u8 file contains a single item playlist to the index_0_av.m3u8 file // this extra "redirection" fails $url = "http://" . @$this->params['hd_ios'] . "/i" . $url . "/index_0_av.m3u8"; } else { $url .= "/file/playlist.m3u8"; } } else { if ($this->clipTo) { $url .= "/clipTo/{$this->clipTo}"; } if ($this->protocol == "hdnetworksmil") { $url = "http://" . $this->params["hd_flash"] . $url . '/forceproxy/true'; } else { if ($this->protocol == StorageProfile::PLAY_FORMAT_RTMP) { $url .= '/forceproxy/true'; $url = trim($url, "/"); if ($this->extention && strtolower($this->extention) != 'flv' || $this->containerFormat && strtolower($this->containerFormat) != 'flash video') { $url = "mp4:{$url}"; } } else { if ($this->extention) { $url .= "/name/a.{$this->extention}"; } if ($this->seekFromTime > 0) { $fromTime = floor($this->seekFromTime / 1000); /* * Akamai servers fail to return subset of the last second of the video. * The URL will return the two last seconds of the video in such cases. **/ $entry = $flavorAsset->getentry(); if ($entry && $fromTime > $entry->getDurationInt() - 1) { $fromTime -= 1; } $url .= "?aktimeoffset={$fromTime}"; } } } } $url = str_replace('\\', '/', $url); return $url; }
/** * @param asset $asset * @params entry $entry * @return string */ public static function getFileName(entry $entry, flavorAsset $flavorAsset = null) { $fileExt = ""; $fileBaseName = $entry->getName(); if ($flavorAsset) { $flavorParams = $flavorAsset->getFlavorParams(); if ($flavorParams) { $fileBaseName = $fileBaseName . " (" . $flavorParams->getName() . ")"; } $fileExt = $flavorAsset->getFileExt(); } else { $syncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA); list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false); if ($fileSync) { $fileExt = $fileSync->getFileExt(); } } return array($fileBaseName, $fileExt); }
/** * @param flavorAsset $flavorAsset * @return string */ public function getFlavorAssetUrl(flavorAsset $flavorAsset) { $entry = $flavorAsset->getentry(); $partnerId = $entry->getPartnerId(); $subpId = $entry->getSubpId(); $flavorAssetId = $flavorAsset->getId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId); $this->setFileExtension($flavorAsset->getFileExt()); $url = "{$partnerPath}/serveFlavor/flavorId/{$flavorAssetId}"; if ($this->clipTo) { $url .= "/clipTo/{$this->clipTo}"; } if ($this->extention) { $url .= "/name/{$flavorAssetId}.{$this->extention}"; } if ($this->protocol != StorageProfile::PLAY_FORMAT_RTMP) { $url .= '?novar=0'; if ($entry->getSecurityPolicy()) { $url = "/s{$url}"; // set expire time in GMT hence the date("Z") offset $url .= "&nva=" . strftime("%Y%m%d%H%M%S", time() - date("Z") + 30); $secret = kConf::get("level3_authentication_key"); $hash = "0" . substr(self::hmac('sha1', $secret, $url), 0, 20); $url .= "&h={$hash}"; } $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $seekFromBytes = $this->getSeekFromBytes(kFileSyncUtils::getLocalFilePathForKey($syncKey)); if ($seekFromBytes) { $url .= '&start=' . $seekFromBytes; } } else { $url .= '/forceproxy/true'; } $url = str_replace('\\', '/', $url); return $url; }
/** * @param string $url * @param string $urlPrefix * @param flavorAsset|flavorParams $flavor * @return array */ protected function getFlavorAssetInfo($url, $urlPrefix = '', $flavor = null) { $ext = null; $audioLanguage = null; $audioLanguageName = null; if ($flavor) { if (is_callable(array($flavor, 'getFileExt'))) { $ext = $flavor->getFileExt(); } //Extract the audio language code from flavor if ($flavor->hasTag(assetParams::TAG_AUDIO_ONLY)) { $audioLanguageData = $this->getAudioLanguage($flavor); if (!$audioLanguageData) { $audioLanguage = 'und'; $audioLanguageName = 'Undefined'; } else { list($audioLanguage, $audioLanguageName) = $audioLanguageData; } } } if (!$ext) { if ($urlPrefix && $url) { $urlPrefix = $urlPrefix . "/"; } $urlPath = parse_url($urlPrefix . $url, PHP_URL_PATH); $ext = pathinfo($urlPath, PATHINFO_EXTENSION); } $bitrate = $flavor ? $flavor->getVideoBitrate() : 0; $width = $flavor ? $flavor->getWidth() : 0; $height = $flavor ? $flavor->getHeight() : 0; return array('url' => $url, 'urlPrefix' => $urlPrefix, 'ext' => $ext, 'bitrate' => $bitrate, 'width' => $width, 'height' => $height, 'audioLanguage' => $audioLanguage, 'audioLanguageName' => $audioLanguageName); }
private function getExternalStorageUrl(flavorAsset $flavorAsset, FileSyncKey $key) { $partner = $this->entry->getPartner(); if (!$partner || !$partner->getStorageServePriority() || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) { return null; } if (is_null($this->storageId) && $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST) { if (kFileSyncUtils::getReadyInternalFileSyncForKey($key)) { // check if having file sync on kaltura dcs return null; } } $fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($key, $this->storageId); if ($fileSync) { $storage = StorageProfilePeer::retrieveByPK($fileSync->getDc()); if (!$storage) { return null; } $urlManager = kUrlManager::getUrlManagerByStorageProfile($fileSync->getDc()); $urlManager->setClipTo($this->clipTo); $urlManager->setSeekFromTime($this->seekFrom); $urlManager->setFileExtension($flavorAsset->getFileExt()); $url = $storage->getDeliveryHttpBaseUrl() . '/' . $urlManager->getFileSyncUrl($fileSync); return $url; } return null; }
/** * @param string $url * @param string $urlPrefix * @param flavorAsset|flavorParams $flavor * @return array */ protected function getFlavorAssetInfo($url, $urlPrefix = '', $flavor = null) { $ext = null; if ($flavor && is_callable(array($flavor, 'getFileExt'))) { $ext = $flavor->getFileExt(); } if (!$ext) { if ($urlPrefix && $url) { $urlPrefix = $urlPrefix . "/"; } $urlPath = parse_url($urlPrefix . $url, PHP_URL_PATH); $ext = pathinfo($urlPath, PATHINFO_EXTENSION); } $bitrate = $flavor ? $flavor->getVideoBitrate() : 0; $width = $flavor ? $flavor->getWidth() : 0; $height = $flavor ? $flavor->getHeight() : 0; return array('url' => $url, 'urlPrefix' => $urlPrefix, 'ext' => $ext, 'bitrate' => $bitrate, 'width' => $width, 'height' => $height); }
/** * @param flavorAsset $flavorAsset * @return string */ protected function doGetFlavorAssetUrl(flavorAsset $flavorAsset) { $partnerId = $flavorAsset->getPartnerId(); $subpId = $flavorAsset->getentry()->getSubpId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId); $flavorAssetId = $flavorAsset->getId(); $this->setFileExtension($flavorAsset->getFileExt()); $this->setContainerFormat($flavorAsset->getContainerFormat()); $versionString = $this->getFlavorVersionString($flavorAsset); $url = "{$partnerPath}/serveFlavor/entryId/" . $flavorAsset->getEntryId() . "{$versionString}/flavorId/{$flavorAssetId}"; if ($this->seekFromTime > 0) { $url .= "/seekFrom/{$this->seekFromTime}"; } if ($this->clipTo) { $url .= "/clipTo/{$this->clipTo}"; } switch ($this->protocol) { case StorageProfile::PLAY_FORMAT_RTMP: $url .= '/forceproxy/true'; if ($this->extention && strtolower($this->extention) != 'flv' || $this->containerFormat && strtolower($this->containerFormat) != 'flash video') { $url = "mp4:{$url}/name/a.mp4"; } else { $url .= "/name/a.flv"; } break; case StorageProfile::PLAY_FORMAT_APPLE_HTTP: $url .= "/file/playlist.m3u8"; break; } $url = str_replace('\\', '/', $url); return $url; }
private static function createNotificationBulkDownloadSucceeded(BatchJob $dbBatchJob, entry $entry, flavorAsset $flavorAsset, FileSyncKey $syncKey) { $localPath = kFileSyncUtils::getLocalFilePathForKey($syncKey); $downloadUrl = $flavorAsset->getDownloadUrl(); $notificationData = array("puserId" => $entry->getPuserId(), "entryId" => $entry->getId(), "entryIntId" => $entry->getIntId(), "entryVersion" => $entry->getVersion(), "fileFormat" => $flavorAsset->getFileExt(), "archivedFile" => $localPath, "downoladPath" => $localPath, "conversionQuality" => $entry->getConversionQuality(), "downloadUrl" => $downloadUrl); $extraData = array("data" => json_encode($notificationData), "partner_id" => $entry->getPartnerId(), "puser_id" => $entry->getPuserId(), "entry_id" => $entry->getId(), "entry_int_id" => $entry->getIntId(), "entry_version" => $entry->getVersion(), "file_format" => $flavorAsset->getFileExt(), "archived_file" => $localPath, "downolad_path" => $localPath, "target" => $localPath, "conversion_quality" => $entry->getConversionQuality(), "download_url" => $downloadUrl, "status" => $entry->getStatus(), "abort" => $dbBatchJob->getExecutionStatus() == BatchJobExecutionStatus::ABORTED, "message" => $dbBatchJob->getMessage(), "description" => $dbBatchJob->getDescription(), "job_type" => BatchJobType::DOWNLOAD, "status" => BatchJob::BATCHJOB_STATUS_FINISHED, "progress" => 100, "debug" => __LINE__); myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_BATCH_JOB_SUCCEEDED, $dbBatchJob, $dbBatchJob->getPartnerId(), null, null, $extraData, $dbBatchJob->getEntryId()); }
private function getExternalStorageUrl(Partner $partner, flavorAsset $flavorAsset, FileSyncKey $key) { if (!$partner->getStorageServePriority() || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) { return null; } if ($partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST) { if (kFileSyncUtils::getReadyInternalFileSyncForKey($key)) { // check if having file sync on kaltura dcs return null; } } $fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($key); if (!$fileSync) { return null; } $storage = StorageProfilePeer::retrieveByPK($fileSync->getDc()); if (!$storage) { return null; } $urlManager = kUrlManager::getUrlManagerByStorageProfile($fileSync->getDc(), $flavorAsset->getEntryId()); $urlManager->setFileExtension($flavorAsset->getFileExt()); $url = $storage->getDeliveryHttpBaseUrl() . '/' . $urlManager->getFileSyncUrl($fileSync); return $url; }
/** * @param kUrlManager $urlManager * @param FileSync $fileSync * @param flavorAsset $flavorAsset * @param string $format */ private function setupUrlManager($urlManager, FileSync $fileSync = null, flavorAsset $flavorAsset = null, $format = null) { $urlManager->setClipTo($this->clipTo); if ($flavorAsset) { $urlManager->setContainerFormat($flavorAsset->getContainerFormat()); } if ($flavorAsset && $flavorAsset->getFileExt() !== null) { // if the extension is missig use the one from the actual path $urlManager->setFileExtension($flavorAsset->getFileExt()); } else { if ($fileSync) { $urlManager->setFileExtension(pathinfo($fileSync->getFilePath(), PATHINFO_EXTENSION)); } } if (!$format) { $format = $this->format; } $urlManager->setProtocol($format); }
/** * @param flavorAsset $flavorAsset * @return string */ public function getFlavorAssetUrl(flavorAsset $flavorAsset) { $partnerId = $flavorAsset->getPartnerId(); $subpId = $flavorAsset->getentry()->getSubpId(); $flavorAssetId = $flavorAsset->getId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId); $this->setFileExtension($flavorAsset->getFileExt()); $this->setContainerFormat($flavorAsset->getContainerFormat()); $url = "{$partnerPath}/serveFlavor/flavorId/{$flavorAssetId}"; if ($this->protocol == StorageProfile::PLAY_FORMAT_APPLE_HTTP) { if (strpos($flavorAsset->getTags(), flavorParams::TAG_APPLEMBR) === FALSE) { $url = "http://" . @$this->params['hd_ios'] . "/i" . $url . "/index_0_av.m3u8"; } else { $url .= "/file/playlist.m3u8"; } } else { if ($this->clipTo) { $url .= "/clipTo/{$this->clipTo}"; } if ($this->extention) { $url .= "/name/{$flavorAssetId}.{$this->extention}"; } if ($this->protocol == StorageProfile::PLAY_FORMAT_RTMP) { $url .= '/forceproxy/true'; if ($this->extention && strtolower($this->extention) != 'flv' || $this->containerFormat && strtolower($this->containerFormat) != 'flash video') { $url = "mp4:{$url}"; } } else { if ($this->seekFromTime > 0) { $url .= '?aktimeoffset=' . floor($this->seekFromTime / 1000); } } } if ($this->protocol == "hdnetworksmil") { $url = "http://" . $this->params["hd_flash"] . $url; } $url = str_replace('\\', '/', $url); if ($this->protocol == StorageProfile::PLAY_FORMAT_HTTP && @$this->params['http_auth_salt']) { $window = $this->params['http_auth_seconds']; $param = $this->params['http_auth_param']; $salt = $this->params['http_auth_salt']; $root_dir = $this->params['http_auth_root_dir']; $url = $this->urlauth_gen_url($root_dir . $url, $param, $window, $salt, null, null); } return $url; }