conversion.inc in Video 7
File
includes/conversion.inc
View source
<?php
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();
}
}
public 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('transcoder', 'Video object is not present', array(), WATCHDOG_ERROR);
return FALSE;
}
if ($video->video_status == VIDEO_RENDERING_PENDING) {
return $this->transcoder
->convert_video($video);
}
else {
$status = array(
VIDEO_RENDERING_INQUEUE => 'in queue',
VIDEO_RENDERING_COMPLETE => 'completed',
VIDEO_RENDERING_FAILED => 'failed',
);
watchdog('transcoder', 'Video conversion has been !status. You should add video to the queue. Please check the re-queue to enable the video conversion.', array(
'!status' => $status[$video->video_status],
), WATCHDOG_WARNING);
return FALSE;
}
}
public function load_completed_job($video) {
return $this->transcoder
->load_completed_job($video);
}
public function create_job($video, $nid) {
return $this->transcoder
->create_job($video, $nid);
}
public function delete_job($video) {
return $this->transcoder
->delete_job($video);
}
public function change_status($vid, $status) {
return $this->transcoder
->change_status($vid, $status);
}
public function load_job($fid) {
return $this->transcoder
->load_job($fid);
}
}