public function video_amazon_s3::queue in Video 6.4
File
- plugins/video_s3/video_s3.lib.inc, line 154
Class
- video_amazon_s3
Code
public function queue() {
$sql = db_query("SELECT vid, fid FROM {video_s3} WHERE status = %d LIMIT %d", VIDEO_S3_PENDING, $this->limit);
while ($row = db_fetch_object($sql)) {
module_load_include('inc', 'video', '/includes/conversion');
$result = db_query('SELECT f.*, vf.data FROM {files} f LEFT JOIN {video_files} vf USING(fid) WHERE f.fid = %d AND (vf.status IS NULL OR vf.status = %d)', $row->fid, VIDEO_RENDERING_COMPLETE);
if (!($video = db_fetch_object($result))) {
$this
->watchdog('Could not find the file id %fid or it is still queued for ffmpeg processing.', array(
'%fid' => $row->fid,
), WATCHDOG_DEBUG, $row);
continue;
}
$this
->working($row->vid);
$success = true;
if (!empty($video->data)) {
foreach (unserialize($video->data) as $file) {
if (!$this
->pushFile($file)) {
$success = false;
}
}
}
if ($success) {
if ($video = $this
->pushFile($video)) {
$video->vid = $row->vid;
$this
->update($video);
}
else {
$success = false;
}
}
if (!$success) {
$this
->failed($row->vid);
}
}
$expires_offset = variable_get('amazon_s3_expires_offset', 604800);
if ($expires_offset !== 'none' && $expires_offset != 0 && variable_get('amazon_s3_expires_last_cron', 0) + $expires_offset < time()) {
$active = db_query('SELECT bucket, filename, filepath, filemime FROM {video_s3} WHERE status = %d', VIDEO_S3_COMPLETE);
$permission = variable_get('amazon_s3_private', FALSE) ? AmazonS3::ACL_PRIVATE : AmazonS3::ACL_PUBLIC;
$headers = array(
'Expires' => gmdate('r', time() + $expires_offset),
);
$cc = variable_get('amazon_s3_cache_control_max_age', 'none');
if ($cc !== 'none') {
$headers['Cache-Control'] = 'max-age=' . $cc;
}
while ($file = db_fetch_object($active)) {
$this
->update_headers($file, $permission, $headers);
}
variable_set('amazon_s3_expires_last_cron', time());
}
}