Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qgstreamerinterface.cpp
Go to the documentation of this file.
1
// Copyright (C) 2026 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
include
"qgstreamerinterface.h"
5
6
#
include
<
QtMultimedia
/
private
/
qplatformmediaintegration_p
.
h
>
7
8
QT_BEGIN_NAMESPACE
9
10
/*!
11
\class QGStreamerInterface
12
\since 6.12
13
14
\brief Provides GStreamer-specific integration points for Qt Multimedia.
15
16
\inmodule QtMultimedia
17
\ingroup multimedia
18
19
\warning The QGStreamerInterface class offers limited compatibility guarantees.
20
There are no source or binary compatibility guarantees for this API, meaning it
21
is only guaranteed to work with the Qt version the application has been developed
22
against. Incompatible changes are aimed to be kept at a minimum and will only be
23
made in minor releases.
24
25
To use this class in an application, link to \c Qt::MultimediaPrivate (if using
26
CMake), and include the header
27
\c{#include <QtMultimedia/spi/qgstreamerinterface.h>}.
28
29
QGStreamerInterface is the entry point for customizing the GStreamer backend:
30
wrapping custom pipeline elements as Qt audio and video devices, accessing the
31
underlying \c GstPipeline of high-level Qt objects, and converting between
32
\l QVideoFrame and GStreamer buffers.
33
34
By default, the class is available in meta-qt6 builds. In custom builds
35
with GStreamer support, the \c gstreamer_qt_api feature can enable it.
36
37
QtMultimedia must be run with the \c gstreamer media backend to get a valid
38
instance of the class.
39
*/
40
41
42
/*!
43
Returns the GStreamer interface for the active Qt Multimedia backend, or
44
\c nullptr if the GStreamer backend is not in use.
45
*/
46
QGStreamerInterface *QGStreamerInterface::instance()
47
{
48
return
QPlatformMediaIntegration::instance()->gstreamerInterface();
49
}
50
51
/*!
52
\fn QGStreamerInterface::~QGStreamerInterface()
53
54
Destroys the interface.
55
*/
56
57
/*!
58
\fn QAudioDevice QGStreamerInterface::makeCustomGStreamerAudioInput(const QByteArray &gstreamerPipeline)
59
60
Creates a custom audio input device from a GStreamer pipeline description.
61
62
The \a gstreamerPipeline string is parsed as a GStreamer bin description. The
63
resulting elements are connected as the audio source of a \l QMediaCaptureSession
64
when the returned \l QAudioDevice is passed to \l QAudioInput and assigned with
65
\l{QMediaCaptureSession::setAudioInput()}.
66
67
Element names in the description can be used to locate nodes in the session
68
pipeline via \c gst_bin_get_by_name() after the capture session is active.
69
70
\code
71
#include <QtMultimedia/spi/qgstreamerinterface.h>
72
73
QMediaCaptureSession session;
74
QAudioInput input{
75
QGStreamerInterface::instance()->makeCustomGStreamerAudioInput(
76
"audiotestsrc wave=2 freq=200 ! identity name=myConverter") };
77
session.setAudioInput(&input);
78
\endcode
79
80
\sa makeCustomGStreamerAudioOutput(), QAudioInput, QMediaCaptureSession
81
*/
82
83
/*!
84
\fn QAudioDevice QGStreamerInterface::makeCustomGStreamerAudioOutput(const QByteArray &gstreamerPipeline)
85
86
Creates a custom audio output device from a GStreamer pipeline description.
87
88
The \a gstreamerPipeline string is parsed as a GStreamer bin description. The
89
resulting elements are connected as the audio sink of a \l QMediaCaptureSession
90
when the returned \l QAudioDevice is passed to \l QAudioOutput and assigned with
91
\l{QMediaCaptureSession::setAudioOutput()}.
92
93
\sa makeCustomGStreamerAudioInput(), QAudioOutput, QMediaCaptureSession
94
*/
95
96
/*!
97
\fn GstPipeline *QGStreamerInterface::gstPipeline(QMediaPlayer *player)
98
99
Returns the underlying GStreamer pipeline for \a player, or \c nullptr if
100
\a player is not backed by the GStreamer media backend.
101
102
\warning The pipeline is still owned and driven by Qt Multimedia. Modifying its
103
state or topology without coordinating with \l QMediaPlayer can cause undefined
104
behavior.
105
106
\sa QMediaPlayer
107
*/
108
109
/*!
110
\fn GstPipeline *QGStreamerInterface::gstPipeline(QMediaCaptureSession *session)
111
112
Returns the underlying GStreamer pipeline for \a session, or \c nullptr if
113
\a session is not backed by the GStreamer media backend.
114
115
\warning The pipeline is still owned and driven by Qt Multimedia. Modifying its
116
state or topology without coordinating with the capture session can cause undefined
117
behavior.
118
119
\sa QMediaCaptureSession
120
*/
121
122
/*!
123
\fn GstBuffer *QGStreamerInterface::gstBuffer(const QVideoFrame &frame)
124
125
Returns the GStreamer buffer backing \a frame, or \c nullptr if \a frame does not
126
hold GStreamer-backed video memory.
127
128
Ownership of the returned buffer is \e not transferred.
129
130
\sa createFrameFromGstBuffer()
131
*/
132
133
/*!
134
\fn QVideoFrame QGStreamerInterface::createFrameFromGstBuffer(GstBuffer *buffer, const GstVideoInfo &videoInfo)
135
136
Creates a \l QVideoFrame that wraps \a buffer using the format described by
137
\a videoInfo.
138
139
The created frame shares ownership of the specified \c GstBuffer with the caller.
140
141
\sa createFrameFromGstBuffer(GstBuffer *, const GstVideoInfoDmaDrm &), gstBuffer()
142
*/
143
144
/*!
145
\fn QVideoFrame QGStreamerInterface::createFrameFromGstBuffer(GstBuffer *buffer, const GstVideoInfoDmaDrm &videoInfo)
146
147
Creates a \l QVideoFrame that wraps a DMA-BUF-backed \a buffer using the format
148
described by \a videoInfo.
149
150
Requires GStreamer 1.24 or later with DMA-BUF video format support. If unsupported,
151
returns an invalid \l QVideoFrame and logs a warning.
152
153
The created frame shares ownership of the specified \c GstBuffer with the caller.
154
155
\sa createFrameFromGstBuffer(GstBuffer *, const GstVideoInfo &), gstBuffer()
156
*/
157
158
QGStreamerInterface::~QGStreamerInterface() =
default
;
159
160
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtmultimedia
src
multimedia
spi
qgstreamerinterface.cpp
Generated on
for Qt by
1.16.1