Skip to content
Snippets Groups Projects
Commit 64d32828 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

sipcall: lock when starting/stopping media

Change-Id: Ia12da6f9e58ec0cd0100eaba206e1d9e711ca0e1
parent dc41bae7
Branches
No related tags found
No related merge requests found
...@@ -929,7 +929,6 @@ SIPCall::getAudioCodec() const ...@@ -929,7 +929,6 @@ SIPCall::getAudioCodec() const
void void
SIPCall::startAllMedia() SIPCall::startAllMedia()
{ {
std::lock_guard<std::recursive_mutex> lock(callMutex_);
if (!transport_) return; if (!transport_) return;
JAMI_WARN("[call:%s] startAllMedia()", getCallId().c_str()); JAMI_WARN("[call:%s] startAllMedia()", getCallId().c_str());
if (isSecure() && not transport_->isSecure()) { if (isSecure() && not transport_->isSecure()) {
...@@ -1135,6 +1134,7 @@ SIPCall::onMediaUpdate() ...@@ -1135,6 +1134,7 @@ SIPCall::onMediaUpdate()
// to a negotiated transport. // to a negotiated transport.
runOnMainThread([w = weak()] { runOnMainThread([w = weak()] {
if (auto this_ = w.lock()) { if (auto this_ = w.lock()) {
std::lock_guard<std::recursive_mutex> lk {this_->callMutex_};
// The call is already ended, so we don't need to restart medias // The call is already ended, so we don't need to restart medias
if (!this_->inv or this_->inv->state == PJSIP_INV_STATE_DISCONNECTED) return; if (!this_->inv or this_->inv->state == PJSIP_INV_STATE_DISCONNECTED) return;
// If ICE is not used, start medias now // If ICE is not used, start medias now
...@@ -1185,6 +1185,7 @@ SIPCall::waitForIceAndStartMedia() ...@@ -1185,6 +1185,7 @@ SIPCall::waitForIceAndStartMedia()
// Negotiation waiting task // Negotiation waiting task
Manager::instance().addTask([weak_call] { Manager::instance().addTask([weak_call] {
if (auto call = weak_call.lock()) { if (auto call = weak_call.lock()) {
std::lock_guard<std::recursive_mutex> lk {call->callMutex_};
auto ice = call->getIceMediaTransport(); auto ice = call->getIceMediaTransport();
if (not ice or ice->isFailed()) { if (not ice or ice->isFailed()) {
......
...@@ -222,8 +222,6 @@ public: // NOT SIP RELATED (good candidates to be moved elsewhere) ...@@ -222,8 +222,6 @@ public: // NOT SIP RELATED (good candidates to be moved elsewhere)
void generateMediaPorts(); void generateMediaPorts();
void startAllMedia();
void openPortsUPnP(); void openPortsUPnP();
void setPeerRegistredName(const std::string& name) { void setPeerRegistredName(const std::string& name) {
...@@ -256,6 +254,7 @@ private: ...@@ -256,6 +254,7 @@ private:
void waitForIceAndStartMedia(); void waitForIceAndStartMedia();
void startAllMedia();
void stopAllMedia(); void stopAllMedia();
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment