mmserv/voipaudioservices/VoIPIntfc/src/VoIPDownlinkStreamImpl.cpp
changeset 55 e267340986c9
parent 0 71ca22bcf22a
equal deleted inserted replaced
52:4ce423f34688 55:e267340986c9
    50 // ---------------------------------------------------------------------------
    50 // ---------------------------------------------------------------------------
    51 //
    51 //
    52 CVoIPAudioDownlinkStreamImpl::~CVoIPAudioDownlinkStreamImpl()
    52 CVoIPAudioDownlinkStreamImpl::~CVoIPAudioDownlinkStreamImpl()
    53     {
    53     {
    54     Close();
    54     Close();
       
    55     iCodecFormats.Close();
    55 
    56 
    56     if (iMsgQHandler)
    57     if (iMsgQHandler)
    57         {
    58         {
    58         iMsgQHandler->Cancel();
    59         iMsgQHandler->Cancel();
    59         delete iMsgQHandler;
    60         delete iMsgQHandler;
   176 //
   177 //
   177 void CVoIPAudioDownlinkStreamImpl::GetSupportedFormatsL(
   178 void CVoIPAudioDownlinkStreamImpl::GetSupportedFormatsL(
   178         const TMMFPrioritySettings aPriority,
   179         const TMMFPrioritySettings aPriority,
   179         RArray<TVoIPCodecFormat>& aFormats)
   180         RArray<TVoIPCodecFormat>& aFormats)
   180     {
   181     {
   181     if (!iCodecFormats || aFormats.Count() <= 0)
   182     TInt count = iCodecFormats.Count();
       
   183     aFormats.Reset();
       
   184     if (count > 0)
       
   185         {
       
   186         for (TInt i = 0; i < count; i++)
       
   187             {
       
   188             aFormats.Append(iCodecFormats[i]);
       
   189             }
       
   190         }
       
   191     else
   182         {
   192         {
   183         RArray<TUint32> codecIDs;
   193         RArray<TUint32> codecIDs;
   184         CleanupClosePushL(codecIDs);
   194         CleanupClosePushL(codecIDs);
   185         codecIDs.Reset();
   195         codecIDs.Reset();
   186         iVoIPAudioSession.GetSupportedDecoders(aPriority, codecIDs,
   196         iVoIPAudioSession.GetSupportedDecoders(aPriority, codecIDs,
   187                 iG711FrameSize);
   197                 iG711FrameSize);
   188 
   198 
       
   199 #ifdef _DEBUG
       
   200         RDebug::Print(_L("G711 Frame Size=%d"), iG711FrameSize);
       
   201 #endif
       
   202 
   189         TUint32 codec = 0;
   203         TUint32 codec = 0;
   190         TInt count = codecIDs.Count();
   204         TInt count = codecIDs.Count();
   191         TVoIPCodecFormat format;
   205         TVoIPCodecFormat format;
   192         aFormats.Reset();
   206         iCodecFormats.Reset();
   193 
   207 
   194         for (TInt i = 0; i < count; i++)
   208         for (TInt i = 0; i < count; i++)
   195             {
   209             {
   196             codec = codecIDs[i];
   210             codec = codecIDs[i];
   197 
   211 
   203             RDebug::Print(_L("%c%c%c%c"), a, b, c, d);
   217             RDebug::Print(_L("%c%c%c%c"), a, b, c, d);
   204 #endif
   218 #endif
   205             format = ConvertFourCC(codec);
   219             format = ConvertFourCC(codec);
   206             if (format != ENULL)
   220             if (format != ENULL)
   207                 {
   221                 {
       
   222                 iCodecFormats.Append(format);
   208                 aFormats.Append(format);
   223                 aFormats.Append(format);
   209                 }
   224                 }
   210             }
   225             }
   211 
       
   212         iCodecFormats = &aFormats;
       
   213         CleanupStack::PopAndDestroy(&codecIDs);
   226         CleanupStack::PopAndDestroy(&codecIDs);
   214         }
   227         }
   215     }
   228     }
   216 
   229 
   217 // ---------------------------------------------------------------------------
   230 // ---------------------------------------------------------------------------
   272             }
   285             }
   273         }
   286         }
   274 
   287 
   275     TUint32 codecFourCC = CodecFourCC(iFormat);
   288     TUint32 codecFourCC = CodecFourCC(iFormat);
   276     iVoIPAudioSession.SetDecoder(codecFourCC);
   289     iVoIPAudioSession.SetDecoder(codecFourCC);
   277     }
       
   278 
       
   279 // ---------------------------------------------------------------------------
       
   280 // CVoIPAudioDownlinkStreamImpl::GetFormat
       
   281 // ---------------------------------------------------------------------------
       
   282 //
       
   283 TVoIPCodecFormat CVoIPAudioDownlinkStreamImpl::GetFormat()
       
   284     {
       
   285     return iFormat;
       
   286     }
   290     }
   287 
   291 
   288 // ---------------------------------------------------------------------------
   292 // ---------------------------------------------------------------------------
   289 // CVoIPAudioDownlinkStreamImpl::SetAudioDevice
   293 // CVoIPAudioDownlinkStreamImpl::SetAudioDevice
   290 // ---------------------------------------------------------------------------
   294 // ---------------------------------------------------------------------------
   546 TBool CVoIPAudioDownlinkStreamImpl::IsCodecSupportedL(
   550 TBool CVoIPAudioDownlinkStreamImpl::IsCodecSupportedL(
   547         TVoIPCodecFormat aFormat)
   551         TVoIPCodecFormat aFormat)
   548     {
   552     {
   549     TBool status = EFalse;
   553     TBool status = EFalse;
   550 
   554 
   551     if (!iCodecFormats)
   555     if (iCodecFormats.Count() > 0)
       
   556         {
       
   557         status = FindFormat(aFormat);
       
   558         }
       
   559     else
   552         {
   560         {
   553         // Client hasn't called GetSupportedFormatsL
   561         // Client hasn't called GetSupportedFormatsL
   554         RArray<TVoIPCodecFormat> codecs;
   562         RArray<TVoIPCodecFormat> codecs;
   555         CleanupClosePushL(codecs);
   563         CleanupClosePushL(codecs);
   556         codecs.Reset();
   564         codecs.Reset();
   557         GetSupportedFormatsL(iPriority, codecs); //sets iCodecFormats
   565         GetSupportedFormatsL(iPriority, codecs); //sets iCodecFormats
   558         status = FindFormat(aFormat);
   566         status = FindFormat(aFormat);
   559         CleanupStack::PopAndDestroy(&codecs);
   567         CleanupStack::PopAndDestroy(&codecs);
   560         iCodecFormats = NULL;
       
   561         }
       
   562     else
       
   563         {
       
   564         status = FindFormat(aFormat);
       
   565         }
   568         }
   566 
   569 
   567     return status;
   570     return status;
   568     }
   571     }
   569 
   572 
   573 //
   576 //
   574 TBool CVoIPAudioDownlinkStreamImpl::FindFormat(TVoIPCodecFormat aFormat)
   577 TBool CVoIPAudioDownlinkStreamImpl::FindFormat(TVoIPCodecFormat aFormat)
   575     {
   578     {
   576     TBool found = EFalse;
   579     TBool found = EFalse;
   577 
   580 
   578     if (iCodecFormats)
   581     if (iCodecFormats.Count() > 0)
   579         {
   582         {
   580         if (iCodecFormats->Count() > 0)
   583         if (iCodecFormats.Find(aFormat) == KErrNotFound)
   581             {
   584             {
   582             if (iCodecFormats->Find(aFormat) == KErrNotFound)
   585             // For backward compatibility with VAS 1.0
       
   586             if (aFormat == EG711)
   583                 {
   587                 {
   584                 // For backward compatibility with VAS 1.0
   588                 if (iCodecFormats.Find(EG711_10MS) != KErrNotFound)
   585                 if (aFormat == EG711)
       
   586                     {
   589                     {
   587                     if (iCodecFormats->Find(EG711_10MS) != KErrNotFound)
   590                     iFormat = EG711_10MS;
   588                         {
   591                     found = ETrue;
   589                         iFormat = EG711_10MS;
       
   590                         found = ETrue;
       
   591                         }
       
   592                     }
   592                     }
   593                 }
   593                 }
   594             else
   594             else if (aFormat == EG711_10MS)
   595                 {
   595                 {
   596                 iFormat = aFormat;
   596                 if (iCodecFormats.Find(EG711) != KErrNotFound)
   597                 found = ETrue;
   597                     {
       
   598                     iFormat = EG711;
       
   599                     found = ETrue;
       
   600                     }
   598                 }
   601                 }
       
   602             }
       
   603         else
       
   604             {
       
   605             iFormat = aFormat;
       
   606             found = ETrue;
   599             }
   607             }
   600         }
   608         }
   601 
   609 
   602     return found;
   610     return found;
   603     }
   611     }