コード例 #1
0
 protected function doGetFlavorAssetUrl(flavorAsset $flavorAsset)
 {
     $partnerId = $flavorAsset->getPartnerId();
     $flavorAssetId = $flavorAsset->getId();
     $versionString = $this->getFlavorVersionString($flavorAsset);
     return "/p/{$partnerId}/serveFlavor{$versionString}/flavorId/{$flavorAssetId}";
 }
 /**
  * @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;
 }
コード例 #3
0
 /**
  * @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;
 }
コード例 #5
0
 /**
  * @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;
 }
コード例 #6
0
 public static function getReadyBehavior(flavorAsset $flavorAsset, conversionProfile2 $profile = null)
 {
     $targetFlavor = assetParamsOutputPeer::retrieveByAssetId($flavorAsset->getId());
     if ($targetFlavor) {
         return $targetFlavor->getReadyBehavior();
     }
     if (!$profile) {
         try {
             $profile = myPartnerUtils::getConversionProfile2ForEntry($flavorAsset->getEntryId());
         } catch (Exception $e) {
             KalturaLog::err($e->getMessage());
         }
     }
     if ($profile) {
         $flavorParamsConversionProfile = flavorParamsConversionProfilePeer::retrieveByFlavorParamsAndConversionProfile($flavorAsset->getFlavorParamsId(), $profile->getId());
         if ($flavorParamsConversionProfile) {
             return $flavorParamsConversionProfile->getReadyBehavior();
         }
     }
     return flavorParamsConversionProfile::READY_BEHAVIOR_NO_IMPACT;
 }
コード例 #7
0
 public static function getReadyBehavior(flavorAsset $flavorAsset)
 {
     if ($flavorAsset->getIsOriginal()) {
         try {
             $profile = myPartnerUtils::getConversionProfile2ForEntry($flavorAsset->getEntryId());
             if ($profile) {
                 $flavorParamsConversionProfile = flavorParamsConversionProfilePeer::retrieveByFlavorParamsAndConversionProfile($flavorAsset->getFlavorParamsId(), $profile->getId());
                 if ($flavorParamsConversionProfile) {
                     return $flavorParamsConversionProfile->getReadyBehavior();
                 }
             }
         } catch (Exception $e) {
             KalturaLog::err('getConversionProfile2ForEntry Error: ' . $e->getMessage());
         }
     }
     $targetFlavor = flavorParamsOutputPeer::retrieveByFlavorAssetId($flavorAsset->getId());
     if ($targetFlavor) {
         return $targetFlavor->getReadyBehavior();
     }
     return flavorParamsConversionProfile::READY_BEHAVIOR_INHERIT_FLAVOR_PARAMS;
 }
コード例 #8
0
 /**
  * @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;
 }
コード例 #9
0
 private static function decideSourceFlavorConvert($entryId, assetParams $sourceFlavor = null, flavorAsset $originalFlavorAsset, $conversionProfileId, $flavors, mediaInfo $mediaInfo = null, BatchJob $parentJob, BatchJob $convertProfileJob)
 {
     if ($sourceFlavor && ($sourceFlavor->getOperators() || $sourceFlavor->getConversionEngines()) && $originalFlavorAsset->getInterFlowCount() == null) {
         KalturaLog::log("Source flavor asset requires conversion");
         self::adjustAssetParams($entryId, array($sourceFlavor));
         $srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         $errDescription = null;
         $sourceFlavorOutput = self::validateFlavorAndMediaInfo($sourceFlavor, $mediaInfo, $errDescription);
         if (!$sourceFlavorOutput) {
             if (!$errDescription) {
                 $errDescription = "Failed to create flavor params output from source flavor";
             }
             $originalFlavorAsset->setDescription($originalFlavorAsset->getDescription() . "\n{$errDescription}");
             $originalFlavorAsset->setStatus(flavorAsset::ASSET_STATUS_ERROR);
             $originalFlavorAsset->save();
             kBatchManager::updateEntry($entryId, entryStatus::ERROR_CONVERTING);
             kJobsManager::updateBatchJob($convertProfileJob, BatchJob::BATCHJOB_STATUS_FAILED);
             return false;
         }
     } elseif ($mediaInfo) {
         /*
          * Check whether there is a need for an intermediate source pre-processing
          */
         $sourceFlavorOutput = KDLWrap::GenerateIntermediateSource($mediaInfo, $flavors);
         if (!$sourceFlavorOutput) {
             return true;
         }
         $srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         $errDescription = null;
         /*
          * Save the original source asset in another asset, in order 
          * to prevent its liquidated by the inter-source asset.
          * But, do it only if the conversion profile contains source flavor
          */
         if ($sourceFlavor) {
             $sourceAsset = assetPeer::retrieveById($mediaInfo->getFlavorAssetId());
             $copyFlavorParams = assetParamsPeer::retrieveBySystemName(self::SAVE_ORIGINAL_SOURCE_FLAVOR_PARAM_SYS_NAME);
             if (!$copyFlavorParams) {
                 throw new APIException(APIErrors::OBJECT_NOT_FOUND);
             }
             $asset = $sourceAsset->copy();
             $asset->setFlavorParamsId($copyFlavorParams->getId());
             $asset->setFromAssetParams($copyFlavorParams);
             $asset->setStatus(flavorAsset::ASSET_STATUS_READY);
             $asset->setIsOriginal(0);
             $asset->setTags($copyFlavorParams->getTags());
             $asset->incrementVersion();
             $asset->save();
             kFileSyncUtils::createSyncFileLinkForKey($asset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET), $sourceAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET));
             $origFileSync = kFileSyncUtils::getLocalFileSyncForKey($sourceAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET));
             $asset->setSize(intval($origFileSync->getFileSize() / 1000));
             $asset->save();
         }
     }
     /*
      * '_passthrough' controls whether the source is to be 'passthrough' although there 
      * is a source flavor that contains transcoder settings.
      * Looks for a '_passthrough' flag on the source's flavor params output.
      */
     if (!$sourceFlavorOutput || $sourceFlavorOutput->_passthrough == true) {
         return true;
     }
     // save flavor params
     $sourceFlavorOutput->setPartnerId($sourceFlavorOutput->getPartnerId());
     $sourceFlavorOutput->setEntryId($entryId);
     $sourceFlavorOutput->setFlavorAssetId($originalFlavorAsset->getId());
     $sourceFlavorOutput->setFlavorAssetVersion($originalFlavorAsset->getVersion());
     $sourceFlavorOutput->save();
     if ($errDescription) {
         $originalFlavorAsset->setDescription($originalFlavorAsset->getDescription() . "\n{$errDescription}");
     }
     $errDescription = kBusinessConvertDL::parseFlavorDescription($sourceFlavorOutput);
     if ($errDescription) {
         $originalFlavorAsset->setDescription($originalFlavorAsset->getDescription() . "\n{$errDescription}");
     }
     // decided by the business logic layer
     if ($sourceFlavorOutput->_create_anyway) {
         KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] selected to be created anyway");
     } else {
         if (!$sourceFlavorOutput->IsValid()) {
             KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is invalid");
             $originalFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
             $originalFlavorAsset->save();
             $errDescription = "Source flavor could not be converted";
             self::setError($errDescription, $convertProfileJob, BatchJobType::CONVERT_PROFILE, $convertProfileJob->getEntryId());
             return false;
         }
         if ($sourceFlavorOutput->_force) {
             KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is forced");
         } elseif ($sourceFlavorOutput->_isNonComply) {
             KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is none-comply");
         } else {
             KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is valid");
         }
     }
     $originalFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_CONVERTING);
     if (isset($sourceFlavor)) {
         $originalFlavorAsset->addTags($sourceFlavor->getTagsArray());
         $originalFlavorAsset->setFileExt($sourceFlavorOutput->getFileExt());
         $originalFlavorAsset->save();
     }
     // save flavor params
     $sourceFlavorOutput->setFlavorAssetVersion($originalFlavorAsset->getVersion());
     $sourceFlavorOutput->save();
     $mediaInfoId = null;
     if ($mediaInfo) {
         $mediaInfoId = $mediaInfo->getId();
     }
     kJobsManager::addFlavorConvertJob(array($srcSyncKey), $sourceFlavorOutput, $originalFlavorAsset->getId(), $conversionProfileId, $mediaInfoId, $parentJob);
     return false;
 }
