Commit e446c8e0 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #13250: sdp: fetch sessionVideoMedia properly

parent 2f899812
......@@ -270,7 +270,7 @@ CallManager::getIsRecording(const std::string& callID)
std::string CallManager::getCurrentAudioCodecName(const std::string& callID)
{
return Manager::instance().getCurrentCodecName(callID).c_str();
return Manager::instance().getCurrentAudioCodecName(callID);
}
std::map<std::string, std::string>
......
......@@ -412,16 +412,15 @@ IAXVoIPLink::sendTextMessage(const std::string& callID,
}
}
#ifdef SFL_VIDEO
std::string
IAXVoIPLink::getCurrentVideoCodecName(const std::string& /*id*/)
IAXVoIPLink::getCurrentVideoCodecName(Call * /*call*/) const
{
// FIXME: Video not supported for IAX yet
return "";
}
#endif
std::string
IAXVoIPLink::getCurrentCodecName(Call *c) const
IAXVoIPLink::getCurrentAudioCodecName(Call *c) const
{
IAXCall *call = dynamic_cast<IAXCall*>(c);
sfl::Codec *audioCodec = Manager::instance().audioCodecFactory.getCodec(call->getAudioCodec());
......
......@@ -173,10 +173,8 @@ class IAXVoIPLink : public VoIPLink {
* Return the codec protocol used for this call
* @param id The call identifier
*/
#ifdef SFL_VIDEO
virtual std::string getCurrentVideoCodecName(const std::string& id);
#endif
virtual std::string getCurrentCodecName(Call *c) const;
virtual std::string getCurrentVideoCodecName(Call *c) const;
virtual std::string getCurrentAudioCodecName(Call *c) const;
private:
NON_COPYABLE(IAXVoIPLink);
......
......@@ -1819,7 +1819,7 @@ std::string ManagerImpl::join_string(const std::vector<std::string> &v)
return os.str();
}
std::string ManagerImpl::getCurrentCodecName(const std::string& id)
std::string ManagerImpl::getCurrentAudioCodecName(const std::string& id)
{
std::string accountid = getAccountFromCall(id);
VoIPLink* link = getAccountLink(accountid);
......@@ -1830,20 +1830,20 @@ std::string ManagerImpl::getCurrentCodecName(const std::string& id)
Call::CallState state = call->getState();
if (state == Call::ACTIVE or state == Call::CONFERENCING)
codecName = link->getCurrentCodecName(call);
codecName = link->getCurrentAudioCodecName(call);
}
return codecName;
}
#ifdef SFL_VIDEO
std::string ManagerImpl::getCurrentVideoCodecName(const std::string& ID)
std::string
ManagerImpl::getCurrentVideoCodecName(const std::string& ID)
{
std::string accountID = getAccountFromCall(ID);
VoIPLink* link = getAccountLink(accountID);
return link->getCurrentVideoCodecName(ID);
Call *call(getCallFromCallID(ID));
return link->getCurrentVideoCodecName(call);
}
#endif
/**
* Set input audio plugin
......
......@@ -504,10 +504,8 @@ class ManagerImpl {
* @param call id
* @return std::string The codec name
*/
std::string getCurrentCodecName(const std::string& id);
#ifdef SFL_VIDEO
std::string getCurrentAudioCodecName(const std::string& id);
std::string getCurrentVideoCodecName(const std::string& id);
#endif
/**
* Set input audio plugin
......
......@@ -76,33 +76,34 @@ void Sdp::setActiveLocalSdpSession(const pjmedia_sdp_session *sdp)
if (activeLocalSession_->media_count < 1)
return;
pjmedia_sdp_media *current = activeLocalSession_->media[0];
for (unsigned media = 0; media < activeLocalSession_->media_count; ++media) {
pjmedia_sdp_media *current = activeLocalSession_->media[media];
for (unsigned j = 0; j < current->desc.fmt_count; j++) {
static const pj_str_t STR_RTPMAP = { (char*) "rtpmap", 6 };
pjmedia_sdp_attr *attribute = pjmedia_sdp_media_find_attr(current, &STR_RTPMAP, NULL);
for (unsigned fmt = 0; fmt < current->desc.fmt_count; ++fmt) {
static const pj_str_t STR_RTPMAP = { (char*) "rtpmap", 6 };
pjmedia_sdp_attr *attribute = pjmedia_sdp_media_find_attr(current, &STR_RTPMAP, NULL);
if (!attribute) {
sessionAudioMedia_.clear();
return;
}
pjmedia_sdp_rtpmap *rtpmap;
pjmedia_sdp_attr_to_rtpmap(memPool_, attribute, &rtpmap);
string type(current->desc.media.ptr, current->desc.media.slen);
if (type == "audio") {
const int pt = pj_strtoul(&rtpmap->pt);
sfl::Codec *codec = Manager::instance().audioCodecFactory.getCodec(pt);
if (codec)
sessionAudioMedia_.push_back(codec);
else {
DEBUG("Could not get codec for payload type %lu", pt);
sessionAudioMedia_.clear();
return;
if (!attribute) {
ERROR("Could not find rtpmap attribute");
break;
}
} else if (type == "video")
sessionVideoMedia_.push_back(string(rtpmap->enc_name.ptr, rtpmap->enc_name.slen));
pjmedia_sdp_rtpmap *rtpmap;
pjmedia_sdp_attr_to_rtpmap(memPool_, attribute, &rtpmap);
string type(current->desc.media.ptr, current->desc.media.slen);
if (type == "audio") {
const int pt = pj_strtoul(&rtpmap->pt);
sfl::Codec *codec = Manager::instance().audioCodecFactory.getCodec(pt);
if (codec)
sessionAudioMedia_.push_back(codec);
else {
DEBUG("Could not get codec for payload type %lu", pt);
break;
}
} else if (type == "video")
sessionVideoMedia_.push_back(string(rtpmap->enc_name.ptr, rtpmap->enc_name.slen));
}
}
}
......
......@@ -1094,22 +1094,14 @@ SIPVoIPLink::refuse(const std::string& id)
removeCall(id);
}
#ifdef SFL_VIDEO
std::string
SIPVoIPLink::getCurrentVideoCodecName(const std::string& id)
SIPVoIPLink::getCurrentVideoCodecName(Call *call) const
{
SIPCall *call = getSIPCall(id);
if (call) {
Call::CallState state = call->getState();
if (state == Call::ACTIVE or state == Call::CONFERENCING)
return call->getLocalSDP()->getSessionVideoCodec();
}
return "";
return dynamic_cast<SIPCall*>(call)->getLocalSDP()->getSessionVideoCodec();
}
#endif
std::string
SIPVoIPLink::getCurrentCodecName(Call *call) const
SIPVoIPLink::getCurrentAudioCodecName(Call *call) const
{
return dynamic_cast<SIPCall*>(call)->getLocalSDP()->getAudioCodecName();
}
......
......@@ -218,10 +218,8 @@ class SIPVoIPLink : public VoIPLink {
* Return the codec protocol used for this call
* @param c The call identifier
*/
#ifdef SFL_VIDEO
std::string getCurrentVideoCodecName(const std::string& id);
#endif
std::string getCurrentCodecName(Call *c) const;
std::string getCurrentVideoCodecName(Call *c) const;
std::string getCurrentAudioCodecName(Call *c) const;
/**
* Retrive useragent name from account
......
......@@ -150,10 +150,8 @@ class VoIPLink {
* Return the codec protocol used for this call
* @param call The call
*/
#ifdef SFL_VIDEO
virtual std::string getCurrentVideoCodecName(const std::string& id) = 0;
#endif
virtual std::string getCurrentCodecName(Call *call) const = 0;
virtual std::string getCurrentVideoCodecName(Call *call) const = 0;
virtual std::string getCurrentAudioCodecName(Call *call) const = 0;
/**
* Send a message to a call identified by its callid
......
......@@ -50,12 +50,8 @@ static const char *sdp_answer1 = "v=0\r\n"
"t=0 0\r\n"
"m=audio 49920 RTP/AVP 0\r\n"
"a=rtpmap:0 PCMU/8000\r\n"
#ifdef SFL_VIDEO
"m=video 0 RTP/AVP 31\r\n"
"m=video 53002 RTP/AVP 32\r\n"
"a=rtpmap:32 MPV/90000\r\n"
#endif
;
"a=rtpmap:32 MPV/90000\r\n";
static const char *sdp_offer1 = "v=0\r\n"
"o=bob 2890844730 2890844730 IN IP4 host.example.com\r\n"
......@@ -64,12 +60,8 @@ static const char *sdp_offer1 = "v=0\r\n"
"t=0 0\r\n"
"m=audio 49920 RTP/AVP 0\r\n"
"a=rtpmap:0 PCMU/8000\r\n"
#ifdef SFL_VIDEO
"m=video 0 RTP/AVP 31\r\n"
"m=video 53002 RTP/AVP 32\r\n"
"a=rtpmap:32 MPV/90000\r\n"
#endif
;
"a=rtpmap:32 MPV/90000\r\n";
static const char *sdp_answer2 = "v=0\r\n"
"o=bob 2890844730 2890844730 IN IP4 host.example.com\r\n"
......@@ -80,12 +72,8 @@ static const char *sdp_answer2 = "v=0\r\n"
"a=rtpmap:3 GSM/8000\r\n"
"a=rtpmap:97 iLBC/8000\r\n"
"a=rtpmap:9 G722/8000\r\n"
#ifdef SFL_VIDEO
"m=video 0 RTP/AVP 31\r\n"
"m=video 53002 RTP/AVP 32\r\n"
"a=rtpmap:32 MPV/90000\r\n"
#endif
;
"a=rtpmap:32 MPV/90000\r\n";
static const char *sdp_offer2 = "v=0\r\n"
"o=bob 2890844730 2890844730 IN IP4 host.example.com\r\n"
......@@ -96,12 +84,8 @@ static const char *sdp_offer2 = "v=0\r\n"
"a=rtpmap:3 GSM/8000\r\n"
"a=rtpmap:97 iLBC/8000\r\n"
"a=rtpmap:9 G722/8000\r\n"
#ifdef SFL_VIDEO
"m=video 0 RTP/AVP 31\r\n"
"m=video 53002 RTP/AVP 32\r\n"
"a=rtpmap:32 MPV/90000\r\n"
#endif
;
"a=rtpmap:32 MPV/90000\r\n";
static const char *sdp_reinvite = "v=0\r\n"
"o=bob 2890844730 2890844730 IN IP4 host.example.com\r\n"
......@@ -110,12 +94,8 @@ static const char *sdp_reinvite = "v=0\r\n"
"t=0 0\r\n"
"m=audio 42445 RTP/AVP 0\r\n"
"a=rtpmap:0 PCMU/8000\r\n"
#ifdef SFL_VIDEO
"m=video 0 RTP/AVP 31\r\n"
"m=video 53002 RTP/AVP 32\r\n"
"a=rtpmap:32 MPV/90000\r\n"
#endif
;
"a=rtpmap:32 MPV/90000\r\n";
static const char *const LOCALHOST = "127.0.0.1";
......
Supports Markdown
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