8#include <QtCore/QCoreApplication>
26constexpr guint64 kRecordingReservedMaxDurationNs = 2 * 3600 * GST_SECOND;
27constexpr guint64 kRecordingMoovUpdatePeriodNs = 5 * GST_SECOND;
28constexpr std::chrono::seconds kRecordingWatchInterval{1};
32constexpr gint64 kRecordingSyncPeriodUs =
static_cast<gint64
>(kRecordingMoovUpdatePeriodNs / GST_USECOND);
34 static_cast<qint64
>(2 * kRecordingMoovUpdatePeriodNs),
35 "The muxer's estimate of its header space counts from its second header update");
37 static_cast<qint64
>(kRecordingReservedMaxDurationNs),
38 "A recording's part must end well within the header space its muxer reserves");
53const char* recordingParserFactory(
const GstCaps* caps)
55 if (!caps || gst_caps_is_any(caps) || gst_caps_is_empty(caps)) {
59 for (guint i = 0; i < gst_caps_get_size(caps); ++i) {
60 const GstStructure* structure = gst_caps_get_structure(caps, i);
61 if (gst_structure_has_name(structure,
"video/x-h264")) {
64 if (gst_structure_has_name(structure,
"video/x-h265")) {
75GstPadProbeReturn timestampForMuxer([[maybe_unused]] GstPad* pad, GstPadProbeInfo* info, [[maybe_unused]] gpointer data)
77 GstBuffer* buffer = GST_PAD_PROBE_INFO_BUFFER(info);
78 if (!buffer || GST_BUFFER_PTS_IS_VALID(buffer)) {
79 return GST_PAD_PROBE_OK;
81 if (!GST_BUFFER_DTS_IS_VALID(buffer)) {
82 return GST_PAD_PROBE_DROP;
84 buffer = gst_buffer_make_writable(buffer);
85 GST_BUFFER_PTS(buffer) = GST_BUFFER_DTS(buffer);
86 GST_PAD_PROBE_INFO_DATA(info) = buffer;
87 return GST_PAD_PROBE_OK;
92GstPadProbeReturn syncPeriodically([[maybe_unused]] GstPad* pad, GstPadProbeInfo* info, gpointer data)
94 auto*
const markedAt =
static_cast<gint64*
>(data);
95 const gint64 now = g_get_monotonic_time();
96 GstBuffer* buffer = GST_PAD_PROBE_INFO_BUFFER(info);
97 if (!buffer || ((*markedAt != 0) && ((now - *markedAt) < kRecordingSyncPeriodUs))) {
98 return GST_PAD_PROBE_OK;
101 buffer = gst_buffer_make_writable(buffer);
102 GST_BUFFER_FLAG_SET(buffer, GST_BUFFER_FLAG_SYNC_AFTER);
103 GST_PAD_PROBE_INFO_DATA(info) = buffer;
104 return GST_PAD_PROBE_OK;
112GstPadProbeReturn syncAtEnd(GstPad* pad, GstPadProbeInfo* info, [[maybe_unused]] gpointer data)
114 const GstEvent*
const event = gst_pad_probe_info_get_event(info);
115 if (!event || (GST_EVENT_TYPE(event) != GST_EVENT_EOS)) {
116 return GST_PAD_PROBE_OK;
118 GstBuffer*
const buffer = gst_buffer_new();
119 gst_buffer_append_memory(buffer, gst_allocator_alloc(
nullptr, 0,
nullptr));
120 GST_BUFFER_FLAG_SET(buffer, GST_BUFFER_FLAG_SYNC_AFTER);
122 (void) gst_pad_chain(pad, buffer);
123 return GST_PAD_PROBE_OK;
129 RecordingBranch* branch =
nullptr;
130 quint64 recording = 0;
134GstPadProbeReturn holdCapsEvent([[maybe_unused]] GstPad* pad, GstPadProbeInfo* info, gpointer data)
136 GstEvent*
const event = gst_pad_probe_info_get_event(info);
137 GstCaps* caps =
nullptr;
138 if (event && (GST_EVENT_TYPE(event) == GST_EVENT_CAPS)) {
139 gst_event_parse_caps(event, &caps);
141 return (caps && gst_caps_is_equal(caps,
static_cast<const GstCaps*
>(data))) ? GST_PAD_PROBE_OK : GST_PAD_PROBE_PASS;
147 RecordingBranch* branch =
nullptr;
153bool reportsFullStorage(
const GError* error,
const char* debug)
158 if (g_error_matches(error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_NO_SPACE_LEFT)) {
161 return g_error_matches(error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_WRITE) && debug &&
162 (std::strstr(debug, g_strerror(ENOSPC)) !=
nullptr);
165QString notFinalizedError()
167 return QCoreApplication::translate(
"RecordingBranch",
168 "The recording was not finalized in time and may be incomplete.");
171void warnNotFinalized()
173 qCWarning(GstVideoReceiverLog) <<
"Recording not finalized within"
175 <<
"ms; closing it (MP4/MOV stay playable up to the last moov update)";
181 const GstCaps* inputCaps)
183 const char*
const muxerName = muxerFactory(format);
185 qCCritical(GstVideoReceiverLog) <<
"Unsupported file format" <<
static_cast<int>(format);
191 qCWarning(GstVideoReceiverLog) <<
"gst_bin_new('sinkbin') failed";
196 if (
const char* parserFactory = recordingParserFactory(inputCaps)) {
199 qCWarning(GstVideoReceiverLog) <<
"gst_element_factory_make() failed for" << parserFactory;
202 g_object_set(parserOwner.get(),
"config-interval", -1,
nullptr);
211 if (!muxerOwner || !fileSinkOwner) {
212 qCWarning(GstVideoReceiverLog) <<
"gst_element_factory_make() failed for" << muxerName <<
"or filesink";
217 if (GST_IS_TAG_SETTER(muxerOwner.get())) {
218 GstDateTime*
const started = gst_date_time_new_from_g_date_time(g_date_time_new_now_utc());
219 gst_tag_setter_add_tags(GST_TAG_SETTER(muxerOwner.get()), GST_TAG_MERGE_REPLACE, GST_TAG_DATE_TIME, started,
221 gst_date_time_unref(started);
225 g_object_set(muxerOwner.get(),
"reserved-max-duration", kRecordingReservedMaxDurationNs,
226 "reserved-moov-update-period", kRecordingMoovUpdatePeriodNs,
nullptr);
229 g_object_set(fileSinkOwner.get(),
"location",
GStreamer::glibFileName(file).constData(),
"async", FALSE,
nullptr);
233 if (!muxer || !fileSink || !gst_element_link(muxer, fileSink)) {
234 qCWarning(GstVideoReceiverLog) <<
"Failed to link the muxer and filesink";
239 (void) gst_pad_add_probe(fileSinkPad.get(), GST_PAD_PROBE_TYPE_BUFFER, syncPeriodically, g_new0(gint64, 1),
241 (void) gst_pad_add_probe(fileSinkPad.get(), GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, syncAtEnd,
nullptr,
nullptr);
247 qCWarning(GstVideoReceiverLog) <<
"gst_element_request_pad_simple(" << muxerName <<
", video_%u) failed";
250 (void) gst_pad_add_probe(muxerPad.get(), GST_PAD_PROBE_TYPE_BUFFER, timestampForMuxer,
nullptr,
nullptr);
256 if (!parserSrcPad || !parserSinkPad) {
257 qCCritical(GstVideoReceiverLog) <<
"gst_element_get_static_pad(parser) failed";
261 const GstPadLinkReturn linkResult = gst_pad_link(parserSrcPad.get(), muxerPad.get());
262 if (linkResult != GST_PAD_LINK_OK) {
263 qCWarning(GstVideoReceiverLog) <<
"Failed to link parser and muxer:" << gst_pad_link_get_name(linkResult);
269 for (
GstElement*
const element : {bin.get(), parser, muxer, fileSink}) {
275 GstPad*
const ghostpad = gst_ghost_pad_new(
"sink", parserSinkPad ? parserSinkPad.get() : muxerPad.get());
276 if (!ghostpad || !gst_element_add_pad(bin.get(), ghostpad)) {
277 qCWarning(GstVideoReceiverLog) <<
"Failed to add the recording sink's ghost pad";
286 , _listener(listener)
288 _finalizeTimer.setSingleShot(
true);
290 (void) QObject::connect(&_finalizeTimer, &QTimer::timeout, &_finalizeTimer, [
this]() {
291 if (_state == State::Finalizing) {
293 _finish(notFinalizedError());
296 _watchTimer.setInterval(kRecordingWatchInterval);
297 (void) QObject::connect(&_watchTimer, &QTimer::timeout, &_watchTimer, [
this]() {
316 g_object_set(_head.queue(),
"max-size-time", G_GUINT64_CONSTANT(0),
"max-size-buffers", 0,
"max-size-bytes",
318 _head.onOverrun(G_CALLBACK(_onQueueOverrun),
this);
323 gst_util_set_object_arg(G_OBJECT(_head.valve()),
"drop-mode",
"forward-sticky-events");
329 _finalizeTimer.stop();
331 _keyframeWatch.remove();
332 _startWatch.remove();
334 _releaseSwitchHold();
339 _state = State::Idle;
345 _requested = request;
355void RecordingBranch::_reconcile()
359 if (_requested && _streaming) {
363 case State::Recording:
364 if (_requested && (*_requested == _current)) {
365 _releaseSwitchHold();
366 }
else if (_requested && _fileStarted.load(std::memory_order_acquire)) {
369 if (_capsHold.load(std::memory_order_acquire) != 0) {
378 case State::Finalizing:
383void RecordingBranch::_start(
const Request& request)
386 (void) _recording.fetch_add(1, std::memory_order_relaxed);
388 _fileStarted.store(
false, std::memory_order_relaxed);
389 _fedAt.store(0, std::memory_order_relaxed);
390 _openedReported =
false;
391 _state = State::Recording;
393 qCDebug(GstVideoReceiverLog) <<
"Starting recording" << request.file << _context.redactedUri;
402 _fileSink =
makeFileSink(request.file, request.format, inputCaps.get());
404 _failure = QCoreApplication::translate(
"RecordingBranch",
"Unable to create the recording sink.");
410 gst_util_set_object_arg(G_OBJECT(_head.queue()),
"leaky",
"no");
411 if (!gst_bin_add(GST_BIN(_context.pipeline), _fileSink.get()) ||
412 !gst_element_link(_head.valve(), _fileSink.get())) {
413 qCWarning(GstVideoReceiverLog) <<
"Failed to add the recording sink" << _context.redactedUri;
414 _failure = QCoreApplication::translate(
"RecordingBranch",
"Unable to add the recording sink.");
419 if (!gst_element_sync_state_with_parent(_fileSink.get())) {
422 _failure = QCoreApplication::translate(
"RecordingBranch",
"Unable to start recording to %1.").arg(request.file);
423 _state = State::Finalizing;
424 _finalizeTimer.start();
436 const auto newWatch = [
this]() {
437 return new RecordingWatch{.branch =
this, .recording = _recording.load(std::memory_order_relaxed)};
439 const GDestroyNotify deleteWatch = [](gpointer watch) {
delete static_cast<RecordingWatch*
>(watch); };
440 if (!_keyframeWatch.add(valveSrc.get(), GST_PAD_PROBE_TYPE_BUFFER, _keyframeProbe,
this) ||
441 !_startWatch.add(parserSrc ? parserSrc.get() : valveSrc.get(), GST_PAD_PROBE_TYPE_BUFFER, _startProbe,
442 newWatch(), deleteWatch) ||
443 !_capsWatch.add(valveSink.get(), GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, _capsProbe, newWatch(), deleteWatch)) {
444 qCCritical(GstVideoReceiverLog) <<
"Failed to add the recording's probes" << _context.redactedUri;
445 _failure = QCoreApplication::translate(
"RecordingBranch",
"Unable to start recording.");
450 if (_switching || (_capsHold.load(std::memory_order_acquire) != 0)) {
453 g_object_set(_head.valve(),
"drop", FALSE,
nullptr);
458 _context.dotDumper->dump(_context.pipeline,
"pipeline-with-filesink");
461void RecordingBranch::_switchAtKeyframe()
467 if (!_switchHold.add(valveSrc.get(),
468 static_cast<GstPadProbeType
>(GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_BUFFER),
469 _switchProbe,
new SwitchWatch{.branch = this, .hold = ++_switchHoldId},
470 [](gpointer watch) { delete static_cast<SwitchWatch*>(watch); })) {
471 qCWarning(GstVideoReceiverLog) <<
"Unable to hold the next keyframe; frames up to it are not recorded";
478 _head.requestKeyframe();
481void RecordingBranch::_onSwitchKeyframe(quint64 hold)
483 if (!_switching || (hold != _switchHoldId) || (_state != State::Recording)) {
490void RecordingBranch::_releaseSwitchHold()
492 _switchHold.remove();
495 if (
const gulong capsHold = _capsHold.exchange(0, std::memory_order_acq_rel); (capsHold != 0) && _head.valve()) {
497 gst_pad_remove_probe(valveSrc.get(), capsHold);
501void RecordingBranch::_end(
const QString& failure)
503 if (_state != State::Recording) {
506 if (!failure.isEmpty()) {
511 _keyframeWatch.remove();
514 if (!_fileStarted.load(std::memory_order_acquire)) {
523 if (!recorderSink || !gst_pad_unlink(valveSrc.get(), recorderSink.get())) {
524 qCWarning(GstVideoReceiverLog) <<
"Unable to unlink the recording sink";
525 _finish(notFinalizedError());
529 _state = State::Finalizing;
530 _finalizeTimer.start();
533void RecordingBranch::_finish(
const QString& error,
bool fileClosed)
535 _finalizeTimer.stop();
537 _keyframeWatch.remove();
538 _startWatch.remove();
552 _state = State::Idle;
553 _context.dotDumper->dump(_context.pipeline,
"pipeline-recording-stopped");
555 const QString file = _current.file;
556 const bool fileOpened = _fileStarted.load(std::memory_order_acquire);
559 const QString fileError = error.isEmpty() ? _failure : error;
560 qCDebug(GstVideoReceiverLog) <<
"Recording closed" << file << fileError;
561 _listener.onRecordingFileClosed(file, fileError);
562 }
else if (QFile::exists(file) && !QFile::remove(file)) {
564 qCDebug(GstVideoReceiverLog) <<
"Unable to remove the empty recording" << file;
567 if (!_failure.isEmpty()) {
568 if (_requested && (_requested->file == file)) {
571 const QString failure = std::exchange(_failure, QString());
572 _listener.onRecordingFailed(file, failure, fileOpened);
579 _releaseSwitchHold();
588 _releaseSwitchHold();
589 if (_state != State::Recording) {
593 if (!_fileStarted.load(std::memory_order_acquire)) {
602 _state = State::Finalizing;
608 if (_state != State::Finalizing) {
617 (void) gst_pad_send_event(queueSink.get(), gst_event_new_flush_start());
618 _finish(notFinalizedError());
621bool RecordingBranch::_fromRecorder(GstObject* source)
const
623 return _fileSink && source && gst_object_has_as_ancestor(source, GST_OBJECT_CAST(_fileSink.get()));
628 if (!_fromRecorder(GST_MESSAGE_SRC(message))) {
629 qCDebug(GstVideoReceiverLog) <<
"Ignoring an error from an earlier recording:" << text;
635 qCWarning(GstVideoReceiverLog) <<
"Recording error:" << text <<
"-" << debug;
637 qCWarning(GstVideoReceiverLog) <<
"Recording error:" << text;
640 _failure = reportsFullStorage(error, debug) ? QCoreApplication::translate(
"RecordingBranch",
"The storage is full.")
650 const GstStructure* structure = gst_message_get_structure(message);
651 if (!structure || !gst_structure_has_name(structure,
"GstBinForwarded")) {
654 GstMessage* forwardedMessage =
nullptr;
655 (void) gst_structure_get(structure,
"message", GST_TYPE_MESSAGE, &forwardedMessage,
nullptr);
657 if (!forwarded || (GST_MESSAGE_TYPE(forwarded.get()) != GST_MESSAGE_EOS)) {
660 if (!_fromRecorder(GST_MESSAGE_SRC(forwarded.get()))) {
663 if (_state == State::Recording) {
668 qCDebug(GstVideoReceiverLog) <<
"Recording finalized" << _current.file;
669 _finish(QString(),
true);
672void RecordingBranch::_onFileOpened(quint64 recording)
674 if ((recording != _recording.load(std::memory_order_relaxed)) || (_state != State::Recording)) {
680void RecordingBranch::_onOverrun(quint64 recording)
682 if ((recording != _recording.load(std::memory_order_relaxed)) || (_state != State::Recording)) {
685 qCWarning(GstVideoReceiverLog) <<
"Recording storage too slow, its backlog is full; ending the recording"
687 _end(QCoreApplication::translate(
"RecordingBranch",
"The storage is too slow to keep up with the video."));
690void RecordingBranch::_onCapsChanged(quint64 recording)
692 if ((_capsHold.load(std::memory_order_acquire) == 0) || (_state == State::Finalizing)) {
696 if ((_state != State::Recording) || (recording != _recording.load(std::memory_order_relaxed))) {
698 _releaseSwitchHold();
703 qCDebug(GstVideoReceiverLog) <<
"The stream's caps changed while recording" << _current.file;
704 if (_requested && (*_requested == _current)) {
707 _listener.onRecordingNeedsNewFile(_current.file);
714void RecordingBranch::_checkStarted()
716 if ((_state != State::Recording) || _fileStarted.load(std::memory_order_acquire)) {
719 const gint64 fedAt = _fedAt.load(std::memory_order_relaxed);
720 if ((fedAt == 0) || ((g_get_monotonic_time() - fedAt) < std::chrono::microseconds(
kStartTimeout).count())) {
723 qCWarning(GstVideoReceiverLog) <<
"No keyframe to start the recording with within"
725 <<
"s of the stream's first one, as when keyframes come without their parameter"
726 <<
"sets; ending the recording" << _current.file;
728 QCoreApplication::translate(
"RecordingBranch",
"The video stream has no keyframe a recording can start from."));
731void RecordingBranch::_checkHeaderSpace()
735 if ((_state != State::Recording) || _switching || !_fileSink || !_openedReported ||
741 if (!muxer || !g_object_class_find_property(G_OBJECT_GET_CLASS(muxer.get()),
"reserved-duration-remaining")) {
745 guint64 remainingNs = 0;
746 g_object_get(muxer.get(),
"reserved-duration-remaining", &remainingNs,
nullptr);
747 if (remainingNs >=
static_cast<guint64
>(std::chrono::nanoseconds(
kHeaderSpaceMargin).count())) {
750 qCDebug(GstVideoReceiverLog) <<
"Header space left for about" << (remainingNs / GST_SECOND) <<
"s in"
752 _listener.onRecordingNeedsNewFile(_current.file);
755void RecordingBranch::_reportOpened()
757 if (_openedReported) {
760 _openedReported =
true;
762 qCDebug(GstVideoReceiverLog) <<
"Recording started" << _current.file;
763 _listener.onRecordingFileOpened(_current.file);
766GstPadProbeReturn RecordingBranch::_keyframeProbe([[maybe_unused]] GstPad* pad, GstPadProbeInfo* info, gpointer data)
769 if (self->_fedAt.load(std::memory_order_relaxed) != 0) {
770 return GST_PAD_PROBE_OK;
774 const GstBuffer*
const buffer = gst_pad_probe_info_get_buffer(info);
775 if (!buffer || GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT)) {
776 return GST_PAD_PROBE_DROP;
778 self->_fedAt.store(g_get_monotonic_time(), std::memory_order_relaxed);
779 return GST_PAD_PROBE_OK;
782GstPadProbeReturn RecordingBranch::_startProbe(GstPad* pad, GstPadProbeInfo* info, gpointer data)
784 const auto*
const watch =
static_cast<const RecordingWatch*
>(data);
786 if (self->_fileStarted.load(std::memory_order_relaxed)) {
787 return GST_PAD_PROBE_OK;
791 GstBuffer* buf = gst_pad_probe_info_get_buffer(info);
792 if (!buf || GST_BUFFER_FLAG_IS_SET(buf, GST_BUFFER_FLAG_DELTA_UNIT) || !GST_BUFFER_PTS_IS_VALID(buf)) {
793 return GST_PAD_PROBE_DROP;
797 GstClockTime runningTime = GST_CLOCK_TIME_NONE;
800 const GstSegment* segment =
nullptr;
801 gst_event_parse_segment(segmentEvent.get(), &segment);
802 if (segment && (segment->format == GST_FORMAT_TIME)) {
803 runningTime = gst_segment_to_running_time(segment, GST_FORMAT_TIME, GST_BUFFER_PTS(buf));
806 if (!GST_CLOCK_TIME_IS_VALID(runningTime)) {
807 return GST_PAD_PROBE_DROP;
811 gst_pad_set_offset(pad, -
static_cast<gint64
>(runningTime));
813 self->_fileStarted.store(
true, std::memory_order_release);
815 const quint64 recording = watch->recording;
816 self->_context.
post([self, recording]() { self->_onFileOpened(recording); });
817 return GST_PAD_PROBE_OK;
820GstPadProbeReturn RecordingBranch::_capsProbe(GstPad* pad, GstPadProbeInfo* info, gpointer data)
822 const auto*
const watch =
static_cast<const RecordingWatch*
>(data);
824 GstEvent*
const event = gst_pad_probe_info_get_event(info);
826 if (!event || (GST_EVENT_TYPE(event) != GST_EVENT_CAPS) || !self->_fileStarted.load(std::memory_order_acquire) ||
827 (self->_capsHold.load(std::memory_order_acquire) != 0)) {
828 return GST_PAD_PROBE_OK;
832 GstCaps* caps =
nullptr;
833 gst_event_parse_caps(event, &caps);
836 if (!
valve || (recorded && gst_caps_is_equal(recorded.get(), caps))) {
837 return GST_PAD_PROBE_OK;
845 self->_capsHold.store(
846 gst_pad_add_probe(valveSrc.get(),
847 static_cast<GstPadProbeType
>(GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM),
848 holdCapsEvent, gst_caps_ref(caps),
849 [](gpointer held) { gst_caps_unref(
static_cast<GstCaps*
>(held)); }),
850 std::memory_order_release);
851 const quint64 recording = watch->recording;
852 self->_context.
post([self, recording]() { self->_onCapsChanged(recording); });
853 return GST_PAD_PROBE_OK;
856GstPadProbeReturn RecordingBranch::_switchProbe([[maybe_unused]] GstPad* pad, GstPadProbeInfo* info, gpointer data)
858 const GstBuffer*
const buffer = gst_pad_probe_info_get_buffer(info);
859 if (!buffer || GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT) || !GST_BUFFER_PTS_IS_VALID(buffer)) {
861 return GST_PAD_PROBE_PASS;
864 const auto*
const watch =
static_cast<const SwitchWatch*
>(data);
866 const quint64 hold = watch->hold;
867 self->_context.
post([self, hold]() { self->_onSwitchKeyframe(hold); });
869 return GST_PAD_PROBE_OK;
872void RecordingBranch::_onQueueOverrun(
GstElement* queue, gpointer data)
877 gst_util_set_object_arg(G_OBJECT(queue),
"leaky",
"upstream");
878 const quint64 recording = self->_recording.load(std::memory_order_relaxed);
879 self->_context.
post([self, recording]() { self->_onOverrun(recording); });
struct _GstElement GstElement
static constexpr std::chrono::seconds kFinalizeTimeout
static constexpr std::chrono::seconds kHeaderEstimateDelay
static constexpr guint64 kQueueMaxBytes
Backlog the recording queue holds for slow storage before the recording gives up.
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)
RecordingBranch(const BranchContext &context, Listener &listener)
void setRequest(const std::optional< Request > &request)
GstElement * valve() const
static constexpr std::chrono::seconds kHeaderSpaceMargin
void onBusElement(GstMessage *message)
A bus ELEMENT message: the current recorder's EOS, as the pipeline forwards it, means its file is clo...
bool build()
Adds the branch's queue and closed valve behind the tee.
void onSourceStreaming()
The first frame reached the tee, so the input caps are known: a waiting request starts.
void reset()
Drops the recording, if any, without reports; the pipeline must be in NULL.
static GStreamer::GstElementPtr makeFileSink(const QString &file, VideoReceiver::FileFormat format, const GstCaps *inputCaps)
static constexpr std::chrono::seconds kStartTimeout
static constexpr std::chrono::minutes kMaxPartDuration
static void absorbFlowErrors(GstElement *part)
FileFormat
Values are persisted by VideoSettings::recordingFormat.
static QString recordingComment()
The comment recordings carry, of GStreamer and of a USB camera alike: the application and its version...
void disposeChild(GstElement *element)
std::unique_ptr< GstCaps, GstCapsDeleter > GstCapsPtr
std::unique_ptr< GstEvent, GstEventDeleter > GstEventPtr
GstElementPtr makeElement(const char *factory, const char *name=nullptr)
GstEventPtr adoptEvent(GstEvent *event) noexcept
void markBranch(GstElement *element, PipelineBranch branch)
Marks element and everything inside it as part of branch.
GstElement * addToBin(GstElement *bin, GstElementPtr element, const char *what)
std::unique_ptr< T, GstObjectDeleter > adoptFloating(T *object) noexcept
Sinks the floating ref of a new object (pipeline, bin, pad, element) and owns it. Null for null.
void sendEventAsync(GstPad *pad, GstEvent *event)
GstCapsPtr adoptCaps(GstCaps *caps) noexcept
std::unique_ptr< GstElement, GstObjectDeleter > GstElementPtr
std::unique_ptr< GstPad, GstObjectDeleter > GstPadPtr
GstElementPtr adoptElement(GstElement *element) noexcept
QByteArray glibFileName(const QString &file)
std::unique_ptr< GstMessage, GstMessageDeleter > GstMessagePtr
GstMessagePtr adoptMessage(GstMessage *message) noexcept
void flushAndDisposeChild(GstElement *element)
GstPadPtr adoptPad(GstPad *pad) noexcept
std::function< void(std::function< void()>)> post
Runs a task on the worker thread unless the session is gone by then.