private static function buildSubTitleCommandParam(KalturaConvartableJobData $data, KalturaClient $client)
 {
     //		$cmdStr.= " -add ".KDLCmdlinePlaceholders::OutFileName.".temp.srt:hdlr=sbtl:lang=$lang:group=0:layer=-1";
     // impersonite
     $preImpersoniteId = $client->getConfig()->partnerId;
     $client->getConfig()->partnerId = $data->flavorParamsOutput->partnerId;
     $flrAsst = $client->flavorAsset->get($data->flavorAssetId);
     if (!isset($flrAsst)) {
         throw new KOperationEngineException("Failed to retrieve the flavor asset object (" . $data->flavorAssetId . ")");
     }
     $filter = new KalturaAssetFilter();
     $filter->entryIdEqual = $flrAsst->entryId;
     $captionsList = $client->captionAsset->listAction($filter, null);
     if (!isset($captionsList) || count($captionsList->objects) == 0) {
         throw new KOperationEngineException("No caption assets for entry (" . $flrAsst->entryId . ")");
     }
     $captionsStr = null;
     $addedSubs = 0;
     foreach ($captionsList->objects as $captionObj) {
         try {
             $cptUrl = $client->captionAsset->getUrl($captionObj->id, null);
         } catch (Exception $ex) {
             $cptUrl = null;
             KalturaLog::err("Exception on etrieve caption asset url retrieval (" . $captionObj->id . "),\nexception:" . print_r($ex, 1));
         }
         if (!isset($cptUrl)) {
             KalturaLog::err("Failed to retrieve caption asset url (" . $captionObj->id . ")");
             continue;
         }
         $cptFilePath = self::retrieveCaptionFile($captionObj, $cptUrl, $data->destFileSyncLocalPath);
         if (!isset($cptFilePath)) {
             continue;
         }
         /*
          * group - "An integer that specifies a group or collection of tracks. If this field is 0 there is no information
          * 	on possible relations to other tracks. If this field is not 0, it should be the same for tracks that contain 
          * 	alternate data for one another and different for tracks belonging to different such groups. Only one track 
          * 	within an alternate group should be played or streamed at any one time, and must be distinguishable from other 
          * 	racks in the group via attributes such as bitrate, codec, language, packet size etc. A group may have only one member. "
          *	To follow that desc, the group id for all subtitles would be set to 1.
          *	Apart from the first subs track, all the others would be tagged with 'disabled', otherwise the older iOS devices (pre 5.x)
          *	does not handle it properly.
          * layer - "Specifies the front-to-back ordering of video tracks; tracks with lower numbers are closer to the viewer. 
          *	0 is the normal value, and -1 would be in front of track 0, and so on."
          *	layer=-1, closest to the viewer
          */
         $captionsStr .= " -add " . $cptFilePath . ":hdlr=sbtl:lang=" . $captionObj->languageCode . ":group=1:layer=-1";
         if ($addedSubs > 0) {
             $captionsStr .= ":disabled";
         }
         $addedSubs++;
     }
     // un-impersonite
     $client->getConfig()->partnerId = $preImpersoniteId;
     if (!isset($captionsStr)) {
         throw new KOperationEngineException("Error: missing caption data or files.");
     }
     return $captionsStr;
 }
 protected function unimpersonate()
 {
     $clientConfig = $this->client->getConfig();
     $clientConfig->partnerId = $this->batchPartnerId;
     $this->client->setConfig($clientConfig);
 }
 /**
  * 
  * Add the data for DWH
  */
 private static function addDWHdata(KalturaClient $client)
 {
     $partnerId = $client->getConfig()->partnerId;
     KalturaGlobalData::setData("@DWH_START_TIME@", time());
     try {
         $ch = curl_init();
         for ($i = 0; $i < 1000; $i++) {
             $eventType = KalturaStatsEventType::PLAY;
             $entryId = KalturaGlobalData::getData("@DEFAULT_ENTRY_ID@");
             $event->clientVer = "test client";
             $clientVer = "testClient";
             $event->sessionId = "test session";
             $sessionId = "testSession";
             $referer = "http://kaltura.com/" . $i % 10;
             $uiconfId = KalturaGlobalData::getData("@UI_CONF_ID@");
             $currentTimeStamp = time();
             //			$statsString = "GET //api_v3/index.php?service=stats&action=collect&kalsig=5e1adae915042f96eacf7c6d972b2f54&event%3AeventTimestamp=$currentTimeStamp&event%3AuiconfId=$uiconfId&event%3AsessionId=53BDB894%2D35D8%2D6369%2DE4BF%2DF227861A76FD&event%3AobjectType=KalturaStatsEvent&event%3AisFirstInSession=false&event%3AclientVer=3%2E0%3Av3%2E5%2E16%2Ea&event%3Aseek=false&event%3ApartnerId=$partnerId&ignoreNull=1&event%3Aduration=11&clientTag=kdp%3Av3%2E5%2E16%2Ea%2Ccache%5Fst%3A1314028568&event%3AcurrentPoint=33&event%3AeventType=$eventType&event%3Areferrer=$referer&event%3AentryId=$entryId HTTP/1.1";
             //		self::$serviceUrl;
             // set URL and other appropriate options
             curl_setopt($ch, CURLOPT_URL, self::$serviceUrl . "/api_v3/index.php?service=stats&action=collect&kalsig=5e1adae915042f96eacf7c6d972b2f54&event%3AeventTimestamp={$currentTimeStamp}&event%3AuiconfId={$uiconfId}&event%3AsessionId=53BDB894%2D35D8%2D6369%2DE4BF%2DF227861A76FD&event%3AobjectType=KalturaStatsEvent&event%3AisFirstInSession=false&event%3AclientVer=3%2E0%3Av3%2E5%2E16%2Ea&event%3Aseek=false&event%3ApartnerId={$partnerId}&ignoreNull=1&event%3Aduration=11&clientTag=kdp%3Av3%2E5%2E16%2Ea%2Ccache%5Fst%3A1314028568&event%3AcurrentPoint=33&event%3AeventType={$eventType}&event%3Areferrer={$referer}&event%3AentryId={$entryId}");
             curl_setopt($ch, CURLOPT_HEADER, 0);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             // grab URL and pass it to the browser
             $res = curl_exec($ch);
         }
         // close cURL resource, and free up system resources
         curl_close($ch);
     } catch (Exception $e) {
         KalturaLog::err("Exception was raised during http request: " . $e->getMessage() . "\n");
     }
     KalturaGlobalData::setData("@PLAYS@", $i);
     //Log rotating only if the service url is localhost
     if (self::$serviceUrl == "localhost") {
         $logRotateConfString = "/opt/kaltura/log/kaltura_apache_access.log {\nrotate 5\ndaily\nmissingok\ncompress\nnodateext\nnotifempty\nsharedscripts\npostrotate\n\t/usr/sbin/apachectl -k restart\nendscript\nlastaction\n\tmv /opt/kaltura/log/kaltura_apache_access.log.1.gz /opt/kaltura/log/kaltura_apache_access.log-{$partnerId}.gz\nendscript\n}";
         $logRotatePath = "/tmp/log_rotate.conf";
         file_put_contents($logRotatePath, $logRotateConfString);
         //Now log rotate on local machine
         exec("dos2unix {$logRotatePath}");
         exec("logrotate -f {$logRotatePath}");
         //			//run hourly
         exec("/opt/kaltura/dwh/etlsource/execute/etl_hourly.sh");
         //
         //			//run daily
         exec("/opt/kaltura/dwh/etlsource/execute/etl_daily.sh");
     }
     KalturaGlobalData::setData("@DWH_END_TIME@", time());
 }
Example #4
0
 public function impersonate($partnerId)
 {
     $config = $this->kalturaClient->getConfig();
     $config->partnerId = $partnerId;
     $this->kalturaClient->setConfig($config);
 }
 protected function unimpersonate()
 {
     $this->_client->getConfig()->partnerId = $this->_originalPartnerId;
     $this->_originalPartnerId = null;
 }
 /**
  * @param KSchedularTaskConfig $taskConfig
  */
 public function __construct(KSchedularTaskConfig $taskConfig, KalturaClient $kClient, KalturaBatchJob $job)
 {
     if ($taskConfig->params->multiRequestSize) {
         $this->multiRequestSize = $taskConfig->params->multiRequestSize;
     }
     if ($taskConfig->params->maxRecords) {
         $this->maxRecords = $taskConfig->params->maxRecords;
     }
     if ($taskConfig->params->maxRecordsEachRun) {
         $this->maxRecordsEachRun = $taskConfig->params->maxRecordsEachRun;
     }
     $this->kClient = $kClient;
     $this->kClientConfig = $kClient->getConfig();
     $this->taskConfig = $taskConfig;
     $this->job = $job;
     $this->data = $job->data;
     $this->currentPartnerId = $this->job->partnerId;
 }