public static function updateEntry($entryId, $status) { $entry = entryPeer::retrieveByPK($entryId); if (!$entry) { KalturaLog::err("Entry was not found for id [{$entryId}]"); return null; } // entry status didn't change - no need to send notification if ($entry->getStatus() == $status) { return $entry; } // backward compatibility // if entry has kshow, and this is the first entry in the mix, // the thumbnail of the entry should be copied into the mix entry if ($status == entryStatus::READY && $entry->getKshowId()) { myEntryUtils::createRoughcutThumbnailFromEntry($entry, false); } // entry status is ready and above, not changing status through batch job $unAcceptedStatuses = array(entryStatus::READY, entryStatus::DELETED); if (in_array($entry->getStatus(), $unAcceptedStatuses)) { KalturaLog::info("Entry status [" . $entry->getStatus() . "] will not be changed"); return $entry; } $entry->setStatus($status); $entry->save(); myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_UPDATE, $entry, null, null, null, null, $entry->getId()); return $entry; }
private function updateConvertedEntry($ok, $entry, kConversionResult $conv_res) { $file_before_conversion = $conv_res->conv_cmd->source_file; $file_after_conversion = $conv_res->conv_cmd->target_file; // TODO -get all targets if ($ok == true) { // TODO - write all targets not only primary one KalturaLog::debug("File [{$file_before_conversion}] converted OK to [{$file_after_conversion}]"); try { // TODO - do we need to create the helpers eagerly ?? // $this->createFlvWrappersForTargets( $conv_res ); } catch (Exception $ex) { KalturaLog::debug("Error while creating helper files for [{$file_after_conversion}]"); } $entry->setStatusReady(); } else { KalturaLog::debug("Problem converting file [{$file_before_conversion}]"); $entry->setStatus(entryStatus::ERROR_CONVERTING); } $this->updateConversionInDb($entry, $conv_res); // loop until the file is really ready - sometimes the size of the file or the mtime is wrong for ($i = 0; $i < 15; $i++) { clearstatcache(); if (!file_exists($file_after_conversion) || filesize($file_after_conversion) == 0) { // KalturaLog::debug ( "Entry id [" . $entry->getId() . "] printing file stats: " . print_r( stat ($file_after_conversion ) , true ) ); KalturaLog::debug("Entry id [" . $entry->getId() . "]. no such file [{$file_after_conversion}]. Sleeping for 1 second for the [{$i}] time."); sleep(2); } else { break; } } KalturaLog::debug("Entry id [" . $entry->getId() . "] setting duration"); $entry->setLengthInMsecs(kConversionHelper::getFlvDuration($file_after_conversion)); KalturaLog::debug("Entry id [" . $entry->getId() . "] duration [" . $entry->getLengthInMsecs() . "]"); // how could it be otherwise ?? if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_VIDEO) { // TODO - move out of this function if the partner is required for more configurations $partner = PartnerPeer::retrieveByPK($entry->getPartnerId()); // TODO - make sure the width & height of the target are part of the kConversionReulst // if ( $conversion_info ) $entry->setDimensions ( $conversion_info->video_width , $conversion_info->video_height ); $offset = $entry->getBestThumbOffset($partner->getDefThumbOffset()); KalturaLog::debug("Entry id [" . $entry->getId() . "] Thumb offset: [{$offset}]"); // first create the thumb for the entry myEntryUtils::createThumbnailFromEntry($entry, $entry, $offset); // then make sure it will propage to the roughcut if needed myEntryUtils::createRoughcutThumbnailFromEntry($entry, false); $entry->updateVideoDimensions(); KalturaLog::debug("Entry id [" . $entry->getId() . "] dimensions: [" . $entry->getWidth() . "x" . $entry->getHeight() . "]"); } // send notification - regardless its status myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_UPDATE, $entry); $entry->save(); }
public static function updateEntry(BatchJob $dbBatchJob, $status) { $entry = $dbBatchJob->getEntry(); if (!$entry) { KalturaLog::debug("Entry was not found for job id [{$dbBatchJob->getId}()]"); return null; } // entry status didn't change - no need to send notification if ($entry->getStatus() == $status) { return $entry; } // backward compatibility // if entry has kshow, and this is the first entry in the mix, // the thumbnail of the entry should be copied into the mix entry if ($status == entryStatus::READY) { myEntryUtils::createRoughcutThumbnailFromEntry($entry, false); } // entry status is ready and above, not changing status through batch job if ($entry->getStatus() >= entryStatus::READY) { return $entry; } $entry->setStatus($status); $entry->save(); kFlowHelper::createEntryUpdateNotification($dbBatchJob); return $entry; }