aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeshan <heshan@heidisoft.com>2011-03-04 23:20:28 +0530
committerHeshan <heshan@heidisoft.com>2011-03-04 23:20:28 +0530
commit72f7b7109d1cdf3ec1f5fb022170dedc8c9dc5e1 (patch)
tree4df43cb8b1a5371f792ca5bf657fdf0c4de32cf6
parent554508a1df489a8634e876ada1fa3ddd66375f7a (diff)
downloadvideo-72f7b7109d1cdf3ec1f5fb022170dedc8c9dc5e1.tar.gz
video-72f7b7109d1cdf3ec1f5fb022170dedc8c9dc5e1.tar.bz2
Creating presets which can be exported with features, chostools and move subsidary module to modules directory
-rw-r--r--INSTALL.txt17
-rw-r--r--README.txt3
-rw-r--r--includes/preset.inc16
-rw-r--r--includes/video.features.inc50
-rw-r--r--includes/video.preset.inc546
-rw-r--r--modules/video_s3/filesystem/video_s3.inc (renamed from plugins/video_s3/filesystem/video_s3.inc)0
-rw-r--r--modules/video_s3/includes/S3.php (renamed from plugins/video_s3/includes/S3.php)0
-rw-r--r--modules/video_s3/includes/amazon_s3.inc (renamed from plugins/video_s3/includes/amazon_s3.inc)0
-rw-r--r--modules/video_s3/video_s3.info (renamed from plugins/video_s3/video_s3.info)0
-rw-r--r--modules/video_s3/video_s3.install (renamed from plugins/video_s3/video_s3.install)0
-rw-r--r--modules/video_s3/video_s3.module (renamed from plugins/video_s3/video_s3.module)0
-rw-r--r--modules/video_zencoder/includes/LICENSE (renamed from plugins/video_zencoder/includes/LICENSE)0
-rw-r--r--modules/video_zencoder/includes/README.markdown (renamed from plugins/video_zencoder/includes/README.markdown)0
-rw-r--r--modules/video_zencoder/includes/Zencoder.php (renamed from plugins/video_zencoder/includes/Zencoder.php)0
-rw-r--r--modules/video_zencoder/includes/lib/JSON.php (renamed from plugins/video_zencoder/includes/lib/JSON.php)0
-rw-r--r--modules/video_zencoder/includes/zencoder.inc (renamed from plugins/video_zencoder/includes/zencoder.inc)0
-rw-r--r--modules/video_zencoder/transcoders/video_zencoder.inc (renamed from plugins/video_zencoder/transcoders/video_zencoder.inc)0
-rw-r--r--modules/video_zencoder/video_zencoder.info (renamed from plugins/video_zencoder/video_zencoder.info)0
-rw-r--r--modules/video_zencoder/video_zencoder.install (renamed from plugins/video_zencoder/video_zencoder.install)0
-rw-r--r--modules/video_zencoder/video_zencoder.module (renamed from plugins/video_zencoder/video_zencoder.module)0
-rw-r--r--theme/video-play-html5.tpl.php37
-rw-r--r--video.info6
-rw-r--r--video.install108
-rw-r--r--video.module143
24 files changed, 755 insertions, 171 deletions
diff --git a/INSTALL.txt b/INSTALL.txt
index 167a268..c825a48 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
@@ -1,11 +1,6 @@
REQUIREMENTS
-------------------------------------
-Required :
- CCK Module.
- Filefield Module.
-
-
+------------
INSTALL INSTRUCTIONS FOR VIDEO.MODULE
-------------------------------------
@@ -36,8 +31,8 @@ writable by the webserver or the user executling the cron job)
The crontab should look something like this:
- # m h dom mon dow user command
- */20 * * * * www-data cd /absolute/path/to/drupal/ ; php video_scheduler.php http://www.example.com/path_to_drupal
+ # m h dom mon dow command
+ */20 * * * * cd /absolute/path/to/drupal/ ; php video_scheduler.php http://www.example.com/path_to_drupal
This will execute the video_scheduler every 20 minutes.
@@ -57,8 +52,4 @@ have a look at them if you are experiencing problems with transcoding.
The ffmpeg puts in the drupal logs the commands it was trying to execute. You
might try to rerun them on a command shell in order understand what went wrong.
-Or contact a Drupal developer
-
-
-
-
+Or contact a Drupal developer \ No newline at end of file
diff --git a/README.txt b/README.txt
index 06c9e6c..fd062f6 100644
--- a/README.txt
+++ b/README.txt
@@ -1,4 +1,5 @@
-------------
+README
+------
To embed videos into drupal pages, using CCK and filefield support.
This module add the possibility to create video nodes which are containers
diff --git a/includes/preset.inc b/includes/preset.inc
index 195d3b9..e06b9f6 100644
--- a/includes/preset.inc
+++ b/includes/preset.inc
@@ -21,19 +21,27 @@ class video_preset {
* @return array $form
*/
public function admin_settings() {
- $presets = preset_get_presets('video');
+ $form = array();
+ $presets = video_preset_get_presets();
+ if (count($presets) == 0) {
+ return $form['video_preset'] = array(
+ '#markup' => t('No Features were found. Please use the !create_link link to create
+ a new Feature module, or upload an existing Feature to your modules directory.',
+ array('!create_link' => l(t('Create Feature'), 'admin/structure/features/create'))),
+ );
+ }
$preset = array();
foreach ($presets as $id => $value) {
$preset[$id] = $value['name'];
- $help[] = $value['name'] . ' - ' . $value['description'] . ' ' . l(t('edit'), preset_get_preset_path('video', $value['name']));
+// $help[] = $value['name'] . ' - ' . $value['description'] . ' ' . l(t('edit'), preset_get_preset_path('video', $value['name']));
}
- $form = array();
+
$form['video_preset'] = array(
'#type' => 'checkboxes',
'#title' => t('Video transcode presets'),
'#options' => $preset,
'#default_value' => variable_get('video_preset', array()),
- '#description' => t('!list', array('!list' => theme('item_list', array('items' => $help)))),
+// '#description' => t('!list', array('!list' => theme('item_list', array('items' => $help)))),
'#prefix' => '<div id="preset-checkboxes">',
'#suffix' => '</div>',
);
diff --git a/includes/video.features.inc b/includes/video.features.inc
new file mode 100644
index 0000000..10fbc9d
--- /dev/null
+++ b/includes/video.features.inc
@@ -0,0 +1,50 @@
+<?php
+
+// include the preset file
+module_load_include('inc', 'video', 'includes/video.preset');
+
+/**
+ * Implementation of hook_features_export_options().
+ */
+function video_features_export_options() {
+ $options = array();
+ foreach (video_preset_get_presets () as $preset) {
+ $options[$preset['name']] = $preset['name'];
+ }
+ return $options;
+}
+
+/**
+ * Implementation of hook_features_export().
+ */
+function video_features_export($data, &$export, $module_name = '') {
+ foreach ($data as $preset) {
+ $export['features']['video'][$preset] = $preset;
+ }
+}
+
+/**
+ * Implementation of hook_features_export_render().
+ */
+function video_features_export_render($module_name, $data) {
+ $items = array();
+ foreach ($data as $key) {
+ $preset = video_get_preset($key);
+ unset($preset['pid']);
+ $items[$key] = $preset;
+ }
+ $code = " \$items = " . features_var_export($items, ' ') . ";\n";
+ $code .= ' return $items;';
+ return array('video_default_presets' => $code);
+}
+
+/**
+ * Implementation of hook_features_revert().
+ */
+function video_features_revert($module) {
+ if ($default_presets = features_get_default('video', $module)) {
+ foreach (array_keys($default_presets) as $default_preset) {
+ video_preset_delete($default_preset);
+ }
+ }
+}
diff --git a/includes/video.preset.inc b/includes/video.preset.inc
index 4416de5..534e5d3 100644
--- a/includes/video.preset.inc
+++ b/includes/video.preset.inc
@@ -1,19 +1,6 @@
<?php
-/**
- * This is used to set some required settings while the preset is being created.
- *
- * @return <array> - The form elements that you would like to add for the settings.
- *
- * Special Note: It is required to structure all your settings using
- * $form['preset']['settings'] as the parent form element. Otherwise,
- * they will not get serialized within the "settings" column of the database.
- * @TODO : we can add some required values there
- */
-function video_preset_create_form() {
- $form = array();
- return $form;
-}
+define('VIDEO_PRESET_MAX_LENGTH', 64);
/**
* This is used to add all the other settings that you need to declare in your preset.
@@ -23,16 +10,16 @@ function video_preset_create_form() {
* @param <array> - The preset object.
* @return <array> - The additional form settings that you would like to add to your preset.
*/
-function video_preset_form($preset) {
+function video_preset_default_form($form, &$form_state, $preset) {
$form = array();
- $form['preset']['settings']['device_profile'] = array(
+ $form['settings']['device_profile'] = array(
'#type' => 'fieldset',
'#title' => t('Output parameter'),
'#description' => t('All output settings are optional. We choose sensible defaults for web and iPhone playback.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE
);
- $form['preset']['settings']['device_profile']['device_profile'] = array(
+ $form['settings']['device_profile']['device_profile'] = array(
'#type' => 'select',
'#title' => t('Device profile'),
'#description' => t('A profile for your target device.'),
@@ -49,13 +36,13 @@ function video_preset_form($preset) {
'#default_value' => (!empty($preset['settings']['device_profile'])) ? $preset['settings']['device_profile'] : 0
);
// video settings
- $form['preset']['settings']['video'] = array(
+ $form['settings']['video'] = array(
'#type' => 'fieldset',
'#title' => t('Video settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE
);
- $form['preset']['settings']['video']['video_codec'] = array(
+ $form['settings']['video']['video_codec'] = array(
'#type' => 'select',
'#title' => t('Video codec'),
'#description' => t('The video codec used in the video file can affect the ability to play the video on certain devices. The default codec used is H.264.'),
@@ -69,7 +56,7 @@ function video_preset_form($preset) {
),
'#default_value' => (!empty($preset['settings']['video_codec'])) ? $preset['settings']['video_codec'] : 'h264'
);
- $form['preset']['settings']['video']['video_quality'] = array(
+ $form['settings']['video']['video_quality'] = array(
'#type' => 'select',
'#title' => t('Video quality'),
'#description' => t('A target video quality. Affects bitrate and file size.'),
@@ -82,7 +69,7 @@ function video_preset_form($preset) {
),
'#default_value' => (!empty($preset['settings']['video_quality'])) ? $preset['settings']['video_quality'] : 2
);
- $form['preset']['settings']['video']['video_speed'] = array(
+ $form['settings']['video']['video_speed'] = array(
'#type' => 'select',
'#title' => t('Video speed'),
'#description' => t('Speed of encoding. Affects compression.'),
@@ -95,19 +82,19 @@ function video_preset_form($preset) {
),
'#default_value' => (!empty($preset['settings']['video_speed'])) ? $preset['settings']['video_speed'] : 2
);
- $form['preset']['settings']['video']['width'] = array(
+ $form['settings']['video']['width'] = array(
'#type' => 'textfield',
'#title' => t('Width'),
'#description' => t('The maximum width of the output video (in pixels).'),
'#default_value' => !empty($preset['settings']['width']) ? $preset['settings']['width'] : ''
);
- $form['preset']['settings']['video']['height'] = array(
+ $form['settings']['video']['height'] = array(
'#type' => 'textfield',
'#title' => t('Height'),
'#description' => t('The maximum height of the output video (in pixels).'),
'#default_value' => !empty($preset['settings']['height']) ? $preset['settings']['height'] : ''
);
- $form['preset']['settings']['video']['video_aspectmode'] = array(
+ $form['settings']['video']['video_aspectmode'] = array(
'#type' => 'select',
'#title' => t('Aspect mode'),
'#description' => t('What to do when aspect ratio of input file does not match the target width/height aspect ratio.'),
@@ -119,20 +106,20 @@ function video_preset_form($preset) {
),
'#default_value' => (!empty($preset['settings']['video_aspectmode'])) ? $preset['settings']['video_aspectmode'] : 'preserve'
);
- $form['preset']['settings']['video']['video_upscale'] = array(
+ $form['settings']['video']['video_upscale'] = array(
'#type' => 'checkbox',
'#title' => t('Upscale'),
'#description' => t('If the input file is smaller than the target output, should the file be upscaled to the target size?'),
'#default_value' => !empty($preset['settings']['video_upscale']) ? $preset['settings']['video_upscale'] : ''
);
// audio settings
- $form['preset']['settings']['audio'] = array(
+ $form['settings']['audio'] = array(
'#type' => 'fieldset',
'#title' => t('Audio settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE
);
- $form['preset']['settings']['audio']['audio_codec'] = array(
+ $form['settings']['audio']['audio_codec'] = array(
'#type' => 'select',
'#title' => t('Audio codec'),
'#description' => t('The audio codec to be used.'),
@@ -144,7 +131,7 @@ function video_preset_form($preset) {
),
'#default_value' => (!empty($preset['settings']['audio_codec'])) ? $preset['settings']['audio_codec'] : 'h264'
);
- $form['preset']['settings']['audio']['audio_quality'] = array(
+ $form['settings']['audio']['audio_quality'] = array(
'#type' => 'select',
'#title' => t('Audio quality'),
'#description' => t('A target audio quality. Affects bitrate and file size.'),
@@ -158,13 +145,13 @@ function video_preset_form($preset) {
'#default_value' => (!empty($preset['settings']['audio_quality'])) ? $preset['settings']['audio_quality'] : 2
);
// advanced video settings
- $form['preset']['settings']['adv_video'] = array(
+ $form['settings']['adv_video'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced video settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE
);
- $form['preset']['settings']['adv_video']['deinterlace'] = array(
+ $form['settings']['adv_video']['deinterlace'] = array(
'#type' => 'select',
'#title' => t('Deinterlace'),
'#description' => t('Note that detect mode will auto-detect and deinterlace interlaced content.'),
@@ -175,68 +162,68 @@ function video_preset_form($preset) {
),
'#default_value' => (!empty($preset['settings']['deinterlace'])) ? $preset['settings']['deinterlace'] : 'detect'
);
- $form['preset']['settings']['adv_video']['max_frame_rate'] = array(
+ $form['settings']['adv_video']['max_frame_rate'] = array(
'#type' => 'textfield',
'#title' => t('Maximum frame rate'),
'#description' => t('A maximum frame rate cap (in frames per second).'),
'#default_value' => !empty($preset['settings']['max_frame_rate']) ? $preset['settings']['max_frame_rate'] : ''
);
- $form['preset']['settings']['adv_video']['frame_rate'] = array(
+ $form['settings']['adv_video']['frame_rate'] = array(
'#type' => 'textfield',
'#title' => t('Frame rate'),
'#description' => t('Force a specific output frame rate (in frames per second). For best quality, do not use this setting.'),
'#default_value' => !empty($preset['settings']['frame_rate']) ? $preset['settings']['frame_rate'] : ''
);
- $form['preset']['settings']['adv_video']['frame_rate'] = array(
+ $form['settings']['adv_video']['frame_rate'] = array(
'#type' => 'textfield',
'#title' => t('Frame rate'),
'#description' => t('Force a specific output frame rate (in frames per second). For best quality, do not use this setting.'),
'#default_value' => !empty($preset['settings']['frame_rate']) ? $preset['settings']['frame_rate'] : ''
);
- $form['preset']['settings']['adv_video']['video_bitrate'] = array(
+ $form['settings']['adv_video']['video_bitrate'] = array(
'#type' => 'textfield',
'#title' => t('Video bitrate'),
'#description' => t('A target bitrate in kbps. Not necessary if you select a Video Quality setting, unless you want to target a specific bitrate.'),
'#default_value' => !empty($preset['settings']['video_bitrate']) ? $preset['settings']['video_bitrate'] : ''
);
- $form['preset']['settings']['adv_video']['bitrate_cap'] = array(
+ $form['settings']['adv_video']['bitrate_cap'] = array(
'#type' => 'textfield',
'#title' => t('Bitrate cap'),
'#description' => t('A bitrate cap in kbps, used for streaming servers.'),
'#default_value' => !empty($preset['settings']['bitrate_cap']) ? $preset['settings']['bitrate_cap'] : ''
);
- $form['preset']['settings']['adv_video']['buffer_size'] = array(
+ $form['settings']['adv_video']['buffer_size'] = array(
'#type' => 'textfield',
'#title' => t('Buffer size'),
'#description' => t('The buffer size for the bitrate cap in kbps.'),
'#default_value' => !empty($preset['settings']['buffer_size']) ? $preset['settings']['buffer_size'] : ''
);
- $form['preset']['settings']['adv_video']['one_pass'] = array(
+ $form['settings']['adv_video']['one_pass'] = array(
'#type' => 'checkbox',
'#title' => t('One pass'),
'#description' => t('Force one-pass encoding when targeting a specific video_bitrate. True or False.'),
'#default_value' => !empty($preset['settings']['one_pass']) ? $preset['settings']['one_pass'] : ''
);
- $form['preset']['settings']['adv_video']['skip_video'] = array(
+ $form['settings']['adv_video']['skip_video'] = array(
'#type' => 'checkbox',
'#title' => t('Skip video'),
'#description' => t('The video track will be omitted from the output. You can still specify a video format, however, no video track will be present in the resulting file.'),
'#default_value' => !empty($preset['settings']['skip_video']) ? $preset['settings']['skip_video'] : ''
);
// advanced audio settings
- $form['preset']['settings']['adv_audio'] = array(
+ $form['settings']['adv_audio'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced audio settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE
);
- $form['preset']['settings']['adv_audio']['audio_bitrate'] = array(
+ $form['settings']['adv_audio']['audio_bitrate'] = array(
'#type' => 'textfield',
'#title' => t('Audio bitrate'),
'#description' => t('The overall audio bitrate specified as kilobits per second (kbps, e.g. 96 or 160). This value can\'t exceed 160 kbps per channel. 96-160 is usually a good range for stereo output.'),
'#default_value' => !empty($preset['settings']['audio_bitrate']) ? $preset['settings']['audio_bitrate'] : ''
);
- $form['preset']['settings']['adv_audio']['audio_channels'] = array(
+ $form['settings']['adv_audio']['audio_channels'] = array(
'#type' => 'select',
'#title' => t('Audio channels'),
'#description' => t('By default we will choose the lesser of the number of audio channels in the input file or 2 (stereo).'),
@@ -246,38 +233,38 @@ function video_preset_form($preset) {
),
'#default_value' => (!empty($preset['settings']['audio_channels'])) ? $preset['settings']['audio_channels'] : 2
);
- $form['preset']['settings']['adv_audio']['audio_sample_rate'] = array(
+ $form['settings']['adv_audio']['audio_sample_rate'] = array(
'#type' => 'textfield',
'#title' => t('Audio sample rate'),
'#description' => t('The sample rate of the audio in hertz. Manually setting this may cause problems, depending on the selected bitrate and number of channels.'),
'#default_value' => !empty($preset['settings']['audio_sample_rate']) ? $preset['settings']['audio_sample_rate'] : ''
);
- $form['preset']['settings']['adv_audio']['skip_audio'] = array(
+ $form['settings']['adv_audio']['skip_audio'] = array(
'#type' => 'checkbox',
'#title' => t('Skip audio'),
'#description' => t('The audio track will be omitted from the output. You must specify a video format and no audio track will be present in the resulting file.'),
'#default_value' => !empty($preset['settings']['skip_audio']) ? $preset['settings']['skip_audio'] : ''
);
// video optimizations
- $form['preset']['settings']['vid_optimization'] = array(
+ $form['settings']['vid_optimization'] = array(
'#type' => 'fieldset',
'#title' => t('Video Optimization'),
'#collapsible' => TRUE,
'#collapsed' => TRUE
);
- $form['preset']['settings']['vid_optimization']['autolevels'] = array(
+ $form['settings']['vid_optimization']['autolevels'] = array(
'#type' => 'checkbox',
'#title' => t('Autolevels'),
'#description' => t('Automatic brightness / contrast correction.'),
'#default_value' => !empty($preset['settings']['autolevels']) ? $preset['settings']['autolevels'] : ''
);
- $form['preset']['settings']['vid_optimization']['deblock'] = array(
+ $form['settings']['vid_optimization']['deblock'] = array(
'#type' => 'checkbox',
'#title' => t('Deblock'),
'#description' => t('Apply deblocking filter. Useful for highly compressed or blocky input videos.'),
'#default_value' => !empty($preset['settings']['deblock']) ? $preset['settings']['deblock'] : ''
);
- $form['preset']['settings']['vid_optimization']['denoise'] = array(
+ $form['settings']['vid_optimization']['denoise'] = array(
'#type' => 'select',
'#title' => t('Denoise'),
'#description' => t('Apply denoise filter. Generally results in slightly better compression, and slightly slower encoding. Beware of any value higher than "Weak" (unless you\'re encoding animation).'),
@@ -291,13 +278,13 @@ function video_preset_form($preset) {
'#default_value' => (!empty($preset['settings']['denoise'])) ? $preset['settings']['denoise'] : 2
);
// Segmented Streaming
- $form['preset']['settings']['segmented_streaming'] = array(
+ $form['settings']['segmented_streaming'] = array(
'#type' => 'fieldset',
'#title' => t('Segmented Streaming'),
'#collapsible' => TRUE,
'#collapsed' => TRUE
);
- $form['preset']['settings']['segmented_streaming']['segmented_type'] = array(
+ $form['settings']['segmented_streaming']['segmented_type'] = array(
'#type' => 'select',
'#title' => t('Type'),
'#description' => t('Set to segmented for HTTP Live Streaming.'),
@@ -307,33 +294,33 @@ function video_preset_form($preset) {
),
'#default_value' => (!empty($preset['settings']['segmented_type'])) ? $preset['settings']['segmented_type'] : 0
);
- $form['preset']['settings']['segmented_streaming']['segmented_seconds'] = array(
+ $form['settings']['segmented_streaming']['segmented_seconds'] = array(
'#type' => 'textfield',
'#title' => t('Segment Seconds'),
'#description' => t('The maximum duration of each segment in segmented outputs.'),
'#default_value' => !empty($preset['settings']['segmented_seconds']) ? $preset['settings']['segmented_seconds'] : ''
);
// Create clip
- $form['preset']['settings']['create_clip'] = array(
+ $form['settings']['create_clip'] = array(
'#type' => 'fieldset',
'#title' => t('Create Clip'),
'#collapsible' => TRUE,
'#collapsed' => TRUE
);
- $form['preset']['settings']['create_clip']['clip_start'] = array(
+ $form['settings']['create_clip']['clip_start'] = array(
'#type' => 'textfield',
'#title' => t('Start clip'),
'#description' => t('The starting point of a subclip (in timecode or number of seconds).'),
'#default_value' => !empty($preset['settings']['clip_start']) ? $preset['settings']['clip_start'] : ''
);
- $form['preset']['settings']['create_clip']['clip_length'] = array(
+ $form['settings']['create_clip']['clip_length'] = array(
'#type' => 'textfield',
'#title' => t('Clip length '),
'#description' => t('The length of the subclip (in timecode or number of seconds).'),
'#default_value' => !empty($preset['settings']['clip_length']) ? $preset['settings']['clip_length'] : ''
);
// Command line parameters
- $form['preset']['settings']['command_line'] = array(
+ $form['settings']['command_line'] = array(
'#type' => 'fieldset',
'#title' => t('Command line options'),
'#collapsible' => TRUE,
@@ -346,11 +333,458 @@ function video_preset_form($preset) {
'!width - Width of output video',
'!height - Height of output video'
);
- $form['preset']['settings']['command_line']['cli_code'] = array(
+ $form['settings']['command_line']['cli_code'] = array(
'#type' => 'textarea',
'#title' => t('Command line codes to run'),
'#description' => t('Please add command line codes each to run separated by a new line.') . theme('item_list', array('items' => $tokes, 'title' => 'Available Tokes')),
'#default_value' => !empty($preset['settings']['cli_code']) ? $preset['settings']['cli_code'] : '!cmd_path -i !videofile -s !widthx!height -r 15 -b 250 -ar 22050 -ab 48 !convertfile'
);
return $form;
-} \ No newline at end of file
+}
+
+/**
+ * Menu callback: video Module administration.
+ */
+function video_presets_overview() {
+ $presets = video_preset_get_presets();
+
+ if (count($presets) > 0) {
+ $header = array(t('Preset Name'), t('Description'), array('data' => t('Operations'), 'colspan' => '3'));
+ $rows = array();
+ foreach ($presets as $pid => $preset) {
+ $row = array();
+ $row[] = check_plain($preset['name']);
+ $row[] = array('data' => filter_xss_admin($preset['description']), 'class' => 'description');
+ $row[] = array('data' => l(t('edit'), 'admin/structure/video/preset/' . $preset['name']));
+
+ if (!isset($preset['default'])) {
+ $row[] = array('data' => l(t('delete'), 'admin/structure/video/preset/' . $preset['name'] . '/delete'));
+ }
+
+ $row[] = array('data' => l(t('export'), 'admin/structure/video/preset/' . $preset['name'] . '/export'));
+ $rows[] = $row;
+ }
+ return theme('table', array('header' => $header, 'rows' => $rows));
+ } else {
+ return t('No Preset were found. Please use the !create_link link to create
+ a new video preset, or upload an existing Feature to your modules directory.',
+ array('!create_link' => l(t('Create Video Preset'), 'admin/structure/video/add')));
+ }
+}
+
+/**
+ * Preset form
+ * @param <type> $form
+ * @param <type> $form_state
+ * @param <type> $preset
+ * @return string
+ */
+function video_preset_form($form, &$form_state, $preset = false) {
+ $form = array();
+ // basic preset details
+ $form['preset'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Preset information'),
+ '#weight' => -10,
+ );
+ if (isset($preset['pid'])) {
+ $form['preset']['pid'] = array(
+ '#type' => 'value',
+ '#value' => $preset['pid'],
+ );
+ } elseif (video_is_default_preset($preset['name'])) {
+ $form['preset']['default'] = array(
+ '#type' => 'value',
+ '#value' => TRUE,
+ );
+ }
+ $form['preset']['name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Preset name'),
+ '#maxlength' => VIDEO_PRESET_MAX_LENGTH,
+ '#description' => t('Spaces are NOT allowed; punctuation is not allowed except for periods, hyphens, apostrophes, and underscores.'),
+ '#required' => TRUE,
+ '#weight' => -10,
+ '#element_validate' => array('_video_preset_name_validate'),
+ '#default_value' => !empty($preset['name']) ? $preset['name'] : ''
+ );
+
+ $form['preset']['description'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Description'),
+ '#description' => t('Add a brief description to your preset name.'),
+ '#weight' => -9,
+ '#default_value' => !empty($preset['description']) ? $preset['description'] : ''
+ );
+
+ // Preset settings
+ $form += video_preset_default_form($form, $form_state, $preset);
+
+ // Buttons
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Save Preset'),
+ '#weight' => 30,
+ );
+
+ $form['delete'] = array(
+ '#type' => 'submit',
+ '#value' => t('Delete'),
+ '#weight' => 40,
+ '#submit' => array('video_preset_delete_submit'),
+ );
+
+ // Add the form submit handler.
+ $form['#submit'][] = 'video_preset_submit';
+ $form['#validate'][] = 'video_preset_validate';
+ return $form;
+}
+
+/**
+ * Validation for the preset form.
+ */
+function video_preset_validate($form, &$form_state) {
+
+}
+
+/**
+ * Flatten the settings array.
+ *
+ * @param <type> $array
+ * @param <type> $return
+ * @return <type>
+ */
+function video_preset_array_flatten($array, $return=array()) {
+ foreach ($array as $key => $value) {
+ if (is_array($value)) {
+ $return = video_preset_array_flatten($value, $return);
+ } else {
+ $return[$key] = $value;
+ }
+ }
+ return $return;
+}
+
+/**
+ * Submit handler for the preset form.
+ */
+function video_preset_submit($form, &$form_state) {
+ $preset = array();
+ if (isset($form_state['values']['pid'])) {
+ $preset['pid'] = $form_state['values']['pid'];
+ }
+ $preset['name'] = $form_state['values']['name'];
+ $preset['description'] = $form_state['values']['description'];
+ // unset unwanted values saved to database
+ unset($form_state['values']['pid'], $form_state['values']['name'],
+ $form_state['values']['description'], $form_state['values']['submit'],
+ $form_state['values']['delete'], $form_state['values']['form_build_id'],
+ $form_state['values']['form_token'], $form_state['values']['form_id'],
+ $form_state['values']['op']);
+ $preset['settings'] = video_preset_array_flatten($form_state['values']);
+
+ // Save this preset.
+ video_preset_save($preset);
+ drupal_set_message(t('Preset !preset successfully saved.', array('!preset' => $preset['name'])));
+ $form_state['redirect'] = 'admin/structure/video';
+}
+
+/**
+ * Button sumit function: handle the 'Delete' button on the preset form.
+ */
+function video_preset_delete_submit($form, &$form_state) {
+ $preset['name'] = $form_state['values']['name'];
+ $form_state['redirect'] = 'admin/structure/video/preset/' . $preset['name'] . '/delete';
+}
+
+/**
+ * Menu callback; delete a single preset.
+ */
+function video_preset_delete_confirm($form, &$form_state, $preset) {
+ $form['name'] = array('#type' => 'value', '#value' => $preset['name']);
+ $message = t('Are you sure you want to delete the preset %name?', array('%name' => $preset['name']));
+ $caption = '<p>' . t('This action cannot be undone.') . '</p>';
+ return confirm_form($form, $message, 'admin/structure/video', $caption, t('Delete'));
+}
+
+/**
+ * Execute preset deletion
+ */
+function video_preset_delete_confirm_submit($form, &$form_state) {
+ if ($form_state['values']['confirm']) {
+ video_preset_delete($form_state['values']['name']);
+ }
+
+ $form_state['redirect'] = 'admin/structure/video';
+}
+
+/**
+ * Validation for the preset form.
+ */
+function _video_preset_name_validate($element, &$form_state) {
+ $error = video_validate_preset_name($form_state['values']['name']);
+ if ($error && !isset($form_state['values']['pid']) && !isset ($form_state['values']['default'])) {
+ form_set_error('name', $error);
+ }
+}
+
+/**
+ * Import's a preset.
+ */
+function video_preset_import_form($form, &$form_state) {
+ $form['preset'] = array(
+ '#title' => t('Preset Code'),
+ '#type' => 'textarea',
+ '#rows' => 10,
+ '#description' => t('Copy the export text and paste it into this text field to import a new preset.'),
+ );
+
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Import Preset'),
+ '#weight' => 30,
+ );
+
+ $form['#submit'][] = 'video_preset_import_submit';
+ $form['#validate'][] = 'video_preset_import_validate';
+
+ return $form;
+}
+
+/**
+ * Validation for the preset import form.
+ */
+function video_preset_import_validate($form, &$form_state) {
+ $preset = '';
+
+ // Get the preset that they declared in the text field.
+ ob_start();
+ eval($form_state['values']['preset']);
+ ob_end_clean();
+
+ if (is_array($preset)) {
+ $name = isset($preset['name']) ? $preset['name'] : '';
+ if ($error = video_validate_preset_name($name)) {
+ form_set_error('name', $error);
+ }
+ } else {
+ form_set_error('name', 'Invalid preset import.');
+ }
+
+ $form_state['preset'] = &$preset;
+}
+
+/**
+ * Submit handler for the preset import form.
+ */
+function video_preset_import_submit($form, &$form_state) {
+ $preset = $form_state['preset'];
+ video_preset_save($preset);
+ $form_state['redirect'] = 'admin/structure/video/preset/' . $preset['name'];
+}
+
+/**
+ * The preset export form.
+ */
+function video_preset_export_form($form, &$form_state, $preset) {
+ // Unset the unnecessary elements.
+ unset($preset['pid']);
+ unset($preset['default']);
+
+ // Get the code string representation.
+ $code = var_export($preset, true);
+
+ // Make sure to format the arrays like drupal.
+ $code = str_replace("=> \n ", '=> ', $code);
+
+ // Add the preset variable.
+ $code = '$preset = ' . $code . ';';
+
+ $lines = substr_count($code, "\n");
+ $form['export'] = array(
+ '#title' => t('Export Preset'),
+ '#type' => 'textarea',
+ '#value' => $code,
+ '#rows' => $lines,
+ '#description' => t('Copy the export text and paste it into another preset using the import function.'),
+ );
+
+ // Return the form.
+ return $form;
+}
+
+/**
+ * Get's the player settings for the given player.
+ */
+function video_player_settings_form($preset) {
+ $settings_form = $preset['player'] . '_player_settings_form';
+ if (function_exists($settings_form)) {
+ return $settings_form($preset);
+ }
+ return array();
+}
+
+/**
+ * Title callback for a preset.
+ */
+function video_preset_page_title($preset) {
+ return $preset['name'];
+}
+
+/**
+ * Saves a new preset.
+ */
+function video_preset_save($preset) {
+ // If they provide the pid, then this needs to be an update.
+ $pid = (isset($preset['pid']) && $preset['pid']) ? array('pid') : array();
+
+ // Save or update a preset.
+ drupal_write_record('video_preset', $preset, $pid);
+}
+
+/**
+ * Returns the default presets.
+ *
+ * @return <type>
+ */
+function video_preset_get_default_presets() {
+ $default_presets = module_invoke_all('video_default_presets');
+ drupal_alter('video_default_presets', $default_presets);
+ return $default_presets;
+}
+
+/**
+ * Gets a list of all presets.
+ */
+function video_preset_get_presets() {
+ $presets = array();
+ $normal_presets = array();
+
+ // Get all the presets from the database.
+ $result = db_select('video_preset', 'p')
+ ->fields('p')
+ ->orderBy('p.name', 'ASC')
+ ->execute();
+
+ // Iterate through all the presets and structure them in an array.
+ foreach ($result as $preset) {
+ $preset = (array) $preset;
+ $preset['settings'] = $preset['settings'] ? unserialize($preset['settings']) : array();
+ $presets[$preset['pid']] = $preset;
+ $normal_presets[$preset['name']] = $preset['pid'];
+ }
+
+ // Now allow other modules to add their default presets.
+ foreach (video_preset_get_default_presets () as $preset) {
+ // adding default TRUE
+ $preset['default'] = TRUE;
+ if (!empty($preset['name']) && !isset($normal_presets[$preset['name']])) {
+ $presets[$preset['name']] = $preset;
+ }
+ }
+
+ return $presets;
+}
+
+/**
+ * Get's the preset.
+ */
+function video_get_preset($preset_name) {
+ // Get the preset from the database.
+ $preset = db_select('video_preset', 'p')
+ ->fields('p')
+ ->condition('p.name', $preset_name)
+ ->execute()
+ ->fetchAssoc();
+ if ($preset) {
+ $preset['settings'] = $preset['settings'] ? unserialize($preset['settings']) : array();
+ } else {
+ // Get all of the default presets.
+ $default_presets = video_preset_get_default_presets();
+
+ // Check to see if this preset exists.
+ if (isset($default_presets[$preset_name])) {
+ // Make this our preset
+ $preset = $default_presets[$preset_name];
+ }
+ }
+
+ // Return the preset.
+ return $preset;
+}
+
+/**
+ * Deletes a preset
+ */
+function video_preset_delete($preset_name) {
+ // Delete the preset.
+ db_delete('video_preset')
+ ->condition('name', $preset_name)
+ ->execute();
+
+ // Rebuild Theme Registry
+ drupal_theme_rebuild();
+}
+
+/**
+ * Checks to see if another preset is already taken.
+ */
+function video_preset_name_exists($preset_name) {
+
+ // Get the default presets.
+ $default_presets = video_preset_get_default_presets();
+
+ // See if there is a default preset name.
+ if ($default_presets && isset($default_presets[$preset_name])) {
+ return true;
+ } else {
+ return (bool) db_select('video_preset', 'p')
+ ->fields('p')
+ ->condition('p.name', $preset_name)
+ ->range(0, 1)
+ ->execute()
+ ->fetchField();
+ }
+}
+
+/**
+ * Verify the syntax of the given prefix name.
+ *
+ * Borrowed from the user.module. :)
+ */
+function video_validate_preset_name($name) {
+ if (!$name) {
+ return t('You must enter a preset.');
+ }
+ if (video_preset_name_exists($name)) {
+ return t('The preset name %name is already taken.', array('%name' => $name));
+ }
+ if (strpos($name, ' ') !== FALSE) {
+ return t('The preset name cannot contain a space.');
+ }
+ if (is_numeric($name[0])) {
+ return t('The preset name cannot begin with a number.');
+ }
+ if (preg_match('/[^a-z0-9_]/i', $name)) {
+ return t('The preset name contains an illegal character.');
+ }
+ if (drupal_strlen($name) > VIDEO_PRESET_MAX_LENGTH) {
+ return t('The preset name %name is too long: it must be %max characters or less.', array('%name' => $name, '%max' => VIDEO_PRESET_MAX_LENGTH));
+ }
+}
+
+/**
+ * Check for default preset
+ * @param <type> $preset_name
+ * @return <type>
+ */
+function video_is_default_preset($preset_name) {
+ // Get the default presets.
+ $default_presets = video_preset_get_default_presets();
+
+ // See if there is a default preset name.
+ if ($default_presets && isset($default_presets[$preset_name]))
+ return TRUE;
+ else
+ return FALSE;
+}
diff --git a/plugins/video_s3/filesystem/video_s3.inc b/modules/video_s3/filesystem/video_s3.inc
index 1d54fb8..1d54fb8 100644
--- a/plugins/video_s3/filesystem/video_s3.inc
+++ b/modules/video_s3/filesystem/video_s3.inc
diff --git a/plugins/video_s3/includes/S3.php b/modules/video_s3/includes/S3.php
index e1fcb66..e1fcb66 100644
--- a/plugins/video_s3/includes/S3.php
+++ b/modules/video_s3/includes/S3.php
diff --git a/plugins/video_s3/includes/amazon_s3.inc b/modules/video_s3/includes/amazon_s3.inc
index db25032..db25032 100644
--- a/plugins/video_s3/includes/amazon_s3.inc
+++ b/modules/video_s3/includes/amazon_s3.inc
diff --git a/plugins/video_s3/video_s3.info b/modules/video_s3/video_s3.info
index 61a2c71..61a2c71 100644
--- a/plugins/video_s3/video_s3.info
+++ b/modules/video_s3/video_s3.info
diff --git a/plugins/video_s3/video_s3.install b/modules/video_s3/video_s3.install
index 7719070..7719070 100644
--- a/plugins/video_s3/video_s3.install
+++ b/modules/video_s3/video_s3.install
diff --git a/plugins/video_s3/video_s3.module b/modules/video_s3/video_s3.module
index 5762fef..5762fef 100644
--- a/plugins/video_s3/video_s3.module
+++ b/modules/video_s3/video_s3.module
diff --git a/plugins/video_zencoder/includes/LICENSE b/modules/video_zencoder/includes/LICENSE
index d1f0a51..d1f0a51 100644
--- a/plugins/video_zencoder/includes/LICENSE
+++ b/modules/video_zencoder/includes/LICENSE
diff --git a/plugins/video_zencoder/includes/README.markdown b/modules/video_zencoder/includes/README.markdown
index 0be2256..0be2256 100644
--- a/plugins/video_zencoder/includes/README.markdown
+++ b/modules/video_zencoder/includes/README.markdown
diff --git a/plugins/video_zencoder/includes/Zencoder.php b/modules/video_zencoder/includes/Zencoder.php
index 4ff0db7..4ff0db7 100644
--- a/plugins/video_zencoder/includes/Zencoder.php
+++ b/modules/video_zencoder/includes/Zencoder.php
diff --git a/plugins/video_zencoder/includes/lib/JSON.php b/modules/video_zencoder/includes/lib/JSON.php
index f36a203..f36a203 100644
--- a/plugins/video_zencoder/includes/lib/JSON.php
+++ b/modules/video_zencoder/includes/lib/JSON.php
diff --git a/plugins/video_zencoder/includes/zencoder.inc b/modules/video_zencoder/includes/zencoder.inc
index c3023b0..c3023b0 100644
--- a/plugins/video_zencoder/includes/zencoder.inc
+++ b/modules/video_zencoder/includes/zencoder.inc
diff --git a/plugins/video_zencoder/transcoders/video_zencoder.inc b/modules/video_zencoder/transcoders/video_zencoder.inc
index 1eb246a..1eb246a 100644
--- a/plugins/video_zencoder/transcoders/video_zencoder.inc
+++ b/modules/video_zencoder/transcoders/video_zencoder.inc
diff --git a/plugins/video_zencoder/video_zencoder.info b/modules/video_zencoder/video_zencoder.info
index d7d221a..d7d221a 100644
--- a/plugins/video_zencoder/video_zencoder.info
+++ b/modules/video_zencoder/video_zencoder.info
diff --git a/plugins/video_zencoder/video_zencoder.install b/modules/video_zencoder/video_zencoder.install
index 513ebe1..513ebe1 100644
--- a/plugins/video_zencoder/video_zencoder.install
+++ b/modules/video_zencoder/video_zencoder.install
diff --git a/plugins/video_zencoder/video_zencoder.module b/modules/video_zencoder/video_zencoder.module
index 7f2218e..7f2218e 100644
--- a/plugins/video_zencoder/video_zencoder.module
+++ b/modules/video_zencoder/video_zencoder.module
diff --git a/theme/video-play-html5.tpl.php b/theme/video-play-html5.tpl.php
index 7153908..038fa20 100644
--- a/theme/video-play-html5.tpl.php
+++ b/theme/video-play-html5.tpl.php
@@ -11,21 +11,22 @@
*
*/
?>
- <!-- Using the Video for Everybody Embed Code http://camendesign.com/code/video_for_everybody -->
- <video width="<?php echo $video->player_width; ?>" autobuffer="<?php print $video->autobuffering; ?>" height="<?php echo $video->player_height; ?>" controls="controls" preload="auto" poster="<?php echo $video->thumbnail->url; ?>">
- <?php //dd($items); ?>
- <?php static $videojs_sources; ?>
- <?php $codecs = array('video/mp4' => 'avc1.42E01E, mp4a.40.2', 'video/webm' => 'vp8, vorbis', 'video/ogg' => 'theora, vorbis', 'video/ogv' => 'theora, vorbis', 'video/quicktime' => 'avc1.42E01E, mp4a.40.2'); ?>
- <?php foreach ($video->files as $filetype => $file): ?>
- <?php $filepath = $file->url; ?>
- <?php $mimetype = file_get_mimetype($file->filename); ?>
- <?php if (array_key_exists($mimetype, $codecs)): ?>
- <?php $mimetype = ($mimetype == 'video/quicktime') ? 'video/mp4' : $mimetype; ?>
- <?php if($mimetype == 'video/mp4' || $mimetype == 'video/flv') $flash = $filepath;?>
- <?php $videojs_sources .= "<source src=\"$filepath\" type='$mimetype; codecs=\"" . $codecs[$mimetype] . "\"' />"; ?>
- <?php endif; ?>
- <?php endforeach; ?>
- <?php print $videojs_sources; ?>
- <!-- Flash Fallback. Use any flash video player here. Make sure to keep the vjs-flash-fallback class. -->
- <?php echo theme('video_flv', $video, $node); ?>
- </video> \ No newline at end of file
+<!-- Using the Video for Everybody Embed Code http://camendesign.com/code/video_for_everybody -->
+<video width="<?php echo $video->player_width; ?>" autobuffer="<?php print $video->autobuffering; ?>" height="<?php echo $video->player_height; ?>" controls="controls" preload="auto" poster="<?php echo $video->thumbnail->url; ?>">
+ <?php //dd($items); ?>
+ <?php static $videojs_sources; ?>
+ <?php $codecs = array('video/mp4' => 'avc1.42E01E, mp4a.40.2', 'video/webm' => 'vp8, vorbis', 'video/ogg' => 'theora, vorbis', 'video/ogv' => 'theora, vorbis', 'video/quicktime' => 'avc1.42E01E, mp4a.40.2'); ?>
+ <?php foreach ($video->files as $filetype => $file): ?>
+ <?php $filepath = $file->url; ?>
+ <?php $mimetype = file_get_mimetype($file->filename); ?>
+ <?php if (array_key_exists($mimetype, $codecs)): ?>
+ <?php $mimetype = ($mimetype == 'video/quicktime') ? 'video/mp4' : $mimetype; ?>
+ <?php if ($mimetype == 'video/mp4' || $mimetype == 'video/flv')
+ $flash = $filepath; ?>
+ <?php $videojs_sources .= "<source src=\"$filepath\" type='$mimetype; codecs=\"" . $codecs[$mimetype] . "\"' />"; ?>
+ <?php endif; ?>
+ <?php endforeach; ?>
+<?php print $videojs_sources; ?>
+ <!-- Flash Fallback. Use any flash video player here. Make sure to keep the vjs-flash-fallback class. -->
+<?php echo theme('video_flv', $video, $node); ?>
+</video> \ No newline at end of file
diff --git a/video.info b/video.info
index c75004b..8e3dc9b 100644
--- a/video.info
+++ b/video.info
@@ -1,14 +1,14 @@
-
name = Video
description = Implementation of a video field
package = Video
core = 7.x
+configure = admin/config/media/video
dependencies[] = file
-dependencies[] = preset
files[] = video.module
files[] = video.admin.inc
files[] = video.drush.inc
files[] = video.theme.inc
files[] = video_formatter.inc
files[] = video_schedular.inc
-files[] = video.field.inc \ No newline at end of file
+files[] = video.field.inc
+files[] = includes/video.preset.inc \ No newline at end of file
diff --git a/video.install b/video.install
index 956f6ef..3250513 100644
--- a/video.install
+++ b/video.install
@@ -2,61 +2,60 @@
/**
* @file
- * Provides installation functions for video.module.
- *
- * @author Heshan Wanigasooriya <heshan at heidisoft dot com>
+ * Provides installation schema for video.module
+ * @author Heshan Wanigasooriya <heshan@heidisoft.com>
*
- * @todo
*/
/**
* Implementation of hook_schema().
*/
function video_schema() {
+ // video files
$schema['video_files'] = array(
- 'description' => 'Store video transcoding queue',
+ 'description' => 'Store video transcoding queue.',
'fields' => array(
'vid' => array(
- 'description' => t('Video id'),
+ 'description' => t('Video id, the primary identifier'),
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'fid' => array(
- 'description' => 'Original file id',
+ 'description' => 'The {file_managed}.fid being referenced in this field.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'nid' => array(
- 'description' => 'Node id',
+ 'description' => 'The {node}.nid being referenced in this field.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'status' => array(
- 'description' => 'Status of the transcoding',
+ 'description' => 'Status of the transcoding, possible values are 1, 5, 10, 20',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'dimensions' => array(
+ 'description' => 'The dimensions of the output video.',
'type' => 'varchar',
'length' => '255',
'default' => '',
- 'description' => 'The dimensions of the video.',
),
'started' => array(
- 'description' => t('Started transcodings'),
+ 'description' => t('Start timestamp of transcodings'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'completed' => array(
- 'description' => 'Transcoding completed',
+ 'description' => 'Transcoding completed timestamp',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
@@ -65,7 +64,8 @@ function video_schema() {
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
- 'description' => 'A serialized array of converted files. Use of this field is discouraged and it will likely disappear in a future version of Drupal.',
+ 'description' => 'A serialized array of converted files.
+ Use of this field is discouraged and it will likely disappear in a future version of Drupal.',
),
),
'indexes' => array(
@@ -74,38 +74,46 @@ function video_schema() {
),
'primary key' => array('vid'),
);
+ // video preset
+ $schema['video_preset'] = array(
+ 'description' => 'The preset table.',
+ 'fields' => array(
+ 'pid' => array(
+ 'description' => 'The primary identifier for a video preset.',
+ 'type' => 'serial',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ ),
+ 'name' => array(
+ 'description' => 'The name of this preset.',
+ 'type' => 'varchar',
+ 'length' => 64,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'description' => array(
+ 'description' => 'A brief description of this preset.',
+ 'type' => 'text',
+ 'size' => 'medium',
+ 'translatable' => TRUE,
+ ),
+ 'settings' => array(
+ 'type' => 'text',
+ 'size' => 'medium',
+ 'serialize' => TRUE,
+ 'description' => 'Serialized player settings that do not warrant a dedicated column.
+ Use of this field is discouraged and it will likely disappear in a future version of Drupal.',
+ ),
+ ),
+ 'unique keys' => array(
+ 'name' => array('name'),
+ ),
+ 'primary key' => array('pid'),
+ );
return $schema;
}
/**
- * Implementation of hook_install().
- */
-function video_install() {
- // Create the videos directory and ensure it's writable.
- $directory = file_default_scheme() . '://videos';
- file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
-}
-
-/**
- * Implementation of hook_uninstall().
- */
-function video_uninstall() {
- drupal_uninstall_schema('video');
-// Delete all variables which begin with the namespaced "video_*".
-// $video_vars = array();
-// $query = "SELECT name FROM {variable} WHERE name LIKE '%video_%'";
-// $video_vars = db_query($query);
-// while ($result = db_fetch_array($video_vars)) {
-// if (strpos($result['name'], 'video') === 0) {
-// variable_del($result['name']);
-// }
-// }
-//
- // Remove the video directory and generated images.
- file_unmanaged_delete_recursive(file_default_scheme() . '://videos');
-}
-
-/**
* Implements hook_field_schema().
*/
function video_field_schema($field) {
@@ -146,4 +154,22 @@ function video_field_schema($field) {
),
),
);
+}
+
+/**
+ * Implementation of hook_install().
+ */
+function video_install() {
+ // Create the videos directory and ensure it's writable.
+ $directory = file_default_scheme() . '://videos';
+ file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
+}
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function video_uninstall() {
+ drupal_uninstall_schema('video');
+ // Remove the video directory and generated images.
+ file_unmanaged_delete_recursive(file_default_scheme() . '://videos');
} \ No newline at end of file
diff --git a/video.module b/video.module
index ceeb29e..e68c66d 100644
--- a/video.module
+++ b/video.module
@@ -7,6 +7,7 @@
*/
// include the field element
module_load_include('inc', 'video', 'video.field');
+module_load_include('inc', 'video', 'includes/video.features');
/*
* Implementation of hook_init().
@@ -18,32 +19,31 @@ function video_init() {
}
/**
- * Invokes hook_video_*action*() in every module.
- * Eg :
- * hook_video_submit()
- * hook_video_insert()
- * hook_video_preview()
- * hook_video_delete()
- * hook_video_load()
- * hook_video_form() - to show values once upload is completed eg. Resolution, and Convert on Save etc
- *
- * We cannot use module_invoke() for this, because the arguments need to
- * be passed by reference.
+ * Implementation of hook_permission().
*/
-function video_module_invoke($action, &$array, &$video = NULL, $other = NULL) {
- foreach (module_list () as $module) {
- $function = $module . '_video_' . $action;
- if (function_exists($function)) {
- $function($array, $video, $other);
- }
- }
-}
-
-/**
- * Implementation of hook_perm().
- */
-function video_perm() {
- return array('bypass conversion video', 'convert on submission', 'override player dimensions', 'use default thumb');
+function video_permission() {
+ $perms = array(
+ 'bypass conversion video' => array(
+ 'title' => t('Bypass video conversion'),
+ 'description' => t('Warning: Give to trusted roles only; this permission has security implications.'),
+ ),
+ 'convert on submission' => array(
+ 'title' => t('Convert video on submit'),
+ 'description' => t('Warning: Give to trusted roles only; this permission has security implications.'),
+ ),
+ 'override player dimensions' => array(
+ 'title' => t('Change default player dimentions'),
+ 'description' => t('Warning: Give to trusted roles only; this permission has usability implications.'),
+ ),
+ 'use default thumb' => array(
+ 'title' => t('Use default thumbnail'),
+ ),
+ 'administer video presets' => array(
+ 'title' => t('Administer video presets'),
+ 'description' => t('Perform administration tasks for the video presets.'),
+ ),
+ );
+ return $perms;
}
/**
@@ -51,6 +51,7 @@ function video_perm() {
*/
function video_menu() {
$items = array();
+ // General settings
$items['admin/config/media/video'] = array(
'title' => 'Video',
'description' => 'Configure different aspects of the video module and its plugins',
@@ -65,6 +66,7 @@ function video_menu() {
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 0,
);
+ // Player settings
$items['admin/config/media/video/players'] = array(
'title' => 'Players',
'description' => 'Configure your player settings for each video extension.',
@@ -75,6 +77,7 @@ function video_menu() {
'type' => MENU_LOCAL_TASK,
'weight' => 1,
);
+ // Transcoder settings
$items['admin/config/media/video/transcoders'] = array(
'title' => 'Transcoders',
'description' => 'Configure your transcoder to convert your videos or extra thumbnails.',
@@ -85,6 +88,7 @@ function video_menu() {
'type' => MENU_LOCAL_TASK,
'weight' => 2,
);
+ // Preset settings
$items['admin/config/media/video/presets'] = array(
'title' => 'Presets',
'description' => 'Configure your transcoder presets to convert your videos.',
@@ -95,6 +99,72 @@ function video_menu() {
'type' => MENU_LOCAL_TASK,
'weight' => 3,
);
+
+ $items['admin/structure/video'] = array(
+ 'title' => 'Video Presets',
+ 'file' => 'includes/video.preset.inc',
+ 'description' => 'Manage and configure the presets for Video.',
+ 'page callback' => 'video_presets_overview',
+ 'access arguments' => array('administer video presets')
+ );
+ $items['admin/structure/video/list'] = array(
+ 'title' => 'List',
+ 'file' => 'includes/video.preset.inc',
+ 'access arguments' => array('administer video presets'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+ $items['admin/structure/video/add'] = array(
+ 'title' => 'Add preset',
+ 'file' => 'includes/video.preset.inc',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('video_preset_form'),
+ 'access arguments' => array('administer video presets'),
+ 'type' => MENU_LOCAL_TASK
+ );
+ $items['admin/structure/video/import'] = array(
+ 'title' => t('Import preset'),
+ 'file' => 'includes/video.preset.inc',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('video_preset_import_form'),
+ 'access arguments' => array('administer video presets'),
+ 'type' => MENU_LOCAL_TASK
+ );
+
+ $items['admin/structure/video/preset/%video_preset'] = array(
+ 'title' => 'Edit video preset',
+ 'title callback' => 'video_preset_page_title',
+ 'title arguments' => array(4),
+ 'file' => 'includes/video.preset.inc',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('video_preset_form', 4),
+ 'access arguments' => array('administer video presets')
+ );
+ $items['admin/structure/video/preset/%video_preset/edit'] = array(
+ 'title' => 'Edit',
+ 'file' => 'includes/video.preset.inc',
+ 'page arguments' => array(4),
+ 'access arguments' => array('administer video presets'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ );
+ $items['admin/structure/video/preset/%video_preset/delete'] = array(
+ 'title' => 'Delete',
+ 'file' => 'includes/video.preset.inc',
+ 'page arguments' => array('video_preset_delete_confirm', 4),
+ 'access arguments' => array('administer video presets'),
+ 'type' => MENU_CALLBACK
+ );
+ $items['admin/structure/video/preset/%video_preset/export'] = array(
+ 'title' => t('Export'),
+ 'file' => 'includes/video.preset.inc',
+ 'title callback' => 'video_preset_page_title',
+ 'title arguments' => array(4),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('video_preset_export_form', 4),
+ 'access arguments' => array('administer video presets'),
+ 'type' => MENU_CALLBACK
+ );
+ // Metadata settings
$items['admin/config/media/video/metadata'] = array(
'title' => 'Metadata',
'description' => 'Configure your metadata settings.',
@@ -105,7 +175,7 @@ function video_menu() {
'type' => MENU_LOCAL_TASK,
'weight' => 4,
);
-
+ // Filesystem settings
$items['admin/config/media/video/filesystem'] = array(
'title' => 'Filesystem',
'description' => 'Configure your filesystem settings.',
@@ -116,7 +186,7 @@ function video_menu() {
'type' => MENU_LOCAL_TASK,
'weight' => 5,
);
-
+ // Cron settings
$items['admin/config/media/video/cron'] = array(
'title' => 'Cron Settings',
'description' => 'Configure your cron settings.',
@@ -133,6 +203,16 @@ function video_menu() {
}
/**
+ * Used for the menu item to load a preset.
+ *
+ * @param <type> $preset_name
+ */
+function video_preset_load($preset_name) {
+ module_load_include('inc', 'video', 'includes/video.preset');
+ return video_get_preset($preset_name);
+}
+
+/**
* Implementation of hook_theme().
*/
function video_theme() {
@@ -257,8 +337,6 @@ function video_node_update_submit($form, &$form_state) {
$transcoder = new video_transcoder;
$video = array('nid' => $form_state['nid'], 'fid' => $fid);
$transcoder->update_job($video);
- // Lets other module to know to update
- video_module_invoke('update', $form, $form_state);
}
}
}
@@ -422,8 +500,6 @@ function video_file_delete($file) {
$thumb_folder = file_default_scheme() . ':/' . $video_thumb_path . '/' . $file->fid;
// Recursively delete our folder and files
rmdirr($thumb_folder);
- // Let other modules to know about the file delete
- video_module_invoke('delete', $file);
}
/**
@@ -613,15 +689,12 @@ function video_widget_process(&$element, &$form_state) {
video_upload_manual_thumb($element);
}
- // Call hook_video_submit API
- video_module_invoke('insert', $element, $form_state);
//
//queue up the file id to update the node id in the video rendering / cdn tables.
$form_state['values']['video_id'][] = $item['fid'];
break;
case 'node_form_build_preview':
- // Call hook_video_preview API
- video_module_invoke('preview', $element, $form_state);
+ // preview
break;
case 'node_form_delete_submit':
//moved to hook_file_delete in video module.