Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qmediaframeinput_p.h
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#ifndef QMEDIAFRAMEINPUT_P_H
5#define QMEDIAFRAMEINPUT_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtMultimedia/qmediacapturesession.h>
19#include <QtCore/private/qobject_p.h>
20
22
24{
25public:
26 void setCaptureSession(QMediaCaptureSession *session);
27
28 QMediaCaptureSession *captureSession() const { return m_captureSession; }
29
30protected:
31 template <typename Sender>
32 bool sendMediaFrame(Sender &&sender)
33 {
34 if (!m_canSendMediaFrame)
35 return false;
36
37 sender();
38 postponeCheckReadyToSend();
39 return true;
40 }
41
42 template <typename Sender, typename Signal>
43 void addUpdateSignal(Sender sender, Signal signal)
44 {
45 connect(sender, signal, this, &QMediaFrameInputPrivate::updateCanSendMediaFrame);
46 }
47
48 template <typename Sender, typename Signal>
49 void removeUpdateSignal(Sender sender, Signal signal)
50 {
51 disconnect(sender, signal, this, &QMediaFrameInputPrivate::updateCanSendMediaFrame);
52 }
53
55
56private:
57 void postponeCheckReadyToSend();
58
59 virtual bool checkIfCanSendMediaFrame() const = 0;
60
61 virtual void emitReadyToSendMediaFrame() = 0;
62
63 virtual void updateCaptureSessionConnections(QMediaCaptureSession *prevSession,
64 QMediaCaptureSession *currentSession) = 0;
65
66private:
67 QMediaCaptureSession *m_captureSession = nullptr;
68 bool m_canSendMediaFrame = false;
69 bool m_postponeReadyToSendCheckRun = false;
70};
71
72QT_END_NAMESPACE
73
74#endif // QMEDIAFRAMEINPUT_P_H
void updateCaptureSessionConnections(QMediaCaptureSession *prevSession, QMediaCaptureSession *newSession) override
QMediaCaptureSession * session() const
bool sendAudioBuffer(const QAudioBuffer &audioBuffer)
bool checkIfCanSendMediaFrame() const override
QPlatformAudioBufferInput * platfromAudioBufferInput() const
QAudioBufferInputPrivate(QAudioBufferInput *q)
void initialize(const QAudioFormat &format={})
void emitReadyToSendMediaFrame() override
\inmodule QtMultimedia
void addUpdateSignal(Sender sender, Signal signal)
virtual void updateCaptureSessionConnections(QMediaCaptureSession *prevSession, QMediaCaptureSession *currentSession)=0
virtual bool checkIfCanSendMediaFrame() const =0
virtual void emitReadyToSendMediaFrame()=0
void setCaptureSession(QMediaCaptureSession *session)
void removeUpdateSignal(Sender sender, Signal signal)
bool sendMediaFrame(Sender &&sender)
QMediaCaptureSession * captureSession() const
virtual ~QMediaInputEncoderInterface()=default
virtual bool canPushFrame() const =0