4#include <QtMultimedia/qvideosink.h>
6#include <QtCore/qloggingcategory.h>
7#include <QtCore/qthread.h>
31 static std::optional<QString> elementCheck = []() -> std::optional<QString> {
49QGstreamerVideoOutput::QGstreamerVideoOutput(
QObject *parent)
55 QGstElement::createFromFactory(
"queue",
"videoQueue"),
61 QGstElement::createFromFactory(
"fakesink",
"fakeVideoSink"),
64 m_videoSink.
set(
"sync",
true);
65 m_videoSink.
set(
"async",
false);
67 m_outputBin.
add(m_videoQueue, m_videoConvertScale, m_videoSink);
84 if (gstVideoSink == m_platformVideoSink)
87 m_platformVideoSink = gstVideoSink;
88 if (m_platformVideoSink) {
89 m_platformVideoSink->
setActive(m_isActive);
94 if (m_platformVideoSink) {
95 videoSink = m_platformVideoSink->
gstSink();
99 videoSink.
set(
"sync",
true);
100 videoSink.
set(
"async",
false);
107 sink->setSubtitleText(subtitle);
109 sink->setSubtitleText(m_lastSubtitleString);
112 if (m_videoSink == videoSink)
116 if (!m_videoSink.
isNull())
119 m_videoSink = videoSink;
120 m_outputBin.
add(m_videoSink);
124 GstEvent *
event = gst_event_new_reconfigure();
129 qCDebug(qLcMediaVideoOutput) <<
"sinkChanged" << videoSink.
name();
136 m_pipeline = pipeline;
145 if (m_platformVideoSink)
149void QGstreamerVideoOutput::updateNativeSize()
151 if (!m_platformVideoSink)
161 m_videoQueue.
set(
"leaky", 2 );
162 m_videoQueue.
set(
"silent",
true);
163 m_videoQueue.
set(
"max-size-buffers",
uint(1));
164 m_videoQueue.
set(
"max-size-bytes",
uint(0));
165 m_videoQueue.
set(
"max-size-time",
quint64(0));
170 if (!m_subtitleSink.
isNull()) {
171 auto pad = m_subtitleSink.
staticPad(
"sink");
172 auto *
event = gst_event_new_flush_start();
173 pad.sendEvent(
event);
174 event = gst_event_new_flush_stop(
false);
175 pad.sendEvent(
event);
196 m_lastSubtitleString =
string;
203#include "moc_qgstreamervideooutput_p.cpp"
std::enable_if_t<(std::is_base_of_v< QGstElement, Ts > &&...), void add)(const Ts &...ts)
void dumpGraph(const char *fileNamePrefix) const
void addGhostPad(const QGstElement &child, const char *name)
std::enable_if_t<(std::is_base_of_v< QGstElement, Ts > &&...), void stopAndRemoveElements)(Ts... ts)
static QGstBin createFromPipelineDescription(const QByteArray &pipelineDescription, const char *name=nullptr, bool ghostUnlinkedPads=false)
GstElement * element() const
bool setStateSync(GstState state, std::chrono::nanoseconds timeout=std::chrono::seconds(1))
bool syncStateWithParent()
QGstPad staticPad(const char *name) const
static QGstElement createFromFactory(const char *factory, const char *name=nullptr)
static QGstElementFactoryHandle findFactory(const char *)
QLatin1StringView name() const
void set(const char *property, const char *str)
void modifyPipelineWhileNotRunning(Functor &&fn)
static QGstElement createSink(QAbstractSubtitleObserver *observer)
void setPipeline(const QGstPipeline &pipeline)
void subtitleChanged(QString)
void setNativeSize(QSize)
void updateSubtitle(QString) override
void setVideoSink(QVideoSink *sink)
void setRotation(QtVideo::Rotation)
static QMaybe< QGstreamerVideoOutput * > create(QObject *parent=nullptr)
constexpr const char * constData() const noexcept
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
constexpr bool isValid() const noexcept
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
\macro QT_RESTRICTED_CAST_FROM_ASCII
The QVideoSink class represents a generic sink for video data.
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
std::enable_if_t<(std::is_base_of_v< QGstElement, Ts > &&...), void qLinkGstElements)(const Ts &...ts)
std::optional< QString > qGstErrorMessageIfElementsNotAvailable(const Arg &arg, Args... args)
static QT_BEGIN_NAMESPACE QGstElement makeVideoConvertScale(const char *name)
#define qCDebug(category,...)
#define Q_STATIC_LOGGING_CATEGORY(name,...)
GLsizei GLenum GLboolean sink
GLsizei const GLchar *const * string
[0]
unsigned long long quint64
QItemEditorFactory * factory