예제 #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;
 }
예제 #2
0
 /**
  * @param LiveEntry $dbEntry
  * @return entry
  */
 private function createRecordedEntry(LiveEntry $dbEntry, $mediaServerIndex)
 {
     $lock = kLock::create("live_record_" . $dbEntry->getId());
     if ($lock && !$lock->lock(self::KLOCK_CREATE_RECORDED_ENTRY_GRAB_TIMEOUT, self::KLOCK_CREATE_RECORDED_ENTRY_HOLD_TIMEOUT)) {
         return;
     }
     // If while we were waiting for the lock, someone has updated the recorded entry id - we should use it.
     $dbEntry->reload();
     if ($dbEntry->getRecordStatus() != RecordStatus::PER_SESSION && $dbEntry->getRecordedEntryId()) {
         $lock->unlock();
         $recordedEntry = entryPeer::retrieveByPK($dbEntry->getRecordedEntryId());
         return $recordedEntry;
     }
     $recordedEntry = null;
     try {
         $recordedEntryName = $dbEntry->getName();
         if ($dbEntry->getRecordStatus() == RecordStatus::PER_SESSION) {
             $recordedEntryName .= ' ' . ($dbEntry->getRecordedEntryIndex() + 1);
         }
         $recordedEntry = new entry();
         $recordedEntry->setType(entryType::MEDIA_CLIP);
         $recordedEntry->setMediaType(entry::ENTRY_MEDIA_TYPE_VIDEO);
         $recordedEntry->setRootEntryId($dbEntry->getId());
         $recordedEntry->setName($recordedEntryName);
         $recordedEntry->setDescription($dbEntry->getDescription());
         $recordedEntry->setSourceType(EntrySourceType::RECORDED_LIVE);
         $recordedEntry->setAccessControlId($dbEntry->getAccessControlId());
         $recordedEntry->setConversionProfileId($dbEntry->getConversionProfileId());
         $recordedEntry->setKuserId($dbEntry->getKuserId());
         $recordedEntry->setPartnerId($dbEntry->getPartnerId());
         $recordedEntry->setModerationStatus($dbEntry->getModerationStatus());
         $recordedEntry->setIsRecordedEntry(true);
         $recordedEntry->setTags($dbEntry->getTags());
         $recordedEntry->save();
         $dbEntry->setRecordedEntryId($recordedEntry->getId());
         $dbEntry->save();
         $assets = assetPeer::retrieveByEntryId($dbEntry->getId(), array(assetType::LIVE));
         foreach ($assets as $asset) {
             /* @var $asset liveAsset */
             $asset->incLiveSegmentVersion($mediaServerIndex);
             $asset->save();
         }
     } catch (Exception $e) {
         $lock->unlock();
         throw $e;
     }
     $lock->unlock();
     return $recordedEntry;
 }
예제 #3
0
파일: kFlowHelper.php 프로젝트: wzur/server
 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;
 }