Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qvideosink.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qvideosink.h"
5
6#include "qvideoframeformat.h"
7#include "qvideoframe.h"
8#include "qmediaplayer.h"
10
11#include <qvariant.h>
12#include <qpainter.h>
13#include <qmatrix4x4.h>
14#include <QDebug>
15#include <private/qplatformmediaintegration_p.h>
16#include <private/qplatformvideosink_p.h>
17
19
21public:
23 : q_ptr(q)
24 {
25 auto maybeVideoSink = QPlatformMediaIntegration::instance()->createVideoSink(q);
26 if (maybeVideoSink) {
27 videoSink = maybeVideoSink.value();
28 } else {
29 qWarning() << "Failed to create QVideoSink" << maybeVideoSink.error();
30 }
31 }
33 {
34 delete videoSink;
35 }
37 {
38 if (!source)
39 return;
40 auto *old = source;
41 source = nullptr;
42 if (auto *player = qobject_cast<QMediaPlayer *>(old))
43 player->setVideoSink(nullptr);
44 else if (auto *capture = qobject_cast<QMediaCaptureSession *>(old))
45 capture->setVideoSink(nullptr);
46 }
47
48 QVideoSink *q_ptr = nullptr;
50 QObject *source = nullptr;
51 QRhi *rhi = nullptr;
52};
53
83 : QObject(parent),
85{
86 qRegisterMetaType<QVideoFrame>();
87}
88
93{
94 disconnect(this);
96 delete d;
97}
98
103{
104 return d->rhi;
105}
106
113{
114 if (d->rhi == rhi)
115 return;
116 d->rhi = rhi;
117 if (d->videoSink)
118 d->videoSink->setRhi(rhi);
119}
120
128
136
150
157{
158 return d->videoSink ? d->videoSink->subtitleText() : QString{};
159}
160
165{
166 if (d->videoSink)
167 d->videoSink->setSubtitleText(subtitle);
168}
169
177{
178 return d->videoSink ? d->videoSink->nativeSize() : QSize{};
179}
180
181void QVideoSink::setSource(QObject *source)
182{
183 if (d->source == source)
184 return;
185 if (source)
186 d->unregisterSource();
187 d->source = source;
188}
189
191
192#include "moc_qvideosink.cpp"
193
194
QMediaPlayer player
Definition audio.cpp:213
void setVideoSink(QVideoSink *sink)
Sets sink to be the QVideoSink instance to retrieve video data.
\inmodule QtCore
Definition qobject.h:103
static QPlatformMediaIntegration * instance()
QString subtitleText() const
void setSubtitleText(const QString &subtitleText)
virtual void setVideoFrame(const QVideoFrame &frame)
QVideoFrame currentVideoFrame() const
virtual void setRhi(QRhi *)
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1804
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QVideoFrame class represents a frame of video data.
Definition qvideoframe.h:27
QVideoSinkPrivate(QVideoSink *q)
QPlatformVideoSink * videoSink
QVideoSink * q_ptr
The QVideoSink class represents a generic sink for video data.
Definition qvideosink.h:22
QSize videoSize
Returns the size of the video currently being played back.
Definition qvideosink.h:25
void setVideoFrame(const QVideoFrame &frame)
Sets the current video frame.
QPlatformVideoSink * platformVideoSink() const
QVideoFrame videoFrame() const
Returns the current video frame.
QVideoSink(QObject *parent=nullptr)
Constructs a new QVideoSink object with parent.
void setSubtitleText(const QString &subtitle)
Sets the current subtitle text.
QString subtitleText
Returns the current subtitle text.
Definition qvideosink.h:24
QRhi * rhi() const
Returns the QRhi instance being used to create texture data in the video frames.
~QVideoSink()
Destroys the object.
void setRhi(QRhi *rhi)
#define this
Definition dialogs.cpp:9
Combined button and popup list for selecting options.
#define qWarning
Definition qlogging.h:166
GLsizei GLsizei GLchar * source
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
myObject disconnect()
[26]
QFrame frame
[0]