Fix Build PHP 5.3.2

This commit is contained in:
Romain Neutron 2012-04-27 00:48:57 +02:00
commit 26ede7fa87
4 changed files with 33 additions and 47 deletions

View file

@ -20,6 +20,10 @@ interface AudioFormat
public function getKiloBitrate();
/**
* Returns the list of available audio codecs for this format
*
* @return array
*/
public function getAvailableAudioCodecs();
}

View file

@ -18,7 +18,6 @@ namespace FFMpeg\Format;
*/
abstract class DefaultAudioFormat implements AudioFormat
{
protected $audioCodec;
protected $audioSampleRate = 44100;
protected $kiloBitrate = 128;
@ -52,9 +51,11 @@ abstract class DefaultAudioFormat implements AudioFormat
*/
public function setAudioCodec($audioCodec)
{
if ( ! in_array($audioCodec, $this->getAvailableAudioCodecs()))
{
throw new \InvalidArgumentException('Wrong audiocodec value');
if ( ! in_array($audioCodec, $this->getAvailableAudioCodecs())) {
throw new \InvalidArgumentException(sprintf(
'Wrong audiocodec value for %s, available formats are %s'
, $audioCodec, implode(', ', $this->getAvailableAudioCodecs())
));
}
$this->audioCodec = $audioCodec;
@ -78,8 +79,7 @@ abstract class DefaultAudioFormat implements AudioFormat
*/
public function setAudioSampleRate($audioSampleRate)
{
if ($audioSampleRate < 1)
{
if ($audioSampleRate < 1) {
throw new \InvalidArgumentException('Wrong audio sample rate value');
}
@ -104,19 +104,10 @@ abstract class DefaultAudioFormat implements AudioFormat
*/
public function setKiloBitrate($kiloBitrate)
{
if ($kiloBitrate < 1)
{
if ($kiloBitrate < 1) {
throw new \InvalidArgumentException('Wrong kiloBitrate value');
}
$this->kiloBitrate = (int) $kiloBitrate;
}
/**
* Returns the list of available audio codecs for this format
*
* @return array
*/
abstract public function getAvailableAudioCodecs();
}

View file

@ -18,7 +18,6 @@ namespace FFMpeg\Format;
*/
abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFormat
{
protected $width;
protected $height;
protected $frameRate = 25;
@ -60,12 +59,10 @@ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFor
*/
public function setDimensions($width, $height)
{
if ($width < 1)
{
if ($width < 1) {
throw new \InvalidArgumentException('Wrong width value');
}
if ($height < 1)
{
if ($height < 1) {
throw new \InvalidArgumentException('Wrong height value');
}
@ -91,8 +88,7 @@ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFor
*/
public function setFrameRate($frameRate)
{
if ($frameRate < 1)
{
if ($frameRate < 1) {
throw new \InvalidArgumentException('Wrong framerate value');
}
@ -118,9 +114,11 @@ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFor
*/
public function setVideoCodec($videoCodec)
{
if ( ! in_array($videoCodec, $this->getAvailableVideoCodecs()))
{
throw new \InvalidArgumentException('Wrong videocodec value');
if ( ! in_array($videoCodec, $this->getAvailableVideoCodecs())) {
throw new \InvalidArgumentException(sprintf(
'Wrong videocodec value for %s, available formats are %s'
, $videoCodec, implode(', ', $this->getAvailableVideoCodecs())
));
}
$this->videoCodec = $videoCodec;
@ -144,8 +142,7 @@ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFor
*/
public function setGOPsize($GOPsize)
{
if ($GOPsize < 1)
{
if ($GOPsize < 1) {
throw new \InvalidArgumentException('Wrong GOP size value');
}
@ -171,8 +168,7 @@ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFor
else
$bound = 'top';
switch ($bound)
{
switch ($bound) {
default:
case 'top':
$ret = $value + $multiple - $modulo;
@ -182,19 +178,10 @@ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFor
break;
}
if ($ret < $multiple)
{
if ($ret < $multiple) {
$ret = (int) $multiple;
}
return (int) $ret;
}
/**
* Returns the list of available video codecs for this format
*
* @return array
*/
abstract public function getAvailableVideoCodecs();
}

View file

@ -24,6 +24,10 @@ interface VideoFormat extends AudioFormat
public function getGOPSize();
/**
* Returns the list of available video codecs for this format
*
* @return array
*/
public function getAvailableVideoCodecs();
}