qtmobility/plugins/multimedia/symbian/openmaxal/mediarecorder/xarecordsessionimpl.cpp
changeset 14 6fbed849b4f4
parent 11 06b8e2af4411
child 15 1f895d8a5b2b
equal deleted inserted replaced
11:06b8e2af4411 14:6fbed849b4f4
    49  * */
    49  * */
    50 _LIT(KAUDIOCODECPCM, "pcm");
    50 _LIT(KAUDIOCODECPCM, "pcm");
    51 _LIT(KAUDIOCODECAMR, "amr");
    51 _LIT(KAUDIOCODECAMR, "amr");
    52 _LIT(KAUDIOCODECAAC, "aac");
    52 _LIT(KAUDIOCODECAAC, "aac");
    53 
    53 
    54 _LIT(KCONTAINERWAV, "wav");
    54 _LIT(KCONTAINERWAV, "audio/wav");
    55 _LIT(KCONTAINERWAVDESC, "wav container");
    55 _LIT(KCONTAINERWAVDESC, "wav container");
    56 _LIT(KCONTAINERAMR, "amr-nb");
    56 _LIT(KCONTAINERAMR, "audio/amr");
    57 _LIT(KCONTAINERAMRDESC, "amr-nb File format");
    57 _LIT(KCONTAINERAMRDESC, "amr File format");
    58 _LIT(KCONTAINERMP4, "mp4");
    58 _LIT(KCONTAINERMP4, "audio/mpeg");
    59 _LIT(KCONTAINERMP4DESC, "mp4 container");
    59 _LIT(KCONTAINERMP4DESC, "mpeg container");
    60 
    60 
    61 const TUint KRecordPosUpdatePeriod = 1000;
    61 const TUint KRecordPosUpdatePeriod = 1000;
    62 const TUint KMilliToHz = 1000;
    62 const TUint KMilliToHz = 1000;
    63 const TUint KMaxNameLength = 256;
    63 const TUint KMaxNameLength = 256;
    64 
    64 
   208     /* This function will only get called when aURI is different than m_URIName
   208     /* This function will only get called when aURI is different than m_URIName
   209      * and only when recorder is in stopped state.
   209      * and only when recorder is in stopped state.
   210      * If the recorder object was created for a different URI (than aURI), we
   210      * If the recorder object was created for a different URI (than aURI), we
   211      * need to tear it down here.
   211      * need to tear it down here.
   212      */
   212      */
   213     if (!m_URIName && m_MORecorder) {
   213     if (m_MORecorder) {
   214         (*m_MORecorder)->Destroy(m_MORecorder);
   214         (*m_MORecorder)->Destroy(m_MORecorder);
   215         m_MORecorder = NULL;
   215         m_MORecorder = NULL;
   216         m_RecordItf = NULL;
   216         m_RecordItf = NULL;
   217     }
   217     }
   218 
   218 
   236     TInt32 returnValue(KErrGeneral);
   236     TInt32 returnValue(KErrGeneral);
   237     if (!m_MORecorder || !m_RecordItf) {
   237     if (!m_MORecorder || !m_RecordItf) {
   238         TRACE_LOG(_L("XARecordSessionImpl::Record: MORecorder/RecordItf is not created"));
   238         TRACE_LOG(_L("XARecordSessionImpl::Record: MORecorder/RecordItf is not created"));
   239         returnValue = createMediaRecorderObject();
   239         returnValue = createMediaRecorderObject();
   240         RET_ERR_IF_ERR(returnValue);
   240         RET_ERR_IF_ERR(returnValue);
   241     }
   241 
   242 
   242         returnValue = setEncoderSettingsToMediaRecorder();
   243     returnValue = setEncoderSettingsToMediaRecorder();
   243         RET_ERR_IF_ERR(returnValue);
   244     RET_ERR_IF_ERR(returnValue);
   244     }
   245 
   245 
   246     XAuint32 state;
   246     XAuint32 state;
   247     XAresult xa_result = (*m_RecordItf)->GetRecordState(m_RecordItf, &state);
   247     XAresult xa_result = (*m_RecordItf)->GetRecordState(m_RecordItf, &state);
   248     returnValue = mapError(xa_result, ETrue);
   248     returnValue = mapError(xa_result, ETrue);
   249     RET_ERR_IF_ERR(returnValue);
   249     RET_ERR_IF_ERR(returnValue);
   423 TInt32 XARecordSessionImpl::defaultAudioInputDevice(TPtrC &endPoint)
   423 TInt32 XARecordSessionImpl::defaultAudioInputDevice(TPtrC &endPoint)
   424 {
   424 {
   425     TRACE_FUNCTION_ENTRY;
   425     TRACE_FUNCTION_ENTRY;
   426 
   426 
   427     TInt32 err(KErrGeneral);
   427     TInt32 err(KErrGeneral);
   428     if (m_DefaultAudioInputDeviceNames->MdcaCount() >= 0)
   428     if (m_DefaultAudioInputDeviceNames->MdcaCount() >= 0) {
   429         endPoint.Set(m_DefaultAudioInputDeviceNames->MdcaPoint(0));
   429         endPoint.Set(m_DefaultAudioInputDeviceNames->MdcaPoint(0));
       
   430         err = KErrNone;
       
   431     }
   430 
   432 
   431     TRACE_FUNCTION_EXIT;
   433     TRACE_FUNCTION_EXIT;
   432     return err;
   434     return err;
   433 }
   435 }
   434 
   436 
   576 
   578 
   577     TInt32 returnValue(KErrGeneral);
   579     TInt32 returnValue(KErrGeneral);
   578     if (found == false)
   580     if (found == false)
   579         return returnValue;
   581         return returnValue;
   580 
   582 
   581     XAuint32 numCaps = 0;
   583     returnValue = getSampleRatesByAudioCodecID(encoderId, aSampleRates);
   582     XAAudioCodecDescriptor codecDesc;
       
   583     XAresult xa_result = (*m_AudioEncCapsItf)->GetAudioEncoderCapabilities(
       
   584                                         m_AudioEncCapsItf,
       
   585                                         encoderId,
       
   586                                         &numCaps,
       
   587                                         &codecDesc);
       
   588     returnValue = mapError(xa_result, ETrue);
       
   589     RET_ERR_IF_ERR(returnValue);
       
   590 
       
   591     /* TODO What do we do if we have more than one caps?? */
       
   592     aIsContinuous = codecDesc.isFreqRangeContinuous;
       
   593     if (aIsContinuous) {
       
   594         aSampleRates.Append(codecDesc.minSampleRate / KMilliToHz);
       
   595         aSampleRates.Append(codecDesc.maxSampleRate / KMilliToHz);
       
   596     }
       
   597     else {
       
   598         XAuint32 numSRSupported = codecDesc.numSampleRatesSupported;
       
   599         XAmilliHertz *pSampleRatesSupported(NULL);
       
   600         pSampleRatesSupported = codecDesc.pSampleRatesSupported;
       
   601         for (TInt index = 0; index < numSRSupported; index++)
       
   602             aSampleRates.Append((*(pSampleRatesSupported + index)) / KMilliToHz);
       
   603     }
       
   604 
   584 
   605     TRACE_FUNCTION_EXIT;
   585     TRACE_FUNCTION_EXIT;
   606     return returnValue;
   586     return returnValue;
   607 }
   587 }
   608 
   588 
   702 }
   682 }
   703 
   683 
   704 void XARecordSessionImpl::setBitRate(TUint32 aBitRate) {
   684 void XARecordSessionImpl::setBitRate(TUint32 aBitRate) {
   705     TRACE_FUNCTION_ENTRY;
   685     TRACE_FUNCTION_ENTRY;
   706     m_BitRate = aBitRate;
   686     m_BitRate = aBitRate;
       
   687     TRACE_LOG((_L("BitRate[%d]"), m_BitRate));
       
   688     TRACE_FUNCTION_EXIT;
       
   689 }
       
   690 
       
   691 void XARecordSessionImpl::setOptimalBitRate() {
       
   692     TRACE_FUNCTION_ENTRY;
       
   693     m_BitRate = 0xffffffff;
   707     TRACE_FUNCTION_EXIT;
   694     TRACE_FUNCTION_EXIT;
   708 }
   695 }
   709 
   696 
   710 void XARecordSessionImpl::setChannels(TUint32 aChannels) {
   697 void XARecordSessionImpl::setChannels(TUint32 aChannels) {
   711     TRACE_FUNCTION_ENTRY;
   698     TRACE_FUNCTION_ENTRY;
   712     m_ChannelsOut = aChannels;
   699     m_ChannelsOut = aChannels;
       
   700     TRACE_LOG((_L("ChannelCount[%d]"), m_ChannelsOut));
   713     TRACE_FUNCTION_EXIT;
   701     TRACE_FUNCTION_EXIT;
   714 }
   702 }
   715 
   703 
   716 void XARecordSessionImpl::setOptimalChannelCount() {
   704 void XARecordSessionImpl::setOptimalChannelCount() {
   717     TRACE_FUNCTION_ENTRY;
   705     TRACE_FUNCTION_ENTRY;
   721 
   709 
   722 void XARecordSessionImpl::setSampleRate(TUint32 aSampleRate) {
   710 void XARecordSessionImpl::setSampleRate(TUint32 aSampleRate) {
   723     TRACE_FUNCTION_ENTRY;
   711     TRACE_FUNCTION_ENTRY;
   724     /* convert Hz to MilliHz */
   712     /* convert Hz to MilliHz */
   725     m_SampleRate = aSampleRate * KMilliToHz;
   713     m_SampleRate = aSampleRate * KMilliToHz;
       
   714     TRACE_LOG((_L("SampleRate[%d]"), aSampleRate));
   726     TRACE_FUNCTION_EXIT;
   715     TRACE_FUNCTION_EXIT;
   727 }
   716 }
   728 
   717 
   729 void XARecordSessionImpl::setOptimalSampleRate() {
   718 void XARecordSessionImpl::setOptimalSampleRate() {
   730     TRACE_FUNCTION_ENTRY;
   719     TRACE_FUNCTION_ENTRY;
   731     m_SampleRate = 0xffffffff;
   720     m_SampleRate = 0;
       
   721 
       
   722     if (m_AudioEncoderId == XA_AUDIOCODEC_AMR) {
       
   723         m_SampleRate = 8000 * KMilliToHz;
       
   724     } else {
       
   725         RArray<TInt32> sampleRates;
       
   726         TInt res = getSampleRatesByAudioCodecID(m_AudioEncoderId, sampleRates);
       
   727         if ((res == KErrNone) && (sampleRates.Count() > 0)) {
       
   728             /* Sort the array and pick the middle range sample rate */
       
   729             sampleRates.SortUnsigned();
       
   730             m_SampleRate = sampleRates[sampleRates.Count()/2]  * KMilliToHz;
       
   731         }
       
   732         sampleRates.Close();
       
   733     }
       
   734 
   732     TRACE_FUNCTION_EXIT;
   735     TRACE_FUNCTION_EXIT;
   733 }
   736 }
   734 
   737 
   735 TInt32 XARecordSessionImpl::setCBRMode()
   738 TInt32 XARecordSessionImpl::setCBRMode()
   736 {
   739 {
   760     if ((res == KErrNone) && (bitrates.Count() > 0) ) {
   763     if ((res == KErrNone) && (bitrates.Count() > 0) ) {
   761         /* Sort the array and pick the lowest bit rate */
   764         /* Sort the array and pick the lowest bit rate */
   762         bitrates.SortUnsigned();
   765         bitrates.SortUnsigned();
   763         m_BitRate = bitrates[0];
   766         m_BitRate = bitrates[0];
   764     }
   767     }
       
   768     bitrates.Close();
       
   769 
       
   770     if (m_AudioEncoderId == XA_AUDIOCODEC_AMR) {
       
   771         m_SampleRate = 8000 * KMilliToHz;
       
   772     } else {
       
   773         RArray<TInt32> samplerates;
       
   774         TInt res = getSampleRatesByAudioCodecID(m_AudioEncoderId, samplerates);
       
   775         if ((res == KErrNone) && (samplerates.Count() > 0) ) {
       
   776             /* Sort the array and pick the lowest bit rate */
       
   777             samplerates.SortUnsigned();
       
   778             m_SampleRate = samplerates[0] * KMilliToHz;
       
   779         }
       
   780         samplerates.Close();    
       
   781     }    
   765 }
   782 }
   766 
   783 
   767 void XARecordSessionImpl::setLowQuality()
   784 void XARecordSessionImpl::setLowQuality()
   768 {
   785 {
   769     /* Set to low quality encoder preset */
   786     /* Set to low quality encoder preset */
   772     if ((res == KErrNone) && (bitrates.Count() > 0)) {
   789     if ((res == KErrNone) && (bitrates.Count() > 0)) {
   773         /* Sort the array and pick the low quality bit rate */
   790         /* Sort the array and pick the low quality bit rate */
   774         bitrates.SortUnsigned();
   791         bitrates.SortUnsigned();
   775         m_BitRate = bitrates[bitrates.Count()*1/4];
   792         m_BitRate = bitrates[bitrates.Count()*1/4];
   776     }
   793     }
       
   794     bitrates.Close();
       
   795 
       
   796     if (m_AudioEncoderId == XA_AUDIOCODEC_AMR) {
       
   797         m_SampleRate = 8000 * KMilliToHz;
       
   798     } else {
       
   799         RArray<TInt32> samplerates;
       
   800         TInt res = getSampleRatesByAudioCodecID(m_AudioEncoderId, samplerates);
       
   801         if ((res == KErrNone) && (samplerates.Count() > 0) ) {
       
   802             /* Sort the array and pick the lowest bit rate */
       
   803             samplerates.SortUnsigned();
       
   804             m_SampleRate = samplerates[samplerates.Count()*1/4] * KMilliToHz;
       
   805         }
       
   806         samplerates.Close();    
       
   807     }    
   777 }
   808 }
   778 
   809 
   779 void XARecordSessionImpl::setNormalQuality()
   810 void XARecordSessionImpl::setNormalQuality()
   780 {
   811 {
   781     /* Set to normal quality encoder preset */
   812     /* Set to normal quality encoder preset */
   784     if ((res == KErrNone) && (bitrates.Count() > 0)) {
   815     if ((res == KErrNone) && (bitrates.Count() > 0)) {
   785         /* Sort the array and pick the middle range bit rate */
   816         /* Sort the array and pick the middle range bit rate */
   786         bitrates.SortUnsigned();
   817         bitrates.SortUnsigned();
   787         m_BitRate = bitrates[bitrates.Count()/2];
   818         m_BitRate = bitrates[bitrates.Count()/2];
   788     }
   819     }
       
   820     bitrates.Close();
       
   821 
       
   822     if (m_AudioEncoderId == XA_AUDIOCODEC_AMR) {
       
   823         m_SampleRate = 8000 * KMilliToHz;
       
   824     } else {
       
   825         RArray<TInt32> samplerates;
       
   826         TInt res = getSampleRatesByAudioCodecID(m_AudioEncoderId, samplerates);
       
   827         if ((res == KErrNone) && (samplerates.Count() > 0) ) {
       
   828             /* Sort the array and pick the lowest bit rate */
       
   829             samplerates.SortUnsigned();
       
   830             m_SampleRate = samplerates[samplerates.Count()*1/2] * KMilliToHz;
       
   831         }
       
   832         samplerates.Close();    
       
   833     }    
   789 }
   834 }
   790 
   835 
   791 void XARecordSessionImpl::setHighQuality()
   836 void XARecordSessionImpl::setHighQuality()
   792 {
   837 {
   793     /* Set to high quality encoder preset */
   838     /* Set to high quality encoder preset */
   796     if ((res == KErrNone) && (bitrates.Count() > 0)) {
   841     if ((res == KErrNone) && (bitrates.Count() > 0)) {
   797         /* Sort the array and pick the high quality bit rate */
   842         /* Sort the array and pick the high quality bit rate */
   798         bitrates.SortUnsigned();
   843         bitrates.SortUnsigned();
   799         m_BitRate = bitrates[bitrates.Count()*3/4];
   844         m_BitRate = bitrates[bitrates.Count()*3/4];
   800     }
   845     }
       
   846     bitrates.Close();
       
   847 
       
   848     if (m_AudioEncoderId == XA_AUDIOCODEC_AMR) {
       
   849         m_SampleRate = 8000 * KMilliToHz;
       
   850     } else {
       
   851         RArray<TInt32> samplerates;
       
   852         TInt res = getSampleRatesByAudioCodecID(m_AudioEncoderId, samplerates);
       
   853         if ((res == KErrNone) && (samplerates.Count() > 0) ) {
       
   854             /* Sort the array and pick the lowest bit rate */
       
   855             samplerates.SortUnsigned();
       
   856             m_SampleRate = samplerates[samplerates.Count()*3/4] * KMilliToHz;
       
   857         }
       
   858         samplerates.Close();    
       
   859     }    
   801 }
   860 }
   802 
   861 
   803 void XARecordSessionImpl::setVeryHighQuality()
   862 void XARecordSessionImpl::setVeryHighQuality()
   804 {
   863 {
   805     /* Set to very high quality encoder preset */
   864     /* Set to very high quality encoder preset */
   808     if ((res == KErrNone) && (bitrates.Count() > 0)) {
   867     if ((res == KErrNone) && (bitrates.Count() > 0)) {
   809         /* Sort the array and pick the highest bit rate */
   868         /* Sort the array and pick the highest bit rate */
   810         bitrates.SortUnsigned();
   869         bitrates.SortUnsigned();
   811         m_BitRate = bitrates[bitrates.Count()-1];
   870         m_BitRate = bitrates[bitrates.Count()-1];
   812     }
   871     }
       
   872     bitrates.Close();
       
   873 
       
   874     if (m_AudioEncoderId == XA_AUDIOCODEC_AMR) {
       
   875         m_SampleRate = 8000 * KMilliToHz;
       
   876     } else {
       
   877         RArray<TInt32> samplerates;
       
   878         TInt res = getSampleRatesByAudioCodecID(m_AudioEncoderId, samplerates);
       
   879         if ((res == KErrNone) && (samplerates.Count() > 0) ) {
       
   880             /* Sort the array and pick the lowest bit rate */
       
   881             samplerates.SortUnsigned();
       
   882             m_SampleRate = samplerates[samplerates.Count()-1] * KMilliToHz;
       
   883         }
       
   884         samplerates.Close();    
       
   885     }    
   813 }
   886 }
   814 
   887 
   815 /* Internal function */
   888 /* Internal function */
   816 TInt32 XARecordSessionImpl::createMediaRecorderObject()
   889 TInt32 XARecordSessionImpl::createMediaRecorderObject()
   817 {
   890 {
   837         m_Uri.locatorType    = XA_DATALOCATOR_URI;
   910         m_Uri.locatorType    = XA_DATALOCATOR_URI;
   838         /* append zero terminator to end of URI */
   911         /* append zero terminator to end of URI */
   839         TPtr8 uriPtr = m_URIName->Des();
   912         TPtr8 uriPtr = m_URIName->Des();
   840         m_Uri.URI = (XAchar*) uriPtr.PtrZ();
   913         m_Uri.URI = (XAchar*) uriPtr.PtrZ();
   841         m_Mime.formatType    = XA_DATAFORMAT_MIME;
   914         m_Mime.formatType    = XA_DATAFORMAT_MIME;
   842         m_Mime.containerType = XA_CONTAINERTYPE_WAV;
   915         m_Mime.containerType = m_ContainerType;
   843         TPtr8 mimeTypePtr(m_WAVMime->Des());
   916         TPtr8 mimeTypePtr(m_WAVMime->Des());
   844         m_Mime.mimeType = (XAchar*)mimeTypePtr.Ptr();
   917         m_Mime.mimeType = (XAchar*)mimeTypePtr.Ptr();
   845         m_DataSink.pLocator = (void*) &m_Uri;
   918         m_DataSink.pLocator = (void*) &m_Uri;
   846         m_DataSink.pFormat  = (void*) &m_Mime;
   919         m_DataSink.pFormat  = (void*) &m_Mime;
   847 
   920 
  1079     TInt32 returnValue = mapError(xa_result, ETrue);
  1152     TInt32 returnValue = mapError(xa_result, ETrue);
  1080     RET_ERR_IF_ERR(returnValue);
  1153     RET_ERR_IF_ERR(returnValue);
  1081 
  1154 
  1082     XAAudioInputDescriptor audioInputDescriptor;
  1155     XAAudioInputDescriptor audioInputDescriptor;
  1083     for (TInt index = 0; index < numInputs; index++) {
  1156     for (TInt index = 0; index < numInputs; index++) {
  1084         m_InputDeviceIDs.Append(deviceIds[index]);
       
  1085         xa_result = (*m_AudioIODevCapsItf)->QueryAudioInputCapabilities(
  1157         xa_result = (*m_AudioIODevCapsItf)->QueryAudioInputCapabilities(
  1086                 m_AudioIODevCapsItf,
  1158                 m_AudioIODevCapsItf,
  1087                 deviceIds[index],
  1159                 deviceIds[index],
  1088                 &audioInputDescriptor);
  1160                 &audioInputDescriptor);
  1089         returnValue = mapError(xa_result, ETrue);
  1161         returnValue = mapError(xa_result, ETrue);
  1099         TBuf16<KMaxNameLength> name;
  1171         TBuf16<KMaxNameLength> name;
  1100         name.Copy(ptr);
  1172         name.Copy(ptr);
  1101         /* Using TRAP with returnValue results in compiler error */
  1173         /* Using TRAP with returnValue results in compiler error */
  1102         TRAPD(err2, m_AudioInputDeviceNames->AppendL(name));
  1174         TRAPD(err2, m_AudioInputDeviceNames->AppendL(name));
  1103         returnValue = err2;
  1175         returnValue = err2;
  1104         RET_ERR_IF_ERR(returnValue);
  1176         if (returnValue != KErrNone)
       
  1177             continue;
       
  1178         m_InputDeviceIDs.Append(deviceIds[index]);
  1105     }
  1179     }
  1106 
  1180 
  1107     numInputs = MAX_NUMBER_INPUT_DEVICES;
  1181     numInputs = MAX_NUMBER_INPUT_DEVICES;
  1108     for(TInt index = 0; index < MAX_NUMBER_INPUT_DEVICES; index++)
  1182     for(TInt index = 0; index < MAX_NUMBER_INPUT_DEVICES; index++)
  1109         deviceIds[index] = 0;
  1183         deviceIds[index] = 0;
  1114                                         deviceIds);
  1188                                         deviceIds);
  1115     returnValue = mapError(xa_result, ETrue);
  1189     returnValue = mapError(xa_result, ETrue);
  1116     RET_ERR_IF_ERR(returnValue);
  1190     RET_ERR_IF_ERR(returnValue);
  1117 
  1191 
  1118     for (TInt index = 0; index < numInputs; index++) {
  1192     for (TInt index = 0; index < numInputs; index++) {
  1119         m_DefaultInputDeviceIDs.Append(deviceIds[index]);
       
  1120         xa_result = (*m_AudioIODevCapsItf)->QueryAudioInputCapabilities(
  1193         xa_result = (*m_AudioIODevCapsItf)->QueryAudioInputCapabilities(
  1121                 m_AudioIODevCapsItf,
  1194                 m_AudioIODevCapsItf,
  1122                 deviceIds[index],
  1195                 deviceIds[index],
  1123                 &audioInputDescriptor);
  1196                 &audioInputDescriptor);
  1124         returnValue = mapError(xa_result, ETrue);
  1197         returnValue = mapError(xa_result, ETrue);
  1133         TBuf16<KMaxNameLength> name;
  1206         TBuf16<KMaxNameLength> name;
  1134         name.Copy(ptr);
  1207         name.Copy(ptr);
  1135         /* Using TRAP with returnValue results in compiler error */
  1208         /* Using TRAP with returnValue results in compiler error */
  1136         TRAPD(err2, m_DefaultAudioInputDeviceNames->AppendL(name));
  1209         TRAPD(err2, m_DefaultAudioInputDeviceNames->AppendL(name));
  1137         returnValue = err2;
  1210         returnValue = err2;
  1138         RET_ERR_IF_ERR(returnValue);
  1211         if (returnValue != KErrNone)
       
  1212             continue;
       
  1213         m_DefaultInputDeviceIDs.Append(deviceIds[index]);
  1139     }
  1214     }
  1140 
  1215 
  1141     TRACE_FUNCTION_EXIT;
  1216     TRACE_FUNCTION_EXIT;
  1142     return returnValue;
  1217     return returnValue;
  1143 }
  1218 }
  1156     settings.encoderId = m_AudioEncoderId;
  1231     settings.encoderId = m_AudioEncoderId;
  1157     if (m_ChannelsOut != 0xffffffff)
  1232     if (m_ChannelsOut != 0xffffffff)
  1158         settings.channelsOut = m_ChannelsOut;
  1233         settings.channelsOut = m_ChannelsOut;
  1159     if (m_SampleRate != 0xffffffff)
  1234     if (m_SampleRate != 0xffffffff)
  1160         settings.sampleRate = m_SampleRate;
  1235         settings.sampleRate = m_SampleRate;
  1161     if (m_BitRate != 0)
  1236     if ((m_BitRate != 0) && (m_BitRate != 0xffffffff))
  1162         settings.bitRate = m_BitRate;
  1237         settings.bitRate = m_BitRate;
  1163     if (m_RateControl != 0)
  1238     if (m_RateControl != 0)
  1164         settings.rateControl = m_RateControl;
  1239         settings.rateControl = m_RateControl;
  1165     settings.profileSetting = m_ProfileSetting;
  1240     settings.profileSetting = m_ProfileSetting;
  1166     xa_result = (*m_AudioEncItf)->SetEncoderSettings(
  1241     xa_result = (*m_AudioEncItf)->SetEncoderSettings(
  1207 
  1282 
  1208     TRACE_FUNCTION_ENTRY;
  1283     TRACE_FUNCTION_ENTRY;
  1209     return returnValue;
  1284     return returnValue;
  1210 }
  1285 }
  1211 
  1286 
       
  1287 TInt32 XARecordSessionImpl::getSampleRatesByAudioCodecID(XAuint32 encoderId,
       
  1288                       RArray<TInt32> &aSampleRates)
       
  1289 {
       
  1290     TRACE_FUNCTION_ENTRY;
       
  1291 
       
  1292     if (!m_AudioEncCapsItf)
       
  1293         return KErrGeneral;
       
  1294 
       
  1295     XAuint32 numCaps = 0;
       
  1296     XAAudioCodecDescriptor codecDesc;
       
  1297     XAresult xa_result = (*m_AudioEncCapsItf)->GetAudioEncoderCapabilities(
       
  1298                                         m_AudioEncCapsItf,
       
  1299                                         encoderId,
       
  1300                                         &numCaps,
       
  1301                                         &codecDesc);
       
  1302     TInt returnValue = mapError(xa_result, ETrue);
       
  1303     RET_ERR_IF_ERR(returnValue);
       
  1304 
       
  1305     /* TODO What do we do if we have more than one caps?? */
       
  1306     if (codecDesc.isFreqRangeContinuous == XA_BOOLEAN_TRUE) {
       
  1307         aSampleRates.Append(codecDesc.minSampleRate / KMilliToHz);
       
  1308         aSampleRates.Append(codecDesc.maxSampleRate / KMilliToHz);
       
  1309     }
       
  1310     else {
       
  1311         XAuint32 numSRSupported = codecDesc.numSampleRatesSupported;
       
  1312         XAmilliHertz *pSampleRatesSupported(NULL);
       
  1313         pSampleRatesSupported = codecDesc.pSampleRatesSupported;
       
  1314         for (TInt index = 0; index < numSRSupported; index++)
       
  1315             aSampleRates.Append((*(pSampleRatesSupported + index)) / KMilliToHz);
       
  1316     }
       
  1317 
       
  1318     TRACE_FUNCTION_ENTRY;
       
  1319     return returnValue;
       
  1320 }
       
  1321 
  1212 /* Local function implementation */
  1322 /* Local function implementation */
  1213 void cbXAObjectItf(
  1323 void cbXAObjectItf(
  1214             XAObjectItf caller,
  1324             XAObjectItf caller,
  1215             const void *pContext,
  1325             const void *pContext,
  1216             XAuint32 event,
  1326             XAuint32 event,