Add doc blocks

This commit is contained in:
Romain Neutron 2012-04-13 15:42:34 +02:00
commit d58059c087
5 changed files with 126 additions and 5 deletions

View file

@ -15,6 +15,8 @@ use \Symfony\Component\Process\ExecutableFinder;
/** /**
* Binary abstract class * Binary abstract class
*
* @author Romain Neutron imprec@gmail.com
*/ */
abstract class Binary implements AdapterInterface abstract class Binary implements AdapterInterface
{ {

View file

@ -20,4 +20,6 @@ interface AudioFormat
public function getKiloBitrate(); public function getKiloBitrate();
public function getAvailableAudioCodecs();
} }

View file

@ -11,6 +11,11 @@
namespace FFMpeg\Format; namespace FFMpeg\Format;
/**
* The abstract default Audio format
*
* @author Romain Neutron imprec@gmail.com
*/
abstract class DefaultAudioFormat implements AudioFormat abstract class DefaultAudioFormat implements AudioFormat
{ {
@ -18,16 +23,33 @@ abstract class DefaultAudioFormat implements AudioFormat
protected $audioSampleRate = 44100; protected $audioSampleRate = 44100;
protected $kiloBitrate = 128; protected $kiloBitrate = 128;
/**
* Returns extra parameters for the encoding
*
* @return string
*/
public function getExtraParams() public function getExtraParams()
{ {
return ''; return '';
} }
/**
* Returns the audio codec
*
* @return string
*/
public function getAudioCodec() public function getAudioCodec()
{ {
return $this->audioCodec; 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) public function setAudioCodec($audioCodec)
{ {
if ( ! in_array($audioCodec, $this->getAvailableAudioCodecs())) if ( ! in_array($audioCodec, $this->getAvailableAudioCodecs()))
@ -38,11 +60,22 @@ abstract class DefaultAudioFormat implements AudioFormat
$this->audioCodec = $audioCodec; $this->audioCodec = $audioCodec;
} }
/**
* Get the audio sample rate
*
* @return type
*/
public function getAudioSampleRate() public function getAudioSampleRate()
{ {
return $this->audioSampleRate; return $this->audioSampleRate;
} }
/**
* Set the audio sample rate
*
* @param int $audioSampleRate
* @throws \InvalidArgumentException
*/
public function setAudioSampleRate($audioSampleRate) public function setAudioSampleRate($audioSampleRate)
{ {
if ($audioSampleRate < 1) if ($audioSampleRate < 1)
@ -53,11 +86,22 @@ abstract class DefaultAudioFormat implements AudioFormat
$this->audioSampleRate = (int) $audioSampleRate; $this->audioSampleRate = (int) $audioSampleRate;
} }
/**
* Get the kiloBitrate value
*
* @return int
*/
public function getKiloBitrate() public function getKiloBitrate()
{ {
return $this->kiloBitrate; return $this->kiloBitrate;
} }
/**
* Set the kiloBitrate value
*
* @param int $kiloBitrate
* @throws \InvalidArgumentException
*/
public function setKiloBitrate($kiloBitrate) public function setKiloBitrate($kiloBitrate)
{ {
if ($kiloBitrate < 1) if ($kiloBitrate < 1)
@ -68,6 +112,11 @@ abstract class DefaultAudioFormat implements AudioFormat
$this->kiloBitrate = (int) $kiloBitrate; $this->kiloBitrate = (int) $kiloBitrate;
} }
abstract protected function getAvailableAudioCodecs(); /**
* Returns the list of available audio codecs for this format
*
* @return array
*/
abstract public function getAvailableAudioCodecs();
} }

View file

@ -11,6 +11,11 @@
namespace FFMpeg\Format; namespace FFMpeg\Format;
/**
* The abstract default Video format
*
* @author Romain Neutron imprec@gmail.com
*/
abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFormat abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFormat
{ {
@ -26,16 +31,33 @@ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFor
$this->setDimensions($width, $height); $this->setDimensions($width, $height);
} }
/**
* Returns the width
*
* @return int
*/
public function getWidth() public function getWidth()
{ {
return $this->width; return $this->width;
} }
/**
* Returns the height
*
* @return int
*/
public function getHeight() public function getHeight()
{ {
return $this->height; return $this->height;
} }
/**
* Set the dimensions
*
* @param int $width The heigth
* @param int $height The width
* @throws \InvalidArgumentException
*/
public function setDimensions($width, $height) public function setDimensions($width, $height)
{ {
if ($width < 1) if ($width < 1)
@ -49,15 +71,24 @@ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFor
$this->width = $this->getMultiple($width, 16); $this->width = $this->getMultiple($width, 16);
$this->height = $this->getMultiple($height, 16); $this->height = $this->getMultiple($height, 16);
return;
} }
/**
* Returns the framerate
*
* @return int
*/
public function getFrameRate() public function getFrameRate()
{ {
return $this->frameRate; return $this->frameRate;
} }
/**
* Set the framerate
*
* @param int $frameRate
* @throws \InvalidArgumentException
*/
public function setFrameRate($frameRate) public function setFrameRate($frameRate)
{ {
if ($frameRate < 1) if ($frameRate < 1)
@ -68,11 +99,23 @@ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFor
$this->frameRate = (int) $frameRate; $this->frameRate = (int) $frameRate;
} }
/**
* Returns the video codec
*
* @return string
*/
public function getVideoCodec() public function getVideoCodec()
{ {
return $this->videoCodec; 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) public function setVideoCodec($videoCodec)
{ {
if ( ! in_array($videoCodec, $this->getAvailableVideoCodecs())) if ( ! in_array($videoCodec, $this->getAvailableVideoCodecs()))
@ -83,11 +126,22 @@ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFor
$this->videoCodec = $videoCodec; $this->videoCodec = $videoCodec;
} }
/**
* Returns the GOP size
*
* @return int
*/
public function getGOPsize() public function getGOPsize()
{ {
return $this->GOPsize; return $this->GOPsize;
} }
/**
* Set the GOP size
*
* @param int $GOPsize
* @throws \InvalidArgumentException
*/
public function setGOPsize($GOPsize) public function setGOPsize($GOPsize)
{ {
if ($GOPsize < 1) if ($GOPsize < 1)
@ -98,6 +152,13 @@ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFor
$this->GOPsize = (int) $GOPsize; $this->GOPsize = (int) $GOPsize;
} }
/**
* Returns the nearest multiple for a value
*
* @param int $value
* @param int $multiple
* @return int
*/
protected function getMultiple($value, $multiple) protected function getMultiple($value, $multiple)
{ {
$modulo = $value % $multiple; $modulo = $value % $multiple;
@ -129,6 +190,11 @@ abstract class DefaultVideoFormat extends DefaultAudioFormat implements VideoFor
return (int) $ret; return (int) $ret;
} }
abstract protected function getAvailableVideoCodecs(); /**
* Returns the list of available video codecs for this format
*
* @return array
*/
abstract public function getAvailableVideoCodecs();
} }

View file

@ -24,4 +24,6 @@ interface VideoFormat extends AudioFormat
public function getGOPSize(); public function getGOPSize();
public function getAvailableVideoCodecs();
} }