コード例 #10
0
ファイル: kJobsManager.php プロジェクト: ace3535/server
 /**
  * @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);
 }
コード例 #11
0
 /**
  * 
  * @param $flavorAsset
  * @param $con
  * 
  * @return flavorParamsOutput
  */
 public static function retrieveByFlavorAsset(flavorAsset $flavorAsset, $con = null)
 {
     return self::retrieveByFlavorAssetId($flavorAsset->getId(), $flavorAsset->getVersion(), $con);
 }
コード例 #12
0
ファイル: DocumentsService.php プロジェクト: DBezemer/server
 /**
  * Serves the file content
  * 
  * @action serve
  * @param flavorAsset $flavorAsset
  * @param string $fileName
  * @param bool $forceProxy
  * @return file
  * 
  * @throws KalturaErrors::FLAVOR_ASSET_IS_NOT_READY
  */
 protected function serveFlavorAsset(flavorAsset $flavorAsset, $fileName, $forceProxy = false)
 {
     $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
     if (!$fileSync) {
         throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_IS_NOT_READY, $flavorAsset->getId());
     }
     /* @var $fileSync FileSync */
     if ($fileSync->getFileExt() != assetParams::CONTAINER_FORMAT_SWF) {
         header("Content-Disposition: attachment; filename=\"{$fileName}\"");
     }
     if ($local) {
         $filePath = $fileSync->getFullPath();
         $mimeType = kFile::mimeType($filePath);
         return $this->dumpFile($filePath, $mimeType);
     } else {
         $remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
         KalturaLog::info("Redirecting to [{$remoteUrl}]");
         if ($forceProxy) {
             kFileUtils::dumpUrl($remoteUrl);
         } else {
             // or redirect if no proxy
             header("Location: {$remoteUrl}");
             die;
         }
     }
 }
コード例 #13
0
ファイル: kBatchManager.php プロジェクト: richhl/kalturaCE
 /**
  * batch createFlavorAsset orgenize a convert job data 
  * 
  * @param flavorParamsOutputWrap $flavor
  * @param int $partnerId
  * @param int $entryId
  * @param string $description
  * @return flavorAsset
  */
 public static function createErrorFlavorAsset(flavorParamsOutputWrap $flavor, $partnerId, $entryId, $description)
 {
     $flavorAsset = flavorAssetPeer::retrieveByEntryIdAndFlavorParams($entryId, $flavor->getFlavorParamsId());
     if ($flavorAsset) {
         $description = $flavorAsset->getDescription() . "\n" . $description;
         $flavorAsset->setDescription($description);
         $flavorAsset->incrementVersion();
     } else {
         // creates the flavor asset
         $flavorAsset = new flavorAsset();
         $flavorAsset->setPartnerId($partnerId);
         $flavorAsset->setEntryId($entryId);
         $flavorAsset->setDescription($description);
     }
     $flavorAsset->setTags($flavor->getTags());
     $flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
     $flavorAsset->setFlavorParamsId($flavor->getFlavorParamsId());
     $flavorAsset->setFileExt($flavor->getFileExt());
     $flavorAsset->save();
     // save flavor params
     $flavor->setPartnerId($partnerId);
     $flavor->setEntryId($entryId);
     $flavor->setFlavorAssetId($flavorAsset->getId());
     $flavor->setFlavorAssetVersion($flavorAsset->getVersion());
     $flavor->save();
     return $flavorAsset;
 }
