Commit d45bc178 authored by Simon Morlat's avatar Simon Morlat

repair stereo support of opus codec

parent 0add8168
......@@ -59,19 +59,25 @@ static FileInfo *file_info_new(const char *file){
ms_error("%s: not a wav file", file);
return NULL;
}
if (wave_header_get_channel(&header)<1){
ms_error("%s: incorrect number of channels", file);
return NULL;
}
fi=ms_new0(FileInfo,1);
size=stbuf.st_size-hsize;
fi->rate=wave_header_get_rate(&header);
fi->nchannels=wave_header_get_channel(&header);
fi->nsamples=size/(sizeof(int16_t)*fi->nchannels);
fi->fd = fd;
return fi;
}
static int file_info_read(FileInfo *fi, int zero_pad_samples, int zero_pad_end_samples){
int err;
int size = fi->nsamples * fi->nchannels *2;
fi->buffer=ms_new0(int16_t,(fi->nsamples + 2*zero_pad_samples + 2*zero_pad_end_samples) * fi->nchannels);
fi->buffer=ms_new0(int16_t,(fi->nsamples + zero_pad_samples + zero_pad_end_samples) * fi->nchannels);
err = read(fi->fd,fi->buffer + (zero_pad_samples * fi->nchannels), size);
if (err == -1){
......@@ -315,6 +321,17 @@ int ms_audio_diff(const char *ref_file, const char *matched_file, double *ret, c
err = -1;
goto end;
}
if (fi1->nsamples == 0){
ms_error("Reference file has no samples !");
err = -1;
goto end;
}
if (fi2->nsamples == 0){
ms_error("Matched file has no samples !");
err = -1;
goto end;
}
max_shift_samples = MIN(fi1->nsamples, fi2->nsamples) * MIN(MAX(1, params->max_shift_percent), 100) / 100;
if (fi1->nsamples > fi2->nsamples){
......
......@@ -892,8 +892,9 @@ int audio_stream_start_from_io(AudioStream *stream, RtpProfile *profile, const c
}
/*hack for opus, that claims stereo all the time, but we can't support stereo yet*/
if (strcasecmp(pt->mime_type,"opus")==0){
if ( (stream->features & (~AUDIO_STREAM_FEATURE_PLC) ) != 0){
/*all features except PLC prevent from activating the stereo*/
if ( (stream->features & (~(AUDIO_STREAM_FEATURE_PLC|AUDIO_STREAM_FEATURE_REMOTE_PLAYING)) ) != 0){
/*all features except PLC and REMOTE_PLAYING prevent from activating the stereo*/
ms_message("opus stereo support is deactivated because of incompatible features targeted for this AudioStream");
nchannels=1;
}else{
ms_message("Full stereo enabled in this audiostream.");
......
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