4#include <common/qgst_p.h>
5#include <common/qgst_debug_p.h>
6#include <common/qgstpipeline_p.h>
7#include <common/qgstreamermessage_p.h>
8#include <common/qgstutils_p.h>
10#include <QtCore/qdebug.h>
11#include <QtMultimedia/qcameradevice.h>
27 { QVideoFrameFormat::Format_YUV420P, GST_VIDEO_FORMAT_I420 },
28 { QVideoFrameFormat::Format_YUV422P, GST_VIDEO_FORMAT_Y42B },
29 { QVideoFrameFormat::Format_YV12, GST_VIDEO_FORMAT_YV12 },
30 { QVideoFrameFormat::Format_UYVY, GST_VIDEO_FORMAT_UYVY },
31 { QVideoFrameFormat::Format_YUYV, GST_VIDEO_FORMAT_YUY2 },
32 { QVideoFrameFormat::Format_NV12, GST_VIDEO_FORMAT_NV12 },
33 { QVideoFrameFormat::Format_NV21, GST_VIDEO_FORMAT_NV21 },
34 { QVideoFrameFormat::Format_AYUV, GST_VIDEO_FORMAT_AYUV },
35 { QVideoFrameFormat::Format_Y8, GST_VIDEO_FORMAT_GRAY8 },
36 { QVideoFrameFormat::Format_XRGB8888, GST_VIDEO_FORMAT_xRGB },
37 { QVideoFrameFormat::Format_XBGR8888, GST_VIDEO_FORMAT_xBGR },
38 { QVideoFrameFormat::Format_RGBX8888, GST_VIDEO_FORMAT_RGBx },
39 { QVideoFrameFormat::Format_BGRX8888, GST_VIDEO_FORMAT_BGRx },
40 { QVideoFrameFormat::Format_ARGB8888, GST_VIDEO_FORMAT_ARGB },
41 { QVideoFrameFormat::Format_ABGR8888, GST_VIDEO_FORMAT_ABGR },
42 { QVideoFrameFormat::Format_RGBA8888, GST_VIDEO_FORMAT_RGBA },
43 { QVideoFrameFormat::Format_BGRA8888, GST_VIDEO_FORMAT_BGRA },
44#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
45 { QVideoFrameFormat::Format_Y16, GST_VIDEO_FORMAT_GRAY16_LE },
46 { QVideoFrameFormat::Format_P010, GST_VIDEO_FORMAT_P010_10LE },
48 { QVideoFrameFormat::Format_Y16, GST_VIDEO_FORMAT_GRAY16_BE },
49 { QVideoFrameFormat::Format_P010, GST_VIDEO_FORMAT_P010_10BE },
55 for (size_t i = 0; i < qt_videoFormatLookup.size(); ++i)
64 for (size_t i = 0; i < qt_videoFormatLookup.size(); ++i)
84 if (!G_VALUE_HOLDS_BOOLEAN(value))
86 return g_value_get_boolean(value);
91 if (!G_VALUE_HOLDS_INT(value))
93 return g_value_get_int(value);
98 if (!G_VALUE_HOLDS_INT64(value))
100 return g_value_get_int64(value);
105 return value ? g_value_get_string(value) :
nullptr;
110 if (!GST_VALUE_HOLDS_FRACTION(value))
112 return (
float)gst_value_get_fraction_numerator(value)
113 / (
float)gst_value_get_fraction_denominator(value);
118 if (!GST_VALUE_HOLDS_FRACTION_RANGE(value))
122 return QGRange<
float>{ *min.getFraction(), *max.getFraction() };
127 if (!GST_VALUE_HOLDS_INT_RANGE(value))
129 return QGRange<
int>{ gst_value_get_int_range_min(value), gst_value_get_int_range_max(value) };
134 if (!value || !GST_VALUE_HOLDS_STRUCTURE(value))
135 return QGstStructureView(
nullptr);
141 if (!value || !GST_VALUE_HOLDS_CAPS(value))
143 return QGstCaps(gst_caps_copy(gst_value_get_caps(value)), QGstCaps::HasRef);
148 return value && GST_VALUE_HOLDS_LIST(value);
153 return gst_value_list_get_size(value);
158 return QGValue{ gst_value_list_get_value(value, index) };
172 return QUniqueGstStructureHandle{ gst_structure_copy(structure) };
182 return gst_structure_get_name(structure);
187 return QGValue{ gst_structure_get_value(structure, fieldname) };
201 QGstTagListHandle tagList;
202 gst_structure_get(structure,
"tags", GST_TYPE_TAG_LIST, &tagList,
nullptr);
211 if (structure && gst_structure_get_int(structure,
"width", &w)
212 && gst_structure_get_int(structure,
"height", &h)) {
222 QVideoFrameFormat::PixelFormat pixelFormat = QVideoFrameFormat::Format_Invalid;
227 if (gst_structure_has_name(structure,
"video/x-raw")) {
228 const gchar *s = gst_structure_get_string(structure,
"format");
230 GstVideoFormat format = gst_video_format_from_string(s);
231 int index = indexOfVideoFormat(format);
234 pixelFormat = qt_videoFormatLookup[index].pixelFormat;
236 }
else if (gst_structure_has_name(structure,
"image/jpeg")) {
237 pixelFormat = QVideoFrameFormat::Format_Jpeg;
248 std::optional<
float> minRate;
249 std::optional<
float> maxRate;
251 auto extractFraction = [](
const GValue *v) ->
float {
252 return (
float)gst_value_get_fraction_numerator(v)
253 / (
float)gst_value_get_fraction_denominator(v);
255 auto extractFrameRate = [&](
const GValue *v) {
256 auto insert = [&](
float min,
float max) {
257 if (!maxRate || max > maxRate)
259 if (!minRate || min < minRate)
263 if (GST_VALUE_HOLDS_FRACTION(v)) {
264 float rate = extractFraction(v);
266 }
else if (GST_VALUE_HOLDS_FRACTION_RANGE(v)) {
267 const GValue *min = gst_value_get_fraction_range_min(v);
268 const GValue *max = gst_value_get_fraction_range_max(v);
269 insert(extractFraction(min), extractFraction(max));
273 const GValue *gstFrameRates = gst_structure_get_value(structure,
"framerate");
275 if (GST_VALUE_HOLDS_LIST(gstFrameRates)) {
276 guint nFrameRates = gst_value_list_get_size(gstFrameRates);
277 for (guint f = 0; f < nFrameRates; ++f) {
278 extractFrameRate(gst_value_list_get_value(gstFrameRates, f));
281 extractFrameRate(gstFrameRates);
284 const GValue *min = gst_structure_get_value(structure,
"min-framerate");
285 const GValue *max = gst_structure_get_value(structure,
"max-framerate");
287 minRate = extractFraction(min);
288 maxRate = extractFraction(max);
292 if (!minRate || !maxRate)
296 minRate.value_or(*maxRate),
297 maxRate.value_or(*minRate),
306 const GValue *width = gst_structure_get_value(structure,
"width");
307 const GValue *height = gst_structure_get_value(structure,
"height");
309 if (!width || !height)
312 for (
const GValue *v : { width, height })
313 if (!GST_VALUE_HOLDS_INT_RANGE(v))
316 int minWidth = gst_value_get_int_range_min(width);
317 int maxWidth = gst_value_get_int_range_max(width);
318 int minHeight = gst_value_get_int_range_min(height);
319 int maxHeight = gst_value_get_int_range_max(height);
321 return QGRange<QSize>{
322 QSize(minWidth, minHeight),
323 QSize(maxWidth, maxHeight),
329 GstMessage *message =
nullptr;
330 gst_structure_get(structure,
"message", GST_TYPE_MESSAGE, &message,
nullptr);
331 return QGstreamerMessage(message, QGstreamerMessage::HasRef);
338 if (gst_structure_get_fraction(structure,
"pixel-aspect-ratio", &numerator, &denominator)) {
350 QSize size = resolution();
351 if (!size.isValid()) {
352 qWarning() << Q_FUNC_INFO <<
"invalid resolution when querying nativeSize";
364std::optional<std::pair<QVideoFrameFormat, GstVideoInfo>>
QGstCaps::formatAndVideoInfo()
const
366 GstVideoInfo vidInfo;
368 bool success = gst_video_info_from_caps(&vidInfo, get());
372 int index = indexOfVideoFormat(vidInfo.finfo->format);
376 QVideoFrameFormat format(QSize(vidInfo.width, vidInfo.height),
377 qt_videoFormatLookup[index].pixelFormat);
379 if (vidInfo.fps_d > 0)
380 format.setStreamFrameRate(qreal(vidInfo.fps_n) / vidInfo.fps_d);
382 QVideoFrameFormat::ColorRange range = QVideoFrameFormat::ColorRange_Unknown;
383 switch (vidInfo.colorimetry.range) {
384 case GST_VIDEO_COLOR_RANGE_UNKNOWN:
386 case GST_VIDEO_COLOR_RANGE_0_255:
387 range = QVideoFrameFormat::ColorRange_Full;
389 case GST_VIDEO_COLOR_RANGE_16_235:
390 range = QVideoFrameFormat::ColorRange_Video;
393 format.setColorRange(range);
395 QVideoFrameFormat::ColorSpace colorSpace = QVideoFrameFormat::ColorSpace_Undefined;
396 switch (vidInfo.colorimetry.matrix) {
397 case GST_VIDEO_COLOR_MATRIX_UNKNOWN:
398 case GST_VIDEO_COLOR_MATRIX_RGB:
399 case GST_VIDEO_COLOR_MATRIX_FCC:
401 case GST_VIDEO_COLOR_MATRIX_BT709:
402 colorSpace = QVideoFrameFormat::ColorSpace_BT709;
404 case GST_VIDEO_COLOR_MATRIX_BT601:
405 colorSpace = QVideoFrameFormat::ColorSpace_BT601;
407 case GST_VIDEO_COLOR_MATRIX_SMPTE240M:
408 colorSpace = QVideoFrameFormat::ColorSpace_AdobeRgb;
410 case GST_VIDEO_COLOR_MATRIX_BT2020:
411 colorSpace = QVideoFrameFormat::ColorSpace_BT2020;
414 format.setColorSpace(colorSpace);
416 QVideoFrameFormat::ColorTransfer transfer = QVideoFrameFormat::ColorTransfer_Unknown;
417 switch (vidInfo.colorimetry.transfer) {
418 case GST_VIDEO_TRANSFER_UNKNOWN:
420 case GST_VIDEO_TRANSFER_GAMMA10:
421 transfer = QVideoFrameFormat::ColorTransfer_Linear;
423 case GST_VIDEO_TRANSFER_GAMMA22:
424 case GST_VIDEO_TRANSFER_SMPTE240M:
425 case GST_VIDEO_TRANSFER_SRGB:
426 case GST_VIDEO_TRANSFER_ADOBERGB:
427 transfer = QVideoFrameFormat::ColorTransfer_Gamma22;
429 case GST_VIDEO_TRANSFER_GAMMA18:
430 case GST_VIDEO_TRANSFER_GAMMA20:
432 case GST_VIDEO_TRANSFER_BT709:
433 case GST_VIDEO_TRANSFER_BT2020_12:
434 transfer = QVideoFrameFormat::ColorTransfer_BT709;
436 case GST_VIDEO_TRANSFER_GAMMA28:
437 transfer = QVideoFrameFormat::ColorTransfer_Gamma28;
439 case GST_VIDEO_TRANSFER_LOG100:
440 case GST_VIDEO_TRANSFER_LOG316:
442 case GST_VIDEO_TRANSFER_SMPTE2084:
443 transfer = QVideoFrameFormat::ColorTransfer_ST2084;
445 case GST_VIDEO_TRANSFER_ARIB_STD_B67:
446 transfer = QVideoFrameFormat::ColorTransfer_STD_B67;
448 case GST_VIDEO_TRANSFER_BT2020_10:
449 transfer = QVideoFrameFormat::ColorTransfer_BT709;
451 case GST_VIDEO_TRANSFER_BT601:
452 transfer = QVideoFrameFormat::ColorTransfer_BT601;
455 format.setColorTransfer(transfer);
464 const char *modifier)
466 if (!gst_caps_is_writable(get()))
467 *
this = QGstCaps(gst_caps_make_writable(release()), QGstCaps::RefMode::HasRef);
470 g_value_init(&list, GST_TYPE_LIST);
472 for (QVideoFrameFormat::PixelFormat format : formats) {
473 int index = indexOfVideoFormat(format);
478 g_value_init(&item, G_TYPE_STRING);
479 g_value_set_string(&item,
480 gst_video_format_to_string(qt_videoFormatLookup[index].gstFormat));
481 gst_value_list_append_value(&list, &item);
482 g_value_unset(&item);
485 auto *structure = gst_structure_new(
"video/x-raw",
"framerate", GST_TYPE_FRACTION_RANGE, 0, 1,
486 INT_MAX, 1,
"width", GST_TYPE_INT_RANGE, 1, INT_MAX,
487 "height", GST_TYPE_INT_RANGE, 1, INT_MAX,
nullptr);
488 gst_structure_set_value(structure,
"format", &list);
489 gst_caps_append_structure(get(), structure);
490 g_value_unset(&list);
493 gst_caps_set_features(get(),
size() - 1, gst_caps_features_from_string(modifier));
498 Q_ASSERT(resolution.isValid());
500 g_value_init(&width, G_TYPE_INT);
501 g_value_set_int(&width, resolution.width());
503 g_value_init(&height, G_TYPE_INT);
504 g_value_set_int(&height, resolution.height());
506 gst_caps_set_value(caps(),
"width", &width);
507 gst_caps_set_value(caps(),
"height", &height);
512 QSize size = format.resolution();
513 GstStructure *structure =
nullptr;
514 if (format.pixelFormat() == QVideoFrameFormat::Format_Jpeg) {
515 structure = gst_structure_new(
"image/jpeg",
"width", G_TYPE_INT, size.width(),
"height",
516 G_TYPE_INT, size.height(),
nullptr);
518 int index = indexOfVideoFormat(format.pixelFormat());
521 auto gstFormat = qt_videoFormatLookup[index].gstFormat;
522 structure = gst_structure_new(
"video/x-raw",
"format", G_TYPE_STRING,
523 gst_video_format_to_string(gstFormat),
"width", G_TYPE_INT,
524 size.width(),
"height", G_TYPE_INT, size.height(),
nullptr);
527 gst_caps_append_structure(caps.get(), structure);
534 gst_caps_copy(caps()),
541 auto *features = gst_caps_get_features(get(), 0);
542 if (gst_caps_features_contains(features,
"memory:GLMemory"))
544 if (gst_caps_features_contains(features,
"memory:DMABuf"))
551 return int(gst_caps_get_size(get()));
557 gst_caps_get_structure(get(), index),
568 return QGstCaps(gst_caps_new_empty(), HasRef);
575 g_object_set(get(), property, str,
nullptr);
580 g_object_set(get(), property, gboolean(b),
nullptr);
585 g_object_set(get(), property, guint(i),
nullptr);
590 g_object_set(get(), property, gint(i),
nullptr);
595 g_object_set(get(), property, gint64(i),
nullptr);
600 g_object_set(get(), property, guint64(i),
nullptr);
605 g_object_set(get(), property, gdouble(d),
nullptr);
610 g_object_set(get(), property, o.object(),
nullptr);
615 g_object_set(get(), property, c.caps(),
nullptr);
618void QGstObject::
set(
const char *property,
void *object, GDestroyNotify destroyFunction)
620 g_object_set_data_full(qGstCheckedCast<GObject>(get()), property, object, destroyFunction);
626 g_object_get(get(), property, &s,
nullptr);
632 GstStructure *s =
nullptr;
633 g_object_get(get(), property, &s,
nullptr);
640 g_object_get(get(), property, &b,
nullptr);
647 g_object_get(get(), property, &i,
nullptr);
654 g_object_get(get(), property, &i,
nullptr);
661 g_object_get(get(), property, &i,
nullptr);
668 g_object_get(get(), property, &i,
nullptr);
675 g_object_get(get(), property, &d,
nullptr);
682 g_object_get(get(), property, &d,
nullptr);
688 GstObject *o =
nullptr;
689 g_object_get(get(), property, &o,
nullptr);
690 return QGstObject(o, HasRef);
695 return g_object_get_data(qGstCheckedCast<GObject>(get()), property);
703 g_signal_connect(get(), name, callback, userData),
709 g_signal_handler_disconnect(get(), handlerId);
714 return G_OBJECT_TYPE(get());
719 return QLatin1StringView{
731 using namespace Qt::StringLiterals;
733 return get() ? QLatin1StringView{ GST_OBJECT_NAME(get()) } :
"(null)"_L1;
748 object.disconnect(handlerId);
750 handlerId = invalidHandlerId;
765 connection.disconnect();
770 connection.disconnect();
793 return QGstCaps(gst_pad_get_current_caps(pad()), QGstCaps::HasRef);
798 return QGstCaps(gst_pad_query_caps(pad(),
nullptr), QGstCaps::HasRef);
803 QGstTagListHandle tagList;
804 g_object_get(object(),
"tags", &tagList,
nullptr);
811 gst_pad_get_stream_id(pad()),
817 using namespace Qt::Literals;
818 QLatin1StringView padName = name();
820 if (padName.startsWith(
"video_"_L1))
821 return QPlatformMediaPlayer::TrackType::VideoStream;
822 if (padName.startsWith(
"audio_"_L1))
823 return QPlatformMediaPlayer::TrackType::AudioStream;
824 if (padName.startsWith(
"text_"_L1))
825 return QPlatformMediaPlayer::TrackType::SubtitleStream;
832 return gst_pad_is_linked(pad());
837 return gst_pad_link(pad(), sink.pad()) == GST_PAD_LINK_OK;
842 return gst_pad_unlink(pad(), sink.pad());
856 return QGstPad(gst_pad_get_peer(pad()), HasRef);
861 return QGstElement(gst_pad_get_parent_element(pad()), HasRef);
866 return qGstCheckedCast<GstPad>(object());
871 return gst_pad_get_sticky_event(pad(), type, 0);
876 return gst_pad_send_event(pad(), event);
881 GstEvent *flushStart = gst_event_new_flush_start();
882 gboolean ret = sendEvent(flushStart);
884 qWarning(
"failed to send flush-start event");
888 GstEvent *flushStop = gst_event_new_flush_stop(resetTime);
889 ret = sendEvent(flushStop);
891 qWarning(
"failed to send flush-stop event");
896 using namespace std::chrono_literals;
898 GstState state =
parent().state(1s);
900 if (state != GST_STATE_PAUSED)
926 return qGstCheckedCast<GstClock>(object());
931 return gst_clock_get_time(clock());
946 GstElement *element = gst_element_factory_make(factory, name);
950 qWarning() <<
"Failed to make element" << name <<
"from factory" << factory;
951 return QGstElement{};
964 gst_element_factory_create(factory, name),
977 return createFromDevice(device.get(), name);
983 gst_device_create_element(device, name),
984 QGstElement::NeedsRef,
990 QUniqueGErrorHandle error;
992 gst_parse_launch(str, &error),
993 QGstElement::NeedsRef,
997 qWarning() <<
"gst_parse_launch error:" << error;
1009 return QGstElementFactoryHandle{
1010 gst_element_factory_find(name),
1011 QGstElementFactoryHandle::HasRef,
1015QGstElementFactoryHandle
QGstElement::findFactory(
const QByteArray &name)
1017 return findFactory(name.constData());
1022 return QGstPad(gst_element_get_static_pad(element(), name), HasRef);
1037 return QGstPad(gst_element_request_pad_simple(element(), name), HasRef);
1042 return gst_element_release_request_pad(element(), pad.pad());
1047 using namespace std::chrono_literals;
1050 GstStateChangeReturn change =
1051 gst_element_get_state(element(), &state,
nullptr, timeout.count());
1053 if (Q_UNLIKELY(change == GST_STATE_CHANGE_ASYNC))
1054 qWarning() <<
"QGstElement::state detected an asynchronous state change. Return value not "
1062 return gst_element_set_state(element(), state);
1067 GstStateChangeReturn change = gst_element_set_state(element(), state);
1068 if (change == GST_STATE_CHANGE_ASYNC)
1069 change = gst_element_get_state(element(),
nullptr, &state, timeout.count());
1071 if (change != GST_STATE_CHANGE_SUCCESS && change != GST_STATE_CHANGE_NO_PREROLL) {
1072 qWarning() <<
"Could not change state of" << name() <<
"to" << state << change;
1075 return change == GST_STATE_CHANGE_SUCCESS || change == GST_STATE_CHANGE_NO_PREROLL;
1080 Q_ASSERT(element());
1081 return gst_element_sync_state_with_parent(element()) == TRUE;
1086 GstState state, pending;
1087 GstStateChangeReturn change =
1088 gst_element_get_state(element(), &state, &pending, timeout.count());
1090 if (change != GST_STATE_CHANGE_SUCCESS && change != GST_STATE_CHANGE_NO_PREROLL) {
1091 qWarning() <<
"Could not finish change state of" << name() << change << state << pending;
1094 return change == GST_STATE_CHANGE_SUCCESS;
1100 GstStateChangeReturn change =
1101 gst_element_get_state(element(), &state,
nullptr, timeout.count());
1102 return change == GST_STATE_CHANGE_ASYNC;
1105bool QGstElement::waitForAsyncStateChangeComplete(
std::chrono::nanoseconds timeout)
const
1107 using namespace std::chrono_literals;
1109 if (!hasAsyncStateChange())
1114 std::this_thread::sleep_for(10ms);
1120 gst_element_set_locked_state(element(), locked);
1125 return gst_element_is_locked_state(element());
1130 gst_element_send_event(element(), event);
1135 sendEvent(gst_event_new_eos());
1141 if (!gst_element_query_duration(element(), GST_FORMAT_TIME, &d)) {
1142 qDebug() <<
"QGstElement: failed to query duration";
1143 return std::nullopt;
1145 return std::chrono::nanoseconds{ d };
1150 using namespace std::chrono;
1151 auto dur = duration();
1153 return round<milliseconds>(*dur);
1154 return std::nullopt;
1159 QGstQueryHandle &query = positionQuery();
1162 if (gst_element_query(element(), query.get())) {
1163 gst_query_parse_position(query.get(),
nullptr, &pos);
1164 return std::chrono::nanoseconds{ pos };
1167 qDebug() <<
"QGstElement: failed to query position";
1168 return std::nullopt;
1173 using namespace std::chrono;
1174 auto pos = position();
1176 return round<milliseconds>(*pos);
1177 return std::nullopt;
1182 QGstQueryHandle query{
1183 gst_query_new_seeking(GST_FORMAT_TIME),
1184 QGstQueryHandle::HasRef,
1186 gboolean canSeek =
false;
1187 gst_query_parse_seeking(query.get(),
nullptr, &canSeek,
nullptr,
nullptr);
1189 if (gst_element_query(element(), query.get())) {
1190 gst_query_parse_seeking(query.get(),
nullptr, &canSeek,
nullptr,
nullptr);
1193 return std::nullopt;
1198 return gst_element_get_base_time(element());
1203 gst_element_set_base_time(element(), time);
1208 return GST_ELEMENT_CAST(get());
1214 qGstCheckedCast<GstElement>(gst_element_get_parent(object())),
1215 QGstElement::HasRef,
1222 qGstCheckedCast<GstBin>(gst_element_get_parent(object())),
1223 QGstElement::HasRef,
1232 if (greatAncestor) {
1233 ancestor =
std::move(greatAncestor);
1236 if (GST_IS_BIN(ancestor.element())) {
1238 qGstSafeCast<GstBin>(ancestor.element()),
1250 if (GST_IS_PIPELINE(rootBin.get())) {
1251 return QGstPipeline{
1252 qGstSafeCast<GstPipeline>(rootBin.element()),
1253 QGstPipeline::NeedsRef,
1256 qWarning() <<
"QGstElement::getPipeline failed for element:" << *
this;
1257 return QGstPipeline{};
1263 if (QGstBin parent = getParentBin())
1264 parent.remove(*
this);
1269 static const bool dumpEnabled = qEnvironmentVariableIsSet(
"GST_DEBUG_DUMP_DOT_DIR");
1275QGstQueryHandle &
QGstElement::positionQuery()
const
1277 if (Q_UNLIKELY(!m_positionQuery))
1278 m_positionQuery = QGstQueryHandle{
1279 gst_query_new_position(GST_FORMAT_TIME),
1280 QGstQueryHandle::HasRef,
1283 return m_positionQuery;
1290 return QGstBin(gst_bin_new(name), NeedsRef);
1296 Q_ASSERT(GST_IS_BIN(element.element()));
1298 GST_BIN(element.release()),
1304 const char *name,
bool ghostUnlinkedPads)
1310 bool ghostUnlinkedPads)
1312 QUniqueGErrorHandle error;
1314 GstElement *element =
1315 gst_parse_bin_from_description_full(pipelineDescription, ghostUnlinkedPads,
1316 nullptr, GST_PARSE_FLAG_NONE, &error);
1319 qWarning() <<
"Failed to make element from pipeline description" << pipelineDescription
1325 gst_element_set_name(element, name);
1343 return qGstCheckedCast<GstBin>(object());
1353 gst_element_add_pad(element(), gst_ghost_pad_new(name, pad.pad()));
1358 Q_ASSERT(direction != GstPadDirection::GST_PAD_UNKNOWN);
1362 gst_bin_find_unlinked_pad(bin(), direction),
1369 addGhostPad(unlinkedPad.name().constData(), unlinkedPad);
1375 return gst_bin_sync_children_states(bin());
1383 if (includeTimestamp)
1384 GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(bin(), GST_DEBUG_GRAPH_SHOW_VERBOSE, fileNamePrefix);
1386 GST_DEBUG_BIN_TO_DOT_FILE(bin(), GST_DEBUG_GRAPH_SHOW_VERBOSE, fileNamePrefix);
1392 gst_bin_get_by_name(bin(), name),
1393 QGstElement::NeedsRef,
1399 gst_bin_recalculate_latency(bin());
1414 gst_base_sink_set_sync(baseSink(), arg ? TRUE : FALSE);
1419 return qGstCheckedCast<GstBaseSink>(element());
1434 return qGstCheckedCast<GstBaseSrc>(element());
1451 qGstCheckedCast<GstAppSink>(created.element()),
1452 QGstAppSink::NeedsRef,
1458 return qGstCheckedCast<GstAppSink>(element());
1461# if GST_CHECK_VERSION(1
, 24
, 0
)
1462void QGstAppSink::setMaxBufferTime(std::chrono::nanoseconds ns)
1464 gst_app_sink_set_max_time(appSink(), qGstClockTimeFromChrono(ns));
1470 gst_app_sink_set_max_buffers(appSink(), n);
1475 gst_app_sink_set_caps(appSink(), caps.caps());
1479 GDestroyNotify notify)
1481 gst_app_sink_set_callbacks(appSink(), &callbacks, user_data, notify);
1486 return QGstSampleHandle{
1487 gst_app_sink_pull_sample(appSink()),
1488 QGstSampleHandle::HasRef,
1506 qGstCheckedCast<GstAppSrc>(created.element()),
1507 QGstAppSrc::NeedsRef,
1513 return qGstCheckedCast<GstAppSrc>(element());
1517 GDestroyNotify notify)
1519 gst_app_src_set_callbacks(appSrc(), &callbacks, user_data, notify);
1524 return gst_app_src_push_buffer(appSrc(), buffer);
1529 return QStringLiteral(
"Could not find the %1 GStreamer element")
1530 .arg(QLatin1StringView(element));
QGObjectHandlerConnection(QGstObject object, gulong handler)
~QGObjectHandlerScopedConnection()
QGObjectHandlerScopedConnection(QGObjectHandlerConnection connection)
std::optional< int > toInt64() const
std::optional< QGRange< int > > toIntRange() const
std::optional< int > toInt() const
QGstStructureView toStructure() const
std::optional< QGRange< float > > getFractionRange() const
const char * toString() const
std::optional< float > getFraction() const
QGValue at(int index) const
std::optional< bool > toBool() const
QGstSampleHandle pullSample()
void setCallbacks(GstAppSinkCallbacks &callbacks, gpointer user_data, GDestroyNotify notify)
GstAppSink * appSink() const
void setCaps(const QGstCaps &caps)
static QGstAppSink create(const char *name)
QGstAppSink(GstAppSink *, RefMode)
static QGstAppSrc create(const char *name)
GstFlowReturn pushBuffer(GstBuffer *)
void setCallbacks(GstAppSrcCallbacks &callbacks, gpointer user_data, GDestroyNotify notify)
QGstAppSrc(GstAppSrc *, RefMode)
GstAppSrc * appSrc() const
QGstBaseSink(GstBaseSink *, RefMode)
GstBaseSink * baseSink() const
QGstBaseSrc(GstBaseSrc *, RefMode)
GstBaseSrc * baseSrc() const
void addUnlinkedGhostPads(GstPadDirection)
void dumpGraph(const char *fileNamePrefix, bool includeTimestamp=true) const
QGstElement findByName(const char *)
void recalculateLatency()
static QGstBin create(const char *name)
void addGhostPad(const QGstElement &child, const char *name)
static QGstBin createFromPipelineDescription(const char *pipelineDescription, const char *name=nullptr, bool ghostUnlinkedPads=false)
static QGstBin createFromFactory(const char *factory, const char *name)
void addGhostPad(const char *name, const QGstPad &pad)
QGstBin(GstBin *bin, RefMode mode=NeedsRef)
void addPixelFormats(const QList< QVideoFrameFormat::PixelFormat > &formats, const char *modifier=nullptr)
MemoryFormat memoryFormat() const
static QGstCaps fromCameraFormat(const QCameraFormat &format)
void setResolution(QSize)
QGstStructureView at(int index) const
QGstClock(GstClock *clock, RefMode mode)
GstClockTime time() const
QGstClock(const QGstObject &o)
void setBaseTime(GstClockTime time) const
GstStateChangeReturn setState(GstState state)
std::optional< std::chrono::nanoseconds > position() const
GstElement * element() const
QGstElement(GstElement *element, RefMode mode)
void lockState(bool locked)
QGstBin getRootBin() const
QGstPad getRequestPad(const char *name) const
std::optional< bool > canSeek() const
std::optional< std::chrono::nanoseconds > duration() const
bool isStateLocked() const
void sendEvent(GstEvent *event) const
void dumpPipelineGraph(const char *filename) const
GstClockTime baseTime() const
void releaseRequestPad(const QGstPad &pad) const
bool syncStateWithParent()
QGstPad staticPad(const char *name) const
QGstBin getParentBin() const
std::optional< std::chrono::milliseconds > positionInMs() const
static QGstElement createFromFactory(const char *factory, const char *name=nullptr)
QGstElement getParent() const
QGstPipeline getPipeline() const
static QGstElement createFromPipelineDescription(const char *)
std::optional< std::chrono::milliseconds > durationInMs() const
void set(const char *property, double d)
QGObjectHandlerConnection connect(const char *name, GCallback callback, gpointer userData)
void * getObject(const char *property) const
double getDouble(const char *property) const
int getInt(const char *property) const
void set(const char *property, int32_t i)
QLatin1StringView name() const
void set(const char *property, const QGstObject &o)
QGString getString(const char *property) const
void disconnect(gulong handlerId)
QGstObject getGstObject(const char *property) const
QLatin1StringView typeName() const
void set(const char *property, const char *str)
bool getBool(const char *property) const
QGstObject & operator=(QGstObject &&) noexcept=default
void set(const char *property, void *object, GDestroyNotify destroyFunction)
void set(const char *property, bool b)
quint64 getUInt64(const char *property) const
QGstStructureView getStructure(const char *property) const
qint64 getInt64(const char *property) const
void set(const char *property, const QGstCaps &c)
float getFloat(const char *property) const
uint getUInt(const char *property) const
GstObject * object() const
bool link(const QGstPad &sink) const
GstEvent * stickyEvent(GstEventType type)
QGstTagListHandle tags() const
QGstPad(const QGstObject &o)
QGstCaps queryCaps() const
QGstPad(GstPad *pad, RefMode mode)
void sendFlushStartStop(bool resetTime)
QGString streamId() const
std::optional< QPlatformMediaPlayer::TrackType > inferTrackTypeFromName() const
bool sendEvent(GstEvent *event)
QGstCaps currentCaps() const
QGstElement parent() const
bool unlink(const QGstPad &sink) const
QGstStructureView(const QUniqueGstStructureHandle &)
QGRange< float > frameRateRange() const
QGValue operator[](const char *fieldname) const
QVideoFrameFormat::PixelFormat pixelFormat() const
QUniqueGstStructureHandle clone() const
std::optional< QGRange< QSize > > resolutionRange() const
QGstreamerMessage getMessage()
std::optional< Fraction > pixelAspectRatio() const
QGstTagListHandle tags() const
QByteArrayView name() const
QGstStructureView(const GstStructure *)
QSize qCalculateFrameSizeGStreamer(QSize resolution, Fraction par)
constexpr std::array< VideoFormat, 19 > qt_videoFormatLookup
int indexOfVideoFormat(QVideoFrameFormat::PixelFormat format)
QString qGstErrorMessageCannotFindElement(std::string_view element)