|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include <QVariant> |
|
43 #include <qtmedianamespace.h> |
|
44 #include "qxarecordsession.h" |
|
45 #include "xarecordsessionimpl.h" |
|
46 #include "qxacommon.h" |
|
47 |
|
48 /* The following declaration is required to allow QList<int> to be added to |
|
49 * QVariant |
|
50 */ |
|
51 Q_DECLARE_METATYPE(QList<int>) |
|
52 |
|
53 /* This macro checks for m_impl null pointer. If it is, emits an error signal |
|
54 * error(QMediaRecorder::ResourceError, tr("Service has not been started")); |
|
55 * and returns from function immediately with value 's'. |
|
56 */ |
|
57 |
|
58 #define RETURN_s_IF_m_impl_IS_NULL(s) \ |
|
59 if (!m_impl) { \ |
|
60 emit error(QMediaRecorder::ResourceError, tr("Service has not been started")); \ |
|
61 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::ResourceError, tr(\"Service has not been started\"))"); \ |
|
62 return s; \ |
|
63 } |
|
64 |
|
65 /* This macro checks for m_impl null pointer. If it is, emits an error signal |
|
66 * error(QMediaRecorder::ResourceError, tr("Service has not been started")); |
|
67 * and returns from function immediately. |
|
68 */ |
|
69 #define RETURN_IF_m_impl_IS_NULL \ |
|
70 if (!m_impl) { \ |
|
71 emit error(QMediaRecorder::ResourceError, tr("Service has not been started")); \ |
|
72 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::ResourceError, tr(\"Service has not been started\"))"); \ |
|
73 return; \ |
|
74 } |
|
75 |
|
76 QXARecordSession::QXARecordSession(QObject *parent) |
|
77 :QObject(parent), |
|
78 m_state(QMediaRecorder::StoppedState) |
|
79 { |
|
80 QT_TRACE_FUNCTION_ENTRY; |
|
81 m_impl = NULL; |
|
82 m_impl = new XARecordSessionImpl(*this); |
|
83 if (m_impl) { |
|
84 if (m_impl->postConstruct() == KErrNone) { |
|
85 initCodecsList(); |
|
86 initContainersList(); |
|
87 m_containerMimeType = QString(); |
|
88 m_audioencodersettings.setBitRate(0); |
|
89 m_audioencodersettings.setChannelCount(-1); |
|
90 m_audioencodersettings.setEncodingMode(QtMedia::ConstantQualityEncoding); |
|
91 m_audioencodersettings.setQuality(QtMedia::NormalQuality); |
|
92 m_audioencodersettings.setSampleRate(-1); |
|
93 QT_TRACE1("Initialized implementation"); |
|
94 } |
|
95 else { |
|
96 delete m_impl; |
|
97 m_impl = NULL; |
|
98 QT_TRACE1("Error initializing implementation"); |
|
99 } |
|
100 } |
|
101 else { |
|
102 emit error(QMediaRecorder::ResourceError, tr("Unable to start Service")); |
|
103 } |
|
104 QT_TRACE_FUNCTION_EXIT; |
|
105 } |
|
106 |
|
107 QXARecordSession::~QXARecordSession() |
|
108 { |
|
109 QT_TRACE_FUNCTION_ENTRY; |
|
110 delete m_impl; |
|
111 QT_TRACE_FUNCTION_EXIT; |
|
112 } |
|
113 |
|
114 QUrl QXARecordSession::outputLocation() |
|
115 { |
|
116 return m_outputLocation; |
|
117 } |
|
118 |
|
119 bool QXARecordSession::setOutputLocation(const QUrl &location) |
|
120 { |
|
121 QT_TRACE_FUNCTION_ENTRY; |
|
122 |
|
123 RETURN_s_IF_m_impl_IS_NULL(false); |
|
124 |
|
125 // Location can be set only when recorder is in stopped state. |
|
126 if (state() != QMediaRecorder::StoppedState ) |
|
127 return false; |
|
128 |
|
129 // Validate URL |
|
130 if (!location.isValid()) |
|
131 return false; |
|
132 |
|
133 // If old and new locations are same, do nothing. |
|
134 QString newUrlStr = (QUrl::fromUserInput(location.toString().toLower())).toString(); |
|
135 QString curUrlStr = (QUrl::fromUserInput(m_outputLocation.toString().toLower())).toString(); |
|
136 if (curUrlStr.compare(newUrlStr) == KErrNone) |
|
137 return true; |
|
138 |
|
139 bool retVal = false; |
|
140 TPtrC16 tempPtr(reinterpret_cast<const TUint16 *>(newUrlStr.utf16())); |
|
141 if (m_impl->setURI(tempPtr) == 0) { |
|
142 m_outputLocation = location; |
|
143 retVal = true; |
|
144 } |
|
145 else { |
|
146 emit error(QMediaRecorder::ResourceError, tr("Generic error")); |
|
147 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::ResourceError, tr(\"Generic error\"))"); |
|
148 } |
|
149 |
|
150 QT_TRACE_FUNCTION_EXIT; |
|
151 return retVal; |
|
152 } |
|
153 |
|
154 QMediaRecorder::State QXARecordSession::state() |
|
155 { |
|
156 return m_state; |
|
157 } |
|
158 |
|
159 qint64 QXARecordSession::duration() |
|
160 { |
|
161 TInt64 dur(0); |
|
162 |
|
163 QT_TRACE_FUNCTION_ENTRY; |
|
164 |
|
165 RETURN_s_IF_m_impl_IS_NULL(dur); |
|
166 |
|
167 m_impl->duration(dur); |
|
168 |
|
169 QT_TRACE_FUNCTION_EXIT; |
|
170 return (qint64)dur; |
|
171 } |
|
172 |
|
173 void QXARecordSession::applySettings() |
|
174 { |
|
175 if (m_appliedaudioencodersettings != m_audioencodersettings) |
|
176 setEncoderSettingsToImpl(); |
|
177 } |
|
178 |
|
179 void QXARecordSession::record() |
|
180 { |
|
181 QT_TRACE_FUNCTION_ENTRY; |
|
182 |
|
183 RETURN_IF_m_impl_IS_NULL; |
|
184 |
|
185 /* 1. Set encoder settings here */ |
|
186 if (m_appliedaudioencodersettings != m_audioencodersettings) |
|
187 RET_IF_FALSE(setEncoderSettingsToImpl()); |
|
188 |
|
189 /* 2. Start recording... |
|
190 * If successful, setRecorderState(QMediaRecorder::RecordingState); |
|
191 * will be called from the callback cbRecordingStarted() |
|
192 */ |
|
193 if (m_impl->record() != KErrNone) { |
|
194 emit error(QMediaRecorder::ResourceError, tr("Generic error")); |
|
195 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::ResourceError, tr(\"Generic error\"))"); |
|
196 } |
|
197 |
|
198 QT_TRACE_FUNCTION_EXIT; |
|
199 } |
|
200 |
|
201 void QXARecordSession::pause() |
|
202 { |
|
203 QT_TRACE_FUNCTION_ENTRY; |
|
204 |
|
205 RETURN_IF_m_impl_IS_NULL; |
|
206 |
|
207 if (m_impl->pause() == KErrNone) { |
|
208 setRecorderState(QMediaRecorder::PausedState); |
|
209 } |
|
210 else { |
|
211 emit error(QMediaRecorder::ResourceError, tr("Unable to pause")); |
|
212 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::ResourceError, tr(\"Unable to pause\"))"); |
|
213 } |
|
214 |
|
215 QT_TRACE_FUNCTION_EXIT; |
|
216 } |
|
217 |
|
218 void QXARecordSession::stop() |
|
219 { |
|
220 QT_TRACE_FUNCTION_ENTRY; |
|
221 |
|
222 RETURN_IF_m_impl_IS_NULL; |
|
223 |
|
224 if ((m_impl->stop() == KErrNone)) { |
|
225 setRecorderState(QMediaRecorder::StoppedState); |
|
226 } |
|
227 else { |
|
228 emit error(QMediaRecorder::ResourceError, tr("Unable to stop")); |
|
229 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::ResourceError, tr(\"Unable to stop\"))"); |
|
230 } |
|
231 |
|
232 QT_TRACE_FUNCTION_EXIT; |
|
233 } |
|
234 |
|
235 void QXARecordSession::cbDurationChanged(TInt64 new_pos) |
|
236 { |
|
237 emit durationChanged((qint64)new_pos); |
|
238 SIGNAL_EMIT_TRACE1("emit durationChanged((qint64)new_pos);"); |
|
239 } |
|
240 |
|
241 void QXARecordSession::cbAvailableAudioInputsChanged() |
|
242 { |
|
243 emit availableAudioInputsChanged(); |
|
244 SIGNAL_EMIT_TRACE1("emit availableAudioInputsChanged();"); |
|
245 } |
|
246 |
|
247 void QXARecordSession::cbRecordingStarted() |
|
248 { |
|
249 setRecorderState(QMediaRecorder::RecordingState); |
|
250 } |
|
251 |
|
252 void QXARecordSession::cbRecordingStopped() |
|
253 { |
|
254 emit error(QMediaRecorder::ResourceError, tr("Resources Unavailable")); |
|
255 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::ResourceError, tr(\"Resources Unavailable\"))"); |
|
256 setRecorderState(QMediaRecorder::StoppedState); |
|
257 } |
|
258 |
|
259 /* For QAudioEndpointSelector begin */ |
|
260 QList<QString> QXARecordSession::availableEndpoints() |
|
261 { |
|
262 QT_TRACE_FUNCTION_ENTRY; |
|
263 |
|
264 QList<QString> strList; |
|
265 |
|
266 RETURN_s_IF_m_impl_IS_NULL(strList); |
|
267 |
|
268 QString str; |
|
269 RArray<TPtrC> names; |
|
270 m_impl->getAudioInputDeviceNames(names); |
|
271 for (TInt index = 0; index < names.Count(); index++) { |
|
272 str = QString((QChar*)names[index].Ptr(), names[index].Length()); |
|
273 strList.append(str); |
|
274 } |
|
275 |
|
276 QT_TRACE_FUNCTION_EXIT; |
|
277 return strList; |
|
278 } |
|
279 |
|
280 QString QXARecordSession::endpointDescription(const QString &name) |
|
281 { |
|
282 /* From AL we get only device name */ |
|
283 return name; |
|
284 } |
|
285 |
|
286 QString QXARecordSession::defaultEndpoint() |
|
287 { |
|
288 QT_TRACE_FUNCTION_ENTRY; |
|
289 |
|
290 QString str; |
|
291 |
|
292 RETURN_s_IF_m_impl_IS_NULL(str); |
|
293 |
|
294 TPtrC name; |
|
295 if(m_impl->defaultAudioInputDevice(name) == KErrNone) |
|
296 str = QString((QChar*)name.Ptr(), name.Length()); |
|
297 |
|
298 QT_TRACE_FUNCTION_EXIT; |
|
299 return str; |
|
300 } |
|
301 |
|
302 QString QXARecordSession::activeEndpoint() |
|
303 { |
|
304 QT_TRACE_FUNCTION_ENTRY; |
|
305 |
|
306 QString str; |
|
307 |
|
308 RETURN_s_IF_m_impl_IS_NULL(str); |
|
309 |
|
310 TPtrC name; |
|
311 if(m_impl->activeAudioInputDevice(name) == KErrNone) |
|
312 str = QString((QChar*)name.Ptr(), name.Length()); |
|
313 |
|
314 QT_TRACE_FUNCTION_EXIT; |
|
315 return str; |
|
316 } |
|
317 |
|
318 void QXARecordSession::setActiveEndpoint(const QString &name) |
|
319 { |
|
320 QT_TRACE_FUNCTION_ENTRY; |
|
321 |
|
322 RETURN_IF_m_impl_IS_NULL; |
|
323 |
|
324 TPtrC16 tempPtr(reinterpret_cast<const TUint16*>(name.utf16())); |
|
325 if (m_impl->setAudioInputDevice(tempPtr) == true) { |
|
326 emit activeEndpointChanged(name); |
|
327 SIGNAL_EMIT_TRACE1("emit activeEndpointChanged(name)"); |
|
328 } |
|
329 else { |
|
330 emit error(QMediaRecorder::ResourceError, tr("Invalid endpoint")); |
|
331 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::ResourceError, tr(\"Invalid endpoint\"))"); |
|
332 } |
|
333 |
|
334 QT_TRACE_FUNCTION_EXIT; |
|
335 } |
|
336 /* For QAudioEndpointSelector end */ |
|
337 |
|
338 /* For QAudioEncoderControl begin */ |
|
339 QStringList QXARecordSession::supportedAudioCodecs() |
|
340 { |
|
341 return m_codecs; |
|
342 } |
|
343 |
|
344 QString QXARecordSession::codecDescription(const QString &codecName) |
|
345 { |
|
346 if (m_codecs.contains(codecName.toLower())) |
|
347 return QString(codecName); |
|
348 return QString(); |
|
349 } |
|
350 |
|
351 QList<int> QXARecordSession::supportedSampleRates( |
|
352 const QAudioEncoderSettings &settings, |
|
353 bool *continuous) |
|
354 { |
|
355 QT_TRACE_FUNCTION_ENTRY; |
|
356 |
|
357 QList<int> srList; |
|
358 |
|
359 RETURN_s_IF_m_impl_IS_NULL(srList); |
|
360 |
|
361 QString selectedCodec = settings.codec().toLower(); |
|
362 |
|
363 if (m_codecs.indexOf(selectedCodec) >= 0) { |
|
364 RArray<TInt32> sampleRates; |
|
365 TBool isContinuous; |
|
366 TPtrC16 tempPtr(reinterpret_cast<const TUint16*>(selectedCodec.utf16())); |
|
367 if (m_impl->getSampleRates(tempPtr, sampleRates, isContinuous) == KErrNone) { |
|
368 for (TInt index = 0; index < sampleRates.Count(); index++) |
|
369 srList.append(sampleRates[index]); |
|
370 sampleRates.Close(); |
|
371 *continuous = false; |
|
372 if (isContinuous == true) |
|
373 *continuous = true; |
|
374 } |
|
375 } |
|
376 |
|
377 QT_TRACE_FUNCTION_EXIT; |
|
378 return srList; |
|
379 } |
|
380 |
|
381 QAudioEncoderSettings QXARecordSession::audioSettings() |
|
382 { |
|
383 return m_audioencodersettings; |
|
384 } |
|
385 |
|
386 void QXARecordSession::setAudioSettings(const QAudioEncoderSettings &settings) |
|
387 { |
|
388 m_audioencodersettings = settings; |
|
389 } |
|
390 |
|
391 QStringList QXARecordSession::supportedEncodingOptions(const QString &codec) |
|
392 { |
|
393 QT_TRACE_FUNCTION_ENTRY; |
|
394 Q_UNUSED(codec); |
|
395 QStringList options; |
|
396 options << "bitrate"; |
|
397 |
|
398 QT_TRACE_FUNCTION_EXIT; |
|
399 return options; |
|
400 } |
|
401 |
|
402 QVariant QXARecordSession::encodingOption(const QString &codec, const QString &name) |
|
403 { |
|
404 QT_TRACE_FUNCTION_ENTRY; |
|
405 |
|
406 QVariant encodingOption; |
|
407 |
|
408 RETURN_s_IF_m_impl_IS_NULL(encodingOption); |
|
409 |
|
410 if (name.toLower().compare("bitrate") == 0) { |
|
411 TPtrC16 tempPtr(reinterpret_cast<const TUint16*>(codec.toLower().utf16())); |
|
412 QList<int> bitrateList; |
|
413 RArray<TUint32> bitrates; |
|
414 if (m_impl->getBitrates(tempPtr, bitrates) == KErrNone) { |
|
415 for (TInt index = 0; index < bitrates.Count(); index++) |
|
416 bitrateList.append(bitrates[index]); |
|
417 bitrates.Close(); |
|
418 } |
|
419 encodingOption.setValue(bitrateList); |
|
420 } |
|
421 |
|
422 QT_TRACE_FUNCTION_EXIT; |
|
423 return encodingOption; |
|
424 } |
|
425 |
|
426 void QXARecordSession::setEncodingOption( |
|
427 const QString &codec, |
|
428 const QString &name, |
|
429 const QVariant &value) |
|
430 { |
|
431 /* |
|
432 * Currently nothing can be set via this function. |
|
433 * Bitrate is set via QAudioEncoderSettings::setBitrate(). |
|
434 */ |
|
435 Q_UNUSED(codec); |
|
436 Q_UNUSED(name); |
|
437 Q_UNUSED(value); |
|
438 } |
|
439 /* For QAudioEncoderControl end */ |
|
440 |
|
441 QStringList QXARecordSession::supportedContainers() |
|
442 { |
|
443 return m_containers; |
|
444 } |
|
445 |
|
446 QString QXARecordSession::containerMimeType() |
|
447 { |
|
448 return m_containerMimeType; |
|
449 } |
|
450 |
|
451 void QXARecordSession::setContainerMimeType(const QString &formatMimeType) |
|
452 { |
|
453 if (m_containers.indexOf(formatMimeType.toLower()) >= 0 ) |
|
454 m_containerMimeType = formatMimeType; |
|
455 else { |
|
456 emit error(QMediaRecorder::FormatError, tr("Invalid container")); |
|
457 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid container\"))"); |
|
458 } |
|
459 } |
|
460 |
|
461 QString QXARecordSession::containerDescription(const QString &formatMimeType) |
|
462 { |
|
463 int index = m_containers.indexOf(formatMimeType.toLower()); |
|
464 if (index >= 0) { |
|
465 return m_containersDesc.at(index); |
|
466 } |
|
467 else { |
|
468 emit error(QMediaRecorder::FormatError, tr("Invalid container")); |
|
469 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid container\"))"); |
|
470 } |
|
471 return QString(); |
|
472 } |
|
473 |
|
474 void QXARecordSession::setRecorderState(QMediaRecorder::State state) |
|
475 { |
|
476 if (state != m_state) { |
|
477 m_state = state; |
|
478 emit stateChanged(m_state); |
|
479 SIGNAL_EMIT_TRACE1("emit stateChanged(m_state);"); |
|
480 } |
|
481 } |
|
482 |
|
483 void QXARecordSession::initCodecsList() |
|
484 { |
|
485 QT_TRACE_FUNCTION_ENTRY; |
|
486 |
|
487 RETURN_IF_m_impl_IS_NULL; |
|
488 |
|
489 m_codecs.clear(); |
|
490 |
|
491 const RArray<TPtrC>& names = m_impl->getAudioEncoderNames(); |
|
492 QString str; |
|
493 |
|
494 for (TInt index = 0; index < names.Count(); index++) { |
|
495 str = QString((QChar*)names[index].Ptr(), names[index].Length()); |
|
496 m_codecs.append(str); |
|
497 } |
|
498 QT_TRACE_FUNCTION_EXIT; |
|
499 } |
|
500 |
|
501 void QXARecordSession::initContainersList() |
|
502 { |
|
503 QT_TRACE_FUNCTION_ENTRY; |
|
504 |
|
505 RETURN_IF_m_impl_IS_NULL; |
|
506 |
|
507 m_containers.clear(); |
|
508 m_containersDesc.clear(); |
|
509 |
|
510 const RArray<TPtrC>& names = m_impl->getContainerNames(); |
|
511 const RArray<TPtrC>& descs = m_impl->getContainerDescs(); |
|
512 QString str; |
|
513 |
|
514 for (TInt32 index = 0; index < names.Count(); index++) { |
|
515 str = QString((QChar*)names[index].Ptr(), names[index].Length()); |
|
516 m_containers.append(str); |
|
517 str = QString((QChar*)descs[index].Ptr(), descs[index].Length()); |
|
518 m_containersDesc.append(str); |
|
519 } |
|
520 QT_TRACE_FUNCTION_EXIT; |
|
521 } |
|
522 |
|
523 bool QXARecordSession::setEncoderSettingsToImpl() |
|
524 { |
|
525 QT_TRACE_FUNCTION_ENTRY; |
|
526 |
|
527 RETURN_s_IF_m_impl_IS_NULL(false); |
|
528 |
|
529 m_impl->resetEncoderAttributes(); |
|
530 |
|
531 QString tempStr = m_containerMimeType.toLower(); |
|
532 TPtrC16 tempPtr(reinterpret_cast<const TUint16 *>(tempStr.utf16())); |
|
533 m_impl->setContainerType(tempPtr); |
|
534 |
|
535 /* Validate and set bitrate only if encoding mode is other than quality encoding */ |
|
536 if (m_audioencodersettings.encodingMode() != QtMedia::ConstantQualityEncoding) { |
|
537 if (m_audioencodersettings.bitRate() < 0 ) { |
|
538 emit error(QMediaRecorder::FormatError, tr("Invalid bitrate")); |
|
539 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid bitrate\"))"); |
|
540 return false; |
|
541 } |
|
542 else { |
|
543 m_impl->setBitRate(m_audioencodersettings.bitRate()); |
|
544 } |
|
545 } |
|
546 |
|
547 if (m_audioencodersettings.channelCount() == -1) { |
|
548 m_impl->setOptimalChannelCount(); |
|
549 } |
|
550 else if (m_audioencodersettings.channelCount() <= 0) { |
|
551 emit error(QMediaRecorder::FormatError, tr("Invalid channel count")); |
|
552 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid channel count\"));"); |
|
553 return false; |
|
554 } |
|
555 else { |
|
556 m_impl->setChannels(m_audioencodersettings.channelCount()); |
|
557 } |
|
558 |
|
559 tempStr = m_audioencodersettings.codec().toLower(); |
|
560 if (m_codecs.indexOf(tempStr) >= 0) { |
|
561 tempPtr.Set(reinterpret_cast<const TUint16*>(tempStr.utf16())); |
|
562 /* We already did validation above, so function always returns true */ |
|
563 m_impl->setCodec(tempPtr); |
|
564 } |
|
565 else { |
|
566 emit error(QMediaRecorder::FormatError, tr("Invalid codec")); |
|
567 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid codec\"));"); |
|
568 return false; |
|
569 } |
|
570 |
|
571 switch (m_audioencodersettings.encodingMode()) { |
|
572 case QtMedia::ConstantQualityEncoding: { |
|
573 switch (m_audioencodersettings.quality()) { |
|
574 case QtMedia::VeryLowQuality: |
|
575 m_impl->setVeryLowQuality(); |
|
576 break; |
|
577 case QtMedia::LowQuality: |
|
578 m_impl->setLowQuality(); |
|
579 break; |
|
580 case QtMedia::NormalQuality: |
|
581 m_impl->setNormalQuality(); |
|
582 break; |
|
583 case QtMedia::HighQuality: |
|
584 m_impl->setHighQuality(); |
|
585 break; |
|
586 case QtMedia::VeryHighQuality: |
|
587 m_impl->setVeryHighQuality(); |
|
588 break; |
|
589 default: |
|
590 emit error(QMediaRecorder::FormatError, tr("Invalid encoding quality setting")); |
|
591 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid encoding quality setting\"));"); |
|
592 return false; |
|
593 }; /* end of switch (m_audioencodersettings.quality())*/ |
|
594 } |
|
595 break; |
|
596 case QtMedia::ConstantBitRateEncoding: { |
|
597 TInt32 status = m_impl->setCBRMode(); |
|
598 if (status == KErrNotSupported) { |
|
599 emit error(QMediaRecorder::FormatError, tr("Invalid encoding mode setting")); |
|
600 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid encoding mode setting\"));"); |
|
601 return false; |
|
602 } |
|
603 else if (status != KErrNone) { |
|
604 emit error(QMediaRecorder::ResourceError, tr("Internal error")); |
|
605 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::ResourceError, tr(\"Internal error\"));"); |
|
606 return false; |
|
607 } |
|
608 } |
|
609 break; |
|
610 case QtMedia::AverageBitRateEncoding: { |
|
611 TInt32 status = m_impl->setVBRMode(); |
|
612 if (status == KErrNotSupported) { |
|
613 emit error(QMediaRecorder::FormatError, tr("Invalid encoding mode setting")); |
|
614 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid encoding mode setting\"));"); |
|
615 return false; |
|
616 } |
|
617 else if (status != KErrNone) { |
|
618 emit error(QMediaRecorder::ResourceError, tr("Internal error")); |
|
619 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::ResourceError, tr(\"Internal error\"));"); |
|
620 return false; |
|
621 } |
|
622 } |
|
623 break; |
|
624 case QtMedia::TwoPassEncoding: |
|
625 // fall through |
|
626 default: { |
|
627 emit error(QMediaRecorder::FormatError, tr("Invalid encoding mode setting")); |
|
628 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid encoding mode setting\"));"); |
|
629 return false; |
|
630 } |
|
631 }; /* switch (m_audioencodersettings.encodingMode()) */ |
|
632 |
|
633 if (m_audioencodersettings.sampleRate() == -1) { |
|
634 m_impl->setOptimalSampleRate(); |
|
635 } |
|
636 else if (m_audioencodersettings.sampleRate() <= 0) { |
|
637 emit error(QMediaRecorder::FormatError, tr("Invalid sample rate")); |
|
638 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid sample rate\"));"); |
|
639 return false; |
|
640 } |
|
641 else { |
|
642 m_impl->setSampleRate(m_audioencodersettings.sampleRate()); |
|
643 } |
|
644 m_appliedaudioencodersettings = m_audioencodersettings; |
|
645 QT_TRACE_FUNCTION_EXIT; |
|
646 return true; |
|
647 } |