QGStreamerInterface Class | Qt Multimedia | Qt 6.12.0
Description: Provides GStreamer-specific integration points for Qt Multimedia.
Keywords: class

- Qt 6.12
- Qt Multimedia
- C++ Classes
- QtMultimedia
- QGStreamerInterface
- Qt 6.12.0 Reference Documentation

# QGStreamerInterface Class

Provides GStreamer-specific integration points for Qt Multimedia. More...

Header: | `#include <QGStreamerInterface>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Multimedia)` `target_link_libraries(mytarget PRIVATE Qt6::Multimedia)`
qmake: | `QT += multimedia`
Since: | Qt 6.12

- List of all members, including inherited members

## Public Functions

virtual | ~QGStreamerInterface()
virtual QVideoFrame | createFrameFromGstBuffer(GstBuffer *buffer, const GstVideoInfo &videoInfo) = 0
virtual QVideoFrame | createFrameFromGstBuffer(GstBuffer *buffer, const GstVideoInfoDmaDrm &videoInfo) = 0
virtual GstBuffer * | gstBuffer(const QVideoFrame &frame) = 0
virtual GstPipeline * | gstPipeline(QMediaCaptureSession *session) = 0
virtual GstPipeline * | gstPipeline(QMediaPlayer *player) = 0
virtual QAudioDevice | makeCustomGStreamerAudioInput(const QByteArray &gstreamerPipeline) = 0
virtual QAudioDevice | makeCustomGStreamerAudioOutput(const QByteArray &gstreamerPipeline) = 0

## Static Public Members

QGStreamerInterface * | instance()

## Detailed Description

Warning: The QGStreamerInterface class offers limited compatibility guarantees. There are no source or binary compatibility guarantees for this API, meaning it is only guaranteed to work with the Qt version the application has been developed against. Incompatible changes are aimed to be kept at a minimum and will only be made in minor releases.

To use this class in an application, link to `Qt::MultimediaPrivate` (if using CMake), and include the header `#include <QtMultimedia/spi/qgstreamerinterface.h>`.

QGStreamerInterface is the entry point for customizing the GStreamer backend: wrapping custom pipeline elements as Qt audio and video devices, accessing the underlying `GstPipeline` of high-level Qt objects, and converting between QVideoFrame and GStreamer buffers.

By default, the class is available in meta-qt6 builds. In custom builds with GStreamer support, the `gstreamer_qt_api` feature can enable it.

QtMultimedia must be run with the `gstreamer` media backend to get a valid instance of the class.

## Member Function Documentation

### `[virtual noexcept]` QGStreamerInterface::~QGStreamerInterface()

Destroys the interface.

### `[pure virtual]` QVideoFrame QGStreamerInterface::createFrameFromGstBuffer(GstBuffer *buffer, const GstVideoInfo &videoInfo)

Creates a QVideoFrame that wraps buffer using the format described by videoInfo.

The created frame shares ownership of the specified `GstBuffer` with the caller.

See also createFrameFromGstBuffer(GstBuffer *, const GstVideoInfoDmaDrm &) and gstBuffer().

### `[pure virtual]` QVideoFrame QGStreamerInterface::createFrameFromGstBuffer(GstBuffer *buffer, const GstVideoInfoDmaDrm &videoInfo)

Creates a QVideoFrame that wraps a DMA-BUF-backed buffer using the format described by videoInfo.

Requires GStreamer 1.24 or later with DMA-BUF video format support. If unsupported, returns an invalid QVideoFrame and logs a warning.

The created frame shares ownership of the specified `GstBuffer` with the caller.

See also createFrameFromGstBuffer(GstBuffer *, const GstVideoInfo &) and gstBuffer().

### `[pure virtual]` GstBuffer *QGStreamerInterface::gstBuffer(const QVideoFrame &frame)

Returns the GStreamer buffer backing frame, or `nullptr` if frame does not hold GStreamer-backed video memory.

Ownership of the returned buffer is not transferred.

See also createFrameFromGstBuffer().

### `[pure virtual]` GstPipeline *QGStreamerInterface::gstPipeline(QMediaCaptureSession *session)

Returns the underlying GStreamer pipeline for session, or `nullptr` if session is not backed by the GStreamer media backend.

Warning: The pipeline is still owned and driven by Qt Multimedia. Modifying its state or topology without coordinating with the capture session can cause undefined behavior.

See also QMediaCaptureSession.

### `[pure virtual]` GstPipeline *QGStreamerInterface::gstPipeline(QMediaPlayer *player)

Returns the underlying GStreamer pipeline for player, or `nullptr` if player is not backed by the GStreamer media backend.

Warning: The pipeline is still owned and driven by Qt Multimedia. Modifying its state or topology without coordinating with QMediaPlayer can cause undefined behavior.

See also QMediaPlayer.

### `[static]` QGStreamerInterface *QGStreamerInterface::instance()

Returns the GStreamer interface for the active Qt Multimedia backend, or `nullptr` if the GStreamer backend is not in use.

### `[pure virtual]` QAudioDevice QGStreamerInterface::makeCustomGStreamerAudioInput(const QByteArray &gstreamerPipeline)

Creates a custom audio input device from a GStreamer pipeline description.

The gstreamerPipeline string is parsed as a GStreamer bin description. The resulting elements are connected as the audio source of a QMediaCaptureSession when the returned QAudioDevice is passed to QAudioInput and assigned with QMediaCaptureSession::setAudioInput().

Element names in the description can be used to locate nodes in the session pipeline via `gst_bin_get_by_name()` after the capture session is active.

     #include <QtMultimedia/spi/qgstreamerinterface.h>

     QMediaCaptureSession session;
     QAudioInput input{
         QGStreamerInterface::instance()->makeCustomGStreamerAudioInput(
             "audiotestsrc wave=2 freq=200 ! identity name=myConverter") };
     session.setAudioInput(&input);

See also makeCustomGStreamerAudioOutput(), QAudioInput, and QMediaCaptureSession.

### `[pure virtual]` QAudioDevice QGStreamerInterface::makeCustomGStreamerAudioOutput(const QByteArray &gstreamerPipeline)

Creates a custom audio output device from a GStreamer pipeline description.

The gstreamerPipeline string is parsed as a GStreamer bin description. The resulting elements are connected as the audio sink of a QMediaCaptureSession when the returned QAudioDevice is passed to QAudioOutput and assigned with QMediaCaptureSession::setAudioOutput().

See also makeCustomGStreamerAudioInput(), QAudioOutput, and QMediaCaptureSession.