From 0c8e7ae689eed6291bb2061c9c75e3057b230339 Mon Sep 17 00:00:00 2001 From: Mohamed Mujahid Date: Tue, 6 Jul 2010 17:04:02 +0000 Subject: merging changes from DRUPAL-6--4 --- includes/transcoder.inc | 96 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 includes/transcoder.inc (limited to 'includes/transcoder.inc') diff --git a/includes/transcoder.inc b/includes/transcoder.inc new file mode 100644 index 0000000..96b9f57 --- /dev/null +++ b/includes/transcoder.inc @@ -0,0 +1,96 @@ +transcoder = new $transcoder; + } + else { + drupal_set_message(t('The transcoder is not configured properly.'), 'error'); + } + } + + public function generate_thumbnails($video) { + return $this->transcoder->generate_thumbnails($video); + } + + public function convert_video($video, $converted, $dimensions) { + $output = $this->transcoder->convert_video($video, $converted, $dimensions); + // If they are using metadata. + if (variable_get('video_metadata', FALSE)) { + module_load_include('inc', 'video', '/includes/metadata'); + $metadata = new video_metadata; + $metadata->process($converted); + } + return $output; + } + + public function admin_settings() { + $form = array(); + $options = $this->_transcoders(); + $form['vid_convertor'] = array( + '#type' => 'radios', + '#title' => t('Video transcoder'), + '#default_value' => variable_get('vid_convertor', 'video_ffmpeg'), + '#options' => $options['radios'], + '#description' => t('Selecting a video transcoder will help you convert videos and generate thumbnails. !list', array('!list' => theme('item_list', $options['help']))), + '#prefix' => '
', + '#suffix' => '
', + ); + $form = $form + $options['admin_settings']; + return $form; + } + + private function _transcoders() { + // Lets find our transcoder classes and build our radio options + // We do this by scanning our transcoders folder + $form = array('radios' => array(), 'help' => array(), 'admin_settings' => array()); + $path = drupal_get_path('module', 'video') .'/transcoders'; + $files = file_scan_directory($path, '^.*\.inc$'); + foreach($files as $file) { + module_load_include('inc', 'video', '/transcoders/' . $file->name); + $focus = new $file->name; + $form['radios'][$focus->get_value()] = $focus->get_name(); + $form['help'][] = $focus->get_help(); + $form['admin_settings'] = $form['admin_settings'] + $focus->admin_settings(); + } + //we need to move our video/thumbnail fieldsets to the bottom of our form as they are used for each trancoder + $autothumb = $form['admin_settings']['autothumb']; + $autoconv = $form['admin_settings']['autoconv']; + unset($form['admin_settings']['autothumb'], $form['admin_settings']['autoconv']); + $form['admin_settings']['autothumb'] = $autothumb; + $form['admin_settings']['autoconv'] = $autoconv; + return $form; + } + + public function get_dimensions($video) { + return $this->transcoder->get_dimensions($video); + } + + public function video_converted_extension() { + return $this->transcoder->video_converted_extension(); + } +} + +interface transcoder_interface { + public function run_command($command); + public function generate_thumbnails($video); + public function convert_video($video, $converted, $dimensions); + public function get_playtime($video); + public function get_name(); + public function get_value(); + public function get_help(); + public function admin_settings(); +} \ No newline at end of file -- cgit v1.2.3