コード例 #1
0
 public function buildCfgFile($inputFile, $outputFile, $format = null, $width = null, $height = null, $keyFramesInSec = null, $bitrate = null, $videoCodec = null, $audioCodec = null)
 {
     if (is_null($format)) {
         $format = "WMV";
     }
     if ($format == "WMV") {
         if (is_null($width)) {
             $width = 1280;
         }
         if (is_null($height)) {
             $height = 960;
         }
         if (is_null($keyFramesInSec)) {
             $keyFramesInSec = 4;
         }
         if (is_null($bitrate)) {
             $bitrate = 2000;
         }
         if (is_null($videoCodec)) {
             $videoCodec = "Windows Media Video 9";
         }
         if (is_null($audioCodec)) {
             $audioCodec = "Windows Media Audio 10 Professional";
         }
     } else {
         if ($format == "MP4") {
         }
     }
     $cfg = str_replace(array("inputfile=", "outputfile=", "media=", "__webexTargetFormat__", "width=", "height=", "videocodec=", "audiocodec=", "videokeyframes=", "maxstream="), array("inputfile=" . $inputFile, "outputfile=" . $outputFile, "media=" . $format, $format, "width=" . $width, "height=" . $height, "videocodec=" . $videoCodec, "audiocodec=" . $audioCodec, "videokeyframes=" . $keyFramesInSec, "maxstream=" . $bitrate), self::WebexCfgTemplate);
     KalturaLog::log($cfg);
     return $cfg;
 }
コード例 #2
0
 /**
  * @param string $str
  */
 private function __construct($str)
 {
     if (empty($str)) {
         $this->data = array();
     }
     try {
         $this->data = @unserialize($str);
         if ($this->data == null) {
             $this->data = array();
         } else {
             foreach ($this->data as $name => $value) {
                 if (strpos($name, ':') > 0) {
                     list($namespace, $subName) = explode(':', $name, 2);
                     unset($this->data[$name]);
                     if (!isset($this->data[$namespace])) {
                         $this->data[$namespace] = array();
                     }
                     $this->data[$namespace][$subName] = $value;
                 }
             }
         }
     } catch (Exception $ex) {
         // cannot initialize from $str
         KalturaLog::log(__METHOD__ . ", cannot init from string [{$str}]");
         $this->data = array();
     }
 }
コード例 #3
0
 public function Generate(KDLMediaDataSet $mediaSet, KDLProfile $profile, array &$targetList)
 {
     if ($mediaSet != null && $mediaSet->IsDataSet()) {
         $rv = $this->Initialize($mediaSet);
         if ($rv == false) {
             /*
              * fix #9599 - handles rm files that fails to extract media info, but still playable by real player -
              * simulate video and audio elements, although no source mediainfo is provided
              */
             if ($this->_srcDataSet->_container && $this->_srcDataSet->_container->IsFormatOf(array("realmedia"))) {
                 $rmSrc = $this->_srcDataSet;
                 $rmSrc->_errors = array();
                 $rmSrc->_video = new KDLVideoData();
                 $rmSrc->_video->_id = $rmSrc->_video->_format = "realvideo";
                 $rmSrc->_audio = new KDLAudioData();
                 $rmSrc->_audio->_id = $rmSrc->_audio->_format = "realaudio";
                 $rmSrc->_warnings[KDLConstants::ContainerIndex][] = KDLWarnings::ToString(KDLWarnings::RealMediaMissingContent);
                 KalturaLog::log("An invalid source RealMedia file thatfails to provide valid mediaInfodata. Set up a flavor with 'default' params.");
             } else {
                 return false;
             }
         }
     }
     if ($profile == null) {
         return true;
     }
     $this->GenerateTargetFlavors($profile, $targetList);
     if (count($this->_srcDataSet->_errors) > 0) {
         return false;
     }
     return true;
 }
