Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix recording not stopping #1812

Merged
merged 5 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {