Commit 429d1f36 authored by Tristan Matthews's avatar Tristan Matthews

* #21507: daemon: get audio codec names from audiortpfactory, not SDP

This fixes the race-condition + SEGFAULT
parent 81b95dd7
......@@ -151,6 +151,15 @@ int AudioRtpFactory::getSessionMedia()
return rtpSession_->getEncoderPayloadType();
}
std::string
AudioRtpFactory::getCurrentAudioCodecNames() const
{
if (rtpSession_ == NULL)
throw AudioRtpFactoryException("RTP session was null when trying to get session media type");
return rtpSession_->getCurrentAudioCodecNames();
}
void AudioRtpFactory::updateSessionMedia(const std::vector<AudioCodec*> &audioCodecs)
{
if (rtpSession_ == NULL)
......
......@@ -149,6 +149,9 @@ class AudioRtpFactory {
void restoreLocalContext();
std::string
getCurrentAudioCodecNames() const;
private:
NON_COPYABLE(AudioRtpFactory);
enum KeyExchangeProtocol { NONE, SDES, ZRTP };
......
......@@ -204,6 +204,24 @@ AudioRtpRecordHandler::AudioRtpRecordHandler(SIPCall &call) :
AudioRtpRecordHandler::~AudioRtpRecordHandler() {}
std::string
AudioRtpRecordHandler::getCurrentAudioCodecNames()
{
std::string result;
ScopedLock lock(audioRtpRecord_.audioCodecMutex_);
{
std::string sep = "";
for (std::vector<AudioCodec*>::const_iterator i = audioRtpRecord_.audioCodecs_.begin();
i != audioRtpRecord_.audioCodecs_.end(); ++i) {
if (*i)
result += sep + (*i)->getMimeSubtype();
sep = " ";
}
}
return result;
}
void AudioRtpRecordHandler::setRtpMedia(const std::vector<AudioCodec*> &audioCodecs)
{
ScopedLock lock(audioRtpRecord_.audioCodecMutex_);
......
......@@ -192,6 +192,8 @@ class AudioRtpRecordHandler {
void putDtmfEvent(char digit);
std::string getCurrentAudioCodecNames();
protected:
bool codecsDiffer(const std::vector<AudioCodec*> &codecs) const;
AudioRtpRecord audioRtpRecord_;
......
......@@ -95,7 +95,7 @@ SIPCall::createHistoryEntry() const
using sfl::HistoryItem;
std::map<std::string, std::string> entry(Call::createHistoryEntry());
entry[HistoryItem::AUDIO_CODEC_KEY] = local_sdp_->getAudioCodecNames();
entry[HistoryItem::AUDIO_CODEC_KEY] = audiortp_.getCurrentAudioCodecNames();
#ifdef SFL_VIDEO
entry[HistoryItem::VIDEO_CODEC_KEY] = local_sdp_->getSessionVideoCodec();
#endif
......
......@@ -1342,7 +1342,12 @@ SIPVoIPLink::getCurrentVideoCodecName(Call *call) const
std::string
SIPVoIPLink::getCurrentAudioCodecNames(Call *call) const
{
return static_cast<SIPCall*>(call)->getLocalSDP()->getAudioCodecNames();
try {
return static_cast<SIPCall*>(call)->getAudioRtp().getCurrentAudioCodecNames();
} catch (const AudioRtpFactoryException &e) {
ERROR("%s", e.what());
return "";
}
}
/* Only use this macro with string literals or character arrays, will not work
......
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