diff --git a/src/conference.cpp b/src/conference.cpp index 6d6fe50f9e49f212fe291dd95bfa059ee7f93c9e..03e7f2cc14185aa92dc5034d944597d6f68e44c5 100644 --- a/src/conference.cpp +++ b/src/conference.cpp @@ -123,6 +123,9 @@ Conference::~Conference() call->toggleRecording(); } } + // Notify that the remaining peer is still recording after conference + if (call->isPeerRecording()) + call->setRemoteRecording(true); } } #endif // ENABLE_VIDEO @@ -245,8 +248,11 @@ Conference::remove(const std::string& participant_id) { if (participants_.erase(participant_id)) { #ifdef ENABLE_VIDEO - if (auto call = Manager::instance().callFactory.getCall<SIPCall>(participant_id)) + if (auto call = Manager::instance().callFactory.getCall<SIPCall>(participant_id)) { call->getVideoRtp().exitConference(); + if (call->isPeerRecording()) + call->setRemoteRecording(false); + } #endif // ENABLE_VIDEO } } @@ -344,10 +350,19 @@ Conference::getDisplayNames() const bool Conference::toggleRecording() { - if (not isRecording()) + bool newState = not isRecording(); + if (newState) initRecorder(recorder_); else deinitRecorder(recorder_); + + // Notify each participant + for (const auto& participant_id : participants_) { + if (auto call = Manager::instance().callFactory.getCall<SIPCall>(participant_id)) { + call->updateRecState(newState); + } + } + return Recordable::toggleRecording(); } diff --git a/src/media/video/video_rtp_session.cpp b/src/media/video/video_rtp_session.cpp index 0d3fc06a55cc30fd2d8cdbe404980a5de1ad3b0d..34ab180936cbdb01a3883e9372b39a808f3b9a80 100644 --- a/src/media/video/video_rtp_session.cpp +++ b/src/media/video/video_rtp_session.cpp @@ -649,8 +649,6 @@ VideoRtpSession::initRecorder(std::shared_ptr<MediaRecorder>& rec) } } } - if (recordingStateCallback_) - recordingStateCallback_(true); } void @@ -666,9 +664,6 @@ VideoRtpSession::deinitRecorder(std::shared_ptr<MediaRecorder>& rec) input->detach(ob); } } - if (recordingStateCallback_) - recordingStateCallback_(false); - } void diff --git a/src/media/video/video_rtp_session.h b/src/media/video/video_rtp_session.h index d7f404c7f3f5ffc5c727e9ce22ee576ad30aade2..12865ba565b99ad93b887cddc3eecb724634519d 100644 --- a/src/media/video/video_rtp_session.h +++ b/src/media/video/video_rtp_session.h @@ -97,9 +97,6 @@ public: const std::string& getInput() const { return input_; } void setChangeOrientationCallback(std::function<void(int)> cb); - void setRecStateCallback(std::function<void(bool)> cb) { - recordingStateCallback_ = std::move(cb); - } void initRecorder(std::shared_ptr<MediaRecorder>& rec) override; void deinitRecorder(std::shared_ptr<MediaRecorder>& rec) override; diff --git a/src/sip/sipcall.cpp b/src/sip/sipcall.cpp index 79c277b3161c37587e14dfd18dcc15a1e2b17687..49526896be37b9de5d75514b352f8cc07569d748 100644 --- a/src/sip/sipcall.cpp +++ b/src/sip/sipcall.cpp @@ -1067,12 +1067,6 @@ SIPCall::startAllMedia() this_->setVideoOrientation(angle); }); }); - videortp_->setRecStateCallback([wthis = weak()] (bool state) { - runOnMainThread([wthis, state] { - if (auto this_ = wthis.lock()) - this_->updateRecState(state); - }); - }); #endif for (const auto& slot : slots) { @@ -1490,6 +1484,7 @@ SIPCall::toggleRecording() // add streams to recorder before starting the record if (not Call::isRecording()) { + updateRecState(true); std::stringstream ss; ss << "Conversation at %TIMESTAMP between " << getSIPAccount().getUserUri() << " and " << peerUri_; @@ -1501,6 +1496,7 @@ SIPCall::toggleRecording() videortp_->initRecorder(recorder_); #endif } else { + updateRecState(false); deinitRecorder(); } pendingRecord_ = false; @@ -1635,11 +1631,7 @@ SIPCall::rtpSetupSuccess(MediaType type) void SIPCall::setRemoteRecording(bool state) { - std::string id {}; - if (getConfId().empty()) - id = getCallId(); - else - id = getConfId(); + const std::string& id = getConfId().empty() ? getCallId() : getConfId(); if (state) { JAMI_WARN("SIP remote recording enabled"); emitSignal<DRing::CallSignal::RemoteRecordingChanged>(id, getPeerNumber(), true); @@ -1647,6 +1639,7 @@ SIPCall::setRemoteRecording(bool state) JAMI_WARN("SIP remote recording disabled"); emitSignal<DRing::CallSignal::RemoteRecordingChanged>(id, getPeerNumber(), false); } + peerRecording_ = state; } } // namespace jami diff --git a/src/sip/sipcall.h b/src/sip/sipcall.h index 72478f81087d86fac4edb155760f3ab980013651..17db1742c86b56405450982d19549e3739dc4c7b 100644 --- a/src/sip/sipcall.h +++ b/src/sip/sipcall.h @@ -237,6 +237,8 @@ public: // NOT SIP RELATED (good candidates to be moved elsewhere) void setRemoteRecording(bool state); + bool isPeerRecording() { return peerRecording_; } + private: using clock = std::chrono::steady_clock; using time_point = clock::time_point; @@ -370,6 +372,8 @@ private: OnReadyCb holdCb_ {}; OnReadyCb offHoldCb_ {}; + + bool peerRecording_ {false}; }; // Helpers