Commit 5ddeb6cd authored by Guillaume BIENKOWSKI's avatar Guillaume BIENKOWSKI

Switched to tabs. No code change, just indentation.

parent c6087cfd
......@@ -29,19 +29,20 @@
#define ISAC_SAMPLES_PER_ENCODE 160
typedef enum {
ISAC_60MS_SAMPLE_COUNT = 960,
ISAC_30MS_SAMPLE_COUNT = 480
ISAC_60MS_SAMPLE_COUNT = 960,
ISAC_30MS_SAMPLE_COUNT = 480
} isac_sample_count_e;
/* This enum is to be used in WebRtcIsacfix_EncoderInit() */
typedef enum {
/* In this mode, the bitrate and ptime are adjusted according to statistics
provided by the user through the WebRtcIsacfix_UpdateBwEstimate*() functions */
CODING_AUTOMATIC,
/* Setup the encoder so that bitrate and ptime are controlled by calls to
WebRtcIsacFix_Encode(). This means the user is in charge of evaluating
the correct set of parameters for optimal call quality. */
CODING_USERDEFINED
/* In this mode, the bitrate and ptime are adjusted according to statistics
* provided by the user through the WebRtcIsacfix_UpdateBwEstimate*()
* functions */
CODING_AUTOMATIC,
/* Setup the encoder so that bitrate and ptime are controlled by calls to
* WebRtcIsacFix_Encode(). This means the user is in charge of evaluating
* the correct set of parameters for optimal call quality. */
CODING_USERDEFINED
} isac_codingmode_e;
#define ISAC_BITRATE_MAX 32000
......
......@@ -30,177 +30,177 @@
/*filter common method*/
struct _isac_decoder_struct_t {
ISACFIX_MainStruct* isac;
ISACFIX_MainStruct* isac;
MSConcealerContext* plc_ctx;
unsigned short int seq_nb;
unsigned int ptime;
MSConcealerContext* plc_ctx;
unsigned short int seq_nb;
unsigned int ptime;
};
typedef struct _isac_decoder_struct_t isac_decoder_t;
static void filter_init(MSFilter *f){
ISACFIX_MainStruct* isac_mainstruct = NULL;
isac_decoder_t *obj = NULL;
int instance_size;
WebRtc_Word16 ret;
f->data = ms_new0(isac_decoder_t, 1);
obj = (isac_decoder_t*)f->data;
ret = WebRtcIsacfix_AssignSize( &instance_size );
if( ret ) {
ms_error("WebRtcIsacfix_AssignSize returned size %d", instance_size);
}
isac_mainstruct = ms_malloc(instance_size);
ret = WebRtcIsacfix_Assign(&obj->isac, isac_mainstruct);
if( ret ) {
ms_error("WebRtcIsacfix_Create failed (%d)", ret);
}
ret = WebRtcIsacfix_DecoderInit(obj->isac);
if( ret ) {
ms_error("WebRtcIsacfix_DecoderInit failed (%d)", ret);
}
obj->ptime = 30; // default ptime is 30ms per packet
ISACFIX_MainStruct* isac_mainstruct = NULL;
isac_decoder_t *obj = NULL;
int instance_size;
WebRtc_Word16 ret;
f->data = ms_new0(isac_decoder_t, 1);
obj = (isac_decoder_t*)f->data;
ret = WebRtcIsacfix_AssignSize( &instance_size );
if( ret ) {
ms_error("WebRtcIsacfix_AssignSize returned size %d", instance_size);
}
isac_mainstruct = ms_malloc(instance_size);
ret = WebRtcIsacfix_Assign(&obj->isac, isac_mainstruct);
if( ret ) {
ms_error("WebRtcIsacfix_Create failed (%d)", ret);
}
ret = WebRtcIsacfix_DecoderInit(obj->isac);
if( ret ) {
ms_error("WebRtcIsacfix_DecoderInit failed (%d)", ret);
}
obj->ptime = 30; // default ptime is 30ms per packet
}
static void filter_preprocess(MSFilter *f){
isac_decoder_t* obj = (isac_decoder_t*)f->data;
obj->plc_ctx = ms_concealer_context_new(UINT32_MAX);
isac_decoder_t* obj = (isac_decoder_t*)f->data;
obj->plc_ctx = ms_concealer_context_new(UINT32_MAX);
}
static void decode(MSFilter *f, mblk_t *im) {
isac_decoder_t* obj = (isac_decoder_t*)f->data;
WebRtc_Word16 samples_nb, ret;
WebRtc_Word16 speech_type; // needed but not used..
// im is one packet from the encoder, so it's either 30 or 60 ms of audio
ret = WebRtcIsacfix_ReadFrameLen( (const WebRtc_Word16*)im->b_rptr, &samples_nb);
// ms_message("WebRtcIsacfix_ReadFrameLen -> %d", samples_nb);
if( ret == 0 ) {
mblk_t *om = allocb(samples_nb*2, 0);
mblk_meta_copy(im, om);
obj->ptime = (samples_nb == ISAC_30MS_SAMPLE_COUNT) ? 30 : 60; // update ptime
// ms_message("DECODED om datap @%p", om->b_datap);
ret = WebRtcIsacfix_Decode(obj->isac,
(const WebRtc_UWord16*)im->b_rptr,
(im->b_wptr - im->b_rptr),
(WebRtc_Word16*)om->b_wptr,
&speech_type );
if( ret < 0 ) {
ms_error( "WebRtcIsacfix_Decode error: %d", WebRtcIsacfix_GetErrorCode(obj->isac) );
freeb(om);
} else {
// ms_message("Decoded %d samples", ret);
om->b_wptr+= ret*2;
mblk_set_plc_flag(om, 0);
ms_queue_put(f->outputs[0], om);
}
} else {
ms_error( "WebRtcIsacfix_ReadFrameLen failed: %d", WebRtcIsacfix_GetErrorCode(obj->isac) );
}
obj->seq_nb = mblk_get_cseq(im);
ms_concealer_inc_sample_time(obj->plc_ctx, f->ticker->time, obj->ptime, TRUE);
return;
isac_decoder_t* obj = (isac_decoder_t*)f->data;
WebRtc_Word16 samples_nb, ret;
WebRtc_Word16 speech_type; // needed but not used..
// im is one packet from the encoder, so it's either 30 or 60 ms of audio
ret = WebRtcIsacfix_ReadFrameLen( (const WebRtc_Word16*)im->b_rptr, &samples_nb);
// ms_message("WebRtcIsacfix_ReadFrameLen -> %d", samples_nb);
if( ret == 0 ) {
mblk_t *om = allocb(samples_nb*2, 0);
mblk_meta_copy(im, om);
obj->ptime = (samples_nb == ISAC_30MS_SAMPLE_COUNT) ? 30 : 60; // update ptime
// ms_message("DECODED om datap @%p", om->b_datap);
ret = WebRtcIsacfix_Decode(obj->isac,
(const WebRtc_UWord16*)im->b_rptr,
(im->b_wptr - im->b_rptr),
(WebRtc_Word16*)om->b_wptr,
&speech_type );
if( ret < 0 ) {
ms_error( "WebRtcIsacfix_Decode error: %d", WebRtcIsacfix_GetErrorCode(obj->isac) );
freeb(om);
} else {
// ms_message("Decoded %d samples", ret);
om->b_wptr+= ret*2;
mblk_set_plc_flag(om, 0);
ms_queue_put(f->outputs[0], om);
}
} else {
ms_error( "WebRtcIsacfix_ReadFrameLen failed: %d", WebRtcIsacfix_GetErrorCode(obj->isac) );
}
obj->seq_nb = mblk_get_cseq(im);
ms_concealer_inc_sample_time(obj->plc_ctx, f->ticker->time, obj->ptime, TRUE);
return;
}
static void filter_process(MSFilter *f){
isac_decoder_t* obj = (isac_decoder_t*)f->data;
mblk_t* im;
int count = 0;
isac_decoder_t* obj = (isac_decoder_t*)f->data;
mblk_t* im;
int count = 0;
im = ms_queue_get( f->inputs[0] );
while( im != NULL ){
decode(f, im);
freemsg(im);
count++;
im = ms_queue_get( f->inputs[0] );
}
im = ms_queue_get( f->inputs[0] );
while( im != NULL ){
decode(f, im);
freemsg(im);
count++;
im = ms_queue_get( f->inputs[0] );
}
if( ms_concealer_context_is_concealement_required(obj->plc_ctx, f->ticker->time) ) {
if( ms_concealer_context_is_concealement_required(obj->plc_ctx, f->ticker->time) ) {
WebRtc_Word16 flen = (obj->ptime == 30) ? ISAC_30MS_SAMPLE_COUNT
: ISAC_60MS_SAMPLE_COUNT;
mblk_t* plc_blk = allocb(flen*2, 0 );
// ms_message("PLC for %d ms", obj->ptime);
WebRtc_Word16 flen = (obj->ptime == 30) ? ISAC_30MS_SAMPLE_COUNT
: ISAC_60MS_SAMPLE_COUNT;
mblk_t* plc_blk = allocb(flen*2, 0 );
// ms_message("PLC for %d ms", obj->ptime);
// interpolate 1 frame for 30ms ptime, 2 frames for 60ms
WebRtc_Word16 ret = WebRtcIsacfix_DecodePlc(obj->isac,
(WebRtc_Word16*)plc_blk->b_wptr,
(obj->ptime == 30) ? 1 : 2);
// interpolate 1 frame for 30ms ptime, 2 frames for 60ms
WebRtc_Word16 ret = WebRtcIsacfix_DecodePlc(obj->isac,
(WebRtc_Word16*)plc_blk->b_wptr,
(obj->ptime == 30) ? 1 : 2);
if( ret < 0 ) {
if( ret < 0 ) {
ms_error("WebRtcIsacfix_DecodePlc error: %d", WebRtcIsacfix_GetErrorCode(obj->isac) );
freeb(plc_blk);
ms_error("WebRtcIsacfix_DecodePlc error: %d", WebRtcIsacfix_GetErrorCode(obj->isac) );
freeb(plc_blk);
} else {
} else {
plc_blk->b_wptr += ret*2;
obj->seq_nb++;
plc_blk->b_wptr += ret*2;
obj->seq_nb++;
// insert this interpolated block into the output, with correct args:
mblk_set_cseq(plc_blk, obj->seq_nb );
mblk_set_plc_flag(plc_blk, 1); // this one's a PLC packet
// insert this interpolated block into the output, with correct args:
mblk_set_cseq(plc_blk, obj->seq_nb );
mblk_set_plc_flag(plc_blk, 1); // this one's a PLC packet
ms_queue_put(f->outputs[0], plc_blk);
ms_queue_put(f->outputs[0], plc_blk);
ms_concealer_inc_sample_time(obj->plc_ctx, f->ticker->time, obj->ptime, FALSE);
ms_concealer_inc_sample_time(obj->plc_ctx, f->ticker->time, obj->ptime, FALSE);
}
}
}
}
}
static void filter_postprocess(MSFilter *f){
isac_decoder_t* obj = (isac_decoder_t*)f->data;
ms_concealer_context_destroy(obj->plc_ctx);
obj->plc_ctx = NULL;
isac_decoder_t* obj = (isac_decoder_t*)f->data;
ms_concealer_context_destroy(obj->plc_ctx);
obj->plc_ctx = NULL;
}
static void filter_uninit(MSFilter *f){
isac_decoder_t* obj = (isac_decoder_t*)f->data;
ms_free(obj->isac);
ms_free(f->data);
f->data = NULL;
isac_decoder_t* obj = (isac_decoder_t*)f->data;
ms_free(obj->isac);
ms_free(f->data);
f->data = NULL;
}
/*filter specific method*/
static int filter_set_sample_rate(MSFilter *f, void *arg) {
if( *(int*)arg != ISAC_SAMPLE_RATE) {
ms_error("iSAC doesn't support sampling rate %d, only %d",
*(int*)arg, ISAC_SAMPLE_RATE);
}
return 0;
if( *(int*)arg != ISAC_SAMPLE_RATE) {
ms_error("iSAC doesn't support sampling rate %d, only %d",
*(int*)arg, ISAC_SAMPLE_RATE);
}
return 0;
}
static int filter_get_sample_rate(MSFilter *f, void *arg) {
*(int*)arg = ISAC_SAMPLE_RATE;
return 0;
*(int*)arg = ISAC_SAMPLE_RATE;
return 0;
}
static int filter_have_plc(MSFilter *f, void *arg)
{
*(int*)arg = 1;
return 0;
*(int*)arg = 1;
return 0;
}
static MSFilterMethod filter_methods[]={
{ MS_FILTER_SET_SAMPLE_RATE, filter_set_sample_rate },
{ MS_FILTER_GET_SAMPLE_RATE, filter_get_sample_rate },
{ MS_DECODER_HAVE_PLC, filter_have_plc },
{ 0, NULL}
{ MS_FILTER_SET_SAMPLE_RATE, filter_set_sample_rate },
{ MS_FILTER_GET_SAMPLE_RATE, filter_get_sample_rate },
{ MS_DECODER_HAVE_PLC, filter_have_plc },
{ 0, NULL}
};
......@@ -208,39 +208,39 @@ static MSFilterMethod filter_methods[]={
#ifdef _MSC_VER
MSFilterDesc ms_isac_dec_desc={
MS_FILTER_PLUGIN_ID, /* from Allfilters.h*/
"MSiSACDec",
"isac decoder filter.",
MS_FILTER_DECODER,
"iSAC",
1, /*number of inputs*/
1, /*number of outputs*/
filter_init,
filter_preprocess,
filter_process,
filter_postprocess,
filter_uninit,
filter_methods,
MS_FILTER_IS_PUMP
MS_FILTER_PLUGIN_ID, /* from Allfilters.h*/
"MSiSACDec",
"isac decoder filter.",
MS_FILTER_DECODER,
"iSAC",
1, /*number of inputs*/
1, /*number of outputs*/
filter_init,
filter_preprocess,
filter_process,
filter_postprocess,
filter_uninit,
filter_methods,
MS_FILTER_IS_PUMP
};
#else
MSFilterDesc ms_isac_dec_desc={
.id=MS_FILTER_PLUGIN_ID, /* from Allfilters.h*/
.name="MSiSACDec",
.text="iSAC decoder filter.",
.category=MS_FILTER_DECODER,
.enc_fmt="iSAC",
.ninputs=1, /*number of inputs*/
.noutputs=1, /*number of outputs*/
.init=filter_init,
.preprocess=filter_preprocess,
.process=filter_process,
.postprocess=filter_postprocess,
.uninit=filter_uninit,
.methods=filter_methods,
.flags=MS_FILTER_IS_PUMP
.id=MS_FILTER_PLUGIN_ID, /* from Allfilters.h*/
.name="MSiSACDec",
.text="iSAC decoder filter.",
.category=MS_FILTER_DECODER,
.enc_fmt="iSAC",
.ninputs=1, /*number of inputs*/
.noutputs=1, /*number of outputs*/
.init=filter_init,
.preprocess=filter_preprocess,
.process=filter_process,
.postprocess=filter_postprocess,
.uninit=filter_uninit,
.methods=filter_methods,
.flags=MS_FILTER_IS_PUMP
};
#endif
......
......@@ -28,115 +28,115 @@
/*filter common method*/
struct _isac_encoder_struct_t {
ISACFIX_MainStruct* isac;
MSBufferizer *bufferizer;
unsigned int ptime;
unsigned int bitrate;
unsigned int ts;
ISACFIX_MainStruct* isac;
MSBufferizer *bufferizer;
unsigned int ptime;
unsigned int bitrate;
unsigned int ts;
};
typedef struct _isac_encoder_struct_t isac_encoder_struct_t;
static void filter_init ( MSFilter *f ) {
ISACFIX_MainStruct* isac_mainstruct = NULL;
struct _isac_encoder_struct_t *obj = NULL;
int instance_size;
WebRtc_Word16 ret;
ISACFIX_MainStruct* isac_mainstruct = NULL;
struct _isac_encoder_struct_t *obj = NULL;
int instance_size;
WebRtc_Word16 ret;
f->data = ms_new0(isac_encoder_struct_t, 1);
obj = (isac_encoder_struct_t*)f->data;
f->data = ms_new0(isac_encoder_struct_t, 1);
obj = (isac_encoder_struct_t*)f->data;
ret = WebRtcIsacfix_AssignSize( &instance_size );
if( ret ) {
ms_error("WebRtcIsacfix_AssignSize returned size %d", instance_size);
}
isac_mainstruct = ms_malloc0(instance_size);
ret = WebRtcIsacfix_AssignSize( &instance_size );
if( ret ) {
ms_error("WebRtcIsacfix_AssignSize returned size %d", instance_size);
}
isac_mainstruct = ms_malloc0(instance_size);
ret = WebRtcIsacfix_Assign(&obj->isac, isac_mainstruct);
if( ret ) {
ms_error("WebRtcIsacfix_Create failed (%d)", ret);
}
ret = WebRtcIsacfix_Assign(&obj->isac, isac_mainstruct);
if( ret ) {
ms_error("WebRtcIsacfix_Create failed (%d)", ret);
}
// TODO: AUTO or USER coding mode?
ret = WebRtcIsacfix_EncoderInit(obj->isac, CODING_USERDEFINED);
if( ret ) {
ms_error("WebRtcIsacfix_EncoderInit failed (%d)", WebRtcIsacfix_GetErrorCode(obj->isac));
}
// TODO: AUTO or USER coding mode?
ret = WebRtcIsacfix_EncoderInit(obj->isac, CODING_USERDEFINED);
if( ret ) {
ms_error("WebRtcIsacfix_EncoderInit failed (%d)", WebRtcIsacfix_GetErrorCode(obj->isac));
}
obj->ptime = 30; // iSAC allows 30 or 60ms per packet
obj->bitrate = ISAC_BITRATE_MAX;
obj->ptime = 30; // iSAC allows 30 or 60ms per packet
obj->bitrate = ISAC_BITRATE_MAX;
ret = WebRtcIsacfix_Control(obj->isac, obj->bitrate, obj->ptime);
if( ret ) {
ms_error("WebRtcIsacfix_Control failed: %d", WebRtcIsacfix_GetErrorCode(obj->isac));
}
ret = WebRtcIsacfix_Control(obj->isac, obj->bitrate, obj->ptime);
if( ret ) {
ms_error("WebRtcIsacfix_Control failed: %d", WebRtcIsacfix_GetErrorCode(obj->isac));
}
obj->bufferizer = ms_bufferizer_new();
obj->ts = 0;
obj->bufferizer = ms_bufferizer_new();
obj->ts = 0;
}
static void filter_preprocess ( MSFilter *f ) {
}
static void filter_process ( MSFilter *f ) {
isac_encoder_struct_t* obj = (isac_encoder_struct_t*)f->data;
isac_encoder_struct_t* obj = (isac_encoder_struct_t*)f->data;
mblk_t *im;
mblk_t *om=NULL;
u_int8_t* input_buf = NULL;
WebRtc_Word16 ret;
static int out_count = 0;
mblk_t *im;
mblk_t *om=NULL;
u_int8_t* input_buf = NULL;
WebRtc_Word16 ret;
static int out_count = 0;
// get the input data and put it into our buffered input
while( (im = ms_queue_get( f->inputs[0] ) ) != NULL ) {
ms_bufferizer_put( obj->bufferizer, im );
}
// get the input data and put it into our buffered input
while( (im = ms_queue_get( f->inputs[0] ) ) != NULL ) {
ms_bufferizer_put( obj->bufferizer, im );
}
// feed the encoder with 160 16bit samples, until it has reached enough data
// to produce a packet
while( ms_bufferizer_get_avail(obj->bufferizer) > ISAC_SAMPLES_PER_ENCODE*2 ){
// feed the encoder with 160 16bit samples, until it has reached enough data
// to produce a packet
while( ms_bufferizer_get_avail(obj->bufferizer) > ISAC_SAMPLES_PER_ENCODE*2 ){
om = allocb( WebRtcIsacfix_GetNewFrameLen(obj->isac), 0 );
if(!input_buf) input_buf = ms_malloc( ISAC_SAMPLES_PER_ENCODE*2 );
ms_bufferizer_read(obj->bufferizer, input_buf, ISAC_SAMPLES_PER_ENCODE*2);
om = allocb( WebRtcIsacfix_GetNewFrameLen(obj->isac), 0 );
if(!input_buf) input_buf = ms_malloc( ISAC_SAMPLES_PER_ENCODE*2 );
ms_bufferizer_read(obj->bufferizer, input_buf, ISAC_SAMPLES_PER_ENCODE*2);
ret = WebRtcIsacfix_Encode(obj->isac,
(const WebRtc_Word16*)input_buf,
(WebRtc_Word16*)om->b_wptr);
ret = WebRtcIsacfix_Encode(obj->isac,
(const WebRtc_Word16*)input_buf,
(WebRtc_Word16*)om->b_wptr);
if( ret < 0) {
if( ret < 0) {
ms_error( "WebRtcIsacfix_Encode error: %d", WebRtcIsacfix_GetErrorCode(obj->isac) );
freeb(om);
ms_error( "WebRtcIsacfix_Encode error: %d", WebRtcIsacfix_GetErrorCode(obj->isac) );
freeb(om);
} else if( ret == 0 ) {
// Encode() buffered the input, not yet able to produce a packet, continue feeding it
// 160 samples per-call
obj->ts += ISAC_SAMPLES_PER_ENCODE;
freeb(om);
} else if( ret == 0 ) {
// Encode() buffered the input, not yet able to produce a packet, continue feeding it
// 160 samples per-call
obj->ts += ISAC_SAMPLES_PER_ENCODE;
freeb(om);
} else {
} else {
// a new packet has been encoded, send it
obj->ts += ISAC_SAMPLES_PER_ENCODE;
om->b_wptr += ret;
out_count++;
// ms_message("packet %d out, samples %d", out_count, obj->ts);
// a new packet has been encoded, send it
obj->ts += ISAC_SAMPLES_PER_ENCODE;
om->b_wptr += ret;
out_count++;
// ms_message("packet %d out, samples %d", out_count, obj->ts);
mblk_set_timestamp_info( om, obj->ts );
ms_queue_put(f->outputs[0], om);
mblk_set_timestamp_info( om, obj->ts );
ms_queue_put(f->outputs[0], om);
om = NULL;
}
om = NULL;
}
}
}
if( input_buf ){
ms_free(input_buf);
}
if( input_buf ){
ms_free(input_buf);
}
}
static void filter_postprocess ( MSFilter *f ) {
......@@ -144,119 +144,119 @@ static void filter_postprocess ( MSFilter *f ) {
}
static void filter_uninit ( MSFilter *f ) {
struct _isac_encoder_struct_t *encoder = (struct _isac_encoder_struct_t*)f->data;
ms_free(encoder->isac);
ms_bufferizer_destroy(encoder->bufferizer);
ms_free(encoder);
f->data = 0;
struct _isac_encoder_struct_t *encoder = (struct _isac_encoder_struct_t*)f->data;
ms_free(encoder->isac);
ms_bufferizer_destroy(encoder->bufferizer);
ms_free(encoder);
f->data = 0;
}
/*filter specific method*/
static int filter_get_sample_rate ( MSFilter *f, void *arg ) {
*(int*)arg = ISAC_SAMPLE_RATE;
return 0;
*(int*)arg = ISAC_SAMPLE_RATE;
return 0;
}
#ifdef MS_AUDIO_ENCODER_SET_PTIME
static int filter_get_ptime(MSFilter *f, void *arg){
isac_encoder_struct_t* obj= ( isac_encoder_struct_t* ) f->data;
*(int*)arg=obj->ptime;
return 0;
isac_encoder_struct_t* obj= ( isac_encoder_struct_t* ) f->data;
*(int*)arg=obj->ptime;
return 0;
}
static int filter_set_ptime(MSFilter *f, void *arg){
int asked = *(int*)arg;
isac_encoder_struct_t* obj = (isac_encoder_struct_t*)f->data;
int asked = *(int*)arg;
isac_encoder_struct_t* obj = (isac_encoder_struct_t*)f->data;
// iSAC handles only 30 or 60ms ptime
if( asked != 30 && asked != 60 ){
// use the closest
asked = (asked > 45)? 60 : 30;
ms_warning("iSAC doesn't handle %dms ptime, choosing closest: %dms", *(int*)arg, asked);
}
// iSAC handles only 30 or 60ms ptime
if( asked != 30 && asked != 60 ){
// use the closest
asked = (asked > 45)? 60 : 30;
ms_warning("iSAC doesn't handle %dms ptime, choosing closest: %dms", *(int*)arg, asked);
}
obj->ptime = asked;
obj->ptime = asked;
return 0;
return 0;
}
#endif
static int filter_set_bitrate ( MSFilter *f, void *arg ) {
isac_encoder_struct_t *obj = (isac_encoder_struct_t*)f->data;
int wanted_bitrate = *(int*)arg;
isac_encoder_struct_t *obj = (isac_encoder_struct_t*)f->data;
int wanted_bitrate = *(int*)arg;
if( wanted_bitrate > ISAC_BITRATE_MAX ) {
ms_warning("iSAC doesn't handle bitrate > %d (wanted: %d)",
ISAC_BITRATE_MAX, wanted_bitrate );
if( wanted_bitrate > ISAC_BITRATE_MAX ) {
ms_warning("iSAC doesn't handle bitrate > %d (wanted: %d)",
ISAC_BITRATE_MAX, wanted_bitrate );
wanted_bitrate = ISAC_BITRATE_MAX;
wanted_bitrate = ISAC_BITRATE_MAX;
} else if( wanted_bitrate < ISAC_BITRATE_MIN) {
ms_warning("iSAC doesn't handle bitrate < %d (wanted: %d)",
ISAC_BITRATE_MIN, wanted_bitrate );
} else if( wanted_bitrate < ISAC_BITRATE_MIN) {
ms_warning("iSAC doesn't handle bitrate < %d (wanted: %d)",
ISAC_BITRATE_MIN, wanted_bitrate );
wanted_bitrate = ISAC_BITRATE_MIN;
wanted_bitrate = ISAC_BITRATE_MIN;
}
}
return WebRtcIsacfix_SetMaxRate(obj->isac, wanted_bitrate);
return WebRtcIsacfix_SetMaxRate(obj->isac, wanted_bitrate);
}
static int filter_get_bitrate ( MSFilter *f, void *arg ) {
isac_encoder_struct_t *obj = (isac_encoder_struct_t*)f->data;
*(int*)arg = (int)WebRtcIsacfix_GetUplinkBw(obj->isac);
return 0;
isac_encoder_struct_t *obj = (isac_encoder_struct_t*)f->data;
*(int*)arg = (int)WebRtcIsacfix_GetUplinkBw(obj->isac);
return 0;
}
static MSFilterMethod filter_methods[]= {
{MS_FILTER_GET_SAMPLE_RATE, filter_get_sample_rate },
{MS_FILTER_SET_BITRATE, filter_set_bitrate },
{MS_FILTER_GET_BITRATE, filter_get_bitrate },
#ifdef MS_AUDIO_ENCODER_SET_PTIME
{MS_AUDIO_ENCODER_SET_PTIME, filter_set_ptime },
{MS_AUDIO_ENCODER_GET_PTIME, filter_get_ptime },
#endif
{0, NULL}
{MS_FILTER_GET_SAMPLE_RATE, filter_get_sample_rate },
{MS_FILTER_SET_BITRATE, filter_set_bitrate },
{MS_FILTER_GET_BITRATE, filter_get_bitrate },
#ifdef MS_AUDIO_ENCODER_SET_PTIME
{MS_AUDIO_ENCODER_SET_PTIME, filter_set_ptime },
{MS_AUDIO_ENCODER_GET_PTIME, filter_get_ptime },
#endif
{0, NULL}
};
#ifdef _MSC_VER
MSFilterDesc ms_isac_enc_desc= {
MS_FILTER_PLUGIN_ID, /* from Allfilters.h*/
"MSiSACEnc",
"iSAC audio encoder filter.",
MS_FILTER_ENCODER,
"iSAC",
1, /*number of inputs*/
1, /*number of outputs*/
filter_init,
filter_preprocess,
filter_process,
filter_postprocess,
filter_uninit,
filter_methods,
0
MS_FILTER_PLUGIN_ID, /* from Allfilters.h*/
"MSiSACEnc",
</