Commit ddb7c6ea authored by Simon Morlat's avatar Simon Morlat

add fatal message if AudioStream is required to operate without resampler and resampling is needed.

parent 82704810
......@@ -56,13 +56,12 @@ static int enc_set_ptime(MSFilter *f, void* arg){
EncState *s=(EncState*)f->data;
s->ptime=*(int*)arg;
if (s->ptime > s->max_ptime) {
s->ptime=s->max_ptime;
}
else if (s->ptime%5) {
s->ptime=s->max_ptime;
} else if (s->ptime%5) {
//if the ptime is not a mulptiple of 5, go to the next multiple
s->ptime = s->ptime - s->ptime%5 + 5;
}
ms_message("MSBV16Enc: got ptime=%i ", s->ptime);
ms_message("MSBV16Enc: got ptime=%i ", s->ptime);
return 0;
}
......@@ -80,27 +79,26 @@ static int enc_add_fmtp(MSFilter *f, void *arg){
tmp[0] = '\0';
if (fmtp_get_value(fmtp,"maxptime:",tmp,sizeof(tmp))){
s->max_ptime=atoi(tmp);
if (s->max_ptime <10 || s->max_ptime >100 ) {
if (s->max_ptime < 10 || s->max_ptime > 100 ) {
ms_warning("MSBV16Enc: unknown value [%i] for maxptime, use default value (100) instead",s->max_ptime);
s->max_ptime=100;
}
ms_message("MSBV16Enc: got maxptime=%i",s->max_ptime);
}
else if (fmtp_get_value(fmtp,"ptime",tmp,sizeof(tmp))){
}else if (fmtp_get_value(fmtp,"ptime",tmp,sizeof(tmp))){
int val = atoi(tmp);
return enc_set_ptime(f,&val);
}
return enc_set_ptime(f,&val);
}
return 0;
}
static int enc_add_attr(MSFilter *f, void *arg){
const char *attr=(const char *)arg;
const char *attr=(const char *)arg;
ms_message("MSBV16Enc: enc_add_attr %s", attr);
if (strstr(attr,"ptime:")!=NULL){
int ptime = atoi(attr+6);
return enc_set_ptime(f,&ptime);
}
if (strstr(attr,"ptime:")!=NULL){
int ptime = atoi(attr+6);
return enc_set_ptime(f,&ptime);
}
return 0;
}
......@@ -135,7 +133,7 @@ static void enc_uninit(MSFilter *f){
}
/***
Encodes 8 kHz-sampled narrowband speech at a bit rate of or 16 kbit/s,
Encodes 8 kHz-sampled narrowband speech at a bit rate of or 16 kbit/s,
uses 5 ms frames.
The encoder receives 10 ms speech => 160 bytes.
***/
......@@ -171,8 +169,7 @@ static void enc_process (MSFilter *f){
ms_bufferizer_fill_current_metas(s->bufferizer, outputMessage);
ms_queue_put(f->outputs[0],outputMessage);
s->ts += FRSZ * frame_per_packet;
}
}
}
......@@ -247,7 +244,6 @@ static void dec_preprocess(MSFilter* f){
}else {
s->concealer = NULL;
}
}
static void dec_postprocess(MSFilter* f ){
......@@ -265,7 +261,6 @@ static void dec_uninit(MSFilter *f){
static void dec_process(MSFilter *f){
DecState *s=(DecState*)f->data;
mblk_t *inputMessage, *outputMessage;
struct BV16_Bit_Stream bs;
......@@ -308,8 +303,7 @@ static int dec_enable_plc(MSFilter *f, void* arg ){
return 0;
}
static int dec_have_plc(MSFilter *f, void *arg)
{
static int dec_have_plc(MSFilter *f, void *arg){
*((int *)arg) = 1;
return 0;
}
......@@ -326,7 +320,7 @@ static MSFilterMethod dec_methods[] = {
{ MS_FILTER_GET_SAMPLE_RATE, dec_get_sample_rate },
{ MS_FILTER_GET_NCHANNELS, get_channels },
{ MS_DECODER_HAVE_PLC , dec_have_plc },
{MS_DECODER_ENABLE_PLC, dec_enable_plc },
{ MS_DECODER_ENABLE_PLC, dec_enable_plc },
{ 0, NULL }
};
......
......@@ -779,6 +779,7 @@ int audio_stream_start_from_io(AudioStream *stream, RtpProfile *profile, const c
int nchannels;
int err1,err2;
bool_t has_builtin_ec=FALSE;
bool_t resampler_missing = FALSE;
if (!ms_media_stream_io_is_consistent(io)) return -1;
......@@ -825,6 +826,7 @@ int audio_stream_start_from_io(AudioStream *stream, RtpProfile *profile, const c
} else {
stream->soundread=ms_factory_create_filter(stream->ms.factory, MS_FILE_PLAYER_ID);
stream->read_resampler=ms_factory_create_filter(stream->ms.factory, MS_RESAMPLE_ID);
resampler_missing = stream->read_resampler == NULL;
}
if (io->output.type == MSResourceSoundcard) {
if (stream->soundwrite==NULL)
......@@ -963,7 +965,7 @@ int audio_stream_start_from_io(AudioStream *stream, RtpProfile *profile, const c
if (err1 != 0 || err2 != 0){
/* need to add resampler*/
if (stream->read_resampler == NULL) stream->read_resampler = ms_factory_create_filter(stream->ms.factory, MS_RESAMPLE_ID);
resampler_missing = stream->read_resampler == NULL;
}
err1 = ms_filter_call_method(stream->soundwrite, MS_FILTER_SET_SAMPLE_RATE, &sample_rate);
......@@ -971,6 +973,12 @@ int audio_stream_start_from_io(AudioStream *stream, RtpProfile *profile, const c
if (err1 !=0 || err2 != 0){
/* need to add resampler*/
if (stream->write_resampler == NULL) stream->write_resampler = ms_factory_create_filter(stream->ms.factory, MS_RESAMPLE_ID);
resampler_missing = stream->write_resampler == NULL;
}
if (resampler_missing){
ms_fatal("AudioStream: no resampler implementation found, but resampler is required to perform the AudioStream. "
"Does mediastreamer2 was compiled with libspeex dependency ?");
}
if (stream->ec){
......
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