コード例 #4
0
 /**
  * @param string $entryId
  * @param FileSync $object
  * @param int $fileSyncId
  * @param string $sourceFileUrl
  * @return BatchJob
  */
 public static function addFileSyncImportJob($entryId, FileSync $fileSync, $sourceFileUrl, BatchJob $parentJob = null, $fileSize = null)
 {
     $partnerId = $fileSync->getPartnerId();
     $fileSyncId = $fileSync->getId();
     $dc = $fileSync->getDc();
     KalturaLog::log(__METHOD__ . " entryId[{$entryId}], partnerId[{$partnerId}], fileSyncId[{$fileSyncId}], sourceFileUrl[{$sourceFileUrl}]");
     $fileSyncImportData = new kFileSyncImportJobData();
     $fileSyncImportData->setSourceUrl($sourceFileUrl);
     $fileSyncImportData->setFilesyncId($fileSyncId);
     $fileSyncImportData->setFileSize($fileSize);
     // tmpFilePath and destFilePath will be set later during get exlusive call on the target data center
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild(BatchJobType::FILESYNC_IMPORT, null, true, $dc);
     } else {
         $batchJob = new BatchJob();
         $batchJob->setDc($dc);
         $batchJob->setEntryId($entryId);
         $batchJob->setPartnerId($partnerId);
     }
     $batchJob->setObjectId($fileSyncId);
     $batchJob->setObjectType(BatchJobObjectType::FILE_SYNC);
     //In case file sync is of type data and holds flavor asset than we need to check if its the source asset that is being synced and raise it sync priority
     if ($fileSync->getObjectType() == FileSyncObjectType::FLAVOR_ASSET && $fileSync->getObjectSubType() == entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA && $fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_FILE) {
         $assetdb = assetPeer::retrieveById($fileSync->getObjectId());
         if ($assetdb) {
             $isSourceAsset = $assetdb->getIsOriginal();
             if ($isSourceAsset) {
                 $fileSyncImportData->setIsSourceAsset(true);
             }
         }
     }
     KalturaLog::log("Creating Filesync Import job, with file sync id: {$fileSyncId} size: {$fileSize}");
     return kJobsManager::addJob($batchJob, $fileSyncImportData, BatchJobType::FILESYNC_IMPORT);
 }
コード例 #5
0
ファイル: BatchJob.php プロジェクト: richhl/kalturaCE
 public function save(PropelPDO $con = null)
 {
     KalturaLog::log("BatchJob [{$this->getJobType()}][{$this->getJobSubType()}]: save()");
     $is_new = $this->isNew();
     if ($this->isNew()) {
         $this->setDc(kDataCenterMgr::getCurrentDcId());
         // if the status not set upon creation
         if (is_null($this->status) || !$this->isColumnModified(BatchJobPeer::STATUS)) {
             //echo "sets the status to " . self::BATCHJOB_STATUS_PENDING . "\n";
             $this->setStatus(self::BATCHJOB_STATUS_PENDING);
         }
     }
     $res = parent::save($con);
     if ($is_new && !$this->root_job_id && $this->id) {
         // set the root to point to itself
         $this->setRootJobId($this->id);
         $res = parent::save($con);
     }
     /*		
      * 	remove - no need to use file indicators any more
     		// when new object or status is pending - add the indicator for the batch job to start running
     		if ( $is_new || ( $this->getStatus() == self::BATCHJOB_STATUS_PENDING ) )
     		{
     			self::addIndicator( $this->getId() , $this->getJobType() );
     			KalturaLog::log ( "BatchJob: Added indicator for BatchJob [" . $this->getId() . "] of type [{$this->getJobType() }]" );
     			//debugUtils::st();			
     		}
     		else
     		{
     			KalturaLog::log ( "BatchJob: Didn't add an indicator for BatchJob [" . $this->getId() . "]" );
     		}
     */
     return $res;
 }
コード例 #6
0
 protected function getCmdLine()
 {
     $cmdLine = parent::getCmdLine();
     $cmdLine = KConversionEngineFfmpeg::experimentalFixing($cmdLine, $this->data->flavorParamsOutput, $this->cmd, $this->inFilePath, $this->outFilePath);
     $cmdLine = KConversionEngineFfmpeg::expandForcedKeyframesParams($cmdLine);
     $wmStr = strstr($this->operator->params, "watermark:");
     if ($wmStr == false) {
         return $cmdLine;
     }
     $wmStr = trim(substr($this->operator->params, strlen("watermark:")));
     /*
      * If no watermarkData, carry on 
      */
     if ($wmStr == null) {
         return $cmdLine;
     }
     KalturaLog::log("Watermark string({$wmStr})");
     $wmData = json_decode($wmStr);
     if (!isset($wmData)) {
         KalturaLog::err("Bad watermark JSON string({$wmStr}), carry on without watermark");
     }
     KalturaLog::log("Watermark data:\n" . print_r($wmData, 1));
     // impersonite
     KBatchBase::impersonate($this->data->flavorParamsOutput->partnerId);
     // !!!!!!!!!!!$this->job->partnerId);
     $wmCmdLine = KConversionEngineFfmpeg::buildWatermarkedCommandLine($wmData, $this->data->destFileSyncLocalPath, $cmdLine, KBatchBase::$taskConfig->params->ffmpegCmd, KBatchBase::$taskConfig->params->mediaInfoCmd);
     // un-impersonite
     KBatchBase::unimpersonate();
     if (isset($wmCmdLine)) {
         $cmdLine = $wmCmdLine;
     }
     return $cmdLine;
 }
コード例 #7
0
 public static function uploadFileByToken($file_data, $token, $filename, $extra_id = null, $create_thumb = false)
 {
     KalturaLog::log("Trace while uploading1 [{$filename}] [{$token}] [{$extra_id}] " . print_r($file_data, true));
     $origFilename = @$file_data['name'];
     if (!$origFilename) {
         KalturaLog::log("Error while uploading, file does not have a name. [{$filename}] [{$token}] [{$extra_id}] " . print_r($file_data, true) . "\nerror: [" . @$file_data["error"] . "]");
         return;
     }
     $parts = pathinfo($origFilename);
     $extension = @strtolower($parts['extension']);
     /*
     		$filename = $token .'_'. $filename;
     		// add the file extension after the "." character
     		$fullPath = myContentStorage::getFSUploadsPath().$filename . ( $extra_id ? "_" . $extra_id : "" ) .".".$extension;
     */
     list($fullPath, $fullUrl) = self::getUploadPathAndUrl($token, $filename, $extra_id, $extension);
     KalturaLog::log("Trace while uploading2 [{$filename}] [{$token}] [{$extra_id}] " . print_r($file_data, true) . "\n->[{$fullPath}]");
     // start tracking what will hopefully become an entry
     $te = new TrackEntry();
     $te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_UPLOADED_FILE);
     $te->setParam1Str($token);
     $te->setParam2Str($filename);
     $te->setParam3Str($fullPath);
     $te->setDescription(__METHOD__ . ":" . __LINE__);
     TrackEntry::addTrackEntry($te);
     myContentStorage::fullMkdir($fullPath);
     if (!move_uploaded_file($file_data['tmp_name'], $fullPath)) {
         KalturaLog::log("Error while uploading [{$token}] [{$filename}] [{$extra_id}] [{$create_thumb}] " . print_r($file_data, true) . "\n->[{$fullPath}]");
         $err = array("token" => $token, "filename" => $filename, "origFilename" => $origFilename, "error" => @$file_data["error"]);
         KalturaLog::log("Error while uploading [{$token}] [{$filename}] [{$extra_id}] [{$create_thumb}] " . print_r($file_data, true) . "\n->[{$fullPath}]" . "\n" . print_r($err, true));
         return $err;
     }
     chmod($fullPath, 0777);
     $upload_server_header = isset($_SERVER["HTTP_X_KALTURA_SERVER"]) ? $_SERVER["HTTP_X_KALTURA_SERVER"] : null;
     $thumb_created = false;
     // if the file originated from a kaltura upload server we dont need a thumbnail (kuploader)
     if ($create_thumb && !$upload_server_header) {
         $thumbFullPath = self::getThumbnailPath($fullPath, ".jpg");
         kFile::fullMkdir($thumbFullPath);
         KalturaLog::log("Thumbnail full path [{$thumbFullPath}]");
         if (myContentStorage::fileExtAccepted($extension)) {
             KalturaLog::log("Generating image thumbnail");
             myFileConverter::createImageThumbnail($fullPath, $thumbFullPath, "image2");
             $thumb_url = self::getThumbnailPath($fullUrl, ".jpg");
             $thumb_created = file_exists($thumbFullPath);
         } elseif (myContentStorage::fileExtNeedConversion($extension)) {
             KalturaLog::log("Generating media thumbnail");
             myFileConverter::captureFrame($fullPath, $thumbFullPath, 1, "image2", -1, -1, 3);
             if (!file_exists($thumbFullPath)) {
                 myFileConverter::captureFrame($fullPath, $thumbFullPath, 1, "image2", -1, -1, 0);
             }
         }
     }
     if (!$thumb_created) {
         KalturaLog::log("Thumbnail not generated");
         // in this case no thumbnail was created - don't extract false data
         $thumb_url = "";
     }
     return array("token" => $token, "filename" => $filename, "origFilename" => $origFilename, "thumb_url" => $thumb_url, "thumb_created" => $thumb_created);
 }
コード例 #8
0
 public static function getIdByStrId($strId)
 {
     // try to get strId to id mapping form cache
     $cacheKey = 'UserRolePeer_role_str_id_' . $strId;
     if (kConf::get('enable_cache') && function_exists('apc_fetch') && function_exists('apc_store')) {
         $id = apc_fetch($cacheKey);
         // try to fetch from cache
         if ($id) {
             KalturaLog::debug("UserRole str_id [{$strId}] mapped to id [{$id}] - fetched from cache");
             return $id;
         }
     }
     // not found in cache - get from database
     $c = new Criteria();
     $c->addSelectColumn(UserRolePeer::ID);
     $c->addAnd(UserRolePeer::STR_ID, $strId, Criteria::EQUAL);
     $c->setLimit(1);
     $stmt = UserRolePeer::doSelectStmt($c);
     $id = $stmt->fetch(PDO::FETCH_COLUMN);
     if ($id) {
         // store the found id in cache for later use
         if (kConf::get('enable_cache') && function_exists('apc_fetch') && function_exists('apc_store')) {
             $success = apc_store($cacheKey, $id, kConf::get('apc_cache_ttl'));
             if ($success) {
                 KalturaLog::debug("UserRole str_id [{$strId}] mapped to id [{$id}] - stored in cache");
             }
         }
     }
     if (!$id) {
         KalturaLog::log("UserRole with str_id [{$strId}] not found in DB!");
     }
     return $id;
 }
