Commit 15f8fb84 authored by Nicolas Jager's avatar Nicolas Jager Committed by Guillaume Roguez

incoming call, getCallDetails inform about AUDIO_ONLY

make public Call::setEarlyDetails and change its name
for Call::updateDetails().
This permits to change details at creation AND after
as in the case of RingAccount where we don't have
details when the call is created.

Change-Id: I145624f93358990ed36d027bdb47bd4e498b1770
Signed-off-by: Guillaume Roguez's avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent ba9f49b0
......@@ -84,7 +84,7 @@ Call::Call(Account& account, const std::string& id, Call::CallType type,
, type_(type)
, account_(account)
{
setEarlyDetails(details);
updateDetails(details);
addStateListener([this](UNUSED Call::CallState call_state,
UNUSED Call::ConnectionState cnx_state,
......@@ -312,9 +312,9 @@ Call::toggleRecording()
}
void
Call::setEarlyDetails(const std::map<std::string, std::string>& details)
Call::updateDetails(const std::map<std::string, std::string>& details)
{
auto iter = details.find(DRing::Call::Details::AUDIO_ONLY);
const auto& iter = details.find(DRing::Call::Details::AUDIO_ONLY);
if (iter != std::end(details))
isAudioOnly_ = iter->second == TRUE_STR;
}
......
......@@ -306,6 +306,15 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> {
virtual void restartMediaReceiver() = 0;
/**
* Update call details after creation.
* @param details to update
*
* /note No warranty to update any details, only some details can be modified.
* See the implementation for more ... details :-).
*/
void updateDetails(const std::map<std::string, std::string>& details);
protected:
virtual void merge(Call& scall);
......@@ -339,8 +348,6 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> {
private:
friend void hangupCallsIf(Call::SubcallSet, int, const std::function<bool(Call*)>&);
void setEarlyDetails(const std::map<std::string, std::string>& details);
bool validStateTransition(CallState newState);
void checkPendingIM();
......
......@@ -304,12 +304,13 @@ RingAccount::flush()
}
std::shared_ptr<SIPCall>
RingAccount::newIncomingCall(const std::string& from)
RingAccount::newIncomingCall(const std::string& from, const std::map<std::string, std::string>& details)
{
std::lock_guard<std::mutex> lock(callsMutex_);
auto call_it = pendingSipCalls_.begin();
while (call_it != pendingSipCalls_.end()) {
auto call = call_it->call.lock();
call->updateDetails(details);
if (not call) {
RING_WARN("newIncomingCall: discarding deleted call");
call_it = pendingSipCalls_.erase(call_it);
......
......@@ -239,12 +239,13 @@ class RingAccount : public SIPAccountBase {
/**
* Create incoming SIPCall.
* @param[in] from The origin of the call
* @param details use to set some specific details
* @return std::shared_ptr<T> A shared pointer on the created call.
* The type of this instance is given in template argument.
* This type can be any base class of SIPCall class (included).
*/
virtual std::shared_ptr<SIPCall>
newIncomingCall(const std::string& from = {}) override;
newIncomingCall(const std::string& from, const std::map<std::string, std::string>& details = {}) override;
virtual bool isTlsEnabled() const override {
return true;
......
......@@ -159,10 +159,13 @@ SIPAccount::~SIPAccount()
}
std::shared_ptr<SIPCall>
SIPAccount::newIncomingCall(const std::string& from UNUSED)
SIPAccount::newIncomingCall(const std::string& from UNUSED, const std::map<std::string, std::string>& details)
{
auto& manager = Manager::instance();
return manager.callFactory.newCall<SIPCall, SIPAccount>(*this, manager.getNewCallID(), Call::CallType::INCOMING);
return manager.callFactory.newCall<SIPCall, SIPAccount>(*this,
manager.getNewCallID(),
Call::CallType::INCOMING,
details);
}
template <>
......
......@@ -478,12 +478,13 @@ class SIPAccount : public SIPAccountBase {
/**
* Create incoming SIPCall.
* @param[in] from The origin uri of the call
* @param details use to set some specific details
* @return std::shared_ptr<T> A shared pointer on the created call.
* The type of this instance is given in template argument.
* This type can be any base class of SIPCall class (included).
*/
std::shared_ptr<SIPCall>
newIncomingCall(const std::string& from) override;
newIncomingCall(const std::string& from, const std::map<std::string, std::string>& details = {}) override;
void onRegister(pjsip_regc_cbparam *param);
......
......@@ -126,12 +126,13 @@ public:
/**
* Create incoming SIPCall.
* @param[in] id The ID of the call
* @param details use to set some specific details
* @return std::shared_ptr<T> A shared pointer on the created call.
* The type of this instance is given in template argument.
* This type can be any base class of SIPCall class (included).
*/
virtual std::shared_ptr<SIPCall>
newIncomingCall(const std::string& from) = 0;
newIncomingCall(const std::string& from, const std::map<std::string, std::string>& details = {}) = 0;
virtual bool isStunEnabled() const {
return false;
......
......@@ -273,7 +273,17 @@ transaction_request_cb(pjsip_rx_data *rdata)
Manager::instance().hookPreference.runHook(rdata->msg_info.msg);
auto call = account->newIncomingCall(remote_user);
bool hasVideo = false;
bool hasAudio = false;
auto pj_str_video = pj_str((char*) "video");
auto pj_str_audio = pj_str((char*) "audio");
for (decltype(r_sdp->media_count) i=0 ; i < r_sdp->media_count; i++)
if ( pj_strcmp(&r_sdp->media[i]->desc.media, &pj_str_video) == 0 )
hasVideo = true;
else if ( pj_strcmp(&r_sdp->media[i]->desc.media, &pj_str_audio) == 0 )
hasAudio = true;
auto call = account->newIncomingCall(remote_user, {{"AUDIO_ONLY", ((not hasVideo and hasAudio) ? "true" : "false") }});
if (!call) {
return PJ_FALSE;
}
......@@ -333,7 +343,7 @@ transaction_request_cb(pjsip_rx_data *rdata)
call->getSDP().receiveOffer(r_sdp,
account->getActiveAccountCodecInfoList(MEDIA_AUDIO),
account->getActiveAccountCodecInfoList(account->isVideoEnabled() ? MEDIA_VIDEO : MEDIA_NONE),
account->getActiveAccountCodecInfoList(account->isVideoEnabled() and hasVideo ? MEDIA_VIDEO : MEDIA_NONE),
account->getSrtpKeyExchange());
call->setRemoteSdp(r_sdp);
......@@ -434,7 +444,6 @@ transaction_request_cb(pjsip_rx_data *rdata)
replacedCall->hangup(PJSIP_SC_OK);
}
return PJ_FALSE;
}
......
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