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
qvideoframeinput.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 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 "qvideoframeinput.h"
8
10
12{
13public:
15
17 {
18 return sendMediaFrame([&]() { emit m_platfromVideoFrameInput->newVideoFrame(frame); });
19 }
20
22 {
23 m_platfromVideoFrameInput = std::make_unique<QPlatformVideoFrameInput>(std::move(format));
24 addUpdateSignal(m_platfromVideoFrameInput.get(), &QPlatformVideoFrameInput::encoderUpdated);
25 }
26
28 {
29 m_platfromVideoFrameInput.reset();
30
31 if (captureSession())
33 }
34
36 {
37 return m_platfromVideoFrameInput.get();
38 }
39
40protected:
42 QMediaCaptureSession *newSession) override
43 {
44 if (prevSession)
46
47 if (newSession)
49 }
50
51 bool checkIfCanSendMediaFrame() const override
52 {
53 if (auto encoderInterface = m_platfromVideoFrameInput->encoderInterface())
54 return encoderInterface->canPushFrame();
55
57 }
58
59 void emitReadyToSendMediaFrame() override { emit q->readyToSendVideoFrame(); }
60
61private:
62 QVideoFrameInput *q = nullptr;
63 std::unique_ptr<QPlatformVideoFrameInput> m_platfromVideoFrameInput;
64};
65
83
98 : QObject(*new QVideoFrameInputPrivate(this), parent)
99{
100 Q_D(QVideoFrameInput);
101 d->initialize(format);
102}
103
108{
109 Q_D(QVideoFrameInput);
110 d->uninitialize();
111}
112
131{
132 Q_D(QVideoFrameInput);
133 return d->sendVideoFrame(frame);
134}
135
141{
142 Q_D(const QVideoFrameInput);
143 return d->platfromVideoFrameInput()->frameFormat();
144}
145
154{
155 Q_D(const QVideoFrameInput);
156 return d->captureSession();
157}
158
159void QVideoFrameInput::setCaptureSession(QMediaCaptureSession *captureSession)
160{
161 Q_D(QVideoFrameInput);
162 d->setCaptureSession(captureSession);
163}
164
165QPlatformVideoFrameInput *QVideoFrameInput::platformVideoFrameInput() const
166{
167 Q_D(const QVideoFrameInput);
168 return d->platfromVideoFrameInput();
169}
170
The QMediaCaptureSession class allows capturing of audio and video content.
void setVideoFrameInput(QVideoFrameInput *input)
QVideoSink * videoSink() const
Returns the QVideoSink for the session.
QObject * videoOutput
\qmlproperty VideoOutput QtMultimedia::CaptureSession::videoOutput
void addUpdateSignal(Sender sender, Signal signal)
void removeUpdateSignal(Sender sender, Signal signal)
bool sendMediaFrame(Sender &&sender)
QMediaCaptureSession * captureSession() const
\inmodule QtCore
Definition qobject.h:103
The QVideoFrameFormat class specifies the stream format of a video presentation surface.
QPlatformVideoFrameInput * platfromVideoFrameInput() const
bool sendVideoFrame(const QVideoFrame &frame)
void initialize(QVideoFrameFormat format={})
QVideoFrameInputPrivate(QVideoFrameInput *q)
void updateCaptureSessionConnections(QMediaCaptureSession *prevSession, QMediaCaptureSession *newSession) override
void emitReadyToSendMediaFrame() override
bool checkIfCanSendMediaFrame() const override
\inmodule QtMultimedia
QMediaCaptureSession * captureSession() const
Returns the capture session this video frame input is connected to, or a nullptr if the video frame i...
QVideoFrameFormat format() const
Returns the video frame format that was specified upon construction of the video frame input.
bool sendVideoFrame(const QVideoFrame &frame)
Sends \l QVideoFrame to \l QMediaRecorder or a video output through \l QMediaCaptureSession.
QVideoFrameInput(QObject *parent=nullptr)
Constructs a new QVideoFrameInput object with parent.
~QVideoFrameInput() override
Destroys the object.
The QVideoFrame class represents a frame of video data.
Definition qvideoframe.h:27
#define this
Definition dialogs.cpp:9
Combined button and popup list for selecting options.
GLint GLsizei GLsizei GLenum format
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
#define emit
QFrame frame
[0]