conversion.inc in Video 6.4
File
includes/conversion.inc
View source
<?php
defined('VIDEO_RENDERING_PENDING') || define('VIDEO_RENDERING_PENDING', 1);
defined('VIDEO_RENDERING_ACTIVE') || define('VIDEO_RENDERING_ACTIVE', 5);
defined('VIDEO_RENDERING_COMPLETE') || define('VIDEO_RENDERING_COMPLETE', 10);
defined('VIDEO_RENDERING_FAILED') || define('VIDEO_RENDERING_FAILED', 20);
class video_conversion {
protected $transcoder;
public function __construct() {
module_load_include('inc', 'video', '/includes/transcoder');
$this->transcoder = new video_transcoder();
}
public function run_queue() {
if ($videos = $this
->load_job_queue()) {
foreach ($videos as $video) {
$this
->process($video);
}
cache_clear_all('*', 'cache_content', true);
}
}
private function load_job_queue() {
return $this->transcoder
->load_job_queue();
}
public function process($video) {
if (is_object($video) && isset($video->fid)) {
$return = $this
->render($video);
}
else {
$video_object = $this
->load_job($video);
$return = $this
->render($video_object);
}
return $return;
}
private function render($video) {
if (!is_object($video)) {
watchdog('video_conversion', 'Video object is not present', array(), WATCHDOG_ERROR);
return FALSE;
}
if ($video->video_status == VIDEO_RENDERING_PENDING) {
return $this->transcoder
->convert_video($video);
}
return NULL;
}
public function load_completed_job($video) {
return $this->transcoder
->load_completed_job($video);
}
public function create_job($video) {
return $this->transcoder
->create_job($video);
}
public function update_job($video) {
return $this->transcoder
->update_job($video);
}
public function delete_job($video) {
return $this->transcoder
->delete_job($video);
}
public function load_job($fid) {
return $this->transcoder
->load_job($fid);
}
}