ffmpeg-mappable-media/src/FFMpeg/Format/DefaultAudioFormat.php

114 lines
2.5 KiB
PHP
Raw Normal View History

2012-04-13 12:45:41 +02:00
<?php
2012-04-13 14:34:53 +02:00
/*
* This file is part of PHP-FFmpeg.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
2012-04-13 12:45:41 +02:00
namespace FFMpeg\Format;
2012-04-13 15:42:34 +02:00
/**
* The abstract default Audio format
*
* @author Romain Neutron imprec@gmail.com
*/
2012-04-13 12:45:41 +02:00
abstract class DefaultAudioFormat implements AudioFormat
{
protected $audioCodec;
protected $audioSampleRate = 44100;
2012-04-27 00:48:57 +02:00
protected $kiloBitrate = 128;
2012-04-13 12:45:41 +02:00
2012-04-13 15:42:34 +02:00
/**
* Returns extra parameters for the encoding
*
* @return string
*/
2012-04-13 12:45:41 +02:00
public function getExtraParams()
{
return '';
}
2012-04-13 15:42:34 +02:00
/**
* Returns the audio codec
*
* @return string
*/
2012-04-13 12:45:41 +02:00
public function getAudioCodec()
{
return $this->audioCodec;
}
2012-04-13 15:42:34 +02:00
/**
* Set the audio codec, Should be in the available ones, otherwise an
* exception is thrown
*
2012-05-25 15:44:43 +02:00
* @param string $audioCodec
2012-04-13 15:42:34 +02:00
* @throws \InvalidArgumentException
*/
2012-04-13 12:45:41 +02:00
public function setAudioCodec($audioCodec)
{
2012-04-27 00:48:57 +02:00
if ( ! in_array($audioCodec, $this->getAvailableAudioCodecs())) {
throw new \InvalidArgumentException(sprintf(
'Wrong audiocodec value for %s, available formats are %s'
, $audioCodec, implode(', ', $this->getAvailableAudioCodecs())
));
2012-04-13 12:45:41 +02:00
}
$this->audioCodec = $audioCodec;
}
2012-04-13 15:42:34 +02:00
/**
* Get the audio sample rate
*
* @return type
*/
2012-04-13 12:45:41 +02:00
public function getAudioSampleRate()
{
return $this->audioSampleRate;
}
2012-04-13 15:42:34 +02:00
/**
* Set the audio sample rate
*
2012-05-25 15:44:43 +02:00
* @param integer $audioSampleRate
2012-04-13 15:42:34 +02:00
* @throws \InvalidArgumentException
*/
2012-04-13 12:45:41 +02:00
public function setAudioSampleRate($audioSampleRate)
{
2012-04-27 00:48:57 +02:00
if ($audioSampleRate < 1) {
2012-04-13 12:45:41 +02:00
throw new \InvalidArgumentException('Wrong audio sample rate value');
}
$this->audioSampleRate = (int) $audioSampleRate;
}
2012-04-13 15:42:34 +02:00
/**
* Get the kiloBitrate value
*
* @return int
*/
2012-04-13 12:45:41 +02:00
public function getKiloBitrate()
{
return $this->kiloBitrate;
}
2012-04-13 15:42:34 +02:00
/**
* Set the kiloBitrate value
*
2012-05-25 15:44:43 +02:00
* @param int integer $kiloBitrate
2012-04-13 15:42:34 +02:00
* @throws \InvalidArgumentException
*/
2012-04-13 12:45:41 +02:00
public function setKiloBitrate($kiloBitrate)
{
2012-04-27 00:48:57 +02:00
if ($kiloBitrate < 1) {
2012-04-13 12:45:41 +02:00
throw new \InvalidArgumentException('Wrong kiloBitrate value');
}
$this->kiloBitrate = (int) $kiloBitrate;
}
}