Commit d8de5efe authored by Pierre Lespagnol's avatar Pierre Lespagnol Committed by Adrien Béraud

recorder: host notify each peer when recording + cleanup

- Allows conference host to notify each participant when recording
- Remove unnecessary callback
- Notify host if remaining participant is still recording after conference
- Update host notification if participant leave the conference

Change-Id: Ib17675442f2e175fe8711c695bc737ffa6d89f05
parent bae4f92a
......@@ -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();
}
......
......@@ -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
......
......@@ -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;
......
......@@ -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
......@@ -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
......
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