Add doc blocks
This commit is contained in:
		
					parent
					
						
							
								53efcb255f
							
						
					
				
			
			
				commit
				
					
						d58059c087
					
				
			
		
					 5 changed files with 126 additions and 5 deletions
				
			
		|  | @ -15,6 +15,8 @@ use \Symfony\Component\Process\ExecutableFinder; | |||
| 
 | ||||
| /** | ||||
|  * Binary abstract class | ||||
|  * | ||||
|  * @author Romain Neutron imprec@gmail.com | ||||
|  */ | ||||
| abstract class Binary implements AdapterInterface | ||||
| { | ||||
|  |  | |||
|  | @ -20,4 +20,6 @@ interface AudioFormat | |||
| 
 | ||||
|     public function getKiloBitrate(); | ||||
| 
 | ||||
|     public function getAvailableAudioCodecs(); | ||||
| 
 | ||||
| } | ||||
|  | @ -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(); | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -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(); | ||||
| 
 | ||||
| } | ||||
| } | ||||
|  |  | |||
|  | @ -24,4 +24,6 @@ interface VideoFormat extends AudioFormat | |||
| 
 | ||||
|     public function getGOPSize(); | ||||
| 
 | ||||
|     public function getAvailableVideoCodecs(); | ||||
| 
 | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue