Rename Interfaces
This commit is contained in:
parent
7003cdd1a9
commit
b1e6eeaf95
14 changed files with 238 additions and 76 deletions
115
src/FFMpeg/Format/Audio/DefaultAudio.php
Normal file
115
src/FFMpeg/Format/Audio/DefaultAudio.php
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
<?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\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* The abstract default Audio format
|
||||
*
|
||||
* @author Romain Neutron imprec@gmail.com
|
||||
*/
|
||||
abstract class DefaultAudio implements ResamplableAudio, InteractiveAudio
|
||||
{
|
||||
protected $audioCodec;
|
||||
protected $audioSampleRate = 44100;
|
||||
protected $kiloBitrate = 128;
|
||||
|
||||
/**
|
||||
* Returns extra parameters for the encoding
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExtraParams()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
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())) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'Wrong audiocodec value for %s, available formats are %s'
|
||||
, $audioCodec, implode(', ', $this->getAvailableAudioCodecs())
|
||||
));
|
||||
}
|
||||
|
||||
$this->audioCodec = $audioCodec;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAudioSampleRate()
|
||||
{
|
||||
return $this->audioSampleRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the audio sample rate
|
||||
*
|
||||
* @param integer $audioSampleRate
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setAudioSampleRate($audioSampleRate)
|
||||
{
|
||||
if ($audioSampleRate < 1) {
|
||||
throw new InvalidArgumentException('Wrong audio sample rate value');
|
||||
}
|
||||
|
||||
$this->audioSampleRate = (int) $audioSampleRate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getKiloBitrate()
|
||||
{
|
||||
return $this->kiloBitrate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the kiloBitrate value
|
||||
*
|
||||
* @param int integer $kiloBitrate
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setKiloBitrate($kiloBitrate)
|
||||
{
|
||||
if ($kiloBitrate < 1) {
|
||||
throw new InvalidArgumentException('Wrong kiloBitrate value');
|
||||
}
|
||||
|
||||
$this->kiloBitrate = (int) $kiloBitrate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue