Commit aae23a85 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Add stereo support to the L16 encoder.

parent 18a6f4d8
...@@ -464,14 +464,13 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char ...@@ -464,14 +464,13 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char
/* need to add resampler*/ /* need to add resampler*/
if (stream->read_resampler == NULL) stream->read_resampler=ms_filter_new(MS_RESAMPLE_ID); if (stream->read_resampler == NULL) stream->read_resampler=ms_filter_new(MS_RESAMPLE_ID);
} }
ms_filter_call_method(stream->soundread,MS_FILTER_SET_NCHANNELS,&pt->channels);
if (ms_filter_call_method(stream->soundwrite,MS_FILTER_SET_SAMPLE_RATE,&sample_rate) != 0) { if (ms_filter_call_method(stream->soundwrite,MS_FILTER_SET_SAMPLE_RATE,&sample_rate) != 0) {
/* need to add resampler*/ /* need to add resampler*/
if (stream->write_resampler == NULL) stream->write_resampler=ms_filter_new(MS_RESAMPLE_ID); if (stream->write_resampler == NULL) stream->write_resampler=ms_filter_new(MS_RESAMPLE_ID);
} }
ms_filter_call_method(stream->soundwrite,MS_FILTER_SET_NCHANNELS,&pt->channels);
tmp=1;
ms_filter_call_method(stream->soundwrite,MS_FILTER_SET_NCHANNELS, &tmp);
// Override feature // Override feature
if ((stream->features & AUDIO_STREAM_FEATURE_EC) && !use_ec) if ((stream->features & AUDIO_STREAM_FEATURE_EC) && !use_ec)
...@@ -493,7 +492,9 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char ...@@ -493,7 +492,9 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char
ms_message("Setting audio encoder network bitrate to %i",pt->normal_bitrate); ms_message("Setting audio encoder network bitrate to %i",pt->normal_bitrate);
ms_filter_call_method(stream->encoder,MS_FILTER_SET_BITRATE,&pt->normal_bitrate); ms_filter_call_method(stream->encoder,MS_FILTER_SET_BITRATE,&pt->normal_bitrate);
} }
ms_filter_call_method(stream->encoder,MS_FILTER_SET_NCHANNELS,&pt->channels);
ms_filter_call_method(stream->decoder,MS_FILTER_SET_SAMPLE_RATE,&pt->clock_rate); ms_filter_call_method(stream->decoder,MS_FILTER_SET_SAMPLE_RATE,&pt->clock_rate);
ms_filter_call_method(stream->decoder,MS_FILTER_SET_NCHANNELS,&pt->channels);
if (pt->send_fmtp!=NULL) ms_filter_call_method(stream->encoder,MS_FILTER_ADD_FMTP, (void*)pt->send_fmtp); if (pt->send_fmtp!=NULL) ms_filter_call_method(stream->encoder,MS_FILTER_ADD_FMTP, (void*)pt->send_fmtp);
if (pt->recv_fmtp!=NULL) ms_filter_call_method(stream->decoder,MS_FILTER_ADD_FMTP,(void*)pt->recv_fmtp); if (pt->recv_fmtp!=NULL) ms_filter_call_method(stream->decoder,MS_FILTER_ADD_FMTP,(void*)pt->recv_fmtp);
......
...@@ -24,6 +24,7 @@ struct EncState { ...@@ -24,6 +24,7 @@ struct EncState {
uint32_t ts; uint32_t ts;
int ptime; int ptime;
int rate; int rate;
int nchannels;
int nbytes; int nbytes;
MSBufferizer *bufferizer; MSBufferizer *bufferizer;
}; };
...@@ -35,6 +36,7 @@ static void enc_init(MSFilter *f) ...@@ -35,6 +36,7 @@ static void enc_init(MSFilter *f)
s->bufferizer=ms_bufferizer_new(); s->bufferizer=ms_bufferizer_new();
s->ptime = 20; s->ptime = 20;
s->rate=8000; s->rate=8000;
s->nchannels = 1;
f->data=s; f->data=s;
}; };
...@@ -48,7 +50,7 @@ static void enc_uninit(MSFilter *f) ...@@ -48,7 +50,7 @@ static void enc_uninit(MSFilter *f)
static void enc_preprocess(MSFilter *f){ static void enc_preprocess(MSFilter *f){
struct EncState *s=(struct EncState*)f->data; struct EncState *s=(struct EncState*)f->data;
s->nbytes=(2*s->rate*s->ptime)/1000; s->nbytes=(2*s->nchannels*s->rate*s->ptime)/1000;
} }
static void enc_process(MSFilter *f) static void enc_process(MSFilter *f)
...@@ -62,7 +64,7 @@ static void enc_process(MSFilter *f) ...@@ -62,7 +64,7 @@ static void enc_process(MSFilter *f)
om->b_wptr+=ms_bufferizer_read(s->bufferizer,om->b_wptr,s->nbytes); om->b_wptr+=ms_bufferizer_read(s->bufferizer,om->b_wptr,s->nbytes);
mblk_set_timestamp_info(om,s->ts); mblk_set_timestamp_info(om,s->ts);
ms_queue_put(f->outputs[0],om); ms_queue_put(f->outputs[0],om);
s->ts += s->nbytes/2; s->ts += s->nbytes/(2*s->nchannels);
} }
}; };
...@@ -98,10 +100,17 @@ static int enc_set_sr(MSFilter *f, void *arg){ ...@@ -98,10 +100,17 @@ static int enc_set_sr(MSFilter *f, void *arg){
return 0; return 0;
} }
static int enc_set_nchannels(MSFilter *f, void *arg) {
struct EncState *s = (struct EncState *)f->data;
s->nchannels = *(int *)arg;
return 0;
}
static MSFilterMethod enc_methods[]={ static MSFilterMethod enc_methods[]={
{ MS_FILTER_ADD_ATTR , enc_add_attr}, { MS_FILTER_ADD_ATTR , enc_add_attr},
{ MS_FILTER_ADD_FMTP , enc_add_fmtp}, { MS_FILTER_ADD_FMTP , enc_add_fmtp},
{ MS_FILTER_SET_SAMPLE_RATE , enc_set_sr }, { MS_FILTER_SET_SAMPLE_RATE , enc_set_sr },
{ MS_FILTER_SET_NCHANNELS , enc_set_nchannels},
{ 0 , NULL } { 0 , NULL }
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment