qtmobility/plugins/multimedia/symbian/openmaxal/mediarecorder/qxarecordsession.cpp
changeset 14 6fbed849b4f4
parent 11 06b8e2af4411
child 15 1f895d8a5b2b
equal deleted inserted replaced
11:06b8e2af4411 14:6fbed849b4f4
    55  * and returns from function immediately with value 's'.
    55  * and returns from function immediately with value 's'.
    56  */
    56  */
    57 
    57 
    58 #define RETURN_s_IF_m_impl_IS_NULL(s) \
    58 #define RETURN_s_IF_m_impl_IS_NULL(s) \
    59     if (!m_impl) { \
    59     if (!m_impl) { \
    60         emit error(QMediaRecorder::ResourceError, tr("Service has not been started")); \
    60         emit error(QMediaRecorder::ResourceError, QXARecordSession::tr("Service has not been started")); \
    61         SIGNAL_EMIT_TRACE1("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; \
    62         return s; \
    63         }
    63         }
    64 
    64 
    65 /* This macro checks for m_impl null pointer. If it is, emits an error signal
    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"));
    66  * error(QMediaRecorder::ResourceError, tr("Service has not been started"));
    67  * and returns from function immediately.
    67  * and returns from function immediately.
    68  */
    68  */
    69 #define RETURN_IF_m_impl_IS_NULL \
    69 #define RETURN_IF_m_impl_IS_NULL \
    70     if (!m_impl) { \
    70     if (!m_impl) { \
    71         emit error(QMediaRecorder::ResourceError, tr("Service has not been started")); \
    71         emit error(QMediaRecorder::ResourceError, QXARecordSession::tr("Service has not been started")); \
    72         SIGNAL_EMIT_TRACE1("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; \
    73         return; \
    74         }
    74         }
    75 
    75 
    76 QXARecordSession::QXARecordSession(QObject *parent)
    76 QXARecordSession::QXARecordSession(QObject *parent)
    77 :QObject(parent),
    77 :QObject(parent),
    78 m_state(QMediaRecorder::StoppedState)
    78 m_state(QMediaRecorder::StoppedState),
       
    79 m_previousState(QMediaRecorder::StoppedState)
    79 {
    80 {
    80     QT_TRACE_FUNCTION_ENTRY;
    81     QT_TRACE_FUNCTION_ENTRY;
    81     m_impl = NULL;
    82     m_impl = NULL;
    82     m_impl = new XARecordSessionImpl(*this);
    83     m_impl = new XARecordSessionImpl(*this);
    83     if (m_impl) {
    84     if (m_impl) {
    84         if (m_impl->postConstruct() == KErrNone) {
    85         if (m_impl->postConstruct() == KErrNone) {
    85             initCodecsList();
    86             initCodecsList();
    86             initContainersList();
    87             initContainersList();
    87             m_containerMimeType = QString();
    88             m_containerMimeType = QString("audio/wav");
       
    89             m_audioencodersettings.setCodec("pcm");
    88             m_audioencodersettings.setBitRate(0);
    90             m_audioencodersettings.setBitRate(0);
    89             m_audioencodersettings.setChannelCount(-1);
    91             m_audioencodersettings.setChannelCount(-1);
    90             m_audioencodersettings.setEncodingMode(QtMediaServices::ConstantQualityEncoding);
    92             m_audioencodersettings.setEncodingMode(QtMultimedia::ConstantQualityEncoding);
    91             m_audioencodersettings.setQuality(QtMediaServices::NormalQuality);
    93             m_audioencodersettings.setQuality(QtMultimedia::NormalQuality);
    92             m_audioencodersettings.setSampleRate(-1);
    94             m_audioencodersettings.setSampleRate(-1);
    93             QT_TRACE1("Initialized implementation");
    95             QT_TRACE1("Initialized implementation");
    94         }
    96         }
    95         else {
    97         else {
    96             delete m_impl;
    98             delete m_impl;
   121     QT_TRACE_FUNCTION_ENTRY;
   123     QT_TRACE_FUNCTION_ENTRY;
   122 
   124 
   123     RETURN_s_IF_m_impl_IS_NULL(false);
   125     RETURN_s_IF_m_impl_IS_NULL(false);
   124 
   126 
   125     // Location can be set only when recorder is in stopped state.
   127     // Location can be set only when recorder is in stopped state.
   126     if (state() != QMediaRecorder::StoppedState )
   128     if (state() != QMediaRecorder::StoppedState) {
   127         return false;
   129         return false;
   128 
   130     }
       
   131     
   129     // Validate URL
   132     // Validate URL
   130     if (!location.isValid())
   133     if (!location.isValid())
   131         return false;
   134         return false;
   132 
   135 
   133     // If old and new locations are same, do nothing.
   136     // If old and new locations are same, do nothing.
   137         return true;
   140         return true;
   138 
   141 
   139     bool retVal = false;
   142     bool retVal = false;
   140     TPtrC16 tempPtr(reinterpret_cast<const TUint16 *>(newUrlStr.utf16()));
   143     TPtrC16 tempPtr(reinterpret_cast<const TUint16 *>(newUrlStr.utf16()));
   141     if (m_impl->setURI(tempPtr) == 0) {
   144     if (m_impl->setURI(tempPtr) == 0) {
       
   145         QT_TRACE2("Location:", newUrlStr);
   142         m_outputLocation = location;
   146         m_outputLocation = location;
       
   147         /* New file, so user can set new settings */
       
   148         m_previousState = QMediaRecorder::StoppedState;
   143         retVal = true;
   149         retVal = true;
   144     }
   150     }
   145     else {
   151     else {
   146         emit error(QMediaRecorder::ResourceError, tr("Generic error"));
   152         emit error(QMediaRecorder::ResourceError, tr("Generic error"));
   147         SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::ResourceError, tr(\"Generic error\"))");
   153         SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::ResourceError, tr(\"Generic error\"))");
   170     return (qint64)dur;
   176     return (qint64)dur;
   171 }
   177 }
   172 
   178 
   173 void QXARecordSession::applySettings()
   179 void QXARecordSession::applySettings()
   174 {
   180 {
   175     if (m_appliedaudioencodersettings != m_audioencodersettings)
   181     /* Settings can only be applied when the recorder is in the stopped
   176         setEncoderSettingsToImpl();
   182      * state after creation. */
       
   183     if ((state() == QMediaRecorder::StoppedState) && (m_state == m_previousState)) {
       
   184         if (m_appliedaudioencodersettings != m_audioencodersettings)
       
   185             setEncoderSettingsToImpl();
       
   186     }
       
   187     else {
       
   188         emit error(QMediaRecorder::FormatError, tr("Settings cannot be changed once recording started"));
       
   189         SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Settings cannot be changed once recording started\"))");
       
   190     }
   177 }
   191 }
   178 
   192 
   179 void QXARecordSession::record()
   193 void QXARecordSession::record()
   180 {
   194 {
   181     QT_TRACE_FUNCTION_ENTRY;
   195     QT_TRACE_FUNCTION_ENTRY;
   182 
   196 
   183     RETURN_IF_m_impl_IS_NULL;
   197     RETURN_IF_m_impl_IS_NULL;
       
   198 
       
   199     /* No op if object is already in recording state */
       
   200     if (state() == QMediaRecorder::RecordingState)
       
   201         return;
   184 
   202 
   185     /* 1. Set encoder settings here */
   203     /* 1. Set encoder settings here */
   186     if (m_appliedaudioencodersettings != m_audioencodersettings)
   204     if (m_appliedaudioencodersettings != m_audioencodersettings)
   187         RET_IF_FALSE(setEncoderSettingsToImpl());
   205         RET_IF_FALSE(setEncoderSettingsToImpl());
   188 
   206 
   202 {
   220 {
   203     QT_TRACE_FUNCTION_ENTRY;
   221     QT_TRACE_FUNCTION_ENTRY;
   204 
   222 
   205     RETURN_IF_m_impl_IS_NULL;
   223     RETURN_IF_m_impl_IS_NULL;
   206 
   224 
       
   225     /* No op if object is already in paused/stopped state */
       
   226     if ((state() == QMediaRecorder::PausedState) || (state() == QMediaRecorder::StoppedState)) {
       
   227         return;
       
   228     }
       
   229 
   207     if (m_impl->pause() == KErrNone) {
   230     if (m_impl->pause() == KErrNone) {
   208         setRecorderState(QMediaRecorder::PausedState);
   231         setRecorderState(QMediaRecorder::PausedState);
   209     }
   232     }
   210     else {
   233     else {
   211         emit error(QMediaRecorder::ResourceError, tr("Unable to pause"));
   234         emit error(QMediaRecorder::ResourceError, tr("Unable to pause"));
   219 {
   242 {
   220     QT_TRACE_FUNCTION_ENTRY;
   243     QT_TRACE_FUNCTION_ENTRY;
   221 
   244 
   222     RETURN_IF_m_impl_IS_NULL;
   245     RETURN_IF_m_impl_IS_NULL;
   223 
   246 
       
   247     /* No op if object is already in paused state */
       
   248     if (state() == QMediaRecorder::StoppedState)
       
   249         return;
       
   250 
   224     if ((m_impl->stop() == KErrNone)) {
   251     if ((m_impl->stop() == KErrNone)) {
   225         setRecorderState(QMediaRecorder::StoppedState);
   252         setRecorderState(QMediaRecorder::StoppedState);
   226     }
   253     }
   227     else {
   254     else {
   228         emit error(QMediaRecorder::ResourceError, tr("Unable to stop"));
   255         emit error(QMediaRecorder::ResourceError, tr("Unable to stop"));
   232     QT_TRACE_FUNCTION_EXIT;
   259     QT_TRACE_FUNCTION_EXIT;
   233 }
   260 }
   234 
   261 
   235 void QXARecordSession::cbDurationChanged(TInt64 new_pos)
   262 void QXARecordSession::cbDurationChanged(TInt64 new_pos)
   236 {
   263 {
       
   264     QT_TRACE_FUNCTION_ENTRY;
       
   265 
   237     emit durationChanged((qint64)new_pos);
   266     emit durationChanged((qint64)new_pos);
   238     SIGNAL_EMIT_TRACE1("emit durationChanged((qint64)new_pos);");
   267     SIGNAL_EMIT_TRACE1("emit durationChanged((qint64)new_pos);");
       
   268 
       
   269     QT_TRACE_FUNCTION_EXIT;
   239 }
   270 }
   240 
   271 
   241 void QXARecordSession::cbAvailableAudioInputsChanged()
   272 void QXARecordSession::cbAvailableAudioInputsChanged()
   242 {
   273 {
       
   274     QT_TRACE_FUNCTION_ENTRY;
       
   275 
   243     emit availableAudioInputsChanged();
   276     emit availableAudioInputsChanged();
   244     SIGNAL_EMIT_TRACE1("emit availableAudioInputsChanged();");
   277     SIGNAL_EMIT_TRACE1("emit availableAudioInputsChanged();");
       
   278 
       
   279     QT_TRACE_FUNCTION_EXIT;
   245 }
   280 }
   246 
   281 
   247 void QXARecordSession::cbRecordingStarted()
   282 void QXARecordSession::cbRecordingStarted()
   248 {
   283 {
       
   284     QT_TRACE_FUNCTION_ENTRY;
       
   285 
   249     setRecorderState(QMediaRecorder::RecordingState);
   286     setRecorderState(QMediaRecorder::RecordingState);
       
   287 
       
   288     QT_TRACE_FUNCTION_EXIT;
   250 }
   289 }
   251 
   290 
   252 void QXARecordSession::cbRecordingStopped()
   291 void QXARecordSession::cbRecordingStopped()
   253 {
   292 {
       
   293     QT_TRACE_FUNCTION_ENTRY;
       
   294 
   254     emit error(QMediaRecorder::ResourceError, tr("Resources Unavailable"));
   295     emit error(QMediaRecorder::ResourceError, tr("Resources Unavailable"));
   255     SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::ResourceError, tr(\"Resources Unavailable\"))");
   296     SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::ResourceError, tr(\"Resources Unavailable\"))");
   256     setRecorderState(QMediaRecorder::StoppedState);
   297     setRecorderState(QMediaRecorder::StoppedState);
       
   298     /* Set record state to Stopped */
       
   299     if (m_impl)
       
   300         m_impl->stop();
       
   301 
       
   302     QT_TRACE_FUNCTION_EXIT;
   257 }
   303 }
   258 
   304 
   259 /* For QAudioEndpointSelector begin */
   305 /* For QAudioEndpointSelector begin */
   260 QList<QString> QXARecordSession::availableEndpoints()
   306 QList<QString> QXARecordSession::availableEndpoints()
   261 {
   307 {
   366         TPtrC16 tempPtr(reinterpret_cast<const TUint16*>(selectedCodec.utf16()));
   412         TPtrC16 tempPtr(reinterpret_cast<const TUint16*>(selectedCodec.utf16()));
   367         if (m_impl->getSampleRates(tempPtr, sampleRates, isContinuous) == KErrNone) {
   413         if (m_impl->getSampleRates(tempPtr, sampleRates, isContinuous) == KErrNone) {
   368             for (TInt index = 0; index < sampleRates.Count(); index++)
   414             for (TInt index = 0; index < sampleRates.Count(); index++)
   369                 srList.append(sampleRates[index]);
   415                 srList.append(sampleRates[index]);
   370             sampleRates.Close();
   416             sampleRates.Close();
   371             *continuous = false;
   417             if (continuous)
   372             if (isContinuous == true)
   418                 {
   373                 *continuous = true;
   419                 *continuous = false;
       
   420                 if (isContinuous == true)
       
   421                     *continuous = true;
       
   422                 }
   374         }
   423         }
   375     }
   424     }
   376 
   425 
   377     QT_TRACE_FUNCTION_EXIT;
   426     QT_TRACE_FUNCTION_EXIT;
   378     return srList;
   427     return srList;
   383     return m_audioencodersettings;
   432     return m_audioencodersettings;
   384 }
   433 }
   385 
   434 
   386 void QXARecordSession::setAudioSettings(const QAudioEncoderSettings &settings)
   435 void QXARecordSession::setAudioSettings(const QAudioEncoderSettings &settings)
   387 {
   436 {
   388     m_audioencodersettings = settings;
   437     /* Settings can only be set when the recorder is in the stopped
       
   438      * state after creation. */
       
   439     if ((state() == QMediaRecorder::StoppedState) && (m_state == m_previousState)) {
       
   440         m_audioencodersettings = settings;
       
   441     }
       
   442     else {
       
   443         emit error(QMediaRecorder::FormatError, tr("Settings cannot be changed once recording started"));
       
   444         SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Settings cannot be changed once recording started\"))");
       
   445     }
   389 }
   446 }
   390 
   447 
   391 QStringList QXARecordSession::supportedEncodingOptions(const QString &codec)
   448 QStringList QXARecordSession::supportedEncodingOptions(const QString &codec)
   392 {
   449 {
   393     QT_TRACE_FUNCTION_ENTRY;
   450     QT_TRACE_FUNCTION_ENTRY;
   394     Q_UNUSED(codec);
   451     Q_UNUSED(codec);
   395     QStringList options;
   452     QStringList options;
   396     options << "bitrate";
   453     if ((codec.compare("aac") == 0) ||
       
   454             (codec.compare("amr") == 0))
       
   455         {
       
   456         options << "bitrate";
       
   457         }
   397 
   458 
   398     QT_TRACE_FUNCTION_EXIT;
   459     QT_TRACE_FUNCTION_EXIT;
   399     return options;
   460     return options;
   400 }
   461 }
   401 
   462 
   472 }
   533 }
   473 
   534 
   474 void QXARecordSession::setRecorderState(QMediaRecorder::State state)
   535 void QXARecordSession::setRecorderState(QMediaRecorder::State state)
   475 {
   536 {
   476     if (state != m_state) {
   537     if (state != m_state) {
       
   538         m_previousState = m_state;
   477         m_state = state;
   539         m_state = state;
   478         emit stateChanged(m_state);
   540         emit stateChanged(m_state);
   479         SIGNAL_EMIT_TRACE1("emit stateChanged(m_state);");
   541         SIGNAL_EMIT_TRACE1("emit stateChanged(m_state);");
   480     }
   542     }
   481 }
   543 }
   531     QString tempStr = m_containerMimeType.toLower();
   593     QString tempStr = m_containerMimeType.toLower();
   532     TPtrC16 tempPtr(reinterpret_cast<const TUint16 *>(tempStr.utf16()));
   594     TPtrC16 tempPtr(reinterpret_cast<const TUint16 *>(tempStr.utf16()));
   533     m_impl->setContainerType(tempPtr);
   595     m_impl->setContainerType(tempPtr);
   534 
   596 
   535     /* Validate and set bitrate only if encoding mode is other than quality encoding */
   597     /* Validate and set bitrate only if encoding mode is other than quality encoding */
   536     if (m_audioencodersettings.encodingMode() != QtMediaServices::ConstantQualityEncoding) {
   598     if (m_audioencodersettings.encodingMode() != QtMultimedia::ConstantQualityEncoding) {
   537         if (m_audioencodersettings.bitRate() < 0 ) {
   599         if (m_audioencodersettings.bitRate() == -1) {
       
   600             m_impl->setOptimalBitRate();
       
   601         }
       
   602         else if (m_audioencodersettings.bitRate() < 0 ) {
   538             emit error(QMediaRecorder::FormatError, tr("Invalid bitrate"));
   603             emit error(QMediaRecorder::FormatError, tr("Invalid bitrate"));
   539             SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid bitrate\"))");
   604             SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid bitrate\"))");
   540             return false;
   605             return false;
   541         }
   606         }
   542         else {
   607         else {
   561         tempPtr.Set(reinterpret_cast<const TUint16*>(tempStr.utf16()));
   626         tempPtr.Set(reinterpret_cast<const TUint16*>(tempStr.utf16()));
   562         /* We already did validation above, so function always returns true */
   627         /* We already did validation above, so function always returns true */
   563         m_impl->setCodec(tempPtr);
   628         m_impl->setCodec(tempPtr);
   564     }
   629     }
   565     else {
   630     else {
       
   631         QT_TRACE2("Codec selected is :", m_audioencodersettings.codec().toLower());
   566         emit error(QMediaRecorder::FormatError, tr("Invalid codec"));
   632         emit error(QMediaRecorder::FormatError, tr("Invalid codec"));
   567         SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid codec\"));");
   633         SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid codec\"));");
   568         return false;
   634         return false;
   569     }
   635     }
   570 
   636 
   571     switch (m_audioencodersettings.encodingMode()) {
   637     switch (m_audioencodersettings.encodingMode()) {
   572     case QtMediaServices::ConstantQualityEncoding: {
   638     case QtMultimedia::ConstantQualityEncoding: {
   573             switch (m_audioencodersettings.quality()) {
   639             switch (m_audioencodersettings.quality()) {
   574             case QtMediaServices::VeryLowQuality:
   640             case QtMultimedia::VeryLowQuality:
   575                 m_impl->setVeryLowQuality();
   641                 m_impl->setVeryLowQuality();
   576                 break;
   642                 break;
   577             case QtMediaServices::LowQuality:
   643             case QtMultimedia::LowQuality:
   578                 m_impl->setLowQuality();
   644                 m_impl->setLowQuality();
   579                 break;
   645                 break;
   580             case QtMediaServices::NormalQuality:
   646             case QtMultimedia::NormalQuality:
   581                 m_impl->setNormalQuality();
   647                 m_impl->setNormalQuality();
   582                 break;
   648                 break;
   583             case QtMediaServices::HighQuality:
   649             case QtMultimedia::HighQuality:
   584                 m_impl->setHighQuality();
   650                 m_impl->setHighQuality();
   585                 break;
   651                 break;
   586             case QtMediaServices::VeryHighQuality:
   652             case QtMultimedia::VeryHighQuality:
   587                 m_impl->setVeryHighQuality();
   653                 m_impl->setVeryHighQuality();
   588                 break;
   654                 break;
   589             default:
   655             default:
   590                 emit error(QMediaRecorder::FormatError, tr("Invalid encoding quality setting"));
   656                 emit error(QMediaRecorder::FormatError, tr("Invalid encoding quality setting"));
   591                 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid encoding quality setting\"));");
   657                 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid encoding quality setting\"));");
   592                 return false;
   658                 return false;
   593             }; /* end of switch (m_audioencodersettings.quality())*/
   659             }; /* end of switch (m_audioencodersettings.quality())*/
   594         }
   660         }
   595         break;
   661         break;
   596     case QtMediaServices::ConstantBitRateEncoding: {
   662     case QtMultimedia::ConstantBitRateEncoding: {
   597             TInt32 status = m_impl->setCBRMode();
   663             TInt32 status = m_impl->setCBRMode();
   598             if (status == KErrNotSupported) {
   664             if (status == KErrNotSupported) {
   599                 emit error(QMediaRecorder::FormatError, tr("Invalid encoding mode setting"));
   665                 emit error(QMediaRecorder::FormatError, tr("Invalid encoding mode setting"));
   600                 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid encoding mode setting\"));");
   666                 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid encoding mode setting\"));");
   601                 return false;
   667                 return false;
   605                 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::ResourceError, tr(\"Internal error\"));");
   671                 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::ResourceError, tr(\"Internal error\"));");
   606                 return false;
   672                 return false;
   607             }
   673             }
   608         }
   674         }
   609         break;
   675         break;
   610     case QtMediaServices::AverageBitRateEncoding: {
   676     case QtMultimedia::AverageBitRateEncoding: {
   611             TInt32 status = m_impl->setVBRMode();
   677             TInt32 status = m_impl->setVBRMode();
   612             if (status == KErrNotSupported) {
   678             if (status == KErrNotSupported) {
   613                 emit error(QMediaRecorder::FormatError, tr("Invalid encoding mode setting"));
   679                 emit error(QMediaRecorder::FormatError, tr("Invalid encoding mode setting"));
   614                 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid encoding mode setting\"));");
   680                 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid encoding mode setting\"));");
   615                 return false;
   681                 return false;
   619                 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::ResourceError, tr(\"Internal error\"));");
   685                 SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::ResourceError, tr(\"Internal error\"));");
   620                 return false;
   686                 return false;
   621             }
   687             }
   622         }
   688         }
   623         break;
   689         break;
   624     case QtMediaServices::TwoPassEncoding:
   690     case QtMultimedia::TwoPassEncoding:
   625         // fall through
   691         // fall through
   626     default: {
   692     default: {
   627             emit error(QMediaRecorder::FormatError, tr("Invalid encoding mode setting"));
   693             emit error(QMediaRecorder::FormatError, tr("Invalid encoding mode setting"));
   628             SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid encoding mode setting\"));");
   694             SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid encoding mode setting\"));");
   629             return false;
   695             return false;
   630         }
   696         }
   631     }; /* switch (m_audioencodersettings.encodingMode()) */
   697     }; /* switch (m_audioencodersettings.encodingMode()) */
   632 
   698 
   633     if (m_audioencodersettings.sampleRate() == -1) {
   699     /* Validate and set bitrate only if encoding mode is other than quality encoding */
   634         m_impl->setOptimalSampleRate();
   700     if (m_audioencodersettings.encodingMode() != QtMultimedia::ConstantQualityEncoding) {
   635     }
   701         if (m_audioencodersettings.sampleRate() == -1) {
   636     else if (m_audioencodersettings.sampleRate() <= 0) {
   702             m_impl->setOptimalSampleRate();
   637         emit error(QMediaRecorder::FormatError, tr("Invalid sample rate"));
   703         }
   638         SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid sample rate\"));");
   704         else if (m_audioencodersettings.sampleRate() <= 0) {
   639         return false;
   705             emit error(QMediaRecorder::FormatError, tr("Invalid sample rate"));
   640     }
   706             SIGNAL_EMIT_TRACE1("emit error(QMediaRecorder::FormatError, tr(\"Invalid sample rate\"));");
   641     else {
   707             return false;
   642         m_impl->setSampleRate(m_audioencodersettings.sampleRate());
   708         }
       
   709         else {
       
   710             m_impl->setSampleRate(m_audioencodersettings.sampleRate());
       
   711         }
   643     }
   712     }
   644     m_appliedaudioencodersettings = m_audioencodersettings;
   713     m_appliedaudioencodersettings = m_audioencodersettings;
   645     QT_TRACE_FUNCTION_EXIT;
   714     QT_TRACE_FUNCTION_EXIT;
   646     return true;
   715     return true;
   647 }
   716 }