/** * @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 flavorAsset $flavorAsset * @return string representing the version string */ protected function getFlavorVersionString(flavorAsset $flavorAsset) { $entry = $flavorAsset->getentry(); $partner = $entry->getPartner(); $flavorAssetVersion = $flavorAsset->getVersion(); $partnerFlavorVersion = $partner->getCacheFlavorVersion(); $entryFlavorVersion = $entry->getCacheFlavorVersion(); return (!$flavorAssetVersion ? '' : "/v/{$flavorAssetVersion}") . ($partnerFlavorVersion ? "/pv/{$partnerFlavorVersion}" : '') . ($entryFlavorVersion ? "/ev/{$entryFlavorVersion}" : ''); }
/** * @param flavorAsset $flavor * @param StorageProfile $externalStorage */ protected function exportFlavorAsset(flavorAsset $flavor, StorageProfile $externalStorage) { $flavorParamsIds = $externalStorage->getFlavorParamsIds(); KalturaLog::log(__METHOD__ . " flavorParamsIds [{$flavorParamsIds}]"); if (!is_null($flavorParamsIds) && strlen(trim($flavorParamsIds))) { $flavorParamsArr = explode(',', $flavorParamsIds); if (!in_array($flavor->getFlavorParamsId(), $flavorParamsArr)) { return; } } $key = $flavor->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $this->export($flavor->getentry(), $externalStorage, $key, !$flavor->getIsOriginal()); return true; }
/** * @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; }
/** * @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 BatchJob $parentJob * @param flavorAsset $asset * @param array $files * @return BatchJob */ public static function addConcatJob(BatchJob $parentJob = null, flavorAsset $asset, array $files, $offset = null, $duration = null) { $jobData = new kConcatJobData(); $jobData->setSrcFiles($files); $jobData->setFlavorAssetId($asset->getId()); $jobData->setOffset($offset); $jobData->setDuration($duration); $entry = $asset->getentry(); if ($entry && $entry->getStatus() != entryStatus::READY) { $entry->setStatus(entryStatus::PRECONVERT); $entry->save(); } $batchJob = null; if ($parentJob) { $batchJob = $parentJob->createChild(BatchJobType::CONCAT); } else { $batchJob = new BatchJob(); $batchJob->setPartnerId($asset->getPartnerId()); } $batchJob->setEntryId($asset->getEntryId()); $batchJob->setObjectId($jobData->getFlavorAssetId()); $batchJob->setObjectType(BatchJobObjectType::ASSET); return self::addJob($batchJob, $jobData, BatchJobType::CONCAT); }
/** * @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; }