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
qffmpegmediacapturesession_p.h
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#ifndef QFFMPEGMEDIACAPTURESESSION_H
5#define QFFMPEGMEDIACAPTURESESSION_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 <QtCore/qiodevice.h>
19#include <QtCore/qpointer.h>
20
21#include <QtMultimedia/private/qplatformmediacapture_p.h>
22#include <QtMultimedia/private/qplatformmediaintegration_p.h>
23
24QT_BEGIN_NAMESPACE
25
26class QFFmpegMediaRecorder;
28class QVideoFrame;
29class QAudioSink;
31class QAudioBuffer;
32class QPlatformVideoSource;
33class QPlatformAudioBufferInput;
34class QAudioBufferSource;
35
37{
39
40public:
42
45
46 QPlatformCamera *camera() override;
47 void setCamera(QPlatformCamera *camera) override;
48
50 void setScreenCapture(QPlatformSurfaceCapture *) override;
51
53 void setWindowCapture(QPlatformSurfaceCapture *) override;
54
56 void setVideoFrameInput(QPlatformVideoFrameInput *) override;
57
59 void setImageCapture(QPlatformImageCapture *imageCapture) override;
60
62 void setMediaRecorder(QPlatformMediaRecorder *recorder) override;
63
64 void setAudioInput(QPlatformAudioInput *input) override;
66
67 void setAudioBufferInput(QPlatformAudioBufferInput *input) override;
68
69 void setVideoPreview(QVideoSink *sink) override;
70 void setAudioOutput(QPlatformAudioOutput *output) override;
71
72 // A source may emit frames from a backgrund thread before
73 // its setActive() is done. We need to setup necessary connections
74 // ahead of time as to not miss initial frames. This function
75 // should be called by a source right before it initiates
76 // the internal stream.
77 void onSourceActivating(QPlatformVideoSource &);
78 // Called by a source if it fails to go inactive.
79 void onSourceActivationFailure(QPlatformVideoSource &);
80
81 QPlatformVideoSource *primaryActiveVideoSource();
82
83 // it might be moved to the base class, but it needs QPlatformAudioInput
84 // to be QAudioBufferSource, which might not make sense
86
87private Q_SLOTS:
88 void updateAudioSink();
89 void updateVolume();
90 void updatePrimaryActiveVideoSource();
91
94
95private:
96 template<typename VideoSource>
97 bool setVideoSource(QPointer<VideoSource> &source, VideoSource *newSource);
98
99 [[nodiscard]] QPlatformVideoSource *primaryVideoSource(QPlatformVideoSource *pendingActiveSource);
100
101 void updateVideoFrameConnection(QPlatformVideoSource *pendingActiveSource);
102
103 QPointer<QPlatformCamera> m_camera;
104 QPointer<QPlatformSurfaceCapture> m_screenCapture;
105 QPointer<QPlatformSurfaceCapture> m_windowCapture;
106 QPointer<QPlatformVideoFrameInput> m_videoFrameInput;
107 QPointer<QPlatformVideoSource> m_primaryActiveVideoSource;
108
109 QPointer<QFFmpegAudioInput> m_audioInput;
110 QPointer<QPlatformAudioBufferInput> m_audioBufferInput;
111
112 QFFmpegImageCapture *m_imageCapture = nullptr;
113 QFFmpegMediaRecorder *m_mediaRecorder = nullptr;
114 QPlatformAudioOutput *m_audioOutput = nullptr;
115 QVideoSink *m_videoSink = nullptr;
116 std::unique_ptr<QAudioSink> m_audioSink;
117 QPointer<QIODevice> m_audioIODevice;
118 qsizetype m_audioBufferSize = 0;
119
120 struct SourceSinkConnection {
121 QPlatformVideoSource *source = nullptr;
122 QVideoSink *sink = nullptr;
123 QMetaObject::Connection connection;
124 };
125
126 SourceSinkConnection m_videoSinkConnection;
127};
128
129QT_END_NAMESPACE
130
131#endif // QGSTREAMERCAPTURESERVICE_H
void setMediaRecorder(QPlatformMediaRecorder *recorder) override
void setVideoPreview(QVideoSink *sink) override
QPlatformSurfaceCapture * windowCapture() override
void setWindowCapture(QPlatformSurfaceCapture *) override
void setVideoFrameInput(QPlatformVideoFrameInput *) override
void setScreenCapture(QPlatformSurfaceCapture *) override
void setAudioInput(QPlatformAudioInput *input) override
QPlatformVideoFrameInput * videoFrameInput() override
std::vector< QAudioBufferSource * > activeAudioInputs() const
void setImageCapture(QPlatformImageCapture *imageCapture) override
QPlatformSurfaceCapture * screenCapture() override
QPlatformImageCapture * imageCapture() override
QPlatformAudioInput * audioInput() const
void onSourceActivating(QPlatformVideoSource &)
QPlatformVideoSource * primaryActiveVideoSource()
void setCamera(QPlatformCamera *camera) override
void onSourceActivationFailure(QPlatformVideoSource &)
QPlatformMediaRecorder * mediaRecorder() override
QPlatformCamera * camera() override
~QFFmpegMediaCaptureSession() override
void setAudioBufferInput(QPlatformAudioBufferInput *input) override
void setAudioOutput(QPlatformAudioOutput *output) override
static int preferredAudioSinkBufferSize(const QFFmpegAudioInput &input)
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)