-
-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathMultimediaRecord.h
More file actions
100 lines (90 loc) · 2.32 KB
/
MultimediaRecord.h
File metadata and controls
100 lines (90 loc) · 2.32 KB
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
// Author: Kang Lin <kl222@126.com>
#pragma once
#include <QThread>
#include <QImage>
#if HAVE_QT6_MULTIMEDIA
#include <QMediaCaptureSession>
#endif
#ifdef HAVE_QT6_RECORD
#include <QVideoSink>
#include <QAudioInput>
#include <QAudioOutput>
#include <QAudioBufferInput>
#include <QAudioBufferOutput>
#include <QVideoFrameInput>
#endif
#include "ParameterRecord.h"
#include "ParameterMediaDevices.h"
#include "ParameterWebBrowser.h"
class CMultimediaRecord : public QObject
{
Q_OBJECT
public:
explicit CMultimediaRecord(CParameterWebBrowser* pPara, QObject *parent = nullptr);
~CMultimediaRecord();
enum RV {
Success = 0,
Fail = -1
};
Q_ENUM(RV)
public Q_SLOTS:
void slotStart();
void slotStop();
void slotUpdateVideoFrame(const QImage image);
Q_SIGNALS:
void sigRunning();
void sigFinished();
private:
CParameterRecord m_ParaRecord;
CParameterMediaDevices* m_pMediaDevices;
#if HAVE_QT6_MULTIMEDIA
QMediaCaptureSession m_CaptureSession;
#endif
qint64 m_VideoFrameStartTime;
#ifdef HAVE_QT6_RECORD
QAudioInput m_AudioInput;
QVideoFrameInput m_VideoFrameInput;
QAudioBufferInput m_AudioBufferInput;
QAudioBufferOutput m_AudioBufferOutput;
QMediaRecorder m_Recorder;
private Q_SLOTS:
void slotRecordStateChanged(QMediaRecorder::RecorderState state);
void slotRecordError(QMediaRecorder::Error error, const QString &errorString);
#endif
};
/*!
* \brief The CMultimediaRecordThread class
* \details Must use pointer. eg:
* - New object:
* \code
* CMultimediaRecordThread* pThread = new CMultimediaRecordThread(m_pPara);
* \endcode
* - Start thread:
* \code
* if(pThread)
* pThread->start();
* \endcode
* - Stop thread.
* \code
* pThread->slotQuit();
* \endcode
*
* \note
* - It automatically releases memory when exiting.
* - To stop a thread, you must use slotQuit(), and cannot use quit().
*/
class CMultimediaRecordThread : public QThread
{
Q_OBJECT
public:
explicit CMultimediaRecordThread(CParameterWebBrowser* pPara, QObject *parent = nullptr);
~CMultimediaRecordThread();
public Q_SLOTS:
void slotUpdateVideoFrame(const QImage image);
void slotQuit();
protected:
virtual void run() override;
private:
CParameterWebBrowser* m_pPara;
CMultimediaRecord* m_pRecord;
};