You are here

abstract class TranscoderAbstractionFactory in Video 7.2

Abstract class for the transcoder classes to keep common methods

Hierarchy

Expanded class hierarchy of TranscoderAbstractionFactory

File

includes/TranscoderFactory.inc, line 88
Transcoder Abstract Factory classes

View source
abstract class TranscoderAbstractionFactory {
  protected $settings = array();
  protected $errors = array();
  protected function __construct() {
  }
  public function isAvailable(&$errormsg) {
    return TRUE;
  }

  /**
   * Set Input file to add input file in to settings variable
   */
  public function setInput(array $file) {

    // @TODO : do some validation to check the file exists;
    if (!empty($file)) {
      if (empty($file['uri'])) {
        $file += (array) file_load($file['fid']);
      }
      $this->settings['input'] = $file;
    }
    else {
      drupal_set_message(t('Video file not found.'), 'error');
    }
  }

  /**
   * Set options is to set transcoding settings before send to the transcoder.
   */
  public function setOptions(array $options) {
    foreach ($options as $key => $value) {
      $this->settings[$key] = $value;
    }
  }

  /**
   * Set output file for transcoding, this would be the result file.
   */
  public function setOutput($output_directory, $output_name, $overwrite_mode = FILE_EXISTS_REPLACE) {

    // @TODO : do some validation to check the file exists
    if (count($output_directory) == 1) {
      $this->settings['base_url'] = $output_directory;
    }
    if (count($output_name) == 1) {
      $this->settings['filename'] = $output_name;
    }
    else {
      $this->errors['output'] = 'Output file not found.';
    }
  }

  /**
   * Get the installed transcoder version.
   */
  public function getVersion() {
    return '1.0';
  }

  /**
   * Get file informations
   * @return
   *   Associative array with file informations like duration, dimensions
   */
  public function getFileInfo() {
    return NULL;
  }
  public function getDimensions() {
    $i = $this
      ->getFileInfo();
    if (empty($i) || empty($i['video']['dimensions']['width']) || empty($i['video']['dimensions']['height'])) {
      return NULL;
    }
    return array(
      'width' => intval($i['video']['dimensions']['width']),
      'height' => intval($i['video']['dimensions']['height']),
    );
  }

  /**
   * Get errors
   */
  public function getErrors() {
    return $this->errors;
  }

  /**
   * Check for errors if any
   */
  public function checkErrors() {
    return !empty($this->errors);
  }

  /**
   * Process postback jobs
   */
  public function processPostback() {
    return MENU_NOT_FOUND;
  }

  /**
   * Reset internal variables to their initial state.
   */
  public function reset($keepinput = FALSE) {
    if (!$keepinput) {
      unset($this->settings['input']);
    }
    unset($this->settings['options']);
    unset($this->settings['output']);
    $this->errors = array();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TranscoderAbstractionFactory::$errors protected property
TranscoderAbstractionFactory::$settings protected property
TranscoderAbstractionFactory::checkErrors public function Check for errors if any
TranscoderAbstractionFactory::getDimensions public function
TranscoderAbstractionFactory::getErrors public function Get errors
TranscoderAbstractionFactory::getFileInfo public function Get file informations 1
TranscoderAbstractionFactory::getVersion public function Get the installed transcoder version. 2
TranscoderAbstractionFactory::isAvailable public function 1
TranscoderAbstractionFactory::processPostback public function Process postback jobs 1
TranscoderAbstractionFactory::reset public function Reset internal variables to their initial state. 2
TranscoderAbstractionFactory::setInput public function Set Input file to add input file in to settings variable 2
TranscoderAbstractionFactory::setOptions public function Set options is to set transcoding settings before send to the transcoder. 2
TranscoderAbstractionFactory::setOutput public function Set output file for transcoding, this would be the result file. 2
TranscoderAbstractionFactory::__construct protected function 2