5#include <QStandardPaths>
7#include "ParameterRecord.h"
8#include "RabbitCommonDir.h"
10CParameterRecord::CParameterRecord(QObject *parent,
const QString &szPrefix)
12 , m_bEnableVideo(true)
13 , m_bEnableAudio(true)
14#if HAVE_QT6_MULTIMEDIA
15 , m_FileFormat(QMediaFormat::FileFormat::MPEG4)
16 , m_VideoCodec(QMediaFormat::VideoCodec::H264)
17 , m_AudioCodec(QMediaFormat::AudioCodec::AAC)
18 , m_Quality(QMediaRecorder::NormalQuality)
19 , m_EncodingMode(QMediaRecorder::ConstantQualityEncoding)
22 , m_AudioSampleRate(-1)
23 , m_EndAction(ENDACTION::No)
25 m_szPath = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
27 if(m_szPath.isEmpty() || !d.exists(m_szPath))
28 m_szPath = RabbitCommon::CDir::Instance()->GetDirUserImage();
29 m_szPath += QDir::separator() + tr(
"RabbitRemoteControl")
30 + QDir::separator() + tr(
"Record");
32 if(!d.exists(m_szPath))
35 m_szImagePath = QStandardPaths::writableLocation(
36 QStandardPaths::PicturesLocation);
37 if(m_szImagePath.isEmpty() || !d.exists(m_szImagePath))
38 m_szImagePath = RabbitCommon::CDir::Instance()->GetDirUserImage();
39 m_szImagePath += QDir::separator() + tr(
"RabbitRemoteControl")
40 + QDir::separator() + tr(
"ScreenShot");
41 if(!d.exists(m_szImagePath))
42 d.mkpath(m_szImagePath);
49 m_bEnableVideo = in.m_bEnableVideo;
50 m_bEnableAudio = in.m_bEnableAudio;
51 m_szFile = in.m_szFile;
52 m_szImageFile = in.m_szImageFile;
53 m_szPath = in.m_szPath;
54 m_szImagePath = in.m_szImagePath;
56#if HAVE_QT6_MULTIMEDIA
57 m_FileFormat = in.m_FileFormat;
58 m_VideoCodec = in.m_VideoCodec;
59 m_AudioCodec = in.m_AudioCodec;
60 m_Quality = in.m_Quality;
61 m_EncodingMode = in.m_EncodingMode;
64 m_VideoFrameRate = in.m_VideoFrameRate;
65 m_AudioSampleRate = in.m_AudioSampleRate;
67 m_EndAction = in.m_EndAction;
72bool CParameterRecord::GetEnableVideo()
const
74 return m_bEnableVideo;
77void CParameterRecord::SetEnableVideo(
bool newEnableVideo)
79 if (m_bEnableVideo == newEnableVideo)
81 m_bEnableVideo = newEnableVideo;
83 emit sigEnableVideoChanged();
86bool CParameterRecord::GetEnableAudio()
const
88 return m_bEnableAudio;
91void CParameterRecord::SetEnableAudio(
bool newEnableAudio)
93 if (m_bEnableAudio == newEnableAudio)
95 m_bEnableAudio = newEnableAudio;
97 emit sigEnableAudioChanged();
100CParameterRecord::ENDACTION CParameterRecord::GetEndAction()
const
105void CParameterRecord::SetEndAction(ENDACTION newEndAction)
107 if (m_EndAction == newEndAction)
109 m_EndAction = newEndAction;
111 emit sigEndActionChanged();
114QString CParameterRecord::GetImagePath()
const
116 return m_szImagePath;
119void CParameterRecord::SetImagePath(
const QString &newImagePath)
121 if (m_szImagePath == newImagePath)
123 m_szImagePath = newImagePath;
125 emit ImagePathChanged();
128int CParameterRecord::OnLoad(QSettings &set)
130 set.beginGroup(
"Record");
132 SetEnableVideo(set.value(
"EnableVideo", GetEnableVideo()).toBool());
133 SetEnableAudio(set.value(
"EnableAudio", GetEnableAudio()).toBool());
134 SetPath(set.value(
"Path", GetPath()).toString());
135 SetImagePath(set.value(
"ImagePath", GetImagePath()).toString());
136#if HAVE_QT6_MULTIMEDIA
137 SetFileFormat((QMediaFormat::FileFormat)
138 set.value(
"FileFormat", (
int)GetFileFormat()).toInt());
139 SetVideoCodec((QMediaFormat::VideoCodec)
140 set.value(
"Video/Codec", (
int)GetVideoCodec()).toInt());
141 SetAudioCodec((QMediaFormat::AudioCodec)
142 set.value(
"Audio/Codec", (
int)GetAudioCodec()).toInt());
143 SetQuality((QMediaRecorder::Quality)
144 set.value(
"Quality", GetQuality()).toInt());
145 SetEncodingMode((QMediaRecorder::EncodingMode)
146 set.value(
"EncodingMode", GetEncodingMode()).toInt());
148 SetAudioSampleRate(set.value(
"Audio/SampleRate", GetAudioSampleRate()).toInt());
149 SetVideoFrameRate(set.value(
"Video/FrameRate", GetVideoFrameRate()).toInt());
150 SetEndAction((ENDACTION)set.value(
"EndAction", GetEndAction()).toInt());
155int CParameterRecord::OnSave(QSettings &set)
157 set.beginGroup(
"Record");
159 set.setValue(
"EnableVideo", GetEnableVideo());
160 set.setValue(
"EnableAudio", GetEnableAudio());
161 set.setValue(
"Path", GetPath());
162 set.setValue(
"ImagePath", GetImagePath());
163#if HAVE_QT6_MULTIMEDIA
164 set.setValue(
"FileFormat", (
int)GetFileFormat());
165 set.setValue(
"Video/Codec", (
int)GetVideoCodec());
166 set.setValue(
"Audio/Codec", (
int)GetAudioCodec());
167 set.setValue(
"Quality", (
int)GetQuality());
168 set.setValue(
"EncodingMode", GetEncodingMode());
170 set.setValue(
"Audio/SampleRate", GetAudioSampleRate());
171 set.setValue(
"Video/FrameRate", GetVideoFrameRate());
172 set.setValue(
"EndAction", (
int)GetEndAction());
180 m_szFile = GetPath() + QDir::separator()
181 + QDateTime::currentDateTime().toLocalTime()
182 .toString(
"yyyy_MM_dd_hh_mm_ss_zzz");
187int CParameterRecord::SetFile(
const QString &szFile)
189 if(m_szFile == szFile)
196QString CParameterRecord::GetImageFile(
bool bAuto)
198 QString szPath = GetImagePath();
200 m_szImageFile = szPath
202 + QDateTime::currentDateTime().toLocalTime()
203 .toString(
"yyyy_MM_dd_hh_mm_ss_zzz") +
".png";
205 return m_szImageFile;
208void CParameterRecord::SetImageFile(
const QString &newImageFile)
210 if (m_szImageFile == newImageFile)
212 m_szImageFile = newImageFile;
214 emit sigImageFileChanged();
217const QString CParameterRecord::GetPath()
const
222int CParameterRecord::SetPath(
const QString &szPath)
224 if(m_szPath == szPath)
231#if HAVE_QT6_MULTIMEDIA
232const QMediaFormat::FileFormat CParameterRecord::GetFileFormat()
const
237int CParameterRecord::SetFileFormat(
const QMediaFormat::FileFormat &f)
239 if(m_FileFormat == f)
246const QMediaFormat::VideoCodec CParameterRecord::GetVideoCodec()
const
251int CParameterRecord::SetVideoCodec(QMediaFormat::VideoCodec v)
253 if(m_VideoCodec == v)
260const QMediaFormat::AudioCodec CParameterRecord::GetAudioCodec()
const
265int CParameterRecord::SetAudioCodec(QMediaFormat::AudioCodec a)
267 if(m_AudioCodec == a)
274QMediaRecorder::Quality CParameterRecord::GetQuality()
const
279void CParameterRecord::SetQuality(
const QMediaRecorder::Quality &newQuality)
281 if (m_Quality == newQuality)
283 m_Quality = newQuality;
285 emit sigQualityChanged();
288QMediaRecorder::EncodingMode CParameterRecord::GetEncodingMode()
const
290 return m_EncodingMode;
293void CParameterRecord::SetEncodingMode(
const QMediaRecorder::EncodingMode &newEncodingMode)
295 if (m_EncodingMode == newEncodingMode)
297 m_EncodingMode = newEncodingMode;
299 emit sigEncodingModeChanged();
303qreal CParameterRecord::GetVideoFrameRate()
const
305 return m_VideoFrameRate;
308void CParameterRecord::SetVideoFrameRate(qreal newVideoFrameRate)
310 if(m_VideoFrameRate == newVideoFrameRate)
312 m_VideoFrameRate = newVideoFrameRate;
317int CParameterRecord::GetAudioSampleRate()
const
319 return m_AudioSampleRate;
322void CParameterRecord::SetAudioSampleRate(
int newAudioSampleRate)
324 if(m_AudioSampleRate == newAudioSampleRate)
326 m_AudioSampleRate = newAudioSampleRate;
333#if HAVE_QT6_MULTIMEDIA
334 para.SetVideoFrameRate(recorder.videoFrameRate());
335 para.SetAudioSampleRate(recorder.audioSampleRate());
337 format = recorder.mediaFormat();
338 para.SetAudioCodec(format.audioCodec());
339 para.SetVideoCodec(format.videoCodec());
340 para.SetFileFormat(format.fileFormat());
341 para.SetQuality(recorder.quality());
342 para.SetEncodingMode(recorder.encodingMode());
344 para.SetFile(recorder.outputLocation().toString());
350#if HAVE_QT6_MULTIMEDIA
351 recorder.setVideoFrameRate(para.GetVideoFrameRate());
352 recorder.setAudioSampleRate(para.GetAudioSampleRate());
354 format.setAudioCodec(para.GetAudioCodec());
355 format.setVideoCodec(para.GetVideoCodec());
356 format.setFileFormat(para.GetFileFormat());
357 recorder.setMediaFormat(format);
358 recorder.setEncodingMode(para.GetEncodingMode());
359 recorder.setQuality(para.GetQuality());
362 if(!para.
GetFile(
true).isEmpty())
363 recorder.setOutputLocation(QUrl::fromLocalFile(para.
GetFile(
true)));
const QString GetFile(bool bAuto=false)
int SetModified(bool bModified=true)
When setting parameters, if there is a modification, it is called.