玉兔远程控制 0.1.0-bate2
载入中...
搜索中...
未找到
ParameterPlayer.cpp
1// Author: Kang Lin <kl222@126.com>
2
3#include "ParameterPlayer.h"
4
5CParameterPlayer::CParameterPlayer(QObject *parent)
6 : CParameterBase{parent}
7 , m_Type(TYPE::Url)
8 , m_nCamera(-1)
9 , m_nAudioInput(-1)
10 , m_bEnableAudioInput(true)
11 , m_bAudioInputMuted(false)
12 , m_fAudioInputVolume(100)
13 , m_nAudioOutput(-1)
14 , m_bEnableAudioOutput(true)
15 , m_bAudioOutputMuted(false)
16 , m_fAudioOutputVolume(100)
17 , m_nScreen(-1)
18 , m_bSubtitle(true)
19{}
20
21const CParameterPlayer::TYPE CParameterPlayer::GetType() const
22{
23 return m_Type;
24}
25
26int CParameterPlayer::SetType(TYPE type)
27{
28 if(m_Type == type)
29 return 0;
30 m_Type = type;
31 SetModified(true);
32 return 0;
33}
34
35const QString CParameterPlayer::GetUrl() const
36{
37 return m_szUrl;
38}
39
40int CParameterPlayer::SetUrl(const QString& szUrl)
41{
42 if(m_szUrl == szUrl)
43 return 0;
44 SetModified(true);
45 m_szUrl = szUrl;
46 return 0;
47}
48
49const int CParameterPlayer::GetCamera() const
50{
51 return m_nCamera;
52}
53
54int CParameterPlayer::SetCamera(int nIndex)
55{
56 if(m_nCamera == nIndex)
57 return 0;
58 m_nCamera = nIndex;
59 SetModified(true);
60 return 0;
61}
62
63const int CParameterPlayer::GetAudioInput() const
64{
65 return m_nAudioInput;
66}
67
68int CParameterPlayer::SetAudioInput(int nIndex)
69{
70 if(m_nAudioInput == nIndex)
71 return 0;
72 m_nAudioInput = nIndex;
73 SetModified(true);
74 emit sigAudioInput(m_nAudioInput);
75 return 0;
76}
77
78const bool CParameterPlayer::GetEnableAudioInput() const
79{
80 return m_bEnableAudioInput;
81}
82
83int CParameterPlayer::SetEnableAudioInput(bool bEnable)
84{
85 if(m_bEnableAudioInput == bEnable)
86 return 0;
87 m_bEnableAudioInput = bEnable;
88 SetModified(true);
89 emit sigEnableAudioInput(m_bEnableAudioInput);
90 return 0;
91}
92
93const bool CParameterPlayer::GetAudioInputMuted() const
94{
95 return m_bAudioInputMuted;
96}
97
98int CParameterPlayer::SetAudioInputMuted(bool bMuted)
99{
100 if(m_bAudioInputMuted == bMuted)
101 return 0;
102 m_bAudioInputMuted = bMuted;
103 SetModified(true);
104 emit sigAudioInputMuted(m_bAudioInputMuted);
105 return 0;
106}
107
108const float CParameterPlayer::GetAudioInputVolume() const
109{
110 return m_fAudioInputVolume;
111}
112
113int CParameterPlayer::SetAudioInputVolume(float fVolume)
114{
115 if(m_fAudioInputVolume == fVolume)
116 return 0;
117 m_fAudioInputVolume = fVolume;
118 SetModified(true);
119 emit sigAudioInputVolume(m_fAudioInputVolume);
120 return 0;
121}
122
123const int CParameterPlayer::GetAudioOutput() const
124{
125 return m_nAudioOutput;
126}
127
128int CParameterPlayer::SetAudioOutput(int nIndex)
129{
130 if(m_nAudioOutput == nIndex)
131 return 0;
132 m_nAudioOutput = nIndex;
133 SetModified(true);
134 emit sigAudioOutput(m_nAudioOutput);
135 return 0;
136}
137
138const bool CParameterPlayer::GetEnableAudioOutput() const
139{
140 return m_bEnableAudioOutput;
141}
142
143int CParameterPlayer::SetEnableAudioOutput(bool bEnable)
144{
145 if(m_bEnableAudioOutput == bEnable)
146 return 0;
147 m_bEnableAudioOutput = bEnable;
148 SetModified(true);
149 emit sigEnableAudioOutput(bEnable);
150 return 0;
151}
152
153const bool CParameterPlayer::GetAudioOutputMuted() const
154{
155 return m_bAudioOutputMuted;
156}
157
158int CParameterPlayer::SetAudioOutputMuted(bool bMuted)
159{
160 if(m_bAudioOutputMuted == bMuted)
161 return 0;
162 m_bAudioOutputMuted = bMuted;
163 SetModified(true);
164 emit sigAudioOutputMuted(m_bAudioOutputMuted);
165 return 0;
166}
167
168const float CParameterPlayer::GetAudioOutputVolume() const
169{
170 return m_fAudioOutputVolume;
171}
172
173int CParameterPlayer::SetAudioOutputVolume(float fVolume)
174{
175 if(m_fAudioOutputVolume == fVolume)
176 return 0;
177 m_fAudioOutputVolume = fVolume;
178 SetModified(true);
179 emit sigAudioOutputVolume(m_fAudioOutputVolume);
180 return 0;
181}
182
183int CParameterPlayer::OnLoad(QSettings &set)
184{
185 SetName(set.value("Name", GetName()).toString());
186 SetServerName(set.value("ServerName", GetServerName()).toString());
187 SetShowServerName(set.value("ShowServerName", GetShowServerName()).toBool());
188
189 set.beginGroup("Player");
190 SetType((TYPE)set.value("Type", (int)GetType()).toInt());
191 SetUrl(set.value("Url", GetUrl()).toString());
192 SetCamera(set.value("Camera", GetCamera()).toInt());
193
194 SetSubtitle(set.value("Subtitle", GetSubtitle()).toBool());
195
196 set.beginGroup("Audio/Input");
197 SetAudioInput(set.value("Device", GetAudioInput()).toInt());
198 SetEnableAudioInput(set.value("Enable", GetEnableAudioInput()).toBool());
199 SetAudioInputMuted(set.value("Muted", GetAudioInputMuted()).toBool());
200 SetAudioInputVolume(set.value("Volume", GetAudioInputVolume()).toBool());
201 set.endGroup();
202
203 set.beginGroup("Audio/Output");
204 SetAudioOutput(set.value("Device", GetAudioOutput()).toInt());
205 SetEnableAudioOutput(set.value("Enable", GetEnableAudioOutput()).toBool());
206 SetAudioOutputMuted(set.value("Muted", GetAudioOutputMuted()).toBool());
207 SetAudioOutputVolume(set.value("Volume", GetAudioOutputVolume()).toFloat());
208 set.endGroup();
209
210 set.endGroup();
211 return 0;
212}
213
214int CParameterPlayer::OnSave(QSettings &set)
215{
216 set.setValue("Name", GetName());
217 set.setValue("ServerName", GetServerName());
218 set.setValue("ShowServerName", GetShowServerName());
219
220 set.beginGroup("Player");
221 set.setValue("Type", (int)GetType());
222 set.setValue("Url", GetUrl());
223 set.setValue("Camera", GetCamera());
224 set.setValue("Subtitle", GetSubtitle());
225
226 set.beginGroup("Audio/Input");
227 set.setValue("Device", GetAudioInput());
228 set.setValue("Enable", GetEnableAudioInput());
229 set.setValue("Muted", GetAudioInputMuted());
230 set.setValue("Volume", GetAudioInputVolume());
231 set.endGroup();
232
233 set.beginGroup("Audio/Output");
234 set.setValue("Device", GetAudioOutput());
235 set.setValue("Enable", GetEnableAudioOutput());
236 set.setValue("Muted", GetAudioOutputMuted());
237 set.setValue("Volume", GetAudioOutputVolume());
238 set.endGroup();
239
240 set.endGroup();
241 return 0;
242}
243
244const int CParameterPlayer::GetScreen() const
245{
246 return m_nScreen;
247}
248
249int CParameterPlayer::SetScreen(int nIndex)
250{
251 if(m_nScreen == nIndex)
252 return 0;
253 m_nScreen = nIndex;
254 SetModified(true);
255 return 0;
256}
257
258bool CParameterPlayer::GetSubtitle() const
259{
260 return m_bSubtitle;
261}
262
263void CParameterPlayer::SetSubtitle(bool subtitle)
264{
265 if(m_bSubtitle == subtitle)
266 return;
267 m_bSubtitle = subtitle;
268 SetModified(true);
269}
连接基础参数接口。包括基本参数(网络参数等)。 所有插件的连接参数都应从此类派生。
int SetModified(bool bModified=true)
在设置参数时,如果有修改,则调用。