diff options
author | Heshan <heshan@heidisoft.com> | 2011-03-14 19:14:50 +0530 |
---|---|---|
committer | Heshan <heshan@heidisoft.com> | 2011-03-14 19:14:50 +0530 |
commit | 0d300315ee1144b50bdf666f364cd02dceb2e5cf (patch) | |
tree | 04f10c406652bcc9327dd924511feba8cc04f330 /video.module | |
parent | fbf8a0a295104d0c4d7060c53c2c51330a355d28 (diff) | |
download | video-0d300315ee1144b50bdf666f364cd02dceb2e5cf.tar.gz video-0d300315ee1144b50bdf666f364cd02dceb2e5cf.tar.bz2 |
Adding cron queue to the video schedular
Diffstat (limited to 'video.module')
-rw-r--r-- | video.module | 32 |
1 files changed, 29 insertions, 3 deletions
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. */ |