示例#1
0
 /**
  * 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;
 }
 private function insertLiveStreamEntry(KalturaLiveStreamAdminEntry $liveStreamEntry)
 {
     // first validate the input object
     $liveStreamEntry->validatePropertyNotNull("mediaType");
     $liveStreamEntry->validatePropertyNotNull("sourceType");
     $liveStreamEntry->validatePropertyNotNull("encodingIP1");
     $liveStreamEntry->validatePropertyNotNull("encodingIP2");
     $liveStreamEntry->validatePropertyNotNull("streamPassword");
     // create a default name if none was given
     if (!$liveStreamEntry->name) {
         $liveStreamEntry->name = $this->getPartnerId() . '_' . time();
     }
     // first copy all the properties to the db entry, then we'll check for security stuff
     $dbEntry = $liveStreamEntry->toObject(new entry());
     $this->checkAndSetValidUserInsert($liveStreamEntry, $dbEntry);
     $this->checkAdminOnlyInsertProperties($liveStreamEntry);
     $this->validateAccessControlId($liveStreamEntry);
     $this->validateEntryScheduleDates($liveStreamEntry, $dbEntry);
     $dbEntry->setPartnerId($this->getPartnerId());
     $dbEntry->setSubpId($this->getPartnerId() * 100);
     $dbEntry->setKuserId($this->getKuser()->getId());
     $dbEntry->setCreatorKuserId($this->getKuser()->getId());
     $dbEntry->setStatus(entryStatus::IMPORT);
     $te = new TrackEntry();
     $te->setEntryId($dbEntry->getId());
     $te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY);
     $te->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_MEDIA_SOURCE_AKAMAI_LIVE");
     TrackEntry::addTrackEntry($te);
     //if type is manual don't create batch job, just change entry status to ready
     if ($liveStreamEntry->sourceType == KalturaSourceType::MANUAL_LIVE_STREAM) {
         $dbEntry->setStatus(entryStatus::READY);
         $dbEntry->save();
     } else {
         $dbEntry->save();
         kJobsManager::addProvisionProvideJob(null, $dbEntry);
     }
     return $dbEntry;
 }