summaryrefslogtreecommitdiffstats
path: root/src/multimedia/platform/gstreamer/common/qgstreamervideooutput.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/multimedia/platform/gstreamer/common/qgstreamervideooutput.cpp')
-rw-r--r--src/multimedia/platform/gstreamer/common/qgstreamervideooutput.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/multimedia/platform/gstreamer/common/qgstreamervideooutput.cpp b/src/multimedia/platform/gstreamer/common/qgstreamervideooutput.cpp
index 939e88599..103a15557 100644
--- a/src/multimedia/platform/gstreamer/common/qgstreamervideooutput.cpp
+++ b/src/multimedia/platform/gstreamer/common/qgstreamervideooutput.cpp
@@ -39,6 +39,8 @@
#include <private/qgstreamervideooutput_p.h>
#include <private/qgstreamervideorenderer_p.h>
+#include <private/qgstreamervideowindow_p.h>
+#include <qvideosink.h>
#include <QtCore/qloggingcategory.h>
#include <qthread.h>
@@ -109,6 +111,36 @@ void QGstreamerVideoOutput::setVideoSurface(QAbstractVideoSurface *surface)
pad.addProbe<&QGstreamerVideoOutput::prepareVideoOutputChange>(this, GST_PAD_PROBE_TYPE_IDLE);
}
+void QGstreamerVideoOutput::setVideoSink(QVideoSink *sink)
+{
+ if (!m_videoWindow) {
+ m_videoWindow = new QGstreamerVideoWindow;
+ gstPipeline.installMessageFilter(static_cast<QGstreamerSyncMessageFilter *>(m_videoWindow));
+ gstPipeline.installMessageFilter(static_cast<QGstreamerBusMessageFilter *>(m_videoWindow));
+ m_videoWindow->setWinId(sink->nativeWindowId());
+ }
+
+ newVideoSink = m_videoWindow->videoSink();
+ if (newVideoSink == videoSink) {
+ newVideoSink = {};
+ return;
+ }
+ gstVideoOutput.add(newVideoSink);
+
+ qCDebug(qLcMediaVideoOutput) << "setVideoSurface: Reconfiguring video output" << QThread::currentThreadId();
+
+ auto state = gstPipeline.state();
+
+ if (state != GST_STATE_PLAYING) {
+ changeVideoOutput();
+ return;
+ }
+
+ // This doesn't quite work, as we're be getting the callback in another thread where state changes aren't allowed.
+ auto pad = videoScale.staticPad("src");
+ pad.addProbe<&QGstreamerVideoOutput::prepareVideoOutputChange>(this, GST_PAD_PROBE_TYPE_IDLE);
+}
+
void QGstreamerVideoOutput::setIsPreview()
{
// configures the queue to be fast and lightweight for camera preview