From d58059c0874709a2996d78e655309b274ba249c9 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 13 Apr 2012 15:42:34 +0200 Subject: [PATCH] Add doc blocks --- src/FFMpeg/Binary.php | 2 + src/FFMpeg/Format/AudioFormat.php | 2 + src/FFMpeg/Format/DefaultAudioFormat.php | 51 +++++++++++++++- src/FFMpeg/Format/DefaultVideoFormat.php | 74 ++++++++++++++++++++++-- src/FFMpeg/Format/VideoFormat.php | 2 + 5 files changed, 126 insertions(+), 5 deletions(-) diff --git a/src/FFMpeg/Binary.php b/src/FFMpeg/Binary.php index 9374d93..0d0f766 100644 --- a/src/FFMpeg/Binary.php +++ b/src/FFMpeg/Binary.php @@ -15,6 +15,8 @@ use \Symfony\Component\Process\ExecutableFinder; /** * Binary abstract class + * + * @author Romain Neutron imprec@gmail.com */ abstract class Binary implements AdapterInterface { diff --git a/src/FFMpeg/Format/AudioFormat.php b/src/FFMpeg/Format/AudioFormat.php index d3a82d7..ef09096 100644 --- a/src/FFMpeg/Format/AudioFormat.php +++ b/src/FFMpeg/Format/AudioFormat.php @@ -20,4 +20,6 @@ interface AudioFormat public function getKiloBitrate(); + public function getAvailableAudioCodecs(); + } \ No newline at end of file diff --git a/src/FFMpeg/Format/DefaultAudioFormat.php b/src/FFMpeg/Format/DefaultAudioFormat.php index 6e748b6..16a2f4e 100644 --- a/src/FFMpeg/Format/DefaultAudioFormat.php +++ b/src/FFMpeg/Format/DefaultAudioFormat.php @@ -11,6 +11,11 @@ namespace FFMpeg\Format; +/** + * The abstract default Audio format + * + * @author Romain Neutron imprec@gmail.com + */ abstract class DefaultAudioFormat implements AudioFormat { @@ -18,16 +23,33 @@ abstract class DefaultAudioFormat implements AudioFormat protected $audioSampleRate = 44100; protected $kiloBitrate = 128; + /** + * Returns extra parameters for the encoding + * + * @return string + */ public function getExtraParams() { return ''; } + /** + * Returns the audio codec + * + * @return string + */ public function getAudioCodec() { return $this->audioCodec; } + /** + * Set the audio codec, Should be in the available ones, otherwise an + * exception is thrown + * + * @param string $audioCodec + * @throws \InvalidArgumentException + */ public function setAudioCodec($audioCodec) { if ( ! in_array($audioCodec, $this->getAvailableAudioCodecs())) @@ -38,11 +60,22 @@ abstract class DefaultAudioFormat implements AudioFormat $this->audioCodec = $audioCodec; } + /** + * Get the audio sample rate + * + * @return type + */ public function getAudioSampleRate() { return $this->audioSampleRate; } + /** + * Set the audio sample rate + * + * @param int $audioSampleRate + * @throws \InvalidArgumentException + */ public function setAudioSampleRate($audioSampleRate) { if ($audioSampleRate < 1) @@ -53,11 +86,22 @@ abstract class DefaultAudioFormat implements AudioFormat $this->audioSampleRate = (int) $audioSampleRate; } + /** + * Get the kiloBitrate value + * + * @return int + */ public function getKiloBitrate() { return $this->kiloBitrate; } + /** + * Set the kiloBitrate value + * + * @param int $kiloBitrate + * @throws \InvalidArgumentException + */ public function setKiloBitrate($kiloBitrate) { if ($kiloBitrate < 1) @@ -68,6 +112,11 @@ abstract class DefaultAudioFormat implements AudioFormat $this->kiloBitrate = (int) $kiloBitrate; } - abstract protected function getAvailableAudioCodecs(); + /** + * 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 182b1aa..bd34e8f 100644 --- a/src/FFMpeg/Format/DefaultVideoFormat.php +++ b/src/FFMpeg/Format/DefaultVideoFormat.php @@ -11,6 +11,11 @@ namespace FFMpeg\Format; +/** + * The abstract default Video format + * + * @author Romain Neutron imprec@gmail.com + */ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFormat { @@ -26,16 +31,33 @@ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFor $this->setDimensions($width, $height); } + /** + * Returns the width + * + * @return int + */ public function getWidth() { return $this->width; } + /** + * Returns the height + * + * @return int + */ public function getHeight() { return $this->height; } + /** + * Set the dimensions + * + * @param int $width The heigth + * @param int $height The width + * @throws \InvalidArgumentException + */ public function setDimensions($width, $height) { if ($width < 1) @@ -49,15 +71,24 @@ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFor $this->width = $this->getMultiple($width, 16); $this->height = $this->getMultiple($height, 16); - - return; } + /** + * Returns the framerate + * + * @return int + */ public function getFrameRate() { return $this->frameRate; } + /** + * Set the framerate + * + * @param int $frameRate + * @throws \InvalidArgumentException + */ public function setFrameRate($frameRate) { if ($frameRate < 1) @@ -68,11 +99,23 @@ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFor $this->frameRate = (int) $frameRate; } + /** + * Returns the video codec + * + * @return string + */ public function getVideoCodec() { return $this->videoCodec; } + /** + * Set the video codec, Should be in the available ones, otherwise an + * exception is thrown + * + * @param string $videoCodec + * @throws \InvalidArgumentException + */ public function setVideoCodec($videoCodec) { if ( ! in_array($videoCodec, $this->getAvailableVideoCodecs())) @@ -83,11 +126,22 @@ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFor $this->videoCodec = $videoCodec; } + /** + * Returns the GOP size + * + * @return int + */ public function getGOPsize() { return $this->GOPsize; } + /** + * Set the GOP size + * + * @param int $GOPsize + * @throws \InvalidArgumentException + */ public function setGOPsize($GOPsize) { if ($GOPsize < 1) @@ -98,6 +152,13 @@ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFor $this->GOPsize = (int) $GOPsize; } + /** + * Returns the nearest multiple for a value + * + * @param int $value + * @param int $multiple + * @return int + */ protected function getMultiple($value, $multiple) { $modulo = $value % $multiple; @@ -129,6 +190,11 @@ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFor return (int) $ret; } - abstract protected function getAvailableVideoCodecs(); + /** + * Returns the list of available video codecs for this format + * + * @return array + */ + abstract public function getAvailableVideoCodecs(); -} \ No newline at end of file +} diff --git a/src/FFMpeg/Format/VideoFormat.php b/src/FFMpeg/Format/VideoFormat.php index 579bb50..7792348 100644 --- a/src/FFMpeg/Format/VideoFormat.php +++ b/src/FFMpeg/Format/VideoFormat.php @@ -24,4 +24,6 @@ interface VideoFormat extends AudioFormat public function getGOPSize(); + public function getAvailableVideoCodecs(); + } \ No newline at end of file