blob: 25340dad5e1734104bb37eb55e36f2953ac6a839 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QFFMPEGMEDIACAPTURESESSION_H
#define QFFMPEGMEDIACAPTURESESSION_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <private/qplatformmediacapture_p.h>
#include <private/qplatformmediaintegration_p.h>
#include "qpointer.h"
#include "qiodevice.h"
QT_BEGIN_NAMESPACE
class QFFmpegMediaRecorder;
class QFFmpegImageCapture;
class QVideoFrame;
class QAudioSink;
class QFFmpegAudioInput;
class QAudioBuffer;
class QPlatformVideoSource;
class QPlatformAudioBufferInput;
class QPlatformAudioBufferInputBase;
class QFFmpegMediaCaptureSession : public QPlatformMediaCaptureSession
{
Q_OBJECT
public:
using VideoSources = std::vector<QPointer<QPlatformVideoSource>>;
QFFmpegMediaCaptureSession();
~QFFmpegMediaCaptureSession() override;
QPlatformCamera *camera() override;
void setCamera(QPlatformCamera *camera) override;
QPlatformSurfaceCapture *screenCapture() override;
void setScreenCapture(QPlatformSurfaceCapture *) override;
QPlatformSurfaceCapture *windowCapture() override;
void setWindowCapture(QPlatformSurfaceCapture *) override;
QPlatformVideoFrameInput *videoFrameInput() override;
void setVideoFrameInput(QPlatformVideoFrameInput *) override;
QPlatformImageCapture *imageCapture() override;
void setImageCapture(QPlatformImageCapture *imageCapture) override;
QPlatformMediaRecorder *mediaRecorder() override;
void setMediaRecorder(QPlatformMediaRecorder *recorder) override;
void setAudioInput(QPlatformAudioInput *input) override;
QPlatformAudioInput *audioInput() const;
void setAudioBufferInput(QPlatformAudioBufferInput *input) override;
void setVideoPreview(QVideoSink *sink) override;
void setAudioOutput(QPlatformAudioOutput *output) override;
QPlatformVideoSource *primaryActiveVideoSource();
// it might be moved to the base class, but it needs QPlatformAudioInput
// to be QPlatformAudioBufferInputBase, which might not make sense
std::vector<QPlatformAudioBufferInputBase *> activeAudioInputs() const;
private Q_SLOTS:
void updateAudioSink();
void updateVolume();
void updateVideoFrameConnection();
void updatePrimaryActiveVideoSource();
Q_SIGNALS:
void primaryActiveVideoSourceChanged();
private:
template<typename VideoSource>
bool setVideoSource(QPointer<VideoSource> &source, VideoSource *newSource);
QPointer<QPlatformCamera> m_camera;
QPointer<QPlatformSurfaceCapture> m_screenCapture;
QPointer<QPlatformSurfaceCapture> m_windowCapture;
QPointer<QPlatformVideoFrameInput> m_videoFrameInput;
QPointer<QPlatformVideoSource> m_primaryActiveVideoSource;
QPointer<QFFmpegAudioInput> m_audioInput;
QPointer<QPlatformAudioBufferInput> m_audioBufferInput;
QFFmpegImageCapture *m_imageCapture = nullptr;
QFFmpegMediaRecorder *m_mediaRecorder = nullptr;
QPlatformAudioOutput *m_audioOutput = nullptr;
QVideoSink *m_videoSink = nullptr;
std::unique_ptr<QAudioSink> m_audioSink;
QPointer<QIODevice> m_audioIODevice;
qsizetype m_audioBufferSize = 0;
QMetaObject::Connection m_videoFrameConnection;
};
QT_END_NAMESPACE
#endif // QGSTREAMERCAPTURESERVICE_H
|