Skip to content
Snippets Groups Projects
Commit 48c24139 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

#5954: Clean up getSessionMedia methods

parent 92d4dcbf
No related branches found
No related tags found
No related merge requests found
......@@ -136,27 +136,48 @@ void Sdp::setActiveRemoteSdpSession (const pjmedia_sdp_session *sdp)
getRemoteSdpTelephoneEventFromOffer(sdp);
}
AudioCodec* Sdp::getSessionMedia (void)
bool Sdp::hasSessionMedia(void)
{
std::vector<sdpMedia *> mediaList = getSessionMediaList();
bool listNotEmpty;
int nb_media;
int nb_codec;
if(mediaList.size() > 0) {
listNotEmpty = true;
}
else {
listNotEmpty = false;
}
return listNotEmpty;
}
AudioCodec* Sdp::getSessionMedia (void) throw(SdpException)
{
int nbMedia;
int nbCodec;
sfl::Codec *codec = NULL;
std::vector<sdpMedia*> media_list;
std::vector<sdpMedia *> mediaList;
_debug ("SDP: Get session media");
media_list = getSessionMediaList ();
nb_media = media_list.size();
mediaList = getSessionMediaList ();
nbMedia = mediaList.size();
if (nb_media > 0) {
nb_codec = media_list[0]->get_media_codec_list().size();
if(nbMedia <= 0) {
_error("SDP: Error: No media in session description");
throw SdpException("No media description for this SDP");
}
if (nb_codec > 0) {
codec = media_list[0]->get_media_codec_list() [0];
}
nbCodec = mediaList[0]->get_media_codec_list().size();
if (nbCodec <= 0) {
_error("SDP: Error: No codec description for this media");
throw SdpException("No codec description for this media");
}
codec = mediaList[0]->get_media_codec_list() [0];
return static_cast<AudioCodec *>(codec);
}
......
......@@ -149,10 +149,15 @@ class Sdp
}
/**
* Return wether or not the media have been determined for this sdp session
*/
bool hasSessionMedia(void);
/**
* Return the codec of the first media after negociation
*/
AudioCodec* getSessionMedia (void);
AudioCodec* getSessionMedia (void) throw(SdpException);
/*
* On building an invite outside a dialog, build the local offer and create the
......
......@@ -1347,20 +1347,31 @@ std::string
SIPVoIPLink::getCurrentCodecName()
{
SIPCall *call;
SIPCall *call = NULL;
sfl::Codec *ac = NULL;
std::string name = "";
call = getSIPCall (Manager::instance().getCurrentCallId());
if(call == NULL) {
_error("UserAgent: Error: No current call");
// return empty string
return name;
}
if (call) {
if(call->getLocalSDP()->hasSessionMedia()) {
ac = call->getLocalSDP()->getSessionMedia();
}
else {
return name;
}
if (ac) {
name = ac->getMimeSubtype();
if (ac == NULL) {
_error("UserAgent: Error: No codec initialized for this session");
}
name = ac->getMimeSubtype();
return name;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment