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