コード例 #9
0
ファイル: kXslPathManager.php プロジェクト: DBezemer/server
 /**
  * will return a pair of file_root and file_path
  * This is the only function that should be extended for building a different path
  *
  * @param ISyncableFile $object
  * @param int $subType
  * @param $version
  */
 public function generateFilePathArr(ISyncableFile $object, $subType, $version = null, $storageProfileId = null)
 {
     // currently xsl paths are only used for assets
     if (!$object instanceof asset) {
         return parent::generateFilePathArr($object, $subType, $version, $storageProfileId);
     }
     $storageProfile = kPathManager::getStorageProfile($storageProfileId);
     $pathXsl = $storageProfile->getPathFormat();
     $entry = $object->getEntry();
     $xslVariables = $this->getXslVariables($storageProfile, $object, $subType, $version, $entry);
     $xslStr = $this->getXsl($pathXsl, $xslVariables);
     try {
         $path = $this->getPathValue($entry, $xslStr);
     } catch (Exception $e) {
         KalturaLog::err('Error executing XSL - ' . $e->getMessage());
         $path = null;
     }
     if (empty($path)) {
         KalturaLog::log('Empty path recieved - using parent\'s path instead');
         return parent::generateFilePathArr($object, $subType, $version, $storageProfileId);
     }
     $path = trim($path);
     KalturaLog::debug('Path value [' . $path . ']');
     $root = '/';
     return array($root, $path);
 }
コード例 #10
0
ファイル: ThumbCuePoint.php プロジェクト: kubrickfr/server
 public function copyAssets(entry $toEntry, ThumbCuePoint $toCuePoint, $adjustedStartTime = null)
 {
     $timedThumbAsset = assetPeer::retrieveById($this->getAssetId());
     if (!$timedThumbAsset) {
         KalturaLog::debug("Can't retrieve timedThumbAsset with id: {$this->getAssetId()}");
         return;
     }
     // Offset the startTime according to the duration gap between the live and VOD entries
     if (!is_null($adjustedStartTime)) {
         $toCuePoint->setStartTime($adjustedStartTime);
     }
     $toCuePoint->save();
     // Must save in order to produce an id
     $timedThumbAsset->setCuePointID($toCuePoint->getId());
     // Set the destination cue point's id
     $timedThumbAsset->setCustomDataObj();
     // Write the cached custom data object into the thumb asset
     // Make a copy of the current thumb asset
     // copyToEntry will create a filesync softlink to the original filesync
     $toTimedThumbAsset = $timedThumbAsset->copyToEntry($toEntry->getId(), $toEntry->getPartnerId());
     $toCuePoint->setAssetId($toTimedThumbAsset->getId());
     $toCuePoint->save();
     // Restore the thumb asset's prev. cue point id (for good measures)
     $timedThumbAsset->setCuePointID($this->getId());
     $timedThumbAsset->setCustomDataObj();
     // Save the destination entry's thumb asset
     $toTimedThumbAsset->setCuePointID($toCuePoint->getId());
     $toTimedThumbAsset->save();
     KalturaLog::log("Saved cue point [{$toCuePoint->getId()}] and timed thumb asset [{$toTimedThumbAsset->getId()}]");
 }
コード例 #11
0
ファイル: KDLOperatorBase.php プロジェクト: richhl/kalturaCE
 public function __construct($id, $name = null, $sourceBlacklist = null, $targetBlacklist = null)
 {
     KalturaLog::log("KDLOperatorBase::__construct: id({$id}), name({$name}), sourceBlacklist(" . print_r($sourceBlacklist, true) . "), targetBlacklist(" . print_r($targetBlacklist, true) . ")");
     $this->_id = $id;
     $this->_name = $name;
     $this->_sourceBlacklist = $sourceBlacklist;
     $this->_targetBlacklist = $targetBlacklist;
 }
コード例 #12
0
ファイル: liveAsset.php プロジェクト: DBezemer/server
 protected static function validateFileSyncSubType($sub_type)
 {
     if ($sub_type == self::FILE_SYNC_ASSET_SUB_TYPE_LIVE_PRIMARY || $sub_type == self::FILE_SYNC_ASSET_SUB_TYPE_LIVE_SECONDARY) {
         return true;
     }
     KalturaLog::log("Sub type provided [{$sub_type}] is not one of known live-asset sub types validating from parent");
     return parent::validateFileSyncSubType($sub_type);
 }
コード例 #13
0
ファイル: LiveEntry.php プロジェクト: DBezemer/server
 protected static function validateFileSyncSubType($sub_type)
 {
     if ($sub_type == self::FILE_SYNC_ENTRY_SUB_TYPE_LIVE_PRIMARY || $sub_type == self::FILE_SYNC_ENTRY_SUB_TYPE_LIVE_SECONDARY || $sub_type == self::FILE_SYNC_ENTRY_SUB_TYPE_THUMB || $sub_type == self::FILE_SYNC_ENTRY_SUB_TYPE_OFFLINE_THUMB) {
         return true;
     }
     KalturaLog::log("Sub type provided [{$sub_type}] is not one of knowen LiveEntry sub types validating from parent");
     return parent::validateFileSyncSubType($sub_type);
 }
コード例 #14
0
 public static function filterTagFlavors(array $flavors)
 {
     KalturaLog::log("Filter Tag Flavors, " . count($flavors) . " flavors supplied");
     // check if there is a complete flavor
     $hasComplied = false;
     $hasForced = false;
     $originalFlavorParamsIds = array();
     foreach ($flavors as $flavorParamsId => $flavor) {
         $originalFlavorParamsIds[] = $flavor->getFlavorParamsId();
         if (!$flavor->_isNonComply) {
             $hasComplied = true;
         }
         if ($flavor->_force) {
             $hasForced = true;
         }
     }
     $originalFlavorParams = array();
     $dbOriginalFlavorParams = flavorParamsPeer::retrieveByPKs($originalFlavorParamsIds);
     foreach ($dbOriginalFlavorParams as $dbFlavorParams) {
         $originalFlavorParams[$dbFlavorParams->getId()] = $dbFlavorParams;
     }
     // return only complete flavors
     if ($hasComplied) {
         KalturaLog::log("Has complied flavors");
     }
     if ($hasForced) {
         KalturaLog::log("Has forced flavors");
     }
     if ($hasComplied || $hasForced) {
         return $flavors;
     }
     // find the lowest flavor
     $lowestFlavorParamsId = null;
     foreach ($flavors as $flavorParamsId => $flavor) {
         if (!$flavor->IsValid()) {
             continue;
         }
         // is lower than the selected
         if (!isset($originalFlavorParams[$flavor->getFlavorParamsId()])) {
             continue;
         }
         $currentOriginalFlavor = $originalFlavorParams[$flavor->getFlavorParamsId()];
         // is first flavor to check
         if (is_null($lowestFlavorParamsId)) {
             $lowestFlavorParamsId = $flavorParamsId;
             continue;
         }
         $lowestOriginalFlavor = $originalFlavorParams[$flavors[$lowestFlavorParamsId]->getFlavorParamsId()];
         if (self::isFlavorLower($currentOriginalFlavor, $lowestOriginalFlavor)) {
             $lowestFlavorParamsId = $flavorParamsId;
         }
     }
     if ($lowestFlavorParamsId) {
         KalturaLog::log("Lowest flavor selected [{$lowestFlavorParamsId}]");
         $flavors[$lowestFlavorParamsId]->_create_anyway = true;
     }
     return $flavors;
 }
コード例 #15
0
 public function buildServeFlavors()
 {
     $flavor = $this->getSecureHdUrl();
     if (!$flavor) {
         KalturaLog::log('No flavor found');
         return null;
     }
     return array($flavor);
 }
コード例 #16
0
 public function serve()
 {
     $flavor = $this->getSecureHdUrl();
     if (!$flavor) {
         KalturaLog::log('No flavor found');
         return null;
     }
     return $this->getRenderer(array($flavor));
 }
コード例 #17
0
ファイル: kUrlManager.php プロジェクト: richhl/kalturaCE
 /**
  * @param int $storageProfileId
  * @return kUrlManager
  */
 public static function getUrlManagerByStorageProfile($storageProfileId)
 {
     $class = 'kUrlManager';
     $storageProfile = StorageProfilePeer::retrieveByPK($storageProfileId);
     if ($storageProfile && $storageProfile->getUrlManagerClass() && class_exists($storageProfile->getUrlManagerClass())) {
         $class = $storageProfile->getUrlManagerClass();
     }
     KalturaLog::log("Uses url manager [{$class}]");
     return new $class($storageProfileId);
 }
コード例 #18
0
ファイル: kPathManager.php プロジェクト: richhl/kalturaCE
 /**
  * will return a pair of file_root and file_path
  *
  * @param ISyncableFile $object
  * @param int $subType
  * @param int $storageProfileId
  * @param $version
  */
 public static function getFilePathArr(FileSyncKey $key, $storageProfileId = null)
 {
     KalturaLog::log(__METHOD__ . " - key [{$key}], storageProfileId [{$storageProfileId}]");
     $storageProfile = self::getStorageProfile($storageProfileId);
     if (is_null($storageProfile)) {
         throw new Exception("Storage Profile [{$storageProfileId}] not found");
     }
     $pathManager = $storageProfile->getPathManager();
     $object = kFileSyncUtils::retrieveObjectForSyncKey($key);
     return $pathManager->generateFilePathArr($object, $key->object_sub_type, $key->version);
 }
コード例 #19
0
 public static function removePermissionFromPartner($permissionName, $partnerId)
 {
     $c = new Criteria();
     $c->addAnd(PermissionPeer::PARTNER_ID, $partnerId, Criteria::EQUAL);
     $c->addAnd(PermissionPeer::NAME, $permissionName, Criteria::EQUAL);
     $existingPermission = PermissionPeer::doSelectOne($c);
     if (!$existingPermission) {
         throw new kPermissionException('Permission [' . $permissionName . '] does not exist for partner [' . $partnerId . ']', kPermissionException::PERMISSION_NOT_FOUND);
     }
     KalturaLog::log('Removing permission [' . $permissionName . '] from partner [' . $partnerId . '].');
     $existingPermission->setStatus(PermissionStatus::DELETED);
 }
コード例 #20
0
 /**
  * @param string $entryId
  * @param int $partnerId
  * @param int $fileSyncId
  * @param string $sourceFileUrl
  * @return BatchJob
  */
 public static function addFileSyncImportJob($entryId, $partnerId, $fileSyncId, $sourceFileUrl)
 {
     KalturaLog::log(__METHOD__ . " entryId[{$entryId}], partnerId[{$partnerId}], fileSyncId[{$fileSyncId}], sourceFileUrl[{$sourceFileUrl}]");
     $fileSyncImportData = new kFileSyncImportJobData();
     $fileSyncImportData->setSourceUrl($sourceFileUrl);
     $fileSyncImportData->setFilesyncId($fileSyncId);
     // tmpFilePath and destFilePath will be set later during get exlusive call on the target data center
     $batchJob = new BatchJob();
     $batchJob->setEntryId($entryId);
     $batchJob->setPartnerId($partnerId);
     KalturaLog::log("Creating Filesync Import job, with file sync id: {$fileSyncId}");
     return kJobsManager::addJob($batchJob, $fileSyncImportData, BatchJobType::FILESYNC_IMPORT);
 }
コード例 #21
0
ファイル: Annotation.php プロジェクト: richhl/kalturaCE
 /**
  * generate unique string id for annotation
  */
 public function getUniqueAnnotationId()
 {
     $dc = kDataCenterMgr::getCurrentDc();
     for ($i = 0; $i < 10; $i++) {
         $id = $dc["id"] . '_' . kString::generateStringId();
         $existingObject = AnnotationPeer::retrieveByPK($id);
         if ($existingObject) {
             KalturaLog::log(__METHOD__ . ": id [{$id}] already exists");
         } else {
             return $id;
         }
     }
     throw new Exception("Could not find unique id for annotation");
 }
コード例 #22
0
ファイル: CuePoint.php プロジェクト: kubrickfr/server
 /**
  * generate unique string id for CuePoint
  */
 private function calculateId()
 {
     $currentDcId = kDataCenterMgr::getCurrentDcId();
     for ($i = 0; $i < 10; $i++) {
         $id = $currentDcId . '_' . kString::generateStringId();
         $existingObject = CuePointPeer::retrieveByPKNoFilter($id);
         if ($existingObject) {
             KalturaLog::log(__METHOD__ . ": id [{$id}] already exists");
         } else {
             return $id;
         }
     }
     throw new Exception("Could not find unique id for CuePoint");
 }
コード例 #23
0
ファイル: AppToken.php プロジェクト: DBezemer/server
 private function calculateId()
 {
     $dc = kDataCenterMgr::getCurrentDc();
     for ($i = 0; $i < 10; $i++) {
         $id = $dc["id"] . '_' . kString::generateStringId();
         $existingObject = AppTokenPeer::retrieveByPkNoFilter($id);
         if ($existingObject) {
             KalturaLog::log("ID [{$id}] already exists");
         } else {
             return $id;
         }
     }
     throw new Exception("Could not find unique id for AppToken");
 }
 public function __construct($id, $name = null, $sourceBlacklist = null, $targetBlacklist = null)
 {
     KalturaLog::log("KDLOperatorBase::__construct: id({$id}), name({$name}), sourceBlacklist(" . print_r($sourceBlacklist, true) . "), targetBlacklist(" . print_r($targetBlacklist, true) . ")");
     $this->_id = $id;
     $this->_name = $name;
     $this->_sourceBlacklist = $sourceBlacklist;
     $this->_targetBlacklist = $targetBlacklist;
     if (!isset($sourceBlacklist) && array_key_exists($id, KDLConstants::$TranscodersSourceBlackList)) {
         $this->_sourceBlacklist = KDLConstants::$TranscodersSourceBlackList[$id];
     }
     if (!isset($targetBlacklist) && array_key_exists($id, KDLConstants::$TranscodersTargetBlackList)) {
         $this->_targetBlacklist = KDLConstants::$TranscodersTargetBlackList[$id];
     }
 }
