Skip to content
Snippets Groups Projects
Commit 013963a5 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #15545: sip: restore old Call API but handle invite with no SDP correctly

parent a570dd16
Branches
Tags
No related merge requests found
...@@ -173,6 +173,8 @@ class Call : public Recordable { ...@@ -173,6 +173,8 @@ class Call : public Recordable {
isIPToIP_ = IPToIP; isIPToIP_ = IPToIP;
} }
virtual void answer() = 0;
/** /**
* Set my IP [not protected] * Set my IP [not protected]
* @param ip The local IP address * @param ip The local IP address
......
...@@ -71,11 +71,11 @@ class IAXCall : public Call { ...@@ -71,11 +71,11 @@ class IAXCall : public Call {
int getAudioCodec() const; int getAudioCodec() const;
void answer();
int format; int format;
iax_session* session; iax_session* session;
private: private:
void answer();
NON_COPYABLE(IAXCall); NON_COPYABLE(IAXCall);
}; };
......
...@@ -278,7 +278,7 @@ IAXVoIPLink::answer(Call *call) ...@@ -278,7 +278,7 @@ IAXVoIPLink::answer(Call *call)
Manager::instance().addStream(call->getCallId()); Manager::instance().addStream(call->getCallId());
mutexIAX_.enter(); mutexIAX_.enter();
static_cast<IAXCall*>(call)->answer(); call->answer();
mutexIAX_.leave(); mutexIAX_.leave();
call->setState(Call::ACTIVE); call->setState(Call::ACTIVE);
......
...@@ -62,13 +62,14 @@ SIPCall::~SIPCall() ...@@ -62,13 +62,14 @@ SIPCall::~SIPCall()
pj_pool_release(pool_); pj_pool_release(pool_);
} }
void SIPCall::answer(bool needsSdp) void SIPCall::answer()
{ {
pjsip_tx_data *tdata; pjsip_tx_data *tdata;
if (!inv->last_answer) if (!inv->last_answer)
throw std::runtime_error("Should only be called for initial answer"); throw std::runtime_error("Should only be called for initial answer");
if (pjsip_inv_answer(inv, PJSIP_SC_OK, NULL, needsSdp ? local_sdp_->getLocalSdpSession() : NULL, &tdata) != PJ_SUCCESS) // answer with SDP if no SDP was given in initial invite (i.e. inv->neg is NULL)
if (pjsip_inv_answer(inv, PJSIP_SC_OK, NULL, !inv->neg ? local_sdp_->getLocalSdpSession() : NULL, &tdata) != PJ_SUCCESS)
throw std::runtime_error("Could not init invite request answer (200 OK)"); throw std::runtime_error("Could not init invite request answer (200 OK)");
if (pjsip_inv_send_msg(inv, tdata) != PJ_SUCCESS) if (pjsip_inv_send_msg(inv, tdata) != PJ_SUCCESS)
......
...@@ -100,9 +100,7 @@ class SIPCall : public Call { ...@@ -100,9 +100,7 @@ class SIPCall : public Call {
return pool_; return pool_;
} }
// @param needsSdp: true if the invite was received without an SDP void answer();
// and thus one must been added, false otherwise
void answer(bool needsSdp);
/** /**
* The invite session to be reused in case of transfer * The invite session to be reused in case of transfer
......
...@@ -913,15 +913,13 @@ SIPVoIPLink::answer(Call *call) ...@@ -913,15 +913,13 @@ SIPVoIPLink::answer(Call *call)
return; return;
SIPCall *sipCall = static_cast<SIPCall*>(call); SIPCall *sipCall = static_cast<SIPCall*>(call);
bool needsSdp = false;
if (!sipCall->inv->neg) { if (!sipCall->inv->neg) {
WARN("Negotiator is NULL, we've received an INVITE without an SDP"); WARN("Negotiator is NULL, we've received an INVITE without an SDP");
pjmedia_sdp_session *dummy; pjmedia_sdp_session *dummy;
sdp_create_offer_cb(sipCall->inv, &dummy); sdp_create_offer_cb(sipCall->inv, &dummy);
needsSdp = true;
} }
sipCall->answer(needsSdp); call->answer();
} }
namespace { namespace {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment