The recording branch behind the session's tee: queue ! valve [! parser ! muxer ! filesink]. More...
#include <RecordingBranch.h>
Classes | |
| class | Listener |
| struct | Request |
Public Member Functions | |
| RecordingBranch (const BranchContext &context, Listener &listener) | |
| ~RecordingBranch () | |
| RecordingBranch (const RecordingBranch &)=delete | |
| RecordingBranch & | operator= (const RecordingBranch &)=delete |
| bool | build () |
| Adds the branch's queue and closed valve behind the tee. | |
| void | reset () |
| Drops the recording, if any, without reports; the pipeline must be in NULL. | |
| void | setRequest (const std::optional< Request > &request) |
| void | onSourceStreaming () |
| The first frame reached the tee, so the input caps are known: a waiting request starts. | |
| bool | beginTeardown () |
| bool | finalizing () const |
| void | completeTeardown () |
| Closes a file whose finalization is still outstanding by flushing the recorder, and reports it. | |
| void | onBusError (GstMessage *message, const GError *error, const QString &text, const char *debug) |
| void | onBusElement (GstMessage *message) |
| A bus ELEMENT message: the current recorder's EOS, as the pipeline forwards it, means its file is closed. | |
| GstElement * | valve () const |
Static Public Member Functions | |
| static GStreamer::GstElementPtr | makeFileSink (const QString &file, VideoReceiver::FileFormat format, const GstCaps *inputCaps) |
Static Public Attributes | |
| static constexpr std::chrono::seconds | kFinalizeTimeout {3} |
| static constexpr guint64 | kQueueMaxBytes = 64 * 1024 * 1024 |
| Backlog the recording queue holds for slow storage before the recording gives up. | |
| static constexpr std::chrono::seconds | kStartTimeout {5} |
| static constexpr std::chrono::seconds | kHeaderSpaceMargin {60} |
| static constexpr std::chrono::seconds | kHeaderEstimateDelay {10} |
The recording branch behind the session's tee: queue ! valve [! parser ! muxer ! filesink].
Records the requested file from the next keyframe once the source streams, asking upstream for that keyframe, and finalizes it within kFinalizeTimeout when the request goes away or the pipeline is torn down. The file starts with the first keyframe the recorder's parser passes on, which is one that comes with its parameter sets; the recording fails when none does within kStartTimeout of the stream's first keyframe. A request for another file while one records ends that one before the stream's next keyframe, asked for upstream too, which starts the other: no frame between them is lost. MP4/MOV are muxed so a crash leaves the file playable up to the last header update. The branch asks the listener for another file before the header space they reserve runs out, and when the stream's caps change (a new resolution or profile), where the running file ends and the other begins. A failing recorder (disk full, storage too slow to keep up) ends the recording, not the stream: its queue holds kQueueMaxBytes of backlog and then stops taking frames rather than holding up the tee and with it the display. A finalized file is synced to the disk before it is reported closed.
Threading: the receiver's worker, except the probes and the queue's signal handler (streaming threads), which hand their work to the worker through BranchContext::post().
Definition at line 32 of file RecordingBranch.h.
| RecordingBranch::RecordingBranch | ( | const BranchContext & | context, |
| Listener & | listener ) |
Definition at line 284 of file RecordingBranch.cc.
References kFinalizeTimeout.
Referenced by operator=(), and RecordingBranch().
| RecordingBranch::~RecordingBranch | ( | ) |
Definition at line 303 of file RecordingBranch.cc.
References reset().
|
delete |
References RecordingBranch().
| bool RecordingBranch::beginTeardown | ( | ) |
Before a teardown: drains an open file through EOS. True while its finalization is outstanding, which the caller waits for by handling the bus until completeTeardown().
Definition at line 582 of file RecordingBranch.cc.
References GStreamer::adoptPad(), finalizing(), and GStreamer::sendEventAsync().
|
nodiscard |
Adds the branch's queue and closed valve behind the tee.
Definition at line 308 of file RecordingBranch.cc.
References kQueueMaxBytes, and GStreamer::Recording.
| void RecordingBranch::completeTeardown | ( | ) |
Closes a file whose finalization is still outstanding by flushing the recorder, and reports it.
Definition at line 606 of file RecordingBranch.cc.
References GStreamer::adoptPad().
|
inline |
Definition at line 103 of file RecordingBranch.h.
Referenced by beginTeardown().
|
static |
The sink bin a recording links to the valve: an optional parser for inputCaps, the muxer for format and a filesink writing file. Returns an owned, non-floating ref, or null on failure.
Definition at line 180 of file RecordingBranch.cc.
References GStreamer::addToBin(), GStreamer::adoptFloating(), GStreamer::adoptPad(), GStreamer::glibFileName(), GStreamer::makeElement(), GStreamer::markBranch(), VideoReceiver::Mkv, VideoReceiver::Mov, VideoReceiver::Mp4, GStreamer::Recording, and VideoReceiver::recordingComment().
Referenced by GStreamer::SelfTest::recordSample().
| void RecordingBranch::onBusElement | ( | GstMessage * | message | ) |
A bus ELEMENT message: the current recorder's EOS, as the pipeline forwards it, means its file is closed.
Definition at line 646 of file RecordingBranch.cc.
References GStreamer::adoptMessage().
| void RecordingBranch::onBusError | ( | GstMessage * | message, |
| const GError * | error, | ||
| const QString & | text, | ||
| const char * | debug ) |
A bus ERROR from the recording branch (GStreamer::PipelineBranch::Recording): the current recorder's fails the recording, with text unless the error is a full disk, which is named instead.
Definition at line 626 of file RecordingBranch.cc.
| void RecordingBranch::onSourceStreaming | ( | ) |
The first frame reached the tee, so the input caps are known: a waiting request starts.
Definition at line 349 of file RecordingBranch.cc.
|
delete |
References RecordingBranch().
| void RecordingBranch::reset | ( | ) |
Drops the recording, if any, without reports; the pipeline must be in NULL.
Definition at line 327 of file RecordingBranch.cc.
References GStreamer::flushAndDisposeChild().
Referenced by ~RecordingBranch().
| void RecordingBranch::setRequest | ( | const std::optional< Request > & | request | ) |
Records request from now on, finishing a different one first, at the next keyframe if it has frames; nullopt stops recording.
Definition at line 343 of file RecordingBranch.cc.
|
inline |
Definition at line 114 of file RecordingBranch.h.
|
staticconstexpr |
How long a recording may take to finalize, its last sync to the disk included, before it is closed anyway; covers slow storage.
Definition at line 64 of file RecordingBranch.h.
Referenced by RecordingBranch(), and PipelineSession::shutdown().
|
staticconstexpr |
How long a file records before its muxer's estimate of that room counts: until the muxer's second header update the estimate comes from the file's first frame alone.
Definition at line 75 of file RecordingBranch.h.
|
staticconstexpr |
The recording time an MP4 or MOV file's header must have room for; with less left, the recording asks for another file. Covers the wait for the keyframe the next file starts with.
Definition at line 72 of file RecordingBranch.h.
|
staticconstexpr |
Backlog the recording queue holds for slow storage before the recording gives up.
Definition at line 66 of file RecordingBranch.h.
Referenced by build().
|
staticconstexpr |
How long a recording whose recorder gets the stream's keyframes waits for the first one it can write: one that comes with its parameter sets. The recording fails after that.
Definition at line 69 of file RecordingBranch.h.