From 0d300315ee1144b50bdf666f364cd02dceb2e5cf Mon Sep 17 00:00:00 2001 From: Heshan Date: Mon, 14 Mar 2011 19:14:50 +0530 Subject: Adding cron queue to the video schedular --- video.module | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'video.module') diff --git a/video.module b/video.module index 7f3283d..6e38cab 100644 --- a/video.module +++ b/video.module @@ -127,14 +127,40 @@ function video_theme() { */ function video_cron() { - return; - module_load_include('inc', 'video', 'includes/conversion'); if (variable_get('video_cron', TRUE)) { + module_load_include('inc', 'video', 'includes/conversion'); $video_conversion = new video_conversion; - $video_conversion->run_queue(); + if ($videos = $video_conversion->load_job_queue()) { + $queue = DrupalQueue::get('video_queue'); + foreach ($videos as $video) { + if ($queue->createItem($video)) { + $video_conversion->change_status($video->vid, VIDEO_RENDERING_INQUEUE); + } + } + } } } +/** + * Implmentation of hook_cron_queue_info() + */ +function video_cron_queue_info() { + $queues['video_queue'] = array( + 'worker callback' => 'video_queue_process', + 'time' => variable_get('video_queue_timeout', 90), + ); + return $queues; +} + +/** + * Process video transcoding queue + */ +function video_queue_process($video) { + module_load_include('inc', 'video', 'includes/conversion'); + $video_conversion = new video_conversion; + $video_conversion->process($video); +} + /* * Utility function that will add a preview of thumbnails for you to select when uploading videos. */ -- cgit v1.2.3