mmserv/voipaudioservices/VoIPIntfc/src/VoIPDownlinkStreamImpl.cpp
changeset 53 eabc8c503852
parent 0 71ca22bcf22a
--- a/mmserv/voipaudioservices/VoIPIntfc/src/VoIPDownlinkStreamImpl.cpp	Fri Sep 03 19:34:12 2010 -0500
+++ b/mmserv/voipaudioservices/VoIPIntfc/src/VoIPDownlinkStreamImpl.cpp	Tue Sep 21 11:38:43 2010 -0500
@@ -52,6 +52,7 @@
 CVoIPAudioDownlinkStreamImpl::~CVoIPAudioDownlinkStreamImpl()
     {
     Close();
+    iCodecFormats.Close();
 
     if (iMsgQHandler)
         {
@@ -178,7 +179,16 @@
         const TMMFPrioritySettings aPriority,
         RArray<TVoIPCodecFormat>& aFormats)
     {
-    if (!iCodecFormats || aFormats.Count() <= 0)
+    TInt count = iCodecFormats.Count();
+    aFormats.Reset();
+    if (count > 0)
+        {
+        for (TInt i = 0; i < count; i++)
+            {
+            aFormats.Append(iCodecFormats[i]);
+            }
+        }
+    else
         {
         RArray<TUint32> codecIDs;
         CleanupClosePushL(codecIDs);
@@ -186,10 +196,14 @@
         iVoIPAudioSession.GetSupportedDecoders(aPriority, codecIDs,
                 iG711FrameSize);
 
+#ifdef _DEBUG
+        RDebug::Print(_L("G711 Frame Size=%d"), iG711FrameSize);
+#endif
+
         TUint32 codec = 0;
         TInt count = codecIDs.Count();
         TVoIPCodecFormat format;
-        aFormats.Reset();
+        iCodecFormats.Reset();
 
         for (TInt i = 0; i < count; i++)
             {
@@ -205,11 +219,10 @@
             format = ConvertFourCC(codec);
             if (format != ENULL)
                 {
+                iCodecFormats.Append(format);
                 aFormats.Append(format);
                 }
             }
-
-        iCodecFormats = &aFormats;
         CleanupStack::PopAndDestroy(&codecIDs);
         }
     }
@@ -277,15 +290,6 @@
     }
 
 // ---------------------------------------------------------------------------
-// CVoIPAudioDownlinkStreamImpl::GetFormat
-// ---------------------------------------------------------------------------
-//
-TVoIPCodecFormat CVoIPAudioDownlinkStreamImpl::GetFormat()
-    {
-    return iFormat;
-    }
-
-// ---------------------------------------------------------------------------
 // CVoIPAudioDownlinkStreamImpl::SetAudioDevice
 // ---------------------------------------------------------------------------
 //
@@ -548,7 +552,11 @@
     {
     TBool status = EFalse;
 
-    if (!iCodecFormats)
+    if (iCodecFormats.Count() > 0)
+        {
+        status = FindFormat(aFormat);
+        }
+    else
         {
         // Client hasn't called GetSupportedFormatsL
         RArray<TVoIPCodecFormat> codecs;
@@ -557,11 +565,6 @@
         GetSupportedFormatsL(iPriority, codecs); //sets iCodecFormats
         status = FindFormat(aFormat);
         CleanupStack::PopAndDestroy(&codecs);
-        iCodecFormats = NULL;
-        }
-    else
-        {
-        status = FindFormat(aFormat);
         }
 
     return status;
@@ -575,28 +578,33 @@
     {
     TBool found = EFalse;
 
-    if (iCodecFormats)
+    if (iCodecFormats.Count() > 0)
         {
-        if (iCodecFormats->Count() > 0)
+        if (iCodecFormats.Find(aFormat) == KErrNotFound)
             {
-            if (iCodecFormats->Find(aFormat) == KErrNotFound)
+            // For backward compatibility with VAS 1.0
+            if (aFormat == EG711)
                 {
-                // For backward compatibility with VAS 1.0
-                if (aFormat == EG711)
+                if (iCodecFormats.Find(EG711_10MS) != KErrNotFound)
                     {
-                    if (iCodecFormats->Find(EG711_10MS) != KErrNotFound)
-                        {
-                        iFormat = EG711_10MS;
-                        found = ETrue;
-                        }
+                    iFormat = EG711_10MS;
+                    found = ETrue;
                     }
                 }
-            else
+            else if (aFormat == EG711_10MS)
                 {
-                iFormat = aFormat;
-                found = ETrue;
+                if (iCodecFormats.Find(EG711) != KErrNotFound)
+                    {
+                    iFormat = EG711;
+                    found = ETrue;
+                    }
                 }
             }
+        else
+            {
+            iFormat = aFormat;
+            found = ETrue;
+            }
         }
 
     return found;