Example #1
0
 protected static function getReplacingEntry($recordedEntry, $asset, $retries = 1)
 {
     $replacingEntryId = $recordedEntry->getReplacingEntryId();
     $replacingEntry = null;
     // in replacement
     if ($replacingEntryId) {
         $replacingEntry = entryPeer::retrieveByPKNoFilter($replacingEntryId);
         // check if asset already ingested
         $replacingAsset = assetPeer::retrieveByEntryIdAndParams($replacingEntryId, $asset->getFlavorParamsId());
         if ($replacingAsset) {
             KalturaLog::err('Asset with params [' . $asset->getFlavorParamsId() . '] already replaced');
             return null;
         }
     } else {
         $advancedOptions = new kEntryReplacementOptions();
         $advancedOptions->setKeepManualThumbnails(true);
         $recordedEntry->setReplacementOptions($advancedOptions);
         $replacingEntry = new entry();
         $replacingEntry->setType(entryType::MEDIA_CLIP);
         $replacingEntry->setMediaType(entry::ENTRY_MEDIA_TYPE_VIDEO);
         $replacingEntry->setConversionProfileId($recordedEntry->getConversionProfileId());
         $replacingEntry->setName($recordedEntry->getPartnerId() . '_' . time());
         $replacingEntry->setKuserId($recordedEntry->getKuserId());
         $replacingEntry->setAccessControlId($recordedEntry->getAccessControlId());
         $replacingEntry->setPartnerId($recordedEntry->getPartnerId());
         $replacingEntry->setSubpId($recordedEntry->getPartnerId() * 100);
         $replacingEntry->setDefaultModerationStatus();
         $replacingEntry->setDisplayInSearch(mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM);
         $replacingEntry->setReplacedEntryId($recordedEntry->getId());
         $replacingEntry->save();
         $recordedEntry->setReplacingEntryId($replacingEntry->getId());
         $recordedEntry->setReplacementStatus(entryReplacementStatus::APPROVED_BUT_NOT_READY);
         $affectedRows = $recordedEntry->save();
         if (!$affectedRows) {
             $replacingEntry->delete();
             $replacingEntry = null;
             if ($retries) {
                 sleep(10);
                 $recordedEntry = entryPeer::retrieveByPKNoFilter($recordedEntry->getId());
                 return kFlowHelper::getReplacingEntry($recordedEntry, $asset, 0);
             } else {
                 KalturaLog::err("Failed to update replacing entry");
                 return null;
             }
         }
     }
     return $replacingEntry;
 }
Example #2
0
 private static function createReplacigEntry($recordedEntry)
 {
     $advancedOptions = new kEntryReplacementOptions();
     $advancedOptions->setKeepManualThumbnails(true);
     $recordedEntry->setReplacementOptions($advancedOptions);
     $replacingEntry = new entry();
     $replacingEntry->setType(entryType::MEDIA_CLIP);
     $replacingEntry->setMediaType(entry::ENTRY_MEDIA_TYPE_VIDEO);
     $replacingEntry->setConversionProfileId($recordedEntry->getConversionProfileId());
     $replacingEntry->setName($recordedEntry->getPartnerId() . '_' . time());
     $replacingEntry->setKuserId($recordedEntry->getKuserId());
     $replacingEntry->setAccessControlId($recordedEntry->getAccessControlId());
     $replacingEntry->setPartnerId($recordedEntry->getPartnerId());
     $replacingEntry->setSubpId($recordedEntry->getPartnerId() * 100);
     $replacingEntry->setDefaultModerationStatus();
     $replacingEntry->setDisplayInSearch(mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM);
     $replacingEntry->setReplacedEntryId($recordedEntry->getId());
     $replacingEntry->save();
     $recordedEntry->setReplacingEntryId($replacingEntry->getId());
     $recordedEntry->setReplacementStatus(entryReplacementStatus::APPROVED_BUT_NOT_READY);
     $affectedRows = $recordedEntry->save();
     return $replacingEntry;
 }