1 | /* $Id: RecordScreenSettingsImpl.cpp 75341 2018-11-09 08:37:28Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | *
|
---|
4 | * VirtualBox COM class implementation - Capture settings of one virtual screen.
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2018 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #define LOG_GROUP LOG_GROUP_MAIN_RECORDSCREENSETTINGS
|
---|
20 | #include "LoggingNew.h"
|
---|
21 |
|
---|
22 | #include "RecordScreenSettingsImpl.h"
|
---|
23 | #include "RecordSettingsImpl.h"
|
---|
24 | #include "MachineImpl.h"
|
---|
25 |
|
---|
26 | #include <iprt/path.h>
|
---|
27 | #include <iprt/cpp/utils.h>
|
---|
28 | #include <VBox/settings.h>
|
---|
29 |
|
---|
30 | #include "AutoStateDep.h"
|
---|
31 | #include "AutoCaller.h"
|
---|
32 | #include "Global.h"
|
---|
33 |
|
---|
34 | ////////////////////////////////////////////////////////////////////////////////
|
---|
35 | //
|
---|
36 | // RecordScreenSettings private data definition
|
---|
37 | //
|
---|
38 | ////////////////////////////////////////////////////////////////////////////////
|
---|
39 |
|
---|
40 | struct RecordScreenSettings::Data
|
---|
41 | {
|
---|
42 | Data()
|
---|
43 | : pParent(NULL)
|
---|
44 | { }
|
---|
45 |
|
---|
46 | RecordSettings * const pParent;
|
---|
47 | ComObjPtr<RecordScreenSettings> pPeer;
|
---|
48 | uint32_t uScreenId;
|
---|
49 |
|
---|
50 | // use the XML settings structure in the members for simplicity
|
---|
51 | Backupable<settings::RecordScreenSettings> bd;
|
---|
52 | };
|
---|
53 |
|
---|
54 | // constructor / destructor
|
---|
55 | /////////////////////////////////////////////////////////////////////////////
|
---|
56 |
|
---|
57 | DEFINE_EMPTY_CTOR_DTOR(RecordScreenSettings)
|
---|
58 |
|
---|
59 | HRESULT RecordScreenSettings::FinalConstruct()
|
---|
60 | {
|
---|
61 | return BaseFinalConstruct();
|
---|
62 | }
|
---|
63 |
|
---|
64 | void RecordScreenSettings::FinalRelease()
|
---|
65 | {
|
---|
66 | uninit();
|
---|
67 | BaseFinalRelease();
|
---|
68 | }
|
---|
69 |
|
---|
70 | // public initializer/uninitializer for internal purposes only
|
---|
71 | /////////////////////////////////////////////////////////////////////////////
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * Initializes the audio adapter object.
|
---|
75 | *
|
---|
76 | * @returns COM result indicator
|
---|
77 | */
|
---|
78 | HRESULT RecordScreenSettings::init(RecordSettings *aParent, uint32_t uScreenId, const settings::RecordScreenSettings& data)
|
---|
79 | {
|
---|
80 | LogFlowThisFuncEnter();
|
---|
81 | LogFlowThisFunc(("aParent: %p\n", aParent));
|
---|
82 |
|
---|
83 | ComAssertRet(aParent, E_INVALIDARG);
|
---|
84 |
|
---|
85 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
86 | AutoInitSpan autoInitSpan(this);
|
---|
87 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
88 |
|
---|
89 | m = new Data();
|
---|
90 |
|
---|
91 | /* Share the parent & machine weakly. */
|
---|
92 | unconst(m->pParent) = aParent;
|
---|
93 | /* mPeer is left null. */
|
---|
94 |
|
---|
95 | /* Simply copy the settings data. */
|
---|
96 | m->uScreenId = uScreenId;
|
---|
97 | m->bd.allocate();
|
---|
98 | m->bd->operator=(data);
|
---|
99 |
|
---|
100 | HRESULT rc = S_OK;
|
---|
101 |
|
---|
102 | int vrc = i_initInternal();
|
---|
103 | if (RT_SUCCESS(vrc))
|
---|
104 | {
|
---|
105 | autoInitSpan.setSucceeded();
|
---|
106 | }
|
---|
107 | else
|
---|
108 | {
|
---|
109 | autoInitSpan.setFailed();
|
---|
110 | rc = E_UNEXPECTED;
|
---|
111 | }
|
---|
112 |
|
---|
113 | LogFlowThisFuncLeave();
|
---|
114 | return rc;
|
---|
115 | }
|
---|
116 |
|
---|
117 | /**
|
---|
118 | * Initializes the capture settings object given another capture settings object
|
---|
119 | * (a kind of copy constructor). This object shares data with
|
---|
120 | * the object passed as an argument.
|
---|
121 | *
|
---|
122 | * @note This object must be destroyed before the original object
|
---|
123 | * it shares data with is destroyed.
|
---|
124 | */
|
---|
125 | HRESULT RecordScreenSettings::init(RecordSettings *aParent, RecordScreenSettings *that)
|
---|
126 | {
|
---|
127 | LogFlowThisFuncEnter();
|
---|
128 | LogFlowThisFunc(("aParent: %p, that: %p\n", aParent, that));
|
---|
129 |
|
---|
130 | ComAssertRet(aParent && that, E_INVALIDARG);
|
---|
131 |
|
---|
132 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
133 | AutoInitSpan autoInitSpan(this);
|
---|
134 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
135 |
|
---|
136 | m = new Data();
|
---|
137 |
|
---|
138 | unconst(m->pParent) = aParent;
|
---|
139 | m->pPeer = that;
|
---|
140 |
|
---|
141 | AutoWriteLock thatlock(that COMMA_LOCKVAL_SRC_POS);
|
---|
142 |
|
---|
143 | m->uScreenId = that->m->uScreenId;
|
---|
144 | m->bd.share(that->m->bd);
|
---|
145 |
|
---|
146 | HRESULT rc = S_OK;
|
---|
147 |
|
---|
148 | int vrc = i_initInternal();
|
---|
149 | if (RT_SUCCESS(vrc))
|
---|
150 | {
|
---|
151 | autoInitSpan.setSucceeded();
|
---|
152 | }
|
---|
153 | else
|
---|
154 | {
|
---|
155 | autoInitSpan.setFailed();
|
---|
156 | rc = E_UNEXPECTED;
|
---|
157 | }
|
---|
158 |
|
---|
159 | LogFlowThisFuncLeave();
|
---|
160 | return rc;
|
---|
161 | }
|
---|
162 |
|
---|
163 | /**
|
---|
164 | * Initializes the guest object given another guest object
|
---|
165 | * (a kind of copy constructor). This object makes a private copy of data
|
---|
166 | * of the original object passed as an argument.
|
---|
167 | */
|
---|
168 | HRESULT RecordScreenSettings::initCopy(RecordSettings *aParent, RecordScreenSettings *that)
|
---|
169 | {
|
---|
170 | LogFlowThisFuncEnter();
|
---|
171 | LogFlowThisFunc(("aParent: %p, that: %p\n", aParent, that));
|
---|
172 |
|
---|
173 | ComAssertRet(aParent && that, E_INVALIDARG);
|
---|
174 |
|
---|
175 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
176 | AutoInitSpan autoInitSpan(this);
|
---|
177 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
178 |
|
---|
179 | m = new Data();
|
---|
180 |
|
---|
181 | unconst(m->pParent) = aParent;
|
---|
182 | /* mPeer is left null. */
|
---|
183 |
|
---|
184 | AutoWriteLock thatlock(that COMMA_LOCKVAL_SRC_POS);
|
---|
185 |
|
---|
186 | m->uScreenId = that->m->uScreenId;
|
---|
187 | m->bd.attachCopy(that->m->bd);
|
---|
188 |
|
---|
189 | HRESULT rc = S_OK;
|
---|
190 |
|
---|
191 | int vrc = i_initInternal();
|
---|
192 | if (RT_SUCCESS(vrc))
|
---|
193 | {
|
---|
194 | autoInitSpan.setSucceeded();
|
---|
195 | }
|
---|
196 | else
|
---|
197 | {
|
---|
198 | autoInitSpan.setFailed();
|
---|
199 | rc = E_UNEXPECTED;
|
---|
200 | }
|
---|
201 |
|
---|
202 | LogFlowThisFuncLeave();
|
---|
203 | return rc;
|
---|
204 | }
|
---|
205 |
|
---|
206 | /**
|
---|
207 | * Uninitializes the instance and sets the ready flag to FALSE.
|
---|
208 | * Called either from FinalRelease() or by the parent when it gets destroyed.
|
---|
209 | */
|
---|
210 | void RecordScreenSettings::uninit()
|
---|
211 | {
|
---|
212 | LogFlowThisFuncEnter();
|
---|
213 |
|
---|
214 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
215 | AutoUninitSpan autoUninitSpan(this);
|
---|
216 | if (autoUninitSpan.uninitDone())
|
---|
217 | return;
|
---|
218 |
|
---|
219 | m->bd.free();
|
---|
220 |
|
---|
221 | unconst(m->pPeer) = NULL;
|
---|
222 | unconst(m->pParent) = NULL;
|
---|
223 |
|
---|
224 | delete m;
|
---|
225 | m = NULL;
|
---|
226 |
|
---|
227 | LogFlowThisFuncLeave();
|
---|
228 | }
|
---|
229 |
|
---|
230 | HRESULT RecordScreenSettings::isFeatureEnabled(RecordFeature_T aFeature, BOOL *aEnabled)
|
---|
231 | {
|
---|
232 | AutoCaller autoCaller(this);
|
---|
233 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
234 |
|
---|
235 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
236 |
|
---|
237 | settings::RecordFeatureMap::const_iterator itFeature = m->bd->featureMap.find(aFeature);
|
---|
238 |
|
---|
239 | *aEnabled = ( itFeature != m->bd->featureMap.end()
|
---|
240 | && itFeature->second == true);
|
---|
241 |
|
---|
242 | return S_OK;
|
---|
243 | }
|
---|
244 |
|
---|
245 | HRESULT RecordScreenSettings::getId(ULONG *id)
|
---|
246 | {
|
---|
247 | AutoCaller autoCaller(this);
|
---|
248 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
249 |
|
---|
250 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
251 |
|
---|
252 | *id = m->uScreenId;
|
---|
253 |
|
---|
254 | return S_OK;
|
---|
255 | }
|
---|
256 |
|
---|
257 | HRESULT RecordScreenSettings::getEnabled(BOOL *enabled)
|
---|
258 | {
|
---|
259 | AutoCaller autoCaller(this);
|
---|
260 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
261 |
|
---|
262 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
263 |
|
---|
264 | *enabled = m->bd->fEnabled ? TRUE : FALSE;
|
---|
265 |
|
---|
266 | return S_OK;
|
---|
267 | }
|
---|
268 |
|
---|
269 | HRESULT RecordScreenSettings::setEnabled(BOOL enabled)
|
---|
270 | {
|
---|
271 | AutoCaller autoCaller(this);
|
---|
272 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
273 |
|
---|
274 | LogFlowThisFunc(("Screen %RU32\n", m->uScreenId));
|
---|
275 |
|
---|
276 | if (!m->pParent->i_canChangeSettings())
|
---|
277 | return setError(E_INVALIDARG, tr("Cannot change enabled state of screen while capturing is enabled"));
|
---|
278 |
|
---|
279 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
280 |
|
---|
281 | if (m->bd->fEnabled != RT_BOOL(enabled))
|
---|
282 | {
|
---|
283 | m->bd.backup();
|
---|
284 | m->bd->fEnabled = RT_BOOL(enabled);
|
---|
285 | alock.release();
|
---|
286 |
|
---|
287 | m->pParent->i_onSettingsChanged();
|
---|
288 | }
|
---|
289 |
|
---|
290 | LogFlowThisFunc(("Screen %RU32\n", m->uScreenId));
|
---|
291 | return S_OK;
|
---|
292 | }
|
---|
293 |
|
---|
294 | HRESULT RecordScreenSettings::getFeatures(ULONG *aFeatures)
|
---|
295 | {
|
---|
296 | AutoCaller autoCaller(this);
|
---|
297 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
298 |
|
---|
299 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
300 |
|
---|
301 | *aFeatures = 0;
|
---|
302 |
|
---|
303 | settings::RecordFeatureMap::const_iterator itFeature = m->bd->featureMap.begin();
|
---|
304 | while (itFeature != m->bd->featureMap.end())
|
---|
305 | {
|
---|
306 | if (itFeature->second) /* Is feature enable? */
|
---|
307 | *aFeatures |= (ULONG)itFeature->first;
|
---|
308 |
|
---|
309 | ++itFeature;
|
---|
310 | }
|
---|
311 |
|
---|
312 | return S_OK;
|
---|
313 | }
|
---|
314 |
|
---|
315 | HRESULT RecordScreenSettings::setFeatures(ULONG aFeatures)
|
---|
316 | {
|
---|
317 | AutoCaller autoCaller(this);
|
---|
318 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
319 |
|
---|
320 | if (!m->pParent->i_canChangeSettings())
|
---|
321 | return setError(E_INVALIDARG, tr("Cannot change features while capturing is enabled"));
|
---|
322 |
|
---|
323 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
324 |
|
---|
325 | m->bd.backup();
|
---|
326 | m->bd->featureMap.clear();
|
---|
327 |
|
---|
328 | if (aFeatures & RecordFeature_Audio)
|
---|
329 | m->bd->featureMap[RecordFeature_Audio] = true;
|
---|
330 | if (aFeatures & RecordFeature_Video)
|
---|
331 | m->bd->featureMap[RecordFeature_Video] = true;
|
---|
332 |
|
---|
333 | alock.release();
|
---|
334 |
|
---|
335 | return S_OK;
|
---|
336 | }
|
---|
337 |
|
---|
338 | HRESULT RecordScreenSettings::getDestination(RecordDestination_T *aDestination)
|
---|
339 | {
|
---|
340 | AutoCaller autoCaller(this);
|
---|
341 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
342 |
|
---|
343 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
344 |
|
---|
345 | *aDestination = m->bd->enmDest;
|
---|
346 |
|
---|
347 | return S_OK;
|
---|
348 | }
|
---|
349 |
|
---|
350 | HRESULT RecordScreenSettings::setDestination(RecordDestination_T aDestination)
|
---|
351 | {
|
---|
352 | AutoCaller autoCaller(this);
|
---|
353 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
354 |
|
---|
355 | if (!m->pParent->i_canChangeSettings())
|
---|
356 | return setError(E_INVALIDARG, tr("Cannot change destination type while capturing is enabled"));
|
---|
357 |
|
---|
358 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
359 |
|
---|
360 | m->bd.backup();
|
---|
361 | m->bd->enmDest = aDestination;
|
---|
362 |
|
---|
363 | return S_OK;
|
---|
364 | }
|
---|
365 |
|
---|
366 | HRESULT RecordScreenSettings::getFileName(com::Utf8Str &aFileName)
|
---|
367 | {
|
---|
368 | AutoCaller autoCaller(this);
|
---|
369 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
370 |
|
---|
371 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
372 |
|
---|
373 | aFileName = m->bd->File.strName;
|
---|
374 |
|
---|
375 | return S_OK;
|
---|
376 | }
|
---|
377 |
|
---|
378 | HRESULT RecordScreenSettings::setFileName(const com::Utf8Str &aFileName)
|
---|
379 | {
|
---|
380 | AutoCaller autoCaller(this);
|
---|
381 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
382 |
|
---|
383 | if (!m->pParent->i_canChangeSettings())
|
---|
384 | return setError(E_INVALIDARG, tr("Cannot change file name while capturing is enabled"));
|
---|
385 |
|
---|
386 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
387 |
|
---|
388 | Utf8Str strFile(aFileName);
|
---|
389 |
|
---|
390 | if (!RTPathStartsWithRoot(strFile.c_str()))
|
---|
391 | return setError(E_INVALIDARG, tr("Capture file name '%s' is not absolute"), strFile.c_str());
|
---|
392 |
|
---|
393 | m->bd.backup();
|
---|
394 | m->bd->File.strName = strFile;
|
---|
395 |
|
---|
396 | return S_OK;
|
---|
397 | }
|
---|
398 |
|
---|
399 | HRESULT RecordScreenSettings::getMaxTime(ULONG *aMaxTimeS)
|
---|
400 | {
|
---|
401 | AutoCaller autoCaller(this);
|
---|
402 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
403 |
|
---|
404 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
405 |
|
---|
406 | *aMaxTimeS = m->bd->ulMaxTimeS;
|
---|
407 |
|
---|
408 | return S_OK;
|
---|
409 | }
|
---|
410 |
|
---|
411 | HRESULT RecordScreenSettings::setMaxTime(ULONG aMaxTimeS)
|
---|
412 | {
|
---|
413 | AutoCaller autoCaller(this);
|
---|
414 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
415 |
|
---|
416 | if (!m->pParent->i_canChangeSettings())
|
---|
417 | return setError(E_INVALIDARG, tr("Cannot change maximum time while capturing is enabled"));
|
---|
418 |
|
---|
419 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
420 |
|
---|
421 | m->bd.backup();
|
---|
422 | m->bd->ulMaxTimeS = aMaxTimeS;
|
---|
423 |
|
---|
424 | return S_OK;
|
---|
425 | }
|
---|
426 |
|
---|
427 | HRESULT RecordScreenSettings::getMaxFileSize(ULONG *aMaxFileSizeMB)
|
---|
428 | {
|
---|
429 | AutoCaller autoCaller(this);
|
---|
430 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
431 |
|
---|
432 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
433 |
|
---|
434 | *aMaxFileSizeMB = m->bd->File.ulMaxSizeMB;
|
---|
435 |
|
---|
436 | return S_OK;
|
---|
437 | }
|
---|
438 |
|
---|
439 | HRESULT RecordScreenSettings::setMaxFileSize(ULONG aMaxFileSize)
|
---|
440 | {
|
---|
441 | AutoCaller autoCaller(this);
|
---|
442 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
443 |
|
---|
444 | if (!m->pParent->i_canChangeSettings())
|
---|
445 | return setError(E_INVALIDARG, tr("Cannot change maximum file size while capturing is enabled"));
|
---|
446 |
|
---|
447 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
448 |
|
---|
449 | m->bd.backup();
|
---|
450 | m->bd->File.ulMaxSizeMB = aMaxFileSize;
|
---|
451 |
|
---|
452 | return S_OK;
|
---|
453 | }
|
---|
454 |
|
---|
455 | HRESULT RecordScreenSettings::getOptions(com::Utf8Str &aOptions)
|
---|
456 | {
|
---|
457 | AutoCaller autoCaller(this);
|
---|
458 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
459 |
|
---|
460 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
461 |
|
---|
462 | aOptions = m->bd->strOptions;
|
---|
463 |
|
---|
464 | return S_OK;
|
---|
465 | }
|
---|
466 |
|
---|
467 | HRESULT RecordScreenSettings::setOptions(const com::Utf8Str &aOptions)
|
---|
468 | {
|
---|
469 | AutoCaller autoCaller(this);
|
---|
470 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
471 |
|
---|
472 | if (!m->pParent->i_canChangeSettings())
|
---|
473 | return setError(E_INVALIDARG, tr("Cannot change options while capturing is enabled"));
|
---|
474 |
|
---|
475 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
476 |
|
---|
477 | m->bd.backup();
|
---|
478 | m->bd->strOptions = aOptions;
|
---|
479 |
|
---|
480 | return S_OK;
|
---|
481 | }
|
---|
482 |
|
---|
483 | HRESULT RecordScreenSettings::getAudioCodec(RecordAudioCodec_T *aCodec)
|
---|
484 | {
|
---|
485 | AutoCaller autoCaller(this);
|
---|
486 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
487 |
|
---|
488 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
489 |
|
---|
490 | *aCodec = m->bd->Audio.enmAudioCodec;
|
---|
491 |
|
---|
492 | return S_OK;
|
---|
493 | }
|
---|
494 |
|
---|
495 | HRESULT RecordScreenSettings::setAudioCodec(RecordAudioCodec_T aCodec)
|
---|
496 | {
|
---|
497 | AutoCaller autoCaller(this);
|
---|
498 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
499 |
|
---|
500 | if (!m->pParent->i_canChangeSettings())
|
---|
501 | return setError(E_INVALIDARG, tr("Cannot change audio codec while capturing is enabled"));
|
---|
502 |
|
---|
503 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
504 |
|
---|
505 | m->bd.backup();
|
---|
506 | m->bd->Audio.enmAudioCodec = aCodec;
|
---|
507 |
|
---|
508 | return S_OK;
|
---|
509 | }
|
---|
510 |
|
---|
511 | HRESULT RecordScreenSettings::getAudioHz(ULONG *aHz)
|
---|
512 | {
|
---|
513 | AutoCaller autoCaller(this);
|
---|
514 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
515 |
|
---|
516 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
517 |
|
---|
518 | *aHz = m->bd->Audio.uHz;
|
---|
519 |
|
---|
520 | return S_OK;
|
---|
521 | }
|
---|
522 |
|
---|
523 | HRESULT RecordScreenSettings::setAudioHz(ULONG aHz)
|
---|
524 | {
|
---|
525 | AutoCaller autoCaller(this);
|
---|
526 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
527 |
|
---|
528 | if (!m->pParent->i_canChangeSettings())
|
---|
529 | return setError(E_INVALIDARG, tr("Cannot change audio Hertz rate while capturing is enabled"));
|
---|
530 |
|
---|
531 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
532 |
|
---|
533 | m->bd.backup();
|
---|
534 | m->bd->Audio.uHz = (uint16_t)aHz;
|
---|
535 |
|
---|
536 | return S_OK;
|
---|
537 | }
|
---|
538 |
|
---|
539 | HRESULT RecordScreenSettings::getAudioBits(ULONG *aBits)
|
---|
540 | {
|
---|
541 | AutoCaller autoCaller(this);
|
---|
542 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
543 |
|
---|
544 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
545 |
|
---|
546 | *aBits = m->bd->Audio.cBits;
|
---|
547 |
|
---|
548 | return S_OK;
|
---|
549 | }
|
---|
550 |
|
---|
551 | HRESULT RecordScreenSettings::setAudioBits(ULONG aBits)
|
---|
552 | {
|
---|
553 | AutoCaller autoCaller(this);
|
---|
554 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
555 |
|
---|
556 | if (!m->pParent->i_canChangeSettings())
|
---|
557 | return setError(E_INVALIDARG, tr("Cannot change audio bits while capturing is enabled"));
|
---|
558 |
|
---|
559 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
560 |
|
---|
561 | m->bd.backup();
|
---|
562 | m->bd->Audio.cBits = (uint8_t)aBits;
|
---|
563 |
|
---|
564 | return S_OK;
|
---|
565 | }
|
---|
566 |
|
---|
567 | HRESULT RecordScreenSettings::getAudioChannels(ULONG *aChannels)
|
---|
568 | {
|
---|
569 | AutoCaller autoCaller(this);
|
---|
570 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
571 |
|
---|
572 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
573 |
|
---|
574 | *aChannels = m->bd->Audio.cChannels;
|
---|
575 |
|
---|
576 | return S_OK;
|
---|
577 | }
|
---|
578 |
|
---|
579 | HRESULT RecordScreenSettings::setAudioChannels(ULONG aChannels)
|
---|
580 | {
|
---|
581 | AutoCaller autoCaller(this);
|
---|
582 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
583 |
|
---|
584 | if (!m->pParent->i_canChangeSettings())
|
---|
585 | return setError(E_INVALIDARG, tr("Cannot change audio channels while capturing is enabled"));
|
---|
586 |
|
---|
587 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
588 |
|
---|
589 | m->bd.backup();
|
---|
590 | m->bd->Audio.cChannels = (uint8_t)aChannels;
|
---|
591 |
|
---|
592 | return S_OK;
|
---|
593 | }
|
---|
594 |
|
---|
595 | HRESULT RecordScreenSettings::getVideoCodec(RecordVideoCodec_T *aCodec)
|
---|
596 | {
|
---|
597 | AutoCaller autoCaller(this);
|
---|
598 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
599 |
|
---|
600 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
601 |
|
---|
602 | *aCodec = m->bd->Video.enmCodec;
|
---|
603 |
|
---|
604 | return S_OK;
|
---|
605 | }
|
---|
606 |
|
---|
607 | HRESULT RecordScreenSettings::setVideoCodec(RecordVideoCodec_T aCodec)
|
---|
608 | {
|
---|
609 | AutoCaller autoCaller(this);
|
---|
610 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
611 |
|
---|
612 | if (!m->pParent->i_canChangeSettings())
|
---|
613 | return setError(E_INVALIDARG, tr("Cannot change video codec while capturing is enabled"));
|
---|
614 |
|
---|
615 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
616 |
|
---|
617 | m->bd.backup();
|
---|
618 | m->bd->Video.enmCodec = aCodec;
|
---|
619 |
|
---|
620 | return S_OK;
|
---|
621 | }
|
---|
622 |
|
---|
623 | HRESULT RecordScreenSettings::getVideoWidth(ULONG *aVideoWidth)
|
---|
624 | {
|
---|
625 | AutoCaller autoCaller(this);
|
---|
626 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
627 |
|
---|
628 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
629 |
|
---|
630 | *aVideoWidth = m->bd->Video.ulWidth;
|
---|
631 |
|
---|
632 | return S_OK;
|
---|
633 | }
|
---|
634 |
|
---|
635 | HRESULT RecordScreenSettings::setVideoWidth(ULONG aVideoWidth)
|
---|
636 | {
|
---|
637 | AutoCaller autoCaller(this);
|
---|
638 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
639 |
|
---|
640 | if (!m->pParent->i_canChangeSettings())
|
---|
641 | return setError(E_INVALIDARG, tr("Cannot change video width while capturing is enabled"));
|
---|
642 |
|
---|
643 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
644 |
|
---|
645 | m->bd.backup();
|
---|
646 | m->bd->Video.ulWidth = aVideoWidth;
|
---|
647 |
|
---|
648 | return S_OK;
|
---|
649 | }
|
---|
650 |
|
---|
651 | HRESULT RecordScreenSettings::getVideoHeight(ULONG *aVideoHeight)
|
---|
652 | {
|
---|
653 | AutoCaller autoCaller(this);
|
---|
654 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
655 |
|
---|
656 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
657 |
|
---|
658 | *aVideoHeight = m->bd->Video.ulHeight;
|
---|
659 |
|
---|
660 | return S_OK;
|
---|
661 | }
|
---|
662 |
|
---|
663 | HRESULT RecordScreenSettings::setVideoHeight(ULONG aVideoHeight)
|
---|
664 | {
|
---|
665 | AutoCaller autoCaller(this);
|
---|
666 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
667 |
|
---|
668 | if (!m->pParent->i_canChangeSettings())
|
---|
669 | return setError(E_INVALIDARG, tr("Cannot change video height while capturing is enabled"));
|
---|
670 |
|
---|
671 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
672 |
|
---|
673 | m->bd.backup();
|
---|
674 | m->bd->Video.ulHeight = aVideoHeight;
|
---|
675 |
|
---|
676 | return S_OK;
|
---|
677 | }
|
---|
678 |
|
---|
679 | HRESULT RecordScreenSettings::getVideoRate(ULONG *aVideoRate)
|
---|
680 | {
|
---|
681 | AutoCaller autoCaller(this);
|
---|
682 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
683 |
|
---|
684 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
685 |
|
---|
686 | *aVideoRate = m->bd->Video.ulRate;
|
---|
687 |
|
---|
688 | return S_OK;
|
---|
689 | }
|
---|
690 |
|
---|
691 | HRESULT RecordScreenSettings::setVideoRate(ULONG aVideoRate)
|
---|
692 | {
|
---|
693 | AutoCaller autoCaller(this);
|
---|
694 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
695 |
|
---|
696 | if (!m->pParent->i_canChangeSettings())
|
---|
697 | return setError(E_INVALIDARG, tr("Cannot change video rate while capturing is enabled"));
|
---|
698 |
|
---|
699 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
700 |
|
---|
701 | m->bd.backup();
|
---|
702 | m->bd->Video.ulRate = aVideoRate;
|
---|
703 |
|
---|
704 | return S_OK;
|
---|
705 | }
|
---|
706 |
|
---|
707 | HRESULT RecordScreenSettings::getVideoRateControlMode(RecordVideoRateControlMode_T *aMode)
|
---|
708 | {
|
---|
709 | AutoCaller autoCaller(this);
|
---|
710 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
711 |
|
---|
712 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
713 |
|
---|
714 | *aMode = RecordVideoRateControlMode_CBR; /** @todo Implement VBR. */
|
---|
715 |
|
---|
716 | return S_OK;
|
---|
717 | }
|
---|
718 |
|
---|
719 | HRESULT RecordScreenSettings::setVideoRateControlMode(RecordVideoRateControlMode_T aMode)
|
---|
720 | {
|
---|
721 | AutoCaller autoCaller(this);
|
---|
722 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
723 |
|
---|
724 | if (!m->pParent->i_canChangeSettings())
|
---|
725 | return setError(E_INVALIDARG, tr("Cannot change video rate control mode while capturing is enabled"));
|
---|
726 |
|
---|
727 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
728 |
|
---|
729 | /** @todo Implement this. */
|
---|
730 | RT_NOREF(aMode);
|
---|
731 |
|
---|
732 | return E_NOTIMPL;
|
---|
733 | }
|
---|
734 |
|
---|
735 | HRESULT RecordScreenSettings::getVideoFPS(ULONG *aVideoFPS)
|
---|
736 | {
|
---|
737 | AutoCaller autoCaller(this);
|
---|
738 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
739 |
|
---|
740 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
741 |
|
---|
742 | *aVideoFPS = m->bd->Video.ulFPS;
|
---|
743 |
|
---|
744 | return S_OK;
|
---|
745 | }
|
---|
746 |
|
---|
747 | HRESULT RecordScreenSettings::setVideoFPS(ULONG aVideoFPS)
|
---|
748 | {
|
---|
749 | AutoCaller autoCaller(this);
|
---|
750 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
751 |
|
---|
752 | if (!m->pParent->i_canChangeSettings())
|
---|
753 | return setError(E_INVALIDARG, tr("Cannot change video FPS while capturing is enabled"));
|
---|
754 |
|
---|
755 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
756 |
|
---|
757 | m->bd.backup();
|
---|
758 | m->bd->Video.ulFPS = aVideoFPS;
|
---|
759 |
|
---|
760 | return S_OK;
|
---|
761 | }
|
---|
762 |
|
---|
763 | HRESULT RecordScreenSettings::getVideoScalingMethod(RecordVideoScalingMethod_T *aMode)
|
---|
764 | {
|
---|
765 | AutoCaller autoCaller(this);
|
---|
766 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
767 |
|
---|
768 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
769 |
|
---|
770 | *aMode = RecordVideoScalingMethod_None; /** @todo Implement this. */
|
---|
771 |
|
---|
772 | return S_OK;
|
---|
773 | }
|
---|
774 |
|
---|
775 | HRESULT RecordScreenSettings::setVideoScalingMethod(RecordVideoScalingMethod_T aMode)
|
---|
776 | {
|
---|
777 | AutoCaller autoCaller(this);
|
---|
778 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
779 |
|
---|
780 | if (!m->pParent->i_canChangeSettings())
|
---|
781 | return setError(E_INVALIDARG, tr("Cannot change video rate scaling method while capturing is enabled"));
|
---|
782 |
|
---|
783 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
784 |
|
---|
785 | /** @todo Implement this. */
|
---|
786 | RT_NOREF(aMode);
|
---|
787 |
|
---|
788 | return E_NOTIMPL;
|
---|
789 | }
|
---|
790 |
|
---|
791 | /**
|
---|
792 | * Initializes data, internal version.
|
---|
793 | *
|
---|
794 | * @returns IPRT status code.
|
---|
795 | */
|
---|
796 | int RecordScreenSettings::i_initInternal(void)
|
---|
797 | {
|
---|
798 | Assert(m);
|
---|
799 |
|
---|
800 | int rc = VINF_SUCCESS;
|
---|
801 |
|
---|
802 | switch (m->bd->enmDest)
|
---|
803 | {
|
---|
804 | case RecordDestination_File:
|
---|
805 | {
|
---|
806 | if (m->bd->File.strName.isEmpty())
|
---|
807 | rc = m->pParent->i_getDefaultFileName(m->bd->File.strName);
|
---|
808 | break;
|
---|
809 | }
|
---|
810 |
|
---|
811 | default:
|
---|
812 | break;
|
---|
813 | }
|
---|
814 |
|
---|
815 | return rc;
|
---|
816 | }
|
---|
817 |
|
---|