Rename Interfaces
This commit is contained in:
		
					parent
					
						
							
								7003cdd1a9
							
						
					
				
			
			
				commit
				
					
						b1e6eeaf95
					
				
			
		
					 14 changed files with 238 additions and 76 deletions
				
			
		|  | @ -11,6 +11,11 @@ | |||
| 
 | ||||
| namespace FFMpeg\Format; | ||||
| 
 | ||||
| /** | ||||
|  * The base audio interface | ||||
|  *  | ||||
|  * @author Romain Neutron imprec@gmail.com | ||||
|  */ | ||||
| interface Audio | ||||
| { | ||||
| 
 | ||||
|  | @ -21,13 +26,6 @@ interface Audio | |||
|      */ | ||||
|     public function getAudioCodec(); | ||||
| 
 | ||||
|     /** | ||||
|      * Get the audio sample rate | ||||
|      * | ||||
|      * @return integer | ||||
|      */ | ||||
|     public function getAudioSampleRate(); | ||||
| 
 | ||||
|     /** | ||||
|      * Get the kiloBitrate value | ||||
|      * | ||||
|  | @ -35,10 +33,4 @@ interface Audio | |||
|      */ | ||||
|     public function getKiloBitrate(); | ||||
| 
 | ||||
|     /** | ||||
|      * Returns the list of available audio codecs for this format | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
|     public function getAvailableAudioCodecs(); | ||||
| } | ||||
|  |  | |||
|  | @ -9,7 +9,7 @@ | |||
|  * file that was distributed with this source code. | ||||
|  */ | ||||
| 
 | ||||
| namespace FFMpeg\Format; | ||||
| namespace FFMpeg\Format\Audio; | ||||
| 
 | ||||
| use FFMpeg\Exception\InvalidArgumentException; | ||||
| 
 | ||||
|  | @ -18,7 +18,7 @@ use FFMpeg\Exception\InvalidArgumentException; | |||
|  * | ||||
|  * @author Romain Neutron imprec@gmail.com | ||||
|  */ | ||||
| abstract class DefaultAudio implements Audio | ||||
| abstract class DefaultAudio implements ResamplableAudio, InteractiveAudio | ||||
| { | ||||
|     protected $audioCodec; | ||||
|     protected $audioSampleRate = 44100; | ||||
|  | @ -11,8 +11,6 @@ | |||
| 
 | ||||
| namespace FFMpeg\Format\Audio; | ||||
| 
 | ||||
| use FFMpeg\Format\DefaultAudio; | ||||
| 
 | ||||
| /** | ||||
|  * The Flac audio format | ||||
|  * | ||||
|  |  | |||
							
								
								
									
										32
									
								
								src/FFMpeg/Format/Audio/InteractiveAudio.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/FFMpeg/Format/Audio/InteractiveAudio.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,32 @@ | |||
| <?php | ||||
| 
 | ||||
| /* | ||||
|  * This file is part of PHP-FFmpeg. | ||||
|  * | ||||
|  * (c) Alchemy <info@alchemy.fr> | ||||
|  * | ||||
|  * For the full copyright and license information, please view the LICENSE | ||||
|  * file that was distributed with this source code. | ||||
|  */ | ||||
| 
 | ||||
| namespace FFMpeg\Format\Audio; | ||||
| 
 | ||||
| use FFMpeg\Format\Audio as BaseAudio; | ||||
| 
 | ||||
| /** | ||||
|  * The interactive audio interface. This provide a method to list available  | ||||
|  * codecs. This is usefull to build interactive development and switch between | ||||
|  * different codecs | ||||
|  *  | ||||
|  * @author Romain Neutron imprec@gmail.com | ||||
|  */ | ||||
| interface InteractiveAudio extends BaseAudio | ||||
| { | ||||
| 
 | ||||
|     /** | ||||
|      * Returns the list of available audio codecs for this format | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
|     public function getAvailableAudioCodecs(); | ||||
| } | ||||
|  | @ -11,8 +11,6 @@ | |||
| 
 | ||||
| namespace FFMpeg\Format\Audio; | ||||
| 
 | ||||
| use FFMpeg\Format\DefaultAudio; | ||||
| 
 | ||||
| /** | ||||
|  * The MP3 audio format | ||||
|  * | ||||
|  |  | |||
							
								
								
									
										32
									
								
								src/FFMpeg/Format/Audio/ResamplableAudio.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/FFMpeg/Format/Audio/ResamplableAudio.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,32 @@ | |||
| <?php | ||||
| 
 | ||||
| /* | ||||
|  * This file is part of PHP-FFmpeg. | ||||
|  * | ||||
|  * (c) Alchemy <info@alchemy.fr> | ||||
|  * | ||||
|  * For the full copyright and license information, please view the LICENSE | ||||
|  * file that was distributed with this source code. | ||||
|  */ | ||||
| 
 | ||||
| namespace FFMpeg\Format\Audio; | ||||
| 
 | ||||
| use FFMpeg\Format\Audio as BaseAudio; | ||||
| 
 | ||||
| /** | ||||
|  * The resamplable audio interface | ||||
|  *  | ||||
|  * This provide a method to define the AudiosampleRate  | ||||
|  *  | ||||
|  * @author Romain Neutron imprec@gmail.com | ||||
|  */ | ||||
| interface ResamplableAudio extends BaseAudio | ||||
| { | ||||
| 
 | ||||
|     /** | ||||
|      * Get the audio sample rate | ||||
|      * | ||||
|      * @return integer | ||||
|      */ | ||||
|     public function getAudioSampleRate(); | ||||
| } | ||||
|  | @ -12,42 +12,12 @@ | |||
| namespace FFMpeg\Format; | ||||
| 
 | ||||
| /** | ||||
|  * The video format interface | ||||
|  * The base video interface | ||||
|  *  | ||||
|  * @author Romain Neutron imprec@gmail.com | ||||
|  */ | ||||
| interface Video extends Audio | ||||
| { | ||||
|     const RESIZEMODE_FIT = 'fit'; | ||||
|     const RESIZEMODE_INSET = 'inset'; | ||||
| 
 | ||||
|     /** | ||||
|      * Returns the width | ||||
|      * | ||||
|      * @return integer | ||||
|      */ | ||||
|     public function getWidth(); | ||||
| 
 | ||||
|     /** | ||||
|      * Returns the height | ||||
|      * | ||||
|      * @return integer | ||||
|      */ | ||||
|     public function getHeight(); | ||||
| 
 | ||||
|     /** | ||||
|      * Get the current resize mode | ||||
|      *  | ||||
|      * @return string | ||||
|      */ | ||||
|     public function getResizeMode(); | ||||
| 
 | ||||
|     /** | ||||
|      * Returns the frame rate | ||||
|      * | ||||
|      * @return integer | ||||
|      */ | ||||
|     public function getFrameRate(); | ||||
| 
 | ||||
|     /** | ||||
|      * Returns the video codec | ||||
|  | @ -55,18 +25,4 @@ interface Video extends Audio | |||
|      * @return string | ||||
|      */ | ||||
|     public function getVideoCodec(); | ||||
| 
 | ||||
|     /** | ||||
|      * Returns the GOP size | ||||
|      * | ||||
|      * @return integer | ||||
|      */ | ||||
|     public function getGOPSize(); | ||||
| 
 | ||||
|     /** | ||||
|      * Returns the list of available video codecs for this format | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
|     public function getAvailableVideoCodecs(); | ||||
| } | ||||
|  |  | |||
|  | @ -9,8 +9,9 @@ | |||
|  * file that was distributed with this source code. | ||||
|  */ | ||||
| 
 | ||||
| namespace FFMpeg\Format; | ||||
| namespace FFMpeg\Format\Video; | ||||
| 
 | ||||
| use FFMpeg\Format\Audio\DefaultAudio; | ||||
| use FFMpeg\Exception\InvalidArgumentException; | ||||
| 
 | ||||
| /** | ||||
|  | @ -18,8 +19,10 @@ use FFMpeg\Exception\InvalidArgumentException; | |||
|  * | ||||
|  * @author Romain Neutron imprec@gmail.com | ||||
|  */ | ||||
| abstract class DefaultVideo extends DefaultAudio implements Video | ||||
| abstract class DefaultVideo extends DefaultAudio implements InteractiveVideo, ResamplableVideo, ResizableVideo | ||||
| { | ||||
|     const RESIZEMODE_FIT = 'fit'; | ||||
|     const RESIZEMODE_INSET = 'inset'; | ||||
| 
 | ||||
|     protected $width; | ||||
|     protected $height; | ||||
|  | @ -67,6 +70,34 @@ abstract class DefaultVideo extends DefaultAudio implements Video | |||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * {@inheritdoc) | ||||
|      */ | ||||
|     public function getComputedDimensions($originalWidth, $originalHeight) | ||||
|     { | ||||
|         switch ($this->getResizeMode()) { | ||||
|             case self::RESIZEMODE_INSET: | ||||
|                 $originalRatio = $originalWidth / $originalHeight; | ||||
|                 $targetRatio = $this->width / $this->height; | ||||
| 
 | ||||
|                 if ($targetRatio > $originalRatio) { | ||||
|                     $height = $this->height; | ||||
|                     $width = round($originalRatio * $this->height); | ||||
|                 } else { | ||||
|                     $width = $this->width; | ||||
|                     $height = round($this->width / $originalRatio); | ||||
|                 } | ||||
|                 break; | ||||
|             case self::RESIZEMODE_FIT: | ||||
|             default: | ||||
|                 $width = $this->width; | ||||
|                 $height = $this->height; | ||||
|                 break; | ||||
|         } | ||||
| 
 | ||||
|         return array($width, $height); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Set the resize mode | ||||
|      * | ||||
							
								
								
									
										32
									
								
								src/FFMpeg/Format/Video/InteractiveVideo.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/FFMpeg/Format/Video/InteractiveVideo.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,32 @@ | |||
| <?php | ||||
| 
 | ||||
| /* | ||||
|  * This file is part of PHP-FFmpeg. | ||||
|  * | ||||
|  * (c) Alchemy <info@alchemy.fr> | ||||
|  * | ||||
|  * For the full copyright and license information, please view the LICENSE | ||||
|  * file that was distributed with this source code. | ||||
|  */ | ||||
| 
 | ||||
| namespace FFMpeg\Format\Video; | ||||
| 
 | ||||
| use FFMpeg\Format\Video as BaseVideo; | ||||
| 
 | ||||
| /** | ||||
|  * The interactive video interface. This provide a method to list available  | ||||
|  * codecs. This is usefull to build interactive development and switch between | ||||
|  * different codecs | ||||
|  *  | ||||
|  * @author Romain Neutron imprec@gmail.com | ||||
|  */ | ||||
| interface InteractiveVideo extends BaseVideo | ||||
| { | ||||
| 
 | ||||
|     /** | ||||
|      * Returns the list of available video codecs for this format | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
|     public function getAvailableVideoCodecs(); | ||||
| } | ||||
|  | @ -11,8 +11,6 @@ | |||
| 
 | ||||
| namespace FFMpeg\Format\Video; | ||||
| 
 | ||||
| use FFMpeg\Format\DefaultVideo; | ||||
| 
 | ||||
| /** | ||||
|  * The Ogg video format | ||||
|  * | ||||
|  |  | |||
							
								
								
									
										39
									
								
								src/FFMpeg/Format/Video/ResamplableVideo.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								src/FFMpeg/Format/Video/ResamplableVideo.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,39 @@ | |||
| <?php | ||||
| 
 | ||||
| /* | ||||
|  * This file is part of PHP-FFmpeg. | ||||
|  * | ||||
|  * (c) Alchemy <info@alchemy.fr> | ||||
|  * | ||||
|  * For the full copyright and license information, please view the LICENSE | ||||
|  * file that was distributed with this source code. | ||||
|  */ | ||||
| 
 | ||||
| namespace FFMpeg\Format\Video; | ||||
| 
 | ||||
| use FFMpeg\Format\Video as BaseVideo; | ||||
| 
 | ||||
| /** | ||||
|  * The resamplable video interface | ||||
|  *  | ||||
|  * This interface provides frame rate and GOP size settings for video encoding | ||||
|  *  | ||||
|  * @author Romain Neutron imprec@gmail.com | ||||
|  */ | ||||
| interface ResamplableVideo extends BaseVideo | ||||
| { | ||||
| 
 | ||||
|     /** | ||||
|      * Returns the frame rate | ||||
|      * | ||||
|      * @return integer | ||||
|      */ | ||||
|     public function getFrameRate(); | ||||
| 
 | ||||
|     /** | ||||
|      * Returns the GOP size | ||||
|      * | ||||
|      * @return integer | ||||
|      */ | ||||
|     public function getGOPSize(); | ||||
| } | ||||
							
								
								
									
										58
									
								
								src/FFMpeg/Format/Video/ResizableVideo.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								src/FFMpeg/Format/Video/ResizableVideo.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,58 @@ | |||
| <?php | ||||
| 
 | ||||
| /* | ||||
|  * This file is part of PHP-FFmpeg. | ||||
|  * | ||||
|  * (c) Alchemy <info@alchemy.fr> | ||||
|  * | ||||
|  * For the full copyright and license information, please view the LICENSE | ||||
|  * file that was distributed with this source code. | ||||
|  */ | ||||
| 
 | ||||
| namespace FFMpeg\Format\Video; | ||||
| 
 | ||||
| use FFMpeg\Format\Video as BaseVideo; | ||||
| 
 | ||||
| /** | ||||
|  * The resizable video interface | ||||
|  *  | ||||
|  * This interface provides methods for video resizing. | ||||
|  *  | ||||
|  * @author Romain Neutron imprec@gmail.com | ||||
|  */ | ||||
| interface ResizableVideo extends BaseVideo | ||||
| { | ||||
| 
 | ||||
|     /** | ||||
|      * Returns the width setting.  | ||||
|      * The return of this method should not depend on a media file size | ||||
|      * | ||||
|      * @return integer | ||||
|      */ | ||||
|     public function getWidth(); | ||||
| 
 | ||||
|     /** | ||||
|      * Returns the height setting | ||||
|      * The return of this method should not depend on a media file size | ||||
|      * | ||||
|      * @return integer | ||||
|      */ | ||||
|     public function getHeight(); | ||||
| 
 | ||||
|     /** | ||||
|      * Returns the computed dimensions for the resize, after operation. | ||||
|      * This method return the actual dimensions that FFmpeg will use. | ||||
|      * | ||||
|      * @param  integer $originalWidth | ||||
|      * @param  integer $originalHeight | ||||
|      * @return array   An indexed array containing the width and the height | ||||
|      */ | ||||
|     public function getComputedDimensions($originalWidth, $originalHeight); | ||||
| 
 | ||||
|     /** | ||||
|      * Get the current resize mode name | ||||
|      * | ||||
|      * @return string | ||||
|      */ | ||||
|     public function getResizeMode(); | ||||
| } | ||||
|  | @ -11,8 +11,6 @@ | |||
| 
 | ||||
| namespace FFMpeg\Format\Video; | ||||
| 
 | ||||
| use FFMpeg\Format\DefaultVideo; | ||||
| 
 | ||||
| /** | ||||
|  * The WebM video format | ||||
|  * | ||||
|  |  | |||
|  | @ -11,8 +11,6 @@ | |||
| 
 | ||||
| namespace FFMpeg\Format\Video; | ||||
| 
 | ||||
| use FFMpeg\Format\DefaultVideo; | ||||
| 
 | ||||
| /** | ||||
|  * The X264 video format | ||||
|  * | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue