From 26ede7fa879d6d592b511dcee07cb975b45d0188 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 27 Apr 2012 00:48:57 +0200 Subject: [PATCH] Fix Build PHP 5.3.2 --- src/FFMpeg/Format/AudioFormat.php | 6 +++- src/FFMpeg/Format/DefaultAudioFormat.php | 25 +++++--------- src/FFMpeg/Format/DefaultVideoFormat.php | 43 +++++++++--------------- src/FFMpeg/Format/VideoFormat.php | 6 +++- 4 files changed, 33 insertions(+), 47 deletions(-) diff --git a/src/FFMpeg/Format/AudioFormat.php b/src/FFMpeg/Format/AudioFormat.php index ef09096..99bbeba 100644 --- a/src/FFMpeg/Format/AudioFormat.php +++ b/src/FFMpeg/Format/AudioFormat.php @@ -20,6 +20,10 @@ interface AudioFormat public function getKiloBitrate(); + /** + * Returns the list of available audio codecs for this format + * + * @return array + */ public function getAvailableAudioCodecs(); - } \ No newline at end of file diff --git a/src/FFMpeg/Format/DefaultAudioFormat.php b/src/FFMpeg/Format/DefaultAudioFormat.php index 16a2f4e..dce7601 100644 --- a/src/FFMpeg/Format/DefaultAudioFormat.php +++ b/src/FFMpeg/Format/DefaultAudioFormat.php @@ -18,10 +18,9 @@ namespace FFMpeg\Format; */ abstract class DefaultAudioFormat implements AudioFormat { - protected $audioCodec; protected $audioSampleRate = 44100; - protected $kiloBitrate = 128; + protected $kiloBitrate = 128; /** * Returns extra parameters for the encoding @@ -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(); - } diff --git a/src/FFMpeg/Format/DefaultVideoFormat.php b/src/FFMpeg/Format/DefaultVideoFormat.php index bd34e8f..04125e2 100644 --- a/src/FFMpeg/Format/DefaultVideoFormat.php +++ b/src/FFMpeg/Format/DefaultVideoFormat.php @@ -18,12 +18,11 @@ namespace FFMpeg\Format; */ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFormat { - protected $width; protected $height; - protected $frameRate = 25; + protected $frameRate = 25; protected $videoCodec; - protected $GOPsize = 25; + protected $GOPsize = 25; protected $kiloBitrate = 1000; public function __construct($width, $height) @@ -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'); } @@ -167,12 +164,11 @@ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFor $halfDistance = $multiple / 2; if ($modulo <= $halfDistance) - $bound = 'bottom'; + $bound = 'bottom'; else - $bound = 'top'; + $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(); - } diff --git a/src/FFMpeg/Format/VideoFormat.php b/src/FFMpeg/Format/VideoFormat.php index 7792348..3c7b2fa 100644 --- a/src/FFMpeg/Format/VideoFormat.php +++ b/src/FFMpeg/Format/VideoFormat.php @@ -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(); - } \ No newline at end of file