Commit 721a9d4c authored by Tristan Matthews's avatar Tristan Matthews

* #28675: sip: sipcall shouldn't know about sipaccount

parent ef8c6565
......@@ -230,10 +230,6 @@ class Call : public Recordable {
virtual bool toggleRecording();
protected:
/** Associate account ID */
std::string accountID_;
private:
std::string getTypeStr() const;
/** Protect every attribute that can be changed by two threads */
......@@ -259,6 +255,9 @@ class Call : public Recordable {
/** Type of the call */
CallType type_;
/** Associate account ID */
std::string accountID_;
/** Disconnected/Progressing/Trying/Ringing/Connected */
ConnectionState connectionState_;
......
......@@ -33,7 +33,6 @@
#include "sipcall.h"
#include "sip_utils.h"
#include "sipaccount.h"
#include "logger.h" // for _debug
#include "sdp.h"
#include "manager.h"
......@@ -57,6 +56,7 @@ SIPCall::SIPCall(const std::string& id, Call::CallType type,
#endif
, pool_(pj_pool_create(&caching_pool->factory, id.c_str(), INITIAL_SIZE, INCREMENT_SIZE, NULL))
, local_sdp_(new Sdp(pool_))
, contactHeader_()
{}
SIPCall::~SIPCall()
......@@ -65,6 +65,11 @@ SIPCall::~SIPCall()
pj_pool_release(pool_);
}
void SIPCall::setContactHeader(const std::string &contact)
{
contactHeader_ = contact;
}
void SIPCall::answer()
{
pjsip_tx_data *tdata;
......@@ -75,13 +80,9 @@ void SIPCall::answer()
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)");
SIPAccount *account = Manager::instance().getSipAccount(accountID_);
if (account == NULL)
throw std::runtime_error("Could not find account for this call");
// contactStr must stay in scope as long as tdata
const std::string contactStr(account->getContactHeader());
sip_utils::addContactHeader(contactStr, tdata);
if (not contactHeader_.empty())
sip_utils::addContactHeader(contactHeader_, tdata);
if (pjsip_inv_send_msg(inv, tdata) != PJ_SUCCESS)
throw std::runtime_error("Could not send invite request answer (200 OK)");
......
......@@ -108,6 +108,8 @@ class SIPCall : public Call {
*/
pjsip_inv_session *inv;
void setContactHeader(const std::string &contact);
private:
// override of Call::getDetails
std::map<std::string, std::string>
......@@ -140,6 +142,8 @@ class SIPCall : public Call {
* The SDP session
*/
Sdp *local_sdp_;
std::string contactHeader_;
};
#endif // __SIPCALL_H__
......@@ -1020,16 +1020,22 @@ SIPVoIPLink::answer(Call *call)
return;
SIPCall *sipCall = static_cast<SIPCall*>(call);
SIPAccount *account = Manager::instance().getSipAccount(sipCall->getAccountId());
if (!account) {
ERROR("Could not find account %s", sipCall->getAccountId().c_str());
return;
}
if (!sipCall->inv->neg) {
WARN("Negotiator is NULL, we've received an INVITE without an SDP");
pjmedia_sdp_session *dummy = 0;
sdp_create_offer_cb(sipCall->inv, &dummy);
SIPAccount *account = Manager::instance().getSipAccount(sipCall->getAccountId());
if (account and account->isStunEnabled())
if (account->isStunEnabled())
updateSDPFromSTUN(*sipCall, *account, SIPVoIPLink::instance()->sipTransport);
}
call->answer();
sipCall->setContactHeader(account->getContactHeader());
sipCall->answer();
}
namespace {
......
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