hc
2023-11-06 15ade055295d13f95d49e3d99b09f3bbfb4a43e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
From c8faf3fa70039a2f396d3c2ed423a3f300025f2f Mon Sep 17 00:00:00 2001
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Date: Fri, 15 Jan 2021 16:27:59 +0800
Subject: [PATCH 11/17] quicktools: Prefer VideoWindowBackend when using gst
 sink
 
Prefer VideoWindowBackend for video overlay.
 
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
 .../qdeclarativevideooutput.cpp                   | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
 
diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp b/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp
index ca3a4b2e..d2f735b3 100644
--- a/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp
+++ b/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp
@@ -245,6 +245,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, videoBackendFactoryLoader,
 bool QDeclarativeVideoOutput::createBackend(QMediaService *service)
 {
     bool backendAvailable = false;
+    bool preferWindowBackend = !qgetenv( "QT_GSTREAMER_WINDOW_VIDEOSINK" ).isEmpty();
 
     const auto instances = videoBackendFactoryLoader()->instances(QLatin1String("declarativevideobackend"));
     for (QObject *instance : instances) {
@@ -257,10 +258,11 @@ bool QDeclarativeVideoOutput::createBackend(QMediaService *service)
             }
         }
     }
+
+retry:
 #if QT_CONFIG(opengl)
-    if (!backendAvailable) {
-        if (!m_backend)
-            m_backend.reset(new QDeclarativeVideoRendererBackend(this));
+    if (!backendAvailable && !preferWindowBackend) {
+        m_backend.reset(new QDeclarativeVideoRendererBackend(this));
         if (m_backend->init(service))
             backendAvailable = true;
     }
@@ -268,13 +270,18 @@ bool QDeclarativeVideoOutput::createBackend(QMediaService *service)
 
     // QDeclarativeVideoWindowBackend only works when there is a service with a QVideoWindowControl.
     // Without service, the QDeclarativeVideoRendererBackend should always work.
-    if (!backendAvailable) {
+    if (!backendAvailable && service) {
         Q_ASSERT(service);
         m_backend.reset(new QDeclarativeVideoWindowBackend(this));
         if (m_backend->init(service))
             backendAvailable = true;
     }
 
+    if (!backendAvailable && preferWindowBackend) {
+        preferWindowBackend = false;
+        goto retry;
+    }
+
     if (backendAvailable) {
         // Since new backend has been created needs to update its geometry.
         m_geometryDirty = true;
-- 
2.20.1