From 8aa62cfef7e4f581f88eeaad1cb82f39546bec88 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Sun, 27 Jul 2014 12:51:20 -0400 Subject: Initialize codec session with right values. Audio decoder and encoder channel values are sepparate values, the decoder should be set to the number of channels the other peer has his encoder set. --- toxav/codec.c | 10 ++++++---- toxav/codec.h | 11 +++++++---- toxav/toxav.c | 36 +++++++++++++++++++----------------- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/toxav/codec.c b/toxav/codec.c index 1e8478bb..ed1ee44e 100644 --- a/toxav/codec.c +++ b/toxav/codec.c @@ -151,6 +151,7 @@ int init_audio_decoder(CodecState *cs, uint32_t audio_channels) return -1; } + cs->audio_decoder_channels = audio_channels; return 0; } @@ -261,7 +262,7 @@ int init_audio_encoder(CodecState *cs, uint32_t audio_channels) return -1; } - + cs->audio_encoder_channels = audio_channels; return 0; } @@ -269,7 +270,8 @@ int init_audio_encoder(CodecState *cs, uint32_t audio_channels) CodecState *codec_init_session ( uint32_t audio_bitrate, uint16_t audio_frame_duration, uint32_t audio_sample_rate, - uint32_t audio_channels, + uint32_t encoder_audio_channels, + uint32_t decoder_audio_channels, uint32_t audio_VAD_tolerance_ms, uint16_t max_video_width, uint16_t max_video_height, @@ -292,8 +294,8 @@ CodecState *codec_init_session ( uint32_t audio_bitrate, retu->capabilities |= ( 0 == init_video_decoder(retu) ) ? v_decoding : 0; } - retu->capabilities |= ( 0 == init_audio_encoder(retu, audio_channels) ) ? a_encoding : 0; - retu->capabilities |= ( 0 == init_audio_decoder(retu, audio_channels) ) ? a_decoding : 0; + retu->capabilities |= ( 0 == init_audio_encoder(retu, encoder_audio_channels) ) ? a_encoding : 0; + retu->capabilities |= ( 0 == init_audio_decoder(retu, decoder_audio_channels) ) ? a_decoding : 0; if ( retu->capabilities == 0 ) { /* everything failed */ free (retu); diff --git a/toxav/codec.h b/toxav/codec.h index 755673f3..dceeea7a 100644 --- a/toxav/codec.h +++ b/toxav/codec.h @@ -64,9 +64,11 @@ typedef struct _CodecState { OpusEncoder *audio_encoder; int audio_bitrate; int audio_sample_rate; + int audio_encoder_channels; /* audio decoding */ OpusDecoder *audio_decoder; + int audio_decoder_channels; uint64_t capabilities; /* supports*/ @@ -93,11 +95,12 @@ RTPMessage *dequeue(JitterBuffer *q, int *success); CodecState *codec_init_session ( uint32_t audio_bitrate, uint16_t audio_frame_duration, uint32_t audio_sample_rate, - uint32_t audio_channels, + uint32_t encoder_audio_channels, + uint32_t decoder_audio_channels, uint32_t audio_VAD_tolerance_ms, - uint16_t video_width, - uint16_t video_height, - uint32_t video_bitrate); + uint16_t max_video_width, + uint16_t max_video_height, + uint32_t video_bitrate ); void codec_terminate_session(CodecState *cs); diff --git a/toxav/toxav.c b/toxav/toxav.c index 1e5847a4..1a25a82f 100644 --- a/toxav/toxav.c +++ b/toxav/toxav.c @@ -432,7 +432,8 @@ int toxav_prepare_transmission ( ToxAv *av, int32_t call_index, uint32_t jbuf_ca goto error; } - ToxAvCSettings csettings = toxavcsettings_cast(&av->msi_session->calls[call_index]->csettings_peer[0]); + ToxAvCSettings csettings_peer = toxavcsettings_cast(&av->msi_session->calls[call_index]->csettings_peer[0]); + ToxAvCSettings csettings_local = toxavcsettings_cast(&av->msi_session->calls[call_index]->csettings_local); LOGGER_DEBUG( "Type: %u \n" "Video bitrate: %u \n" @@ -442,23 +443,24 @@ int toxav_prepare_transmission ( ToxAv *av, int32_t call_index, uint32_t jbuf_ca "Audio framedur: %u \n" "Audio sample rate: %u \n" "Audio channels: %u \n", - csettings.call_type, - csettings.video_bitrate, - csettings.max_video_height, - csettings.max_video_width, - csettings.audio_bitrate, - csettings.audio_frame_duration, - csettings.audio_sample_rate, - csettings.audio_channels ); - - if ( (call->cs = codec_init_session(csettings.audio_bitrate, - csettings.audio_frame_duration, - csettings.audio_sample_rate, - csettings.audio_channels, + csettings_peer.call_type, + csettings_peer.video_bitrate, + csettings_peer.max_video_height, + csettings_peer.max_video_width, + csettings_peer.audio_bitrate, + csettings_peer.audio_frame_duration, + csettings_peer.audio_sample_rate, + csettings_peer.audio_channels ); + + if ( (call->cs = codec_init_session(csettings_local.audio_bitrate, + csettings_local.audio_frame_duration, + csettings_local.audio_sample_rate, + csettings_local.audio_channels, + csettings_peer.audio_channels, VAD_treshold, - csettings.max_video_width, - csettings.max_video_height, - csettings.video_bitrate) )) { + csettings_local.max_video_width, + csettings_local.max_video_height, + csettings_local.video_bitrate) )) { if ( pthread_mutex_init(&call->mutex, NULL) != 0 ) goto error; -- cgit v1.2.3