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

This fixes the race-condition + SEGFAULT
This commit is contained in:
Tristan Matthews
2013-03-14 14:55:03 -04:00
parent 81b95dd7f2
commit 429d1f3603
6 changed files with 39 additions and 2 deletions

View File

@ -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)

View File

@ -149,6 +149,9 @@ class AudioRtpFactory {
void restoreLocalContext();
std::string
getCurrentAudioCodecNames() const;
private:
NON_COPYABLE(AudioRtpFactory);
enum KeyExchangeProtocol { NONE, SDES, ZRTP };

View File

@ -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_);

View File

@ -192,6 +192,8 @@ class AudioRtpRecordHandler {
void putDtmfEvent(char digit);
std::string getCurrentAudioCodecNames();
protected:
bool codecsDiffer(const std::vector<AudioCodec*> &codecs) const;
AudioRtpRecord audioRtpRecord_;

View File

@ -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

View File

@ -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