protected function addEventCuePoint(LiveEntry $liveEntry, $eventType) { $cuePoint = new EventCuePoint(); $cuePoint->setPartnerId($liveEntry->getPartnerId()); $cuePoint->setSubType($eventType); $cuePoint->setEntryId($liveEntry->getId()); $cuePoint->setStartTime(time()); $cuePoint->setStatus(CuePointStatus::READY); $cuePoint->save(); }
public function syncEntryEntitlementInfo(entry $vodEntry, LiveEntry $liveEntry) { $entitledPusersEdit = $liveEntry->getEntitledPusersEdit(); $entitledPusersPublish = $liveEntry->getEntitledPusersPublish(); if (!$entitledPusersEdit && !$entitledPusersPublish) { return; } if ($entitledPusersEdit) { $vodEntry->setEntitledPusersEdit($entitledPusersEdit); } if ($entitledPusersPublish) { $vodEntry->setEntitledPusersPublish($entitledPusersPublish); } $vodEntry->save(); }
public static function decideLiveProfile(LiveEntry $entry) { // find all live assets of the entry $c = new Criteria(); $c->add(assetPeer::PARTNER_ID, $entry->getPartnerId()); $c->add(assetPeer::ENTRY_ID, $entry->getId()); $c->add(assetPeer::TYPE, assetType::LIVE); // include deleted assets assetPeer::setUseCriteriaFilter(false); $liveAssets = assetPeer::doSelect($c); assetPeer::setUseCriteriaFilter(true); // build array of all assets with asset params id as key $liveAssetsParams = array(); foreach ($liveAssets as $liveAsset) { /* @var $liveAsset liveAsset */ $flavorParamsId = is_null($liveAsset->getFlavorParamsId()) ? $liveAsset->getId() : $liveAsset->getFlavorParamsId(); $liveAssetsParams[$flavorParamsId] = $liveAsset; } $flavorParamsConversionProfileArray = flavorParamsConversionProfilePeer::retrieveByConversionProfile($entry->getConversionProfileId()); $liveParamIdsArray = array(); foreach ($flavorParamsConversionProfileArray as $flavorParamsConversionProfile) { /* @var $flavorParamsConversionProfile flavorParamsConversionProfile */ $liveParamIdsArray[] = $flavorParamsConversionProfile->getFlavorParamsId(); } asort($liveParamIdsArray); $liveParamIds = implode(",", $liveParamIdsArray); if ($liveParamIds == $entry->getFlavorParamsIds()) { return; } $streamBitrates = array(); $definedRecordingAnchor = false; foreach ($flavorParamsConversionProfileArray as $flavorParamsConversionProfile) { /* @var $flavorParamsConversionProfile flavorParamsConversionProfile */ $liveParams = $flavorParamsConversionProfile->getassetParams(); if ($liveParams instanceof liveParams) { if ($flavorParamsConversionProfile->getOrigin() == assetParamsOrigin::INGEST) { $streamBitrate = array('bitrate' => $liveParams->getVideoBitrate(), 'width' => $liveParams->getWidth(), 'height' => $liveParams->getHeight(), 'tags' => $liveParams->getTags()); $streamBitrates[] = $streamBitrate; } // check if asset already exists if (isset($liveAssetsParams[$liveParams->getId()])) { $liveAsset = $liveAssetsParams[$liveParams->getId()]; $liveAsset->setDeletedAt(null); // remove the asset from the list, the left assets will be deleted later unset($liveAssetsParams[$liveParams->getId()]); } else { // create a new asset $liveAsset = new liveAsset(); $liveAsset->setType(assetType::LIVE); $liveAsset->setPartnerId($entry->getPartnerId()); $liveAsset->setFlavorParamsId($liveParams->getId()); $liveAsset->setFromAssetParams($liveParams); $liveAsset->setEntryId($entry->getId()); if ($entry->getRecordStatus() && !$definedRecordingAnchor) { // We specifically add a flag that does NOT exist on the live asset, since we can't predict which // live params the conversion profile is going to contain. $liveAsset->addTags(array(assetParams::TAG_RECORDING_ANCHOR)); $definedRecordingAnchor = true; } } // set the status according to the entry status if ($entry->getStatus() == entryStatus::READY) { $liveAsset->setStatus(asset::ASSET_STATUS_READY); } else { $liveAsset->setStatus(asset::ASSET_STATUS_IMPORTING); } $liveAsset->save(); } } // delete all left assets foreach ($liveAssetsParams as $liveAsset) { /* @var $liveAsset liveAsset */ $liveAsset->setDeletedAt(time()); $liveAsset->setStatus(asset::ASSET_STATUS_DELETED); $liveAsset->save(); } if (!count($streamBitrates)) { $streamBitrate = array('bitrate' => 900, 'width' => 640, 'height' => 480); $streamBitrates[] = $streamBitrate; } $entry->setStreamBitrates($streamBitrates); $entry->save(); }
/** * @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; }
public function applyDefaultValues() { parent::applyDefaultValues(); $this->setType(EntryType::LIVE_STREAM); $this->setStatus(entryStatus::NO_CONTENT); }
public function preSave(PropelPDO $con = null) { $this->updateStatus(); return parent::preSave($con); }
public function getLiveStatus($mediaServerIndex = null) { if ($mediaServerIndex != null) { return $this->getLiveStatusInternal($mediaServerIndex); } return LiveEntry::maxLiveEntryStatus($this->getLiveStatusInternal(MediaServerIndex::PRIMARY), $this->getLiveStatusInternal(MediaServerIndex::SECONDARY)); }