Skip to content

Commit

Permalink
Fix recording not stopping (lynckia#1812)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arri98 authored May 11, 2022
1 parent 5623df2 commit 19b1c47
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion erizo/src/erizo/media/ExternalOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ bool ExternalOutput::init() {
m.hasVideo = false;
m.hasAudio = false;
recording_ = true;
closed_ = false;
asyncTask([] (std::shared_ptr<ExternalOutput> output) {
output->initializePipeline();
});
Expand All @@ -105,6 +106,7 @@ void ExternalOutput::syncClose() {
if (!recording_) {
return;
}
recording_ = false;
// Stop our thread so we can safely nuke libav stuff and close our
// our file.
cond_.notify_one();
Expand All @@ -129,7 +131,7 @@ void ExternalOutput::syncClose() {
}

pipeline_initialized_ = false;
recording_ = false;
closed_ = true;

ELOG_DEBUG("Closed Successfully");
}
Expand Down Expand Up @@ -591,3 +593,4 @@ AVDictionary* ExternalOutput::genVideoMetadata() {
return dict;
}
} // namespace erizo

5 changes: 3 additions & 2 deletions erizo/src/erizo/media/ExternalOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ class ExternalOutput : public MediaSink, public RawDataReceiver, public Feedback

void notifyUpdateToHandlers() override;

bool isRecording() { return recording_; }
bool hasClosed() { return closed_; }

private:
std::shared_ptr<Worker> worker_;
Pipeline::Ptr pipeline_;
std::unique_ptr<webrtc::UlpfecReceiver> fec_receiver_;
RtpPacketQueue audio_queue_, video_queue_;
std::atomic<bool> recording_, inited_;
std::atomic<bool> recording_, inited_, closed_;
boost::mutex mtx_; // a mutex we use to signal our writer thread that data is waiting.
boost::thread thread_;
boost::condition_variable cond_;
Expand Down Expand Up @@ -163,3 +163,4 @@ class ExternalOuputWriter : public OutboundHandler {

} // namespace erizo
#endif // ERIZO_SRC_ERIZO_MEDIA_EXTERNALOUTPUT_H_

3 changes: 2 additions & 1 deletion erizoAPI/ExternalOutput.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AsyncCloser : public Nan::AsyncWorker {
~AsyncCloser() {}
void Execute() {
external_output_->close();
while (external_output_->isRecording()) {
while (!external_output_->hasClosed()) {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
}
Expand Down Expand Up @@ -166,3 +166,4 @@ NAN_METHOD(ExternalOutput::init) {




0 comments on commit 19b1c47

Please sign in to comment.