You are here

abstract class TranscoderBase in Video 8.2

Hierarchy

Expanded class hierarchy of TranscoderBase

1 file declares its use of TranscoderBase
Ffmpeg.php in modules/video_transcode/src/Plugin/video/Transcoder/Ffmpeg.php
Contains \Drupal\video_transcode\Plugin\video\Transcoder\Ffmpeg.

File

modules/video_transcode/src/TranscoderBase.php, line 15
Provides Drupal\video_transcode\TranscoderBase.

Namespace

Drupal\video_transcode
View source
abstract class TranscoderBase extends PluginBase implements TranscoderInterface, ContainerFactoryPluginInterface {

  /**
   * File object to transcode
   *
   * @var Drupal\file\Entity\File $file
   */
  protected $file;

  /**
   * An http client.
   *
   * @var \GuzzleHttp\ClientInterface
   */
  protected $httpClient;

  /**
   * Create a plugin with the given input.
   *
   * @param string $configuration
   *   The configuration of the plugin.
   * @param \GuzzleHttp\ClientInterface $http_client
   *    An HTTP client.
   *
   * @throws \Exception
   */
  public function __construct($configuration, ClientInterface $http_client) {
    $this->file = $configuration['file'];
    $this->httpClient = $http_client;
  }

  /**
   * Get the Plugin label.
   *
   * @return string
   * The name of the plugin.
   */
  public function getLabel() {
    return $this->pluginDefinition['label'];
  }

  /**
   * Get the ID of the video.
   *
   * @return string
   *   The video ID.
   */
  protected function getInputFile() {
    return $this->file;
  }

  /**
   * Get the transcoder supported codecs.
   *
   * @return array
   *   Array of supported codes.
   */
  public function getAvailableCodecs() {
    return [
      'encode' => [
        'video' => [
          'h264' => 'H.264',
          'vp8' => 'VP8',
          'theora' => 'Theora',
          'vp6' => 'VP6',
          'mpeg4' => 'MPEG-4',
          'wmv' => 'WMV',
        ],
        'audio' => [
          'aac' => 'AAC',
          'mp3' => 'MP3',
          'vorbis' => 'Vorbis',
          'wma' => 'WMA',
        ],
      ],
      'decode' => [],
    ];
  }

  /**
   * Get the transcoder supported formats.
   *
   * @return array
   *   Array of supported formats.
   */
  public function getAvailableFormats($type = FALSE) {
    return [
      '3g2' => '3G2',
      '3gp' => '3GP',
      '3gp2' => '3GP2',
      '3gpp' => '3GPP',
      '3gpp2' => '3GPP2',
      'aac' => 'AAC',
      'f4a' => 'F4A',
      'f4b' => 'F4B',
      'f4v' => 'F4V',
      'flv' => 'FLV',
      'm4a' => 'M4A',
      'm4b' => 'M4B',
      'm4r' => 'M4R',
      'm4v' => 'M4V',
      'mov' => 'MOV',
      'mp3' => 'MP3',
      'mp4' => 'MP4',
      'oga' => 'OGA',
      'ogg' => 'OGG',
      'ogv' => 'OGV',
      'ogx' => 'OGX',
      'ts' => 'TS',
      'webm' => 'WebM',
      'wma' => 'WMA',
      'wmv' => 'WMV',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $container
      ->get('http_client'));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
TranscoderBase::$file protected property File object to transcode
TranscoderBase::$httpClient protected property An http client.
TranscoderBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
TranscoderBase::getAvailableCodecs public function Get the transcoder supported codecs.
TranscoderBase::getAvailableFormats public function Get the transcoder supported formats.
TranscoderBase::getInputFile protected function Get the ID of the video.
TranscoderBase::getLabel public function Get the Plugin label.
TranscoderBase::__construct public function Create a plugin with the given input. Overrides PluginBase::__construct
TranscoderInterface::getOutputFiles public function Get the transcoded files. 1
TranscoderInterface::getVideoThumbnails public function Get the video thumbnails. 1