diff --git a/daemon/src/audio/audiortp/audio_rtp_stream.cpp b/daemon/src/audio/audiortp/audio_rtp_stream.cpp index 25936d2c1d473f8c84ee610c5adbaec596bf3e23..f3279b2a82230944ca0099695afb9682801d2776 100644 --- a/daemon/src/audio/audiortp/audio_rtp_stream.cpp +++ b/daemon/src/audio/audiortp/audio_rtp_stream.cpp @@ -241,16 +241,18 @@ void AudioRtpStream::setRtpMedia(const std::vector<AudioCodec*> &audioCodecs) return; } - AudioFormat f = Manager::instance().getMainBuffer().getInternalAudioFormat(); - audioCodecs[0]->setOptimalFormat(f.sample_rate, f.nb_channels); // FIXME: assuming right encoder/decoder are first? currentEncoderIndex_ = currentDecoderIndex_ = 0; - // FIXME: this is probably not the right payload type - const int pt = audioCodecs[0]->getPayloadType(); + AudioCodec& codec = *audioCodecs[currentEncoderIndex_]; + + AudioFormat f = Manager::instance().getMainBuffer().getInternalAudioFormat(); + codec.setOptimalFormat(f.sample_rate, f.nb_channels); + + const int pt = encoder.getPayloadType(); encoder_.payloadType = decoder_.payloadType = pt; - encoder_.frameSize = decoder_.frameSize = audioCodecs[0]->getFrameSize(); + encoder_.frameSize = decoder_.frameSize = codec.getFrameSize(); - AudioFormat codecFormat(audioCodecs[0]->getCurrentClockRate(), audioCodecs[0]->getCurrentChannels()); + AudioFormat codecFormat(codec.getCurrentClockRate(), codec.getCurrentChannels()); if (codecFormat != decoder_.format or codecFormat != encoder_.format) { encoder_.format = decoder_.format = codecFormat; #if HAVE_SPEEXDSP @@ -258,10 +260,10 @@ void AudioRtpStream::setRtpMedia(const std::vector<AudioCodec*> &audioCodecs) #endif } Manager::instance().audioFormatUsed(codecFormat); - hasDynamicPayloadType_ = audioCodecs[0]->hasDynamicPayload(); + hasDynamicPayloadType_ = codec.hasDynamicPayload(); codecEncMutex_.unlock(); - resetDecoderPLC(audioCodecs[0]); + resetDecoderPLC(audioCodecs[currentDecoderIndex_]); codecDecMutex_.unlock(); } diff --git a/daemon/src/audio/audiortp/audio_rtp_stream.h b/daemon/src/audio/audiortp/audio_rtp_stream.h index 229ef42d69d114ae998a6ce4d4604b620b82bc9e..0debd2be6f21e6cf4e5cd5d3b12157a241a382e0 100644 --- a/daemon/src/audio/audiortp/audio_rtp_stream.h +++ b/daemon/src/audio/audiortp/audio_rtp_stream.h @@ -93,7 +93,13 @@ class AudioRtpStream { AudioRtpStream(const std::string &id); virtual ~AudioRtpStream(); void initBuffers(); + + /** + * Set the list of codecs supported by this stream. + * The codec used for encoding must be first. + */ void setRtpMedia(const std::vector<AudioCodec*> &codecs); + /** * Decode audio data received from peer */ diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp index 2b3f8eb66a67f2a6ef9636dec3bb1d4d393cc1fa..1a3acd452caea67630d7273baf6c5d5c059fd406 100644 --- a/daemon/src/sip/sipvoiplink.cpp +++ b/daemon/src/sip/sipvoiplink.cpp @@ -1964,8 +1964,8 @@ void sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status) DEBUG("Local active SDP Session:\n%s", buffer); // Set active SDP sessions - sdpSession->setActiveRemoteSdpSession(remoteSDP); sdpSession->setActiveLocalSdpSession(local_sdp); + sdpSession->setActiveRemoteSdpSession(remoteSDP); // Update internal field for sdpSession->setMediaTransportInfoFromRemoteSdp();