/** * Adds new live stream entry. * The entry will be queued for provision. * * @action add * @param KalturaLiveStreamEntry $liveStreamEntry Live stream entry metadata * @param KalturaSourceType $sourceType Live stream source type * @return KalturaLiveStreamEntry The new live stream entry * * @throws KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL */ function addAction(KalturaLiveStreamEntry $liveStreamEntry, $sourceType = null) { if ($sourceType) { $liveStreamEntry->sourceType = $sourceType; } elseif (is_null($liveStreamEntry->sourceType)) { // default sourceType is AKAMAI_LIVE $liveStreamEntry->sourceType = kPluginableEnumsManager::coreToApi('EntrySourceType', $this->getPartner()->getDefaultLiveStreamEntrySourceType()); } $dbEntry = $this->prepareEntryForInsert($liveStreamEntry); $dbEntry->save(); $te = new TrackEntry(); $te->setEntryId($dbEntry->getId()); $te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY); $te->setDescription(__METHOD__ . ":" . __LINE__ . "::" . $dbEntry->getSource()); TrackEntry::addTrackEntry($te); //If a jobData can be created for entry sourceType, add provision job. Otherwise, just save the entry. $jobData = kProvisionJobData::getInstance($dbEntry->getSource()); if ($jobData) { /* @var $data kProvisionJobData */ $jobData->populateFromPartner($dbEntry->getPartner()); $jobData->populateFromEntry($dbEntry); kJobsManager::addProvisionProvideJob(null, $dbEntry, $jobData); } else { $dbEntry->setStatus(entryStatus::READY); $dbEntry->save(); $liveAssets = assetPeer::retrieveByEntryId($dbEntry->getId(), array(assetType::LIVE)); foreach ($liveAssets as $liveAsset) { /* @var $liveAsset liveAsset */ $liveAsset->setStatus(asset::ASSET_STATUS_READY); $liveAsset->save(); } } myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry, $this->getPartnerId(), null, null, null, $dbEntry->getId()); $liveStreamEntry->fromObject($dbEntry, $this->getResponseProfile()); return $liveStreamEntry; }
public static function handleProvisionProvideFinished(BatchJob $dbBatchJob, kProvisionJobData $data, BatchJob $twinJob = null) { $entry = $dbBatchJob->getEntry(); $entry->setStreamUsername($data->getEncoderUsername()); $entry->setStreamUrl($data->getRtmp()); $entry->setStreamRemoteId($data->getStreamID()); $entry->setStreamRemoteBackupId($data->getBackupStreamID()); $entry->setPrimaryBroadcastingUrl($data->getPrimaryBroadcastingUrl()); $entry->setSecondaryBroadcastingUrl($data->getSecondaryBroadcastingUrl()); $entry->setStreamName($data->getStreamName()); kBatchManager::updateEntry($dbBatchJob, entryStatus::READY); return $dbBatchJob; }
public static function addProvisionDeleteJob(BatchJob $parentJob = null, entry $entry) { $jobData = kProvisionJobData::getInstance($entry->getSource()); if ($jobData) { $jobData->setStreamID($entry->getStreamRemoteId()); $subType = $entry->getSource(); $jobData->populateFromPartner($entry->getPartner()); $jobData->populateFromEntry($entry); $batchJob = null; if ($parentJob) { $batchJob = $parentJob->createChild(BatchJobType::PROVISION_DELETE, $subType); } else { $batchJob = new BatchJob(); $batchJob->setEntryId($entry->getId()); $batchJob->setPartnerId($entry->getPartnerId()); } $batchJob->setObjectId($entry->getId()); $batchJob->setObjectType(BatchJobObjectType::ENTRY); return self::addJob($batchJob, $jobData, BatchJobType::PROVISION_DELETE, $subType); } return false; }
public static function handleProvisionProvideFinished(BatchJob $dbBatchJob, kProvisionJobData $data) { kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::READY); $entry = $dbBatchJob->getEntry(); if (!$entry) { return $dbBatchJob; } $data->populateEntryFromData($entry); $liveAssets = assetPeer::retrieveByEntryId($entry->getId(), array(assetType::LIVE)); foreach ($liveAssets as $liveAsset) { /* @var $liveAsset liveAsset */ $liveAsset->setStatus(asset::ASSET_STATUS_READY); $liveAsset->save(); } $entry->save(); return $dbBatchJob; }
public static function addProvisionProvideJob(BatchJob $parentJob = null, entry $entry) { $subType = $entry->getSource(); if ($subType == entry::ENTRY_MEDIA_SOURCE_AKAMAI_LIVE) { $partner = $entry->getPartner(); if (!is_null($partner)) { $jobData = new kAkamaiProvisionJobData(); $akamaiLiveParams = $partner->getAkamaiLiveParams(); if ($akamaiLiveParams) { $jobData->setWsdlUsername($akamaiLiveParams->getAkamaiLiveWsdlUsername()); $jobData->setWsdlPassword($akamaiLiveParams->getAkamaiLiveWsdlPassword()); $jobData->setCpcode($akamaiLiveParams->getAkamaiLiveCpcode()); $jobData->setEmailId($akamaiLiveParams->getAkamaiLiveEmailId()); $jobData->setPrimaryContact($akamaiLiveParams->getAkamaiLivePrimaryContact()); $jobData->setSecondaryContact($akamaiLiveParams->getAkamaiLiveSecondaryContact()); } } } else { $jobData = new kProvisionJobData(); } $jobData->setEncoderIP($entry->getEncodingIP1()); $jobData->setBackupEncoderIP($entry->getEncodingIP2()); $jobData->setEncoderPassword($entry->getStreamPassword()); $jobData->setEncoderUsername($entry->getStreamUsername()); $jobData->setEndDate($entry->getEndDate(null)); $jobData->setMediaType($entry->getMediaType()); $batchJob = null; if ($parentJob) { $batchJob = $parentJob->createChild(); } else { $batchJob = new BatchJob(); $batchJob->setEntryId($entry->getId()); $batchJob->setPartnerId($entry->getPartnerId()); } return self::addJob($batchJob, $jobData, BatchJobType::PROVISION_PROVIDE, $subType); }
public static function addProvisionProvideJob(BatchJob $parentJob = null, entry $entry) { $jobData = new kProvisionJobData(); $jobData->setEncoderIP($entry->getEncodingIP1()); $jobData->setBackupEncoderIP($entry->getEncodingIP2()); $jobData->setEncoderPassword($entry->getStreamPassword()); $jobData->setEncoderUsername($entry->getStreamUsername()); $jobData->setEndDate($entry->getEndDate(null)); $jobData->setMediaType($entry->getMediaType()); $batchJob = null; if ($parentJob) { $batchJob = $parentJob->createChild(); } else { $batchJob = new BatchJob(); $batchJob->setEntryId($entry->getId()); $batchJob->setPartnerId($entry->getPartnerId()); } $subType = $entry->getSource(); return self::addJob($batchJob, $jobData, BatchJobType::PROVISION_PROVIDE, $subType); }