@ -73,6 +73,8 @@ static const char *avc_encoder_init(encoder_t *enc, const str *);
static int avc_encoder_input ( encoder_t * enc , AVFrame * * frame ) ;
static int avc_encoder_input ( encoder_t * enc , AVFrame * * frame ) ;
static void avc_encoder_close ( encoder_t * enc ) ;
static void avc_encoder_close ( encoder_t * enc ) ;
static const char * g726_encoder_init ( encoder_t * enc , const str * ) ;
static int amr_decoder_input ( decoder_t * dec , const str * data , GQueue * out ) ;
static int amr_decoder_input ( decoder_t * dec , const str * data , GQueue * out ) ;
static void amr_encoder_got_packet ( encoder_t * enc ) ;
static void amr_encoder_got_packet ( encoder_t * enc ) ;
static int ilbc_decoder_input ( decoder_t * dec , const str * data , GQueue * out ) ;
static int ilbc_decoder_input ( decoder_t * dec , const str * data , GQueue * out ) ;
@ -243,6 +245,15 @@ static const codec_type_t codec_type_avcodec = {
. encoder_input = avc_encoder_input ,
. encoder_input = avc_encoder_input ,
. encoder_close = avc_encoder_close ,
. encoder_close = avc_encoder_close ,
} ;
} ;
static const codec_type_t codec_type_g726 = {
. def_init = avc_def_init ,
. decoder_init = avc_decoder_init ,
. decoder_input = avc_decoder_input ,
. decoder_close = avc_decoder_close ,
. encoder_init = g726_encoder_init ,
. encoder_input = avc_encoder_input ,
. encoder_close = avc_encoder_close ,
} ;
static const codec_type_t codec_type_libopus = {
static const codec_type_t codec_type_libopus = {
. decoder_init = libopus_decoder_init ,
. decoder_init = libopus_decoder_init ,
. decoder_input = libopus_decoder_input ,
. decoder_input = libopus_decoder_input ,
@ -773,94 +784,102 @@ static struct codec_def_s __codec_defs[] = {
. format_cmp = format_cmp_ignore ,
. format_cmp = format_cmp_ignore ,
. codec_type = & codec_type_cn ,
. codec_type = & codec_type_cn ,
} ,
} ,
{
{
. rtpname = " G726-16 " ,
. rtpname = " G726-16 " ,
. avcodec_id = AV_CODEC_ID_ADPCM_G726 ,
. avcodec_id = AV_CODEC_ID_ADPCM_G726 ,
. default_clockrate = 8000 ,
. default_clockrate = 8000 ,
. default_channels = 1 ,
. default_channels = 1 ,
. default_ptime = 20 ,
. default_ptime = 20 ,
. minimum_ptime = 20 ,
. minimum_ptime = 20 ,
. default_bitrate = 16000 ,
. default_bitrate = 16000 ,
. packetizer = packetizer_passthrough ,
. packetizer = packetizer_samplestream ,
. media_type = MT_AUDIO ,
. bits_per_sample = 2 ,
. codec_type = & codec_type_avcodec ,
. media_type = MT_AUDIO ,
. dtx_methods = {
. codec_type = & codec_type_g726 ,
[ DTX_SILENCE ] = & dtx_method_silence ,
. dtx_methods = {
[ DTX_CN ] = & dtx_method_cn ,
[ DTX_SILENCE ] = & dtx_method_silence ,
} ,
[ DTX_CN ] = & dtx_method_cn ,
} ,
} ,
{
. fixed_sizes = 1 ,
. rtpname = " G726-24 " ,
} ,
. avcodec_id = AV_CODEC_ID_ADPCM_G726 ,
{
. default_clockrate = 8000 ,
. rtpname = " G726-24 " ,
. default_channels = 1 ,
. avcodec_id = AV_CODEC_ID_ADPCM_G726 ,
. default_ptime = 20 ,
. default_clockrate = 8000 ,
. minimum_ptime = 20 ,
. default_channels = 1 ,
. default_bitrate = 24000 ,
. default_ptime = 20 ,
. packetizer = packetizer_passthrough ,
. minimum_ptime = 20 ,
. media_type = MT_AUDIO ,
. default_bitrate = 24000 ,
. codec_type = & codec_type_avcodec ,
. packetizer = packetizer_samplestream ,
. dtx_methods = {
. bits_per_sample = 3 ,
[ DTX_SILENCE ] = & dtx_method_silence ,
. media_type = MT_AUDIO ,
[ DTX_CN ] = & dtx_method_cn ,
. codec_type = & codec_type_g726 ,
} ,
. dtx_methods = {
} ,
[ DTX_SILENCE ] = & dtx_method_silence ,
{
[ DTX_CN ] = & dtx_method_cn ,
. rtpname = " G726-32 " ,
} ,
. avcodec_id = AV_CODEC_ID_ADPCM_G726 ,
. fixed_sizes = 1 ,
. default_clockrate = 8000 ,
} ,
. default_channels = 1 ,
{
. default_ptime = 20 ,
. rtpname = " G726-32 " ,
. minimum_ptime = 20 ,
. avcodec_id = AV_CODEC_ID_ADPCM_G726 ,
. default_bitrate = 32000 ,
. default_clockrate = 8000 ,
. packetizer = packetizer_passthrough ,
. default_channels = 1 ,
. media_type = MT_AUDIO ,
. default_ptime = 20 ,
. codec_type = & codec_type_avcodec ,
. minimum_ptime = 20 ,
. dtx_methods = {
. default_bitrate = 32000 ,
[ DTX_SILENCE ] = & dtx_method_silence ,
. packetizer = packetizer_samplestream ,
[ DTX_CN ] = & dtx_method_cn ,
. bits_per_sample = 4 ,
} ,
. media_type = MT_AUDIO ,
} ,
. codec_type = & codec_type_g726 ,
{
. dtx_methods = {
. rtpname = " G726-40 " ,
[ DTX_SILENCE ] = & dtx_method_silence ,
. avcodec_id = AV_CODEC_ID_ADPCM_G726 ,
[ DTX_CN ] = & dtx_method_cn ,
. default_clockrate = 8000 ,
} ,
. default_channels = 1 ,
. fixed_sizes = 1 ,
. default_ptime = 20 ,
} ,
. minimum_ptime = 20 ,
{
. default_bitrate = 40000 ,
. rtpname = " G726-40 " ,
. packetizer = packetizer_passthrough ,
. avcodec_id = AV_CODEC_ID_ADPCM_G726 ,
. media_type = MT_AUDIO ,
. default_clockrate = 8000 ,
. codec_type = & codec_type_avcodec ,
. default_channels = 1 ,
. dtx_methods = {
. default_ptime = 20 ,
[ DTX_SILENCE ] = & dtx_method_silence ,
. minimum_ptime = 20 ,
[ DTX_CN ] = & dtx_method_cn ,
. default_bitrate = 40000 ,
} ,
. packetizer = packetizer_samplestream ,
} ,
. bits_per_sample = 5 ,
{
. media_type = MT_AUDIO ,
. rtpname = " L16 " ,
. codec_type = & codec_type_g726 ,
. avcodec_id = AV_CODEC_ID_PCM_S16BE ,
. dtx_methods = {
. default_clockrate = 44100 ,
[ DTX_SILENCE ] = & dtx_method_silence ,
. default_channels = 1 ,
[ DTX_CN ] = & dtx_method_cn ,
. default_ptime = 20 ,
} ,
. minimum_ptime = 20 ,
. fixed_sizes = 1 ,
. bits_per_sample = 16 ,
} ,
. packetizer = packetizer_passthrough ,
{
. media_type = MT_AUDIO ,
. rtpname = " L16 " ,
. codec_type = & codec_type_avcodec ,
. avcodec_id = AV_CODEC_ID_PCM_S16BE ,
} ,
. default_clockrate = 44100 ,
{
. default_channels = 1 ,
. rtpname = " X-L16 " ,
. default_ptime = 20 ,
. avcodec_id = AV_CODEC_ID_PCM_S16LE ,
. minimum_ptime = 20 ,
. default_clockrate = 44100 ,
. bits_per_sample = 16 ,
. default_channels = 1 ,
. packetizer = packetizer_passthrough ,
. default_ptime = 20 ,
. media_type = MT_AUDIO ,
. minimum_ptime = 20 ,
. codec_type = & codec_type_avcodec ,
. bits_per_sample = 16 ,
} ,
. packetizer = packetizer_passthrough ,
{
. media_type = MT_AUDIO ,
. rtpname = " X-L16 " ,
. codec_type = & codec_type_avcodec ,
. avcodec_id = AV_CODEC_ID_PCM_S16LE ,
} ,
. default_clockrate = 44100 ,
. default_channels = 1 ,
. default_ptime = 20 ,
. minimum_ptime = 20 ,
. bits_per_sample = 16 ,
. packetizer = packetizer_passthrough ,
. media_type = MT_AUDIO ,
. codec_type = & codec_type_avcodec ,
} ,
// for file reading and writing
// for file reading and writing
{
{
. rtpname = " PCM-U8 " ,
. rtpname = " PCM-U8 " ,
@ -1891,6 +1910,16 @@ static const char *avc_encoder_init(encoder_t *enc, const str *extra_opts) {
return NULL ;
return NULL ;
}
}
static const char * g726_encoder_init ( encoder_t * enc , const str * extra_opts ) {
const char * err = avc_encoder_init ( enc , extra_opts ) ;
if ( err )
return err ;
enc - > samples_per_packet = enc - > ptime * 8 ;
return NULL ;
}
int encoder_config ( encoder_t * enc , codec_def_t * def , int bitrate , int ptime ,
int encoder_config ( encoder_t * enc , codec_def_t * def , int bitrate , int ptime ,
const format_t * requested_format , format_t * actual_format )
const format_t * requested_format , format_t * actual_format )
{
{