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

MediaRecorder: avoid unneeded processing when disabled

Change-Id: I73b549126ce325b8643a1194da7cafadf25a0c9b
parent 62cdae01
No related branches found
No related tags found
No related merge requests found
...@@ -84,6 +84,8 @@ struct MediaRecorder::StreamObserver : public Observer<std::shared_ptr<MediaFram ...@@ -84,6 +84,8 @@ struct MediaRecorder::StreamObserver : public Observer<std::shared_ptr<MediaFram
void update(Observable<std::shared_ptr<MediaFrame>>* /*ob*/, void update(Observable<std::shared_ptr<MediaFrame>>* /*ob*/,
const std::shared_ptr<MediaFrame>& m) override const std::shared_ptr<MediaFrame>& m) override
{ {
if (not isEnabled)
return;
#ifdef ENABLE_VIDEO #ifdef ENABLE_VIDEO
if (info.isVideo) { if (info.isVideo) {
std::shared_ptr<VideoFrame> framePtr; std::shared_ptr<VideoFrame> framePtr;
...@@ -139,6 +141,7 @@ struct MediaRecorder::StreamObserver : public Observer<std::shared_ptr<MediaFram ...@@ -139,6 +141,7 @@ struct MediaRecorder::StreamObserver : public Observer<std::shared_ptr<MediaFram
observablesFrames_.erase(it); observablesFrames_.erase(it);
} }
bool isEnabled = false;
private: private:
std::function<void(const std::shared_ptr<MediaFrame>&)> cb_; std::function<void(const std::shared_ptr<MediaFrame>&)> cb_;
std::unique_ptr<MediaFilter> videoRotationFilter_ {}; std::unique_ptr<MediaFilter> videoRotationFilter_ {};
...@@ -201,6 +204,12 @@ MediaRecorder::startRecording() ...@@ -201,6 +204,12 @@ MediaRecorder::startRecording()
JAMI_DBG() << "Start recording '" << getPath() << "'"; JAMI_DBG() << "Start recording '" << getPath() << "'";
if (initRecord() >= 0) { if (initRecord() >= 0) {
isRecording_ = true; isRecording_ = true;
{
std::lock_guard<std::mutex> lk(mutexStreamSetup_);
for (auto& media : streams_) {
media.second->isEnabled = true;
}
}
// start thread after isRecording_ is set to true // start thread after isRecording_ is set to true
dht::ThreadPool::computation().run([rec = shared_from_this()] { dht::ThreadPool::computation().run([rec = shared_from_this()] {
std::lock_guard<std::mutex> lk(rec->encoderMtx_); std::lock_guard<std::mutex> lk(rec->encoderMtx_);
...@@ -249,6 +258,12 @@ MediaRecorder::stopRecording() ...@@ -249,6 +258,12 @@ MediaRecorder::stopRecording()
if (isRecording_) { if (isRecording_) {
JAMI_DBG() << "Stop recording '" << getPath() << "'"; JAMI_DBG() << "Stop recording '" << getPath() << "'";
isRecording_ = false; isRecording_ = false;
{
std::lock_guard<std::mutex> lk(mutexStreamSetup_);
for (auto& media : streams_) {
media.second->isEnabled = false;
}
}
emitSignal<libjami::CallSignal::RecordPlaybackStopped>(getPath()); emitSignal<libjami::CallSignal::RecordPlaybackStopped>(getPath());
} }
} }
...@@ -287,6 +302,7 @@ MediaRecorder::addStream(const MediaStream& ms) ...@@ -287,6 +302,7 @@ MediaRecorder::addStream(const MediaStream& ms)
}); });
} }
} }
it->second->isEnabled = isRecording_;
if (ms.isVideo) if (ms.isVideo)
setupVideoOutput(); setupVideoOutput();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment