| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | 
| 4 | ** Contact: https://www.qt.io/licensing/ | 
| 5 | ** | 
| 6 | ** This file is part of the Qt Toolkit. | 
| 7 | ** | 
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
| 9 | ** Commercial License Usage | 
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | 
| 11 | ** accordance with the commercial license agreement provided with the | 
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | 
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | 
| 16 | ** | 
| 17 | ** GNU Lesser General Public License Usage | 
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
| 19 | ** General Public License version 3 as published by the Free Software | 
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | 
| 21 | ** packaging of this file. Please review the following information to | 
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | 
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | 
| 24 | ** | 
| 25 | ** GNU General Public License Usage | 
| 26 | ** Alternatively, this file may be used under the terms of the GNU | 
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | 
| 28 | ** Public license version 3 or any later version approved by the KDE Free | 
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | 
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | 
| 31 | ** included in the packaging of this file. Please review the following | 
| 32 | ** information to ensure the GNU General Public License requirements will | 
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | 
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | 
| 35 | ** | 
| 36 | ** $QT_END_LICENSE$ | 
| 37 | ** | 
| 38 | ****************************************************************************/ | 
| 39 |  | 
| 40 | #include "qgstreamervideowindow_p.h" | 
| 41 | #include <private/qgstutils_p.h> | 
| 42 |  | 
| 43 | #include <QtCore/qdebug.h> | 
| 44 |  | 
| 45 | QGstreamerVideoWindow::QGstreamerVideoWindow(QObject *parent, const QByteArray &elementName) | 
| 46 |     : QVideoWindowControl(parent) | 
| 47 |     , m_videoOverlay(this, !elementName.isEmpty() ? elementName : qgetenv(varName: "QT_GSTREAMER_WINDOW_VIDEOSINK" )) | 
| 48 | { | 
| 49 |     connect(sender: &m_videoOverlay, signal: &QGstreamerVideoOverlay::nativeVideoSizeChanged, | 
| 50 |             receiver: this, slot: &QGstreamerVideoWindow::nativeSizeChanged); | 
| 51 |     connect(sender: &m_videoOverlay, signal: &QGstreamerVideoOverlay::brightnessChanged, | 
| 52 |             receiver: this, slot: &QGstreamerVideoWindow::brightnessChanged); | 
| 53 |     connect(sender: &m_videoOverlay, signal: &QGstreamerVideoOverlay::contrastChanged, | 
| 54 |             receiver: this, slot: &QGstreamerVideoWindow::contrastChanged); | 
| 55 |     connect(sender: &m_videoOverlay, signal: &QGstreamerVideoOverlay::hueChanged, | 
| 56 |             receiver: this, slot: &QGstreamerVideoWindow::hueChanged); | 
| 57 |     connect(sender: &m_videoOverlay, signal: &QGstreamerVideoOverlay::saturationChanged, | 
| 58 |             receiver: this, slot: &QGstreamerVideoWindow::saturationChanged); | 
| 59 | } | 
| 60 |  | 
| 61 | QGstreamerVideoWindow::~QGstreamerVideoWindow() | 
| 62 | { | 
| 63 | } | 
| 64 |  | 
| 65 | GstElement *QGstreamerVideoWindow::videoSink() | 
| 66 | { | 
| 67 |     return m_videoOverlay.videoSink(); | 
| 68 | } | 
| 69 |  | 
| 70 | WId QGstreamerVideoWindow::winId() const | 
| 71 | { | 
| 72 |     return m_windowId; | 
| 73 | } | 
| 74 |  | 
| 75 | void QGstreamerVideoWindow::setWinId(WId id) | 
| 76 | { | 
| 77 |     if (m_windowId == id) | 
| 78 |         return; | 
| 79 |  | 
| 80 |     WId oldId = m_windowId; | 
| 81 |     m_videoOverlay.setWindowHandle(m_windowId = id); | 
| 82 |  | 
| 83 |     if (!oldId) | 
| 84 |         emit readyChanged(true); | 
| 85 |  | 
| 86 |     if (!id) | 
| 87 |         emit readyChanged(false); | 
| 88 | } | 
| 89 |  | 
| 90 | bool QGstreamerVideoWindow::processSyncMessage(const QGstreamerMessage &message) | 
| 91 | { | 
| 92 |     return m_videoOverlay.processSyncMessage(message); | 
| 93 | } | 
| 94 |  | 
| 95 | bool QGstreamerVideoWindow::processBusMessage(const QGstreamerMessage &message) | 
| 96 | { | 
| 97 |     return m_videoOverlay.processBusMessage(message); | 
| 98 | } | 
| 99 |  | 
| 100 | QRect QGstreamerVideoWindow::displayRect() const | 
| 101 | { | 
| 102 |     return m_displayRect; | 
| 103 | } | 
| 104 |  | 
| 105 | void QGstreamerVideoWindow::setDisplayRect(const QRect &rect) | 
| 106 | { | 
| 107 |     m_videoOverlay.setRenderRectangle(m_displayRect = rect); | 
| 108 |     repaint(); | 
| 109 | } | 
| 110 |  | 
| 111 | Qt::AspectRatioMode QGstreamerVideoWindow::aspectRatioMode() const | 
| 112 | { | 
| 113 |     return m_videoOverlay.aspectRatioMode(); | 
| 114 | } | 
| 115 |  | 
| 116 | void QGstreamerVideoWindow::setAspectRatioMode(Qt::AspectRatioMode mode) | 
| 117 | { | 
| 118 |     m_videoOverlay.setAspectRatioMode(mode); | 
| 119 | } | 
| 120 |  | 
| 121 | void QGstreamerVideoWindow::repaint() | 
| 122 | { | 
| 123 |     m_videoOverlay.expose(); | 
| 124 | } | 
| 125 |  | 
| 126 | int QGstreamerVideoWindow::brightness() const | 
| 127 | { | 
| 128 |     return m_videoOverlay.brightness(); | 
| 129 | } | 
| 130 |  | 
| 131 | void QGstreamerVideoWindow::setBrightness(int brightness) | 
| 132 | { | 
| 133 |     m_videoOverlay.setBrightness(brightness); | 
| 134 | } | 
| 135 |  | 
| 136 | int QGstreamerVideoWindow::contrast() const | 
| 137 | { | 
| 138 |     return m_videoOverlay.contrast(); | 
| 139 | } | 
| 140 |  | 
| 141 | void QGstreamerVideoWindow::setContrast(int contrast) | 
| 142 | { | 
| 143 |     m_videoOverlay.setContrast(contrast); | 
| 144 | } | 
| 145 |  | 
| 146 | int QGstreamerVideoWindow::hue() const | 
| 147 | { | 
| 148 |     return m_videoOverlay.hue(); | 
| 149 | } | 
| 150 |  | 
| 151 | void QGstreamerVideoWindow::setHue(int hue) | 
| 152 | { | 
| 153 |     m_videoOverlay.setHue(hue); | 
| 154 | } | 
| 155 |  | 
| 156 | int QGstreamerVideoWindow::saturation() const | 
| 157 | { | 
| 158 |     return m_videoOverlay.saturation(); | 
| 159 | } | 
| 160 |  | 
| 161 | void QGstreamerVideoWindow::setSaturation(int saturation) | 
| 162 | { | 
| 163 |     m_videoOverlay.setSaturation(saturation); | 
| 164 | } | 
| 165 |  | 
| 166 | bool QGstreamerVideoWindow::isFullScreen() const | 
| 167 | { | 
| 168 |     return m_fullScreen; | 
| 169 | } | 
| 170 |  | 
| 171 | void QGstreamerVideoWindow::setFullScreen(bool fullScreen) | 
| 172 | { | 
| 173 |     emit fullScreenChanged(fullScreen: m_fullScreen = fullScreen); | 
| 174 | } | 
| 175 |  | 
| 176 | QSize QGstreamerVideoWindow::nativeSize() const | 
| 177 | { | 
| 178 |     return m_videoOverlay.nativeVideoSize(); | 
| 179 | } | 
| 180 |  |