Commit 12853b51 authored by Sébastien Blin's avatar Sébastien Blin Committed by RingBot

media: fix pause issue

Wait for ICE negotiation to end before hold or unhold the call

Change-Id: I9e6ddf124cc345d60c3e8ceb14887cd4a09e3f19
parent fd5afa7e
......@@ -578,16 +578,25 @@ SIPCall::attendedTransfer(const std::string& to)
bool
SIPCall::onhold()
{
// If ICE is currently negotiating, we must wait before hold the call
if (isWaitingForIceAndMedia_) {
remainingRequest_ = Request::HoldingOn;
return false;
}
if (not setState(CallState::HOLD))
return false;
stopAllMedia();
if (getConnectionState() == ConnectionState::CONNECTED) {
if (SIPSessionReinvite() != PJ_SUCCESS)
if (SIPSessionReinvite() != PJ_SUCCESS) {
RING_WARN("[call:%s] Reinvite failed", getCallId().c_str());
return true;
}
}
isWaitingForIceAndMedia_ = true;
return true;
}
......@@ -595,6 +604,12 @@ bool
SIPCall::offhold()
{
bool success = false;
// If ICE is currently negotiating, we must wait before unhold the call
if (isWaitingForIceAndMedia_) {
remainingRequest_ = Request::HoldingOff;
return false;
}
auto& account = getSIPAccount();
try {
......@@ -608,6 +623,8 @@ SIPCall::offhold()
throw VoipLinkException("SDP issue in offhold");
}
if (success) isWaitingForIceAndMedia_ = true;
return success;
}
......@@ -635,7 +652,13 @@ SIPCall::switchInput(const std::string& resource)
{
#ifdef RING_VIDEO
videoInput_ = resource;
SIPSessionReinvite();
if (isWaitingForIceAndMedia_) {
remainingRequest_ = Request::SwitchInput;
} else {
if (SIPSessionReinvite() == PJ_SUCCESS) {
isWaitingForIceAndMedia_ = true;
}
}
#endif
}
......@@ -888,6 +911,25 @@ SIPCall::startAllMedia()
peerHolding_ = peer_holding;
emitSignal<DRing::CallSignal::PeerHold>(getCallId(), peerHolding_);
}
// Media is restarted, we can process the last holding request.
isWaitingForIceAndMedia_ = false;
if (remainingRequest_ != Request::NoRequest) {
switch (remainingRequest_) {
case Request::HoldingOn:
onhold();
break;
case Request::HoldingOff:
offhold();
break;
case Request::SwitchInput:
SIPSessionReinvite();
break;
default:
break;
}
remainingRequest_ = Request::NoRequest;
}
}
void
......
......@@ -265,6 +265,15 @@ private:
std::unique_ptr<Sdp> sdp_;
bool peerHolding_ {false};
bool isWaitingForIceAndMedia_ {false};
enum class Request {
HoldingOn,
HoldingOff,
SwitchInput,
NoRequest
};
Request remainingRequest_ {Request::NoRequest};
std::string peerRegistredName_ {};
char contactBuffer_[PJSIP_MAX_URL_SIZE] {};
......
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