Пример #1
0
 /**
  * @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;
 }
Пример #2
0
 /**
  * @param flavorAsset $flavorAsset
  * @return string representing the basic url.
  */
 protected function getBaseUrl(flavorAsset $flavorAsset)
 {
     $entry = entryPeer::retrieveByPK($this->params->getEntryId());
     $partnerId = $flavorAsset->getPartnerId();
     $subpId = $entry->getSubpId();
     $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId);
     $url = "{$partnerPath}/serveFlavor/entryId/" . $entry->getId();
     if ($entry->getType() == entryType::PLAYLIST) {
         $partner = $entry->getPartner();
         $entryVersion = $entry->getVersion();
         $partnerFlavorVersion = $partner->getCacheFlavorVersion();
         $url .= ($entryVersion ? "/v/{$entryVersion}" : '') . ($partnerFlavorVersion ? "/pv/{$partnerFlavorVersion}" : '');
         $url .= '/flavorParamIds/' . $flavorAsset->getFlavorParamsId();
     } else {
         $url .= $this->getFlavorVersionString($flavorAsset);
         $url .= '/flavorId/' . $flavorAsset->getId();
     }
     $url .= $this->params->getUrlParams();
     return $url;
 }
 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;
 }
Пример #4
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;
 }
 /**
  * @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);
 }
Пример #6
0
 /**
  * Check if flavor asset id set for export on the storage profile
  * 
  * @param flavorAsset $flavorAsset
  */
 protected function isFlavorAssetConfiguredForExport(flavorAsset $flavorAsset)
 {
     $configuredForExport = null;
     // check if flavor params id is in the list to export
     $flavorParamsIdsToExport = $this->getFlavorParamsIds();
     KalturaLog::log(__METHOD__ . " flavorParamsIds [{$flavorParamsIdsToExport}]");
     if (is_null($flavorParamsIdsToExport) || strlen(trim($flavorParamsIdsToExport)) == 0) {
         // all flavor assets should be exported
         $configuredForExport = true;
     } else {
         $flavorParamsIdsToExport = array_map('trim', explode(',', $flavorParamsIdsToExport));
         if (in_array($flavorAsset->getFlavorParamsId(), $flavorParamsIdsToExport)) {
             // flavor set to export
             $configuredForExport = true;
         } else {
             // flavor not set to export
             $configuredForExport = false;
         }
     }
     return $configuredForExport;
 }
 /**
  * @param flavorAsset $flavorAsset
  * @return boolean true if the given flavor asset is configured to be exported or false otherwise
  */
 public function shouldExportFlavorAsset(flavorAsset $flavorAsset)
 {
     $shouldExport = null;
     // check if flavor params id is in the list to export
     $flavorParamsIdsToExport = $this->getFlavorParamsIds();
     KalturaLog::log(__METHOD__ . " flavorParamsIds [{$flavorParamsIdsToExport}]");
     if (is_null($flavorParamsIdsToExport) || strlen(trim($flavorParamsIdsToExport)) == 0) {
         // all flavor assets should be exported
         $shouldExport = true;
     } else {
         $flavorParamsIdsToExport = array_map('trim', explode(',', $flavorParamsIdsToExport));
         if (in_array($flavorAsset->getFlavorParamsId(), $flavorParamsIdsToExport)) {
             // flavor set to export
             $shouldExport = true;
         } else {
             // flavor not set to export
             $shouldExport = false;
         }
     }
     // check if flavor fits the export rules defined on the profile
     if ($shouldExport) {
         $key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         $shouldExport = kStorageExporter::shouldExport($key, $this);
         if (!$shouldExport) {
             KalturaLog::log("no need to export key [{$key}] to externalStorage id[" . $this->getId() . "]");
         }
     }
     return $shouldExport;
 }
Пример #8
0
 private static function getSourceFlavorAssets(flavorAsset $flavorAsset, flavorParamsOutput $flavor)
 {
     $srcFlavorParamsIds = explode(',', trim($flavor->getSourceAssetParamsIds()));
     $c = new Criteria();
     $c->add(assetPeer::ENTRY_ID, $flavorAsset->getEntryId());
     $c->add(assetPeer::STATUS, array(flavorAsset::ASSET_STATUS_READY, flavorAsset::ASSET_STATUS_NOT_APPLICABLE, flavorAsset::ASSET_STATUS_EXPORTING), Criteria::IN);
     $c->add(assetPeer::FLAVOR_PARAMS_ID, $srcFlavorParamsIds, Criteria::IN);
     $readyAndNonApplicableAssetsCount = assetPeer::doCount($c);
     KalturaLog::info('Verify source flavors are ready: number of ready and NA assets [' . $readyAndNonApplicableAssetsCount . '], number of source params ids [' . count($srcFlavorParamsIds) . ']');
     if ($readyAndNonApplicableAssetsCount < count($srcFlavorParamsIds)) {
         KalturaLog::info('Not all source flavors are ready, changing status to WAIT_FOR_CONVERT');
         $flavorAsset->setStatus(flavorAsset::ASSET_STATUS_WAIT_FOR_CONVERT);
         $flavorAsset->setDescription("Source flavor assets are not ready");
         $flavorAsset->save();
         return false;
     }
     $srcFlavors = assetPeer::retrieveLocalReadyByEntryIdAndFlavorParams($flavorAsset->getEntryId(), $srcFlavorParamsIds);
     if (!count($srcFlavors)) {
         //assuming all source flavors are Not Applicable
         KalturaLog::log("Flavor [" . $flavorAsset->getFlavorParamsId() . "] is set to N/A since all it's sources are N/A");
         $flavorAsset->setStatus(flavorAsset::ASSET_STATUS_NOT_APPLICABLE);
         $flavorAsset->save();
         return false;
     }
     return $srcFlavors;
 }