aboutsummaryrefslogtreecommitdiff
path: root/plugins/video_ffmpeg_helper/video_scheduler.php
diff options
context:
space:
mode:
authorHeshan Wanigasooriya <heshanmw@gmail.com>2009-04-27 09:47:43 +0000
committerHeshan Wanigasooriya <heshanmw@gmail.com>2009-04-27 09:47:43 +0000
commita69b21cc7ee12c117b58f0d940f7cb9d38278384 (patch)
tree685d65bdf14b69c614b1b6676fb30cdb56c9c25d /plugins/video_ffmpeg_helper/video_scheduler.php
parent8914e5e66485a1cb9ee1fb741ae47a561167104e (diff)
downloadvideo-a69b21cc7ee12c117b58f0d940f7cb9d38278384.tar.gz
video-a69b21cc7ee12c117b58f0d940f7cb9d38278384.tar.bz2
adding plugins to the HEAD
Diffstat (limited to 'plugins/video_ffmpeg_helper/video_scheduler.php')
-rw-r--r--plugins/video_ffmpeg_helper/video_scheduler.php38
1 files changed, 26 insertions, 12 deletions
diff --git a/plugins/video_ffmpeg_helper/video_scheduler.php b/plugins/video_ffmpeg_helper/video_scheduler.php
index 4803dc2..7faf446 100644
--- a/plugins/video_ffmpeg_helper/video_scheduler.php
+++ b/plugins/video_ffmpeg_helper/video_scheduler.php
@@ -1,14 +1,20 @@
<?php
-// $Id$
/**
* @file
* Implement video rendering scheduling.
+ * If you are not using sites/default/settings.php as your settings file,
+ * add an optional parameter for the drupal site url:
+ * "php video_scheduler.php http://example.com/" or
+ * "php video_scheduler.php http://example.org/drupal/"
*
* @author Fabio Varesano <fvaresano at yahoo dot it>
+ * porting to Drupal 6
+ * @author Heshan Wanigasooriya <heshan at heidisoft.com><heshanmw@gmail.com>
+ * @todo
*/
-
-
+
+
/**
* video_scheduler.php configuration
*/
@@ -18,7 +24,7 @@ define('VIDEO_RENDERING_FFMPEG_PATH', '/usr/bin/ffmpeg');
// set to the temp file path.
//IMPORTANT: the user who runs this script must have permissions to create files there. If this is not the case the default php temporary folder will be used.
-define('VIDEO_RENDERING_TEMP_PATH', '/tmp/video');
+define('VIDEO_RENDERING_TEMP_PATH', '/tmp/video');
// number of conversion jobs active at the same time
define('VIDEO_RENDERING_FFMPEG_INSTANCES', 5);
@@ -31,12 +37,18 @@ define('VIDEO_RENDERING_FFMPEG_INSTANCES', 5);
/**
* Define some constants
*/
-define('VIDEO_RENDERING_PENDING', 0);
+define('VIDEO_RENDERING_PENDING', 1);
define('VIDEO_RENDERING_ACTIVE', 5);
define('VIDEO_RENDERING_COMPLETE', 10);
+define('VIDEO_RENDERING_FAILED', 20);
+if (isset($_SERVER['argv'][1])) {
+ $url = parse_url($_SERVER['argv'][1]);
+ $_SERVER['SCRIPT_NAME'] = $url['path'];
+ $_SERVER['HTTP_HOST'] = $url['host'];
+}
-include_once './includes/bootstrap.inc';
+module_load_include('/includes/bootstrap.inc', 'video_scheduler', 'includes/bootstrap');
// disable error reporting for bootstrap process
error_reporting(E_ERROR);
// let's bootstrap: we will be able to use drupal apis
@@ -60,14 +72,14 @@ else {
* Main for video_scheduler.php
*/
function video_scheduler_main() {
-
+
if($jobs = video_scheduler_select()) {
foreach ($jobs as $job) {
video_scheduler_start($job);
}
}
else {
- watchdog('video_scheduler', t('no video conversion jobs to schedule.'));
+ watchdog('video_scheduler', 'no video conversion jobs to schedule.');
}
}
@@ -76,7 +88,8 @@ function video_scheduler_main() {
* Starts rendering for a job
*/
function video_scheduler_start($job) {
- exec("php video_render.php $job->nid $job->vid > /dev/null &");
+ $url = (isset($_SERVER['argv'][1])) ? escapeshellarg($_SERVER['argv'][1]) : '';
+ exec("php video_render.php $job->nid $job->vid $url > /dev/null &");
}
@@ -88,9 +101,10 @@ function video_scheduler_start($job) {
function video_scheduler_select() {
$result = db_query('SELECT * FROM {video_rendering} vr INNER JOIN {node} n ON vr.vid = n.vid INNER JOIN {video} v ON n.vid = v.vid WHERE n.nid = v.nid AND vr.nid = n.nid AND vr.status = %d ORDER BY n.created', VIDEO_RENDERING_PENDING);
-
+
// TODO: order jobs by priority
-
+
+ // TODO: use db_query_range
$jobs = array();
$i = 0;
$count = db_num_rows($result);
@@ -98,7 +112,7 @@ function video_scheduler_select() {
$jobs[] = db_fetch_object($result);
$i++;
}
-
+
return $jobs;
}