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-13 14:15:56 +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
|
|
|
|
|
*
|
|
|
|
|
* @param string $audioCodec
|
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
|
*/
|
2012-04-13 12:45:41 +02:00
|
|
|
public function setAudioCodec($audioCodec)
|
|
|
|
|
{
|
|
|
|
|
if ( ! in_array($audioCodec, $this->getAvailableAudioCodecs()))
|
|
|
|
|
{
|
|
|
|
|
throw new \InvalidArgumentException('Wrong audiocodec value');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$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
|
|
|
|
|
*
|
|
|
|
|
* @param int $audioSampleRate
|
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
|
*/
|
2012-04-13 12:45:41 +02:00
|
|
|
public function setAudioSampleRate($audioSampleRate)
|
|
|
|
|
{
|
|
|
|
|
if ($audioSampleRate < 1)
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
*
|
|
|
|
|
* @param int $kiloBitrate
|
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
|
*/
|
2012-04-13 12:45:41 +02:00
|
|
|
public function setKiloBitrate($kiloBitrate)
|
|
|
|
|
{
|
|
|
|
|
if ($kiloBitrate < 1)
|
|
|
|
|
{
|
|
|
|
|
throw new \InvalidArgumentException('Wrong kiloBitrate value');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->kiloBitrate = (int) $kiloBitrate;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-13 15:42:34 +02:00
|
|
|
/**
|
|
|
|
|
* Returns the list of available audio codecs for this format
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
abstract public function getAvailableAudioCodecs();
|
2012-04-13 12:45:41 +02:00
|
|
|
|
|
|
|
|
}
|