コード例 #25
0
 public function execute()
 {
     $error = false;
     // youtube video id
     $itemId = $this->getRequestParameter("itemId");
     $url = "http://www.youtube.com/watch?v=" . $itemId;
     $sourceUrl = "";
     $retries = 2;
     while ($retries--) {
         $content = kFile::downloadUrlToString($url, 3);
         if (preg_match('/swfArgs.*?\\{.*?, "t":\\s*"(.*?)"/s', $content, $timestampMatch)) {
             $fmt_url = "";
             //"fmt_map": "35/640000/9/0/115,18/512000/9/0/115,34/0/9/0/115,5/0/7/0/0"
             if (preg_match('/swfArgs.*?\\{.*?, "fmt_map":\\s*"(.*?)"/s', $content, $fmt_map)) {
                 $fmt_map_array = explode(",", urldecode($fmt_map[1]));
                 $fmt_details = explode("/", $fmt_map_array[0]);
                 if ($fmt_details[0]) {
                     $fmt_url = "&fmt=" . $fmt_details[0];
                 }
             }
             //var swfArgs = {hl:'en',video_id:'F924-D-g5t8',l:'24',t:'OEgsToPDskL9BIntclUB-PPzMEpVQKo8',sk:'xXvbHpmFGQKgv-b9__DkgwC'};
             $tId = $timestampMatch[1];
             $sourceUrl = "http://youtube.com/get_video?video_id=" . $itemId . "&t={$tId}{$fmt_url}";
         } else {
             KalturaLog::log("youtubeRedirectAction {$retries} {$url} {$content}");
         }
     }
     if ($sourceUrl) {
         if (!$retries) {
             KalturaLog::log("youtubeRedirectAction retry successful {$url}");
         }
     } else {
         die;
     }
     // get only the headers and don't follow the location redirect
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $sourceUrl);
     curl_setopt($ch, CURLOPT_USERAGENT, "curl/7.11.1");
     curl_setopt($ch, CURLOPT_HEADER, 1);
     curl_setopt($ch, CURLOPT_NOBODY, 1);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     $headers = curl_exec($ch);
     // get the location header
     $found1 = preg_match_all('/Location: (.*)/', $headers, $swfUrlResult);
     $swfUrl = str_replace('Location: ', '', $swfUrlResult[0][count($swfUrlResult[0]) - 1]);
     //echo $swfUrl; die();
     $this->redirect($swfUrl);
 }
コード例 #26
0
 public function save(PropelPDO $con = null)
 {
     KalturaLog::log("BatchJob [{$this->getJobType()}][{$this->getJobSubType()}]: save()");
     $is_new = $this->isNew();
     if ($this->isNew()) {
         // set the dc ONLY if it wasnt initialized
         // this is required in the special case of file_sync import jobs which are created on one dc but run from the other
         // all other jobs run from the same datacenter they were created on.
         // setting the dc later results in a race condition were the job is picked up by the current datacenter before the dc value is changed
         if (is_null($this->dc) || !$this->isColumnModified(BatchJobPeer::DC)) {
             // by default set the dc to the current data center. However whenever a batch job is operating on an entry, we rather run it
             // in the DC where the file sync of the entry exists. Since the batch job doesnt refer to a flavor (we only have an entry id member)
             // we check the file sync of the source flavor asset (if one exists)
             $dc = kDataCenterMgr::getCurrentDcId();
             kalturaLog::debug("setting the job's DC to [{$dc}]");
             $this->setDc($dc);
         }
         // if the status not set upon creation
         if (is_null($this->status) || !$this->isColumnModified(BatchJobPeer::STATUS)) {
             //echo "sets the status to " . self::BATCHJOB_STATUS_PENDING . "\n";
             $this->setStatus(self::BATCHJOB_STATUS_PENDING);
         }
     }
     $result = array_intersect(self::$LOCK_VERSION_AFFECTED_BY_COLUMNS_NAMES, $this->getModifiedColumns());
     if (count($result) > 0) {
         $this->setLockVersion($this->getLockVersion() + 1);
     }
     $res = parent::save($con);
     if ($is_new && !$this->root_job_id && $this->id || $this->useNewRoot) {
         // set the root to point to itself
         $this->setRootJobId($this->id);
         $res = parent::save($con);
     }
     /*		
      * 	remove - no need to use file indicators any more
     		// when new object or status is pending - add the indicator for the batch job to start running
     		if ( $is_new || ( $this->getStatus() == self::BATCHJOB_STATUS_PENDING ) )
     		{
     			self::addIndicator( $this->getId() , $this->getJobType() );
     			KalturaLog::log ( "BatchJob: Added indicator for BatchJob [" . $this->getId() . "] of type [{$this->getJobType() }]" );
     			//debugUtils::st();			
     		}
     		else
     		{
     			KalturaLog::log ( "BatchJob: Didn't add an indicator for BatchJob [" . $this->getId() . "]" );
     		}
     */
     return $res;
 }
コード例 #27
0
 protected function getDistributionFiles(FtpDistributionProfile $distributionProfileDb, EntryDistribution $entryDistributionDb)
 {
     $files = new KalturaFtpDistributionFileArray();
     $sendMetadataAfterAssets = false;
     if (!is_null($distributionProfileDb->getSendMetadataAfterAssets())) {
         $sendMetadataAfterAssets = $distributionProfileDb->getSendMetadataAfterAssets();
     }
     if (!$distributionProfileDb->getDisableMetadata()) {
         $metadataFile = new KalturaFtpDistributionFile();
         $metadataXml = $distributionProfileDb->getMetadataXml($entryDistributionDb);
         $metadataFile->filename = $distributionProfileDb->getMetadataFilename($entryDistributionDb);
         $metadataFile->contents = $metadataXml;
         $metadataFile->assetId = 'metadata';
         $metadataFile->hash = md5($metadataXml);
         if (!$sendMetadataAfterAssets) {
             $files[] = $metadataFile;
         }
     }
     $flavorAssetsIds = explode(',', $entryDistributionDb->getFlavorAssetIds());
     $thumbnailAssetIds = explode(',', $entryDistributionDb->getThumbAssetIds());
     $assetIds = explode(',', $entryDistributionDb->getAssetIds());
     $assets = assetPeer::retrieveByIds(array_merge($flavorAssetsIds, $thumbnailAssetIds, $assetIds));
     KalturaLog::log("Assets to distribute: " . print_r($assets, true));
     foreach ($assets as $asset) {
         /* @var $assets asset */
         $syncKey = $asset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         $file = new KalturaFtpDistributionFile();
         $file->assetId = $asset->getId();
         $file->localFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false);
         $file->version = $syncKey->getVersion();
         $defaultFilename = pathinfo($file->localFilePath, PATHINFO_BASENAME);
         if ($asset instanceof thumbAsset) {
             $file->filename = $distributionProfileDb->getThumbnailAssetFilename($entryDistributionDb, $defaultFilename, $asset->getId());
         } else {
             if ($asset instanceof flavorAsset) {
                 $file->filename = $distributionProfileDb->getFlavorAssetFilename($entryDistributionDb, $defaultFilename, $asset->getId());
             } else {
                 $file->filename = $distributionProfileDb->getAssetFilename($entryDistributionDb, $defaultFilename, $asset->getId());
             }
         }
         $files[] = $file;
     }
     //sending metadata after assets as configured in the connector profile
     if ($metadataFile && $sendMetadataAfterAssets) {
         $files[] = $metadataFile;
     }
     return $files;
 }
コード例 #28
0
 /**
  * Check if the given URL contains live entries (typically containing .ts URLs)
  * @param string $url
  * @param string|array $urlContent The URL's parsed content
  * @return boolean
  */
 protected function checkIsLiveMediaPlaylist($url, $urlContent)
 {
     if ($this->isDvrContent($urlContent)) {
         return false;
     }
     $lines = kDeliveryUtils::getM3U8Urls($urlContent);
     $lines = array_slice($lines, -self::MAX_IS_LIVE_ATTEMPTS, self::MAX_IS_LIVE_ATTEMPTS, true);
     foreach ($lines as $urlLine) {
         $tsUrl = $this->checkIfValidUrl($urlLine, $url);
         if ($this->urlExists($tsUrl, kConf::get(self::HLS_LIVE_STREAM_CONTENT_TYPE), '0-1') !== false) {
             KalturaLog::log("Live ts url: {$tsUrl}");
             return true;
         }
     }
     return false;
 }
コード例 #29
0
ファイル: kMemoryManager.php プロジェクト: kubrickfr/server
 public static function clearMemory()
 {
     KalturaLog::log('Clearing memory');
     foreach (self::$peerNames as $peerName => $dontCare) {
         call_user_func(array($peerName, 'clearInstancePool'));
     }
     self::$peerNames = array();
     $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaMemoryCleaner');
     foreach ($pluginInstances as $pluginInstance) {
         $pluginInstance->cleanMemory();
     }
     if (function_exists('gc_collect_cycles')) {
         // php 5.3 and above
         gc_collect_cycles();
     }
 }
コード例 #30
0
 /**
  * @param string $str
  */
 private function myCustomData($str)
 {
     if (empty($str)) {
         $this->data = array();
     }
     try {
         $this->data = @unserialize($str);
         if ($this->data == null) {
             $this->data = array();
         }
     } catch (Exception $ex) {
         // cannot initialize from $str
         KalturaLog::log(__METHOD__ . ", cannot init from string [{$str}]");
         $this->data = array();
     }
 }