コード例 #14
0
ファイル: StorageProfile.php プロジェクト: kubrickfr/server
 /**
  * @param flavorAsset $flavorAsset
  * @return boolean true if the given flavor asset is configured to be exported or false otherwise
  */
 public function shouldExportFlavorAsset(flavorAsset $flavorAsset, $skipFlavorAssetStatusValidation = false)
 {
     KalturaLog::debug('Checking if flavor asset [' . $flavorAsset->getId() . '] should be exported to [' . $this->getId() . ']');
     if (!$skipFlavorAssetStatusValidation && !$flavorAsset->isLocalReadyStatus()) {
         KalturaLog::debug('Flavor is not ready for export');
         return false;
     }
     if (!$this->isFlavorAssetConfiguredForExport($flavorAsset)) {
         KalturaLog::debug('Flavor asset is not configured for export');
         return false;
     }
     $scope = $this->getScope();
     $scope->setEntryId($flavorAsset->getEntryId());
     if (!$this->fulfillsRules($scope)) {
         KalturaLog::debug('Storage profile export rules are not fulfilled');
         return false;
     }
     KalturaLog::debug('Flavor should be exported');
     return true;
 }
 /**
  * @param BatchJob $dbBatchJob
  * @param flavorAsset $currentFlavorAsset
  * @return BatchJob
  */
 public static function handleConvertFinished(BatchJob $dbBatchJob = null, flavorAsset $currentFlavorAsset)
 {
     KalturaLog::debug("entry id [" . $currentFlavorAsset->getEntryId() . "] flavor asset id [" . $currentFlavorAsset->getId() . "]");
     $profile = null;
     try {
         $profile = myPartnerUtils::getConversionProfile2ForEntry($currentFlavorAsset->getEntryId());
         KalturaLog::debug("profile [" . $profile->getId() . "]");
     } catch (Exception $e) {
         KalturaLog::err($e->getMessage());
     }
     $currentReadyBehavior = self::getReadyBehavior($currentFlavorAsset, $profile);
     KalturaLog::debug("Current ready behavior [{$currentReadyBehavior}]");
     if ($currentReadyBehavior == flavorParamsConversionProfile::READY_BEHAVIOR_IGNORE) {
         return $dbBatchJob;
     }
     $rootBatchJob = null;
     if ($dbBatchJob) {
         $rootBatchJob = $dbBatchJob->getRootJob();
     }
     if ($rootBatchJob) {
         KalturaLog::debug("root batch job id [" . $rootBatchJob->getId() . "] type [" . $rootBatchJob->getJobType() . "]");
     }
     // update the root job end exit
     if ($rootBatchJob && $rootBatchJob->getJobType() == BatchJobType::BULKDOWNLOAD) {
         $siblingJobs = $rootBatchJob->getChildJobs();
         foreach ($siblingJobs as $siblingJob) {
             // checking only conversion child jobs
             if ($siblingJob->getJobType() != BatchJobType::CONVERT && $siblingJob->getJobType() != BatchJobType::CONVERT_COLLECTION && $siblingJob->getJobType() != BatchJobType::POSTCONVERT) {
                 continue;
             }
             // if not complete leave function
             if (!in_array($siblingJob->getStatus(), BatchJobPeer::getClosedStatusList())) {
                 KalturaLog::debug("job id [" . $siblingJob->getId() . "] status [" . $siblingJob->getStatus() . "]");
                 return $dbBatchJob;
             }
         }
         KalturaLog::debug("finish bulk download root job");
         // all child jobs completed
         kJobsManager::updateBatchJob($rootBatchJob, BatchJob::BATCHJOB_STATUS_FINISHED);
         return $dbBatchJob;
     }
     $inheritedFlavorParamsIds = array();
     $requiredFlavorParamsIds = array();
     $flavorParamsConversionProfileItems = array();
     if ($profile) {
         $flavorParamsConversionProfileItems = flavorParamsConversionProfilePeer::retrieveByConversionProfile($profile->getId());
     }
     foreach ($flavorParamsConversionProfileItems as $flavorParamsConversionProfile) {
         if ($flavorParamsConversionProfile->getReadyBehavior() == flavorParamsConversionProfile::READY_BEHAVIOR_REQUIRED) {
             $requiredFlavorParamsIds[$flavorParamsConversionProfile->getFlavorParamsId()] = true;
         }
         if ($flavorParamsConversionProfile->getReadyBehavior() == flavorParamsConversionProfile::READY_BEHAVIOR_NO_IMPACT) {
             $inheritedFlavorParamsIds[] = $flavorParamsConversionProfile->getFlavorParamsId();
         }
     }
     $flavorParamsItems = assetParamsPeer::retrieveByPKs($inheritedFlavorParamsIds);
     foreach ($flavorParamsItems as $flavorParams) {
         if ($flavorParams->getReadyBehavior() == flavorParamsConversionProfile::READY_BEHAVIOR_REQUIRED) {
             $requiredFlavorParamsIds[$flavorParamsConversionProfile->getFlavorParamsId()] = true;
         }
     }
     KalturaLog::debug("required flavor params ids [" . print_r($requiredFlavorParamsIds, true) . "]");
     // go over all the flavor assets of the entry
     $inCompleteFlavorIds = array();
     $origianlAssetFlavorId = null;
     $siblingFlavorAssets = assetPeer::retrieveFlavorsByEntryId($currentFlavorAsset->getEntryId());
     foreach ($siblingFlavorAssets as $siblingFlavorAsset) {
         KalturaLog::debug("sibling flavor asset id [" . $siblingFlavorAsset->getId() . "] flavor params id [" . $siblingFlavorAsset->getFlavorParamsId() . "]");
         // don't mark any incomplete flag
         if ($siblingFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_READY) {
             KalturaLog::debug("sibling flavor asset id [" . $siblingFlavorAsset->getId() . "] is ready");
             if (isset($requiredFlavorParamsIds[$siblingFlavorAsset->getFlavorParamsId()])) {
                 unset($requiredFlavorParamsIds[$siblingFlavorAsset->getFlavorParamsId()]);
             }
             continue;
         }
         $readyBehavior = self::getReadyBehavior($siblingFlavorAsset, $profile);
         if ($siblingFlavorAsset->getStatus() == flavorAsset::ASSET_STATUS_EXPORTING) {
             if ($siblingFlavorAsset->getIsOriginal()) {
                 $origianlAssetFlavorId = $siblingFlavorAsset->getFlavorParamsId();
             } else {
                 if ($readyBehavior != flavorParamsConversionProfile::READY_BEHAVIOR_IGNORE) {
                     KalturaLog::debug("sibling flavor asset id [" . $siblingFlavorAsset->getId() . "] is incomplete");
                     $inCompleteFlavorIds[] = $siblingFlavorAsset->getFlavorParamsId();
                 }
             }
         }
         if ($readyBehavior == flavorParamsConversionProfile::READY_BEHAVIOR_IGNORE) {
             KalturaLog::debug("sibling flavor asset id [" . $siblingFlavorAsset->getId() . "] is ignored");
             continue;
         }
         if ($siblingFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_QUEUED || $siblingFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_CONVERTING || $siblingFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_IMPORTING || $siblingFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_VALIDATING) {
             KalturaLog::debug("sibling flavor asset id [" . $siblingFlavorAsset->getId() . "] is incomplete");
             $inCompleteFlavorIds[] = $siblingFlavorAsset->getFlavorParamsId();
         }
         if ($readyBehavior == flavorParamsConversionProfile::READY_BEHAVIOR_REQUIRED) {
             KalturaLog::debug("sibling flavor asset id [" . $siblingFlavorAsset->getId() . "] is required");
             $requiredFlavorParamsIds[$siblingFlavorAsset->getFlavorParamsId()] = true;
         }
     }
     KalturaLog::debug("left required flavor params ids [" . print_r($requiredFlavorParamsIds, true) . "]");
     KalturaLog::debug("left incomplete flavor ids [" . print_r($inCompleteFlavorIds, true) . "]");
     if (count($requiredFlavorParamsIds)) {
         $inCompleteRequiredFlavorParamsIds = array_keys($requiredFlavorParamsIds);
         foreach ($inCompleteRequiredFlavorParamsIds as $inCompleteFlavorId) {
             $inCompleteFlavorIds[] = $inCompleteFlavorId;
         }
         KalturaLog::debug('Convert Finished - has In-Complete Required flavors [[' . print_r($inCompleteRequiredFlavorParamsIds, true) . ']');
     } elseif ($currentFlavorAsset->getStatus() == asset::ASSET_STATUS_READY && ($currentReadyBehavior == flavorParamsConversionProfile::READY_BEHAVIOR_OPTIONAL || $currentReadyBehavior == flavorParamsConversionProfile::READY_BEHAVIOR_REQUIRED)) {
         // mark the entry as ready if all required conversions completed or any of the optionals
         if ($currentFlavorAsset->getentry()->getReplacedEntryId()) {
             KalturaLog::debug('Entry is temporary replacement and requires all flavors to complete');
         } else {
             KalturaLog::debug('Mark the entry as ready');
             kBatchManager::updateEntry($currentFlavorAsset->getEntryId(), entryStatus::READY);
         }
     }
     if ($origianlAssetFlavorId) {
         $inCompleteFlavorIds = array_diff($inCompleteFlavorIds, array($origianlAssetFlavorId));
     }
     if (!count($inCompleteFlavorIds)) {
         KalturaLog::debug('Convert Finished');
         if ($origianlAssetFlavorId && $rootBatchJob && $rootBatchJob->getJobType() == BatchJobType::CONVERT_PROFILE) {
             kStorageExporter::exportSourceAssetFromJob($rootBatchJob);
         } else {
             // mark the context root job as finished only if all conversion jobs are completed
             kBatchManager::updateEntry($currentFlavorAsset->getEntryId(), entryStatus::READY);
             if ($rootBatchJob && $rootBatchJob->getJobType() == BatchJobType::CONVERT_PROFILE) {
                 kJobsManager::updateBatchJob($rootBatchJob, BatchJob::BATCHJOB_STATUS_FINISHED);
             }
         }
         return $dbBatchJob;
     }
     KalturaLog::debug('Convert Finished - has In-Complete flavors [' . print_r($inCompleteFlavorIds, true) . ']');
     if (!$rootBatchJob || $rootBatchJob->getJobType() != BatchJobType::CONVERT_PROFILE) {
         return $dbBatchJob;
     }
     $childJobs = $rootBatchJob->getChildJobs();
     KalturaLog::debug('Child jobs found [' . count($childJobs) . ']');
     if (count($childJobs) > 1) {
         $allDone = true;
         foreach ($childJobs as $childJob) {
             if ($childJob->getId() != $rootBatchJob->getId() && $childJob->getStatus() != BatchJob::BATCHJOB_STATUS_FINISHED) {
                 KalturaLog::debug('Child job id [' . $childJob->getId() . '] status [' . $childJob->getStatus() . ']');
                 $allDone = false;
             }
         }
         if ($allDone) {
             KalturaLog::debug('All child jobs done, closing profile');
             kJobsManager::updateBatchJob($rootBatchJob, BatchJob::BATCHJOB_STATUS_FINISHED);
         }
     }
     return $dbBatchJob;
 }
コード例 #16
0
ファイル: DeliveryProfileVod.php プロジェクト: wzur/server
 /**
  * @param flavorAsset $flavorAsset
  * @param FileSyncKey $key
  * @return array
  */
 protected function getExternalStorageUrl(flavorAsset $flavorAsset)
 {
     $remoteFileSyncs = $this->params->getRemoteFileSyncs();
     $fileSync = $remoteFileSyncs[$flavorAsset->getId()];
     $this->initDeliveryDynamicAttributes($fileSync, $flavorAsset);
     $url = $this->getFileSyncUrl($fileSync, false);
     $url = ltrim($url, "/");
     $urlPrefix = '';
     if (strpos($url, "://") === false) {
         $urlPrefix = $this->getUrlPrefix();
         $url = "/" . $url;
     }
     return $this->getFlavorAssetInfo($url, $urlPrefix, $flavorAsset);
 }
コード例 #17
0
 private function validateVideo(flavorAsset $flavorAsset)
 {
     $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     if (kFileSyncUtils::fileSync_exists($syncKey)) {
         $videoAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false);
         $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($flavorAsset->getId());
         if (!$mediaInfo) {
             return false;
         }
         try {
             FacebookGraphSdkUtils::validateVideoAttributes($videoAssetFilePath, $mediaInfo->getFileSize(), $mediaInfo->getVideoDuration());
             return true;
         } catch (Exception $e) {
             KalturaLog::debug('Asset [' . $flavorAsset->getId() . '] not valid for distribution: ' . $e->getMessage());
         }
     }
     return false;
 }
 /**
  * @param flavorAsset $originalFlavorAsset
  * @param entry $entry
  * @param BatchJob $convertProfileJob
  * @return BatchJob
  */
 public static function bypassConversion(flavorAsset $originalFlavorAsset, entry $entry, BatchJob $convertProfileJob)
 {
     if (!$originalFlavorAsset->hasTag(flavorParams::TAG_MBR)) {
         $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($originalFlavorAsset->getId());
         if ($mediaInfo) {
             $tagsArray = $originalFlavorAsset->getTagsArray();
             $finalTagsArray = KDLWrap::CDLMediaInfo2Tags($mediaInfo, $tagsArray);
             $originalFlavorAsset->setTagsArray($finalTagsArray);
         }
     }
     if (!$entry->getCreateThumb()) {
         // mark the asset as ready
         $originalFlavorAsset->setStatusLocalReady();
         $originalFlavorAsset->save();
         kFlowHelper::generateThumbnailsFromFlavor($entry->getId(), null, $originalFlavorAsset->getFlavorParamsId());
         kBusinessPostConvertDL::handleConvertFinished(null, $originalFlavorAsset);
         return null;
     }
     $offset = $entry->getThumbOffset();
     // entry getThumbOffset now takes the partner DefThumbOffset into consideration
     $srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $srcFileSyncLocalPath = kFileSyncUtils::getLocalFilePathForKey($srcSyncKey);
     $srcFileSyncWamsAssetId = kFileSyncUtils::getWamsAssetIdForKey($srcSyncKey);
     $postConvertAssetType = BatchJob::POSTCONVERT_ASSET_TYPE_BYPASS;
     return kJobsManager::addPostConvertJob($convertProfileJob, $postConvertAssetType, $srcFileSyncLocalPath, $originalFlavorAsset->getId(), null, true, $offset, null, $srcFileSyncWamsAssetId);
 }
コード例 #19
0
 /**
  * @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;
 }
コード例 #20
0
 /**
  * @param flavorAsset $originalFlavorAsset
  * @param entry $entry
  * @param BatchJob $convertProfileJob
  * @return BatchJob
  */
 public static function bypassConversion(flavorAsset $originalFlavorAsset, entry $entry, BatchJob $convertProfileJob)
 {
     if (!$originalFlavorAsset->hasTag(flavorParams::TAG_MBR)) {
         $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($originalFlavorAsset->getId());
         if ($mediaInfo) {
             $tagsArray = $originalFlavorAsset->getTagsArray();
             $finalTagsArray = KDLWrap::CDLMediaInfo2Tags($mediaInfo, $tagsArray);
             $originalFlavorAsset->setTagsArray($finalTagsArray);
         }
     }
     $offset = $entry->getThumbOffset();
     // entry getThumbOffset now takes the partner DefThumbOffset into consideration
     $srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $srcFileSyncLocalPath = kFileSyncUtils::getLocalFilePathForKey($srcSyncKey);
     $jobSubType = BatchJob::BATCHJOB_SUB_TYPE_POSTCONVERT_BYPASS;
     return kJobsManager::addPostConvertJob($convertProfileJob, $jobSubType, $srcFileSyncLocalPath, $originalFlavorAsset->getId(), null, true, $offset);
 }
コード例 #21
0
 private static function decideSourceFlavorConvert($entryId, assetParams $sourceFlavor = null, flavorAsset $originalFlavorAsset, $conversionProfileId, $flavors, mediaInfo $mediaInfo = null, BatchJob $parentJob, BatchJob $convertProfileJob)
 {
     if ($sourceFlavor && ($sourceFlavor->getOperators() || $sourceFlavor->getConversionEngines()) && $originalFlavorAsset->getInterFlowCount() == null) {
         KalturaLog::log("Source flavor asset requires conversion");
         self::adjustAssetParams($entryId, array($sourceFlavor));
         $srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         $errDescription = null;
         $sourceFlavorOutput = self::validateFlavorAndMediaInfo($sourceFlavor, $mediaInfo, $errDescription);
         if (!$sourceFlavorOutput) {
             if (!$errDescription) {
                 $errDescription = "Failed to create flavor params output from source flavor";
             }
             $originalFlavorAsset->setDescription($originalFlavorAsset->getDescription() . "\n{$errDescription}");
             $originalFlavorAsset->setStatus(flavorAsset::ASSET_STATUS_ERROR);
             $originalFlavorAsset->save();
             kBatchManager::updateEntry($entryId, entryStatus::ERROR_CONVERTING);
             kJobsManager::updateBatchJob($convertProfileJob, BatchJob::BATCHJOB_STATUS_FAILED);
             return false;
         }
         /*
          * If the conversion profile contains source flavor and the source is tagged with 'save_source' ==> 
          * save the original source asset in another asset, in order 
          * to prevent its liquidated by the inter-source asset.
          */
         if (isset($sourceFlavor) && strstr($sourceFlavor->getTagsArray(), assetParams::TAG_SAVE_SOURCE) !== false) {
             self::saveOriginalSource($mediaInfo);
         }
     } elseif ($mediaInfo) {
         /*
          * Check whether there is a need for an intermediate source pre-processing
          */
         $sourceFlavorOutput = KDLWrap::GenerateIntermediateSource($mediaInfo, $flavors);
         if (!$sourceFlavorOutput) {
             return true;
         }
         $srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         $errDescription = null;
         /*
          * Save the original source asset in another asset, in order 
          * to prevent its liquidated by the inter-source asset.
          * But, do it only if the conversion profile contains source flavor
          */
         if (isset($sourceFlavor)) {
             self::saveOriginalSource($mediaInfo);
         }
     }
     /*
      * '_passthrough' controls whether the source is to be 'passthrough' although there 
      * is a source flavor that contains transcoder settings.
      * Looks for a '_passthrough' flag on the source's flavor params output.
      */
     if (!isset($sourceFlavorOutput) || $sourceFlavorOutput->_passthrough == true) {
         return true;
     }
     // save flavor params
     $sourceFlavorOutput->setPartnerId($sourceFlavorOutput->getPartnerId());
     $sourceFlavorOutput->setEntryId($entryId);
     $sourceFlavorOutput->setFlavorAssetId($originalFlavorAsset->getId());
     $sourceFlavorOutput->setFlavorAssetVersion($originalFlavorAsset->getVersion());
     $sourceFlavorOutput->save();
     if ($errDescription) {
         $originalFlavorAsset->setDescription($originalFlavorAsset->getDescription() . "\n{$errDescription}");
     }
     $errDescription = kBusinessConvertDL::parseFlavorDescription($sourceFlavorOutput);
     if ($errDescription) {
         $originalFlavorAsset->setDescription($originalFlavorAsset->getDescription() . "\n{$errDescription}");
     }
     // decided by the business logic layer
     if ($sourceFlavorOutput->_create_anyway) {
         KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] selected to be created anyway");
     } else {
         if (!$sourceFlavorOutput->IsValid()) {
             KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is invalid");
             $originalFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
             $originalFlavorAsset->save();
             $errDescription = "Source flavor could not be converted";
             self::setError($errDescription, $convertProfileJob, BatchJobType::CONVERT_PROFILE, $convertProfileJob->getEntryId());
             return false;
         }
         if ($sourceFlavorOutput->_force) {
             KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is forced");
         } elseif ($sourceFlavorOutput->_isNonComply) {
             KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is none-comply");
         } else {
             KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is valid");
         }
     }
     $originalFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_CONVERTING);
     if (isset($sourceFlavor)) {
         $tagsArr = $sourceFlavor->getTagsArray();
         // No need for 'save_source' tag on the inter-src asset, remove it.
         if (($key = array_search(assetParams::TAG_SAVE_SOURCE, $tagsArr)) !== false) {
             unset($tagsArr[$key]);
         }
         $originalFlavorAsset->addTags($tagsArr);
         $originalFlavorAsset->setFileExt($sourceFlavorOutput->getFileExt());
         $originalFlavorAsset->save();
     }
     // save flavor params
     $sourceFlavorOutput->setFlavorAssetVersion($originalFlavorAsset->getVersion());
     $sourceFlavorOutput->save();
     $mediaInfoId = null;
     if ($mediaInfo) {
         $mediaInfoId = $mediaInfo->getId();
     }
     kJobsManager::addFlavorConvertJob(array($srcSyncKey), $sourceFlavorOutput, $originalFlavorAsset->getId(), $conversionProfileId, $mediaInfoId, $parentJob);
     return false;
 }