Commit 939d4ccb authored by Tristan Matthews's avatar Tristan Matthews

* #14428: sdp: don't throw exception if no sessionAudioMedia is found in SDP

Callers are already checking if the pointer is NULL before using it.
parent de3b93a1
......@@ -150,18 +150,16 @@ string Sdp::getSessionVideoCodec() const
string Sdp::getAudioCodecName() const
{
try {
sfl::AudioCodec *codec = getSessionAudioMedia();
return codec ? codec->getMimeSubtype() : "";
} catch (...) {
return "";
}
sfl::AudioCodec *codec = getSessionAudioMedia();
return codec ? codec->getMimeSubtype() : "";
}
sfl::AudioCodec* Sdp::getSessionAudioMedia() const
{
if (sessionAudioMedia_.empty())
throw SdpException("No codec description for this media");
if (sessionAudioMedia_.empty()) {
ERROR("No codec description for this media");
return 0;
}
return dynamic_cast<sfl::AudioCodec *>(sessionAudioMedia_[0]);
}
......
......@@ -980,8 +980,7 @@ SIPVoIPLink::offhold(const std::string& id)
try {
int pl = PAYLOAD_CODEC_ULAW;
sfl::Codec *sessionMedia = sdpSession->getSessionAudioMedia();
sfl::AudioCodec *sessionMedia = sdpSession->getSessionAudioMedia();
if (sessionMedia)
pl = sessionMedia->getPayloadType();
......@@ -1611,7 +1610,6 @@ void sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status)
#endif // HAVE_SDES
sfl::AudioCodec *sessionMedia = sdpSession->getSessionAudioMedia();
if (!sessionMedia)
return;
......
......@@ -287,7 +287,8 @@ void SDPTest::testReinvite()
CPPUNIT_ASSERT(session_->getLocalIP() == LOCALHOST);
CPPUNIT_ASSERT(session_->getRemoteIP() == "host.example.com");
CPPUNIT_ASSERT(session_->getSessionAudioMedia()->getMimeSubtype() == "PCMU");
sfl::AudioCodec *codec = session_->getSessionAudioMedia();
CPPUNIT_ASSERT(codec and codec->getMimeSubtype() == "PCMU");
pjmedia_sdp_session *reinviteOffer;
pjmedia_sdp_parse(testPool_, (char*) sdp_reinvite, strlen(sdp_reinvite), &reinviteOffer);
......
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