1 | // Copyright (C) 2024 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef CAPTURESESSIONFIXTURE_P_H |
5 | #define CAPTURESESSIONFIXTURE_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 <private/framegenerator_p.h> |
19 | #include <QtMultimedia/qvideoframeinput.h> |
20 | #include <QtMultimedia/qaudioinput.h> |
21 | #include <QtMultimedia/qmediacapturesession.h> |
22 | #include <QtMultimedia/qmediarecorder.h> |
23 | #include <QtMultimedia/qaudiobufferinput.h> |
24 | #include <QtCore/qtemporaryfile.h> |
25 | |
26 | #include <private/testvideosink_p.h> |
27 | #include <QtTest/qsignalspy.h> |
28 | |
29 | QT_BEGIN_NAMESPACE |
30 | |
31 | enum class StreamType { Audio, Video, AudioAndVideo }; |
32 | enum class AutoStop { EmitEmpty, No }; |
33 | enum class RunMode { Pull, Push }; |
34 | |
35 | struct CaptureSessionFixture |
36 | { |
37 | explicit CaptureSessionFixture(StreamType streamType); |
38 | ~CaptureSessionFixture(); |
39 | |
40 | void setVideoSink(QVideoSink *videoSink); |
41 | void start(RunMode mode, AutoStop autoStop); |
42 | bool waitForRecorderStopped(std::chrono::milliseconds duration); |
43 | bool hasAudio() const; |
44 | bool hasVideo() const; |
45 | |
46 | VideoGenerator m_videoGenerator; |
47 | AudioGenerator m_audioGenerator; |
48 | QVideoFrameInput m_videoInput; |
49 | QAudioBufferInput m_audioInput; |
50 | QMediaCaptureSession m_session; |
51 | QMediaRecorder m_recorder; |
52 | QTemporaryFile m_tempFile; |
53 | QVideoSink *m_videoSink = nullptr; |
54 | StreamType m_streamType = StreamType::Video; |
55 | |
56 | QSignalSpy readyToSendVideoFrame{ &m_videoInput, &QVideoFrameInput::readyToSendVideoFrame }; |
57 | QSignalSpy readyToSendAudioBuffer{ &m_audioInput, &QAudioBufferInput::readyToSendAudioBuffer }; |
58 | QSignalSpy recorderStateChanged{ &m_recorder, &QMediaRecorder::recorderStateChanged }; |
59 | }; |
60 | |
61 | QT_END_NAMESPACE |
62 | |
63 | #endif |
64 | |