mmserv/tms/tmscallserver/src/tmsipcalldownlinkds.cpp
changeset 21 2ed61feeead6
parent 14 80975da52420
child 28 ebf79c79991a
--- a/mmserv/tms/tmscallserver/src/tmsipcalldownlinkds.cpp	Fri May 14 18:19:45 2010 -0500
+++ b/mmserv/tms/tmscallserver/src/tmsipcalldownlinkds.cpp	Fri May 28 19:26:28 2010 -0500
@@ -32,7 +32,8 @@
 // Standard Constructor
 // -----------------------------------------------------------------------------
 //
-TMSIPDownlink::TMSIPDownlink()
+TMSIPDownlink::TMSIPDownlink(TMSIPDevSoundObserver& observer) :
+    TMSIPCallStreamBase(observer)
     {
     }
 
@@ -61,12 +62,13 @@
 // Symbian two-phase constructor
 // -----------------------------------------------------------------------------
 //
-TMSIPDownlink* TMSIPDownlink::NewL(const guint32 codecID,
-        const TMMFPrioritySettings priority)
+TMSIPDownlink* TMSIPDownlink::NewL(TMSIPDevSoundObserver& observer,
+        const guint32 codecID, const TMMFPrioritySettings priority,
+        const gint retrytime)
     {
-    TMSIPDownlink* self = new (ELeave) TMSIPDownlink();
+    TMSIPDownlink* self = new (ELeave) TMSIPDownlink(observer);
     CleanupStack::PushL(self);
-    self->ConstructL(codecID, priority);
+    self->ConstructL(codecID, priority, retrytime);
     CleanupStack::Pop(self);
     return self;
     }
@@ -77,17 +79,15 @@
 // -----------------------------------------------------------------------------
 //
 void TMSIPDownlink::ConstructL(const guint32 codecID,
-        const TMMFPrioritySettings priority)
+        const TMMFPrioritySettings priority, const gint /*retrytime*/)
     {
     TRACE_PRN_FN_ENT;
-
     iCodecID = codecID;
     iPriority = priority;
 
     // Client must set these before querying!
     iG711DecodeMode = TMS_G711_CODEC_MODE_ALAW;
     iILBCDecodeMode = TMS_ILBC_CODEC_MODE_20MS_FRAME;
-
     TRAPD(err, InitDevSoundL(EMMFStatePlaying, priority));
     if (err != TMS_RESULT_SUCCESS)
         {
@@ -95,7 +95,6 @@
         }
 
     iMaxBufLen = ConfigureMedia(iCodecID);
-
     TRACE_PRN_FN_EXT;
     }
 
@@ -104,26 +103,21 @@
 //
 // -----------------------------------------------------------------------------
 //
-void TMSIPDownlink::Start()
+void TMSIPDownlink::Start(const gint /*retrytime*/)
     {
     TRACE_PRN_FN_ENT;
-
     gint err = TMS_RESULT_ILLEGAL_OPERATION;
 
     if (iStatus == EReady && iDevSound)
         {
         TRAP(err, iDevSound->PlayInitL());
         TRACE_PRN_IF_ERR(err);
-
-#ifdef _DEBUG
-        iSamplesPlayedCount = 0;
-#endif
         if (err != TMS_RESULT_SUCCESS)
             {
             iStatus = EReady;
+            iObserver.DownlinkStarted(err);
             }
         }
-
     TRACE_PRN_FN_EXT;
     }
 
@@ -141,7 +135,6 @@
         iDevSound->Stop();
         iStatus = EReady;
         }
-
     TRACE_PRN_FN_EXT;
     }
 
@@ -156,18 +149,19 @@
 void TMSIPDownlink::BufferToBeFilled(CMMFBuffer* aBuffer)
     {
     // Store pointer to the received buffer
-    iDevSoundBufPtr = static_cast<CMMFDataBuffer*>(aBuffer);
+    iDevSoundBufPtr = static_cast<CMMFDataBuffer*> (aBuffer);
     iBufLen = iDevSoundBufPtr->RequestSize();
     TRACE_PRN_N1(_L("TMS->DNL->BTBF: LEN[%d]"), iBufLen);
 
 #ifndef __WINSCW__
-    //TODO: revisit this!
+    //TODO: Is this still true?
     // The first AMR buffer returns 1 for no data frame.
     /*if (iCodecID == KMccFourCCIdAMRNB)
      {
      iBufLen = iMaxBufLen;
      }*/
 #endif //__WINSCW__
+
     // Create or adjust the chunk
     gint err = DoChunk(iBufLen, iMsgBuffer);
 
@@ -182,6 +176,7 @@
         iMsgBuffer.iStatus = err;
         iMsgBuffer.iInt = iBufLen;
         iStatus = EStreaming;
+
         // If chunk is opened, we will expect a call from the client to
         // get chunk handle. When we get a call to copy chunk handle,
         // check these variables and see if they match. This is not
@@ -195,7 +190,6 @@
 
     iMsgBuffer.iRequest = ECmdFillBuffer;
     err = iMsgQueue.Send(iMsgBuffer);
-
     TRACE_PRN_IF_ERR(err);
     }
 
@@ -210,7 +204,7 @@
 
     // Copy data over from chunk
     TPtr8 dataPtr(iChunk.Base(), buflen, iMaxBufLen);
-    //    RDebug::RawPrint(dataPtr);
+    //RDebug::RawPrint(dataPtr);
 
     if (iStatus == EStreaming && iDevSound && iDevSoundBufPtr)
         {
@@ -362,7 +356,6 @@
             status = TMS_RESULT_ILLEGAL_OPERATION;
             }
         }
-
     TRACE_PRN_IF_ERR(status);
     return status;
     }
@@ -396,7 +389,6 @@
                 }
             }
         }
-
     TRACE_PRN_IF_ERR(err);
     return err;
     }
@@ -443,7 +435,6 @@
                 }
             }
         }
-
     TRACE_PRN_IF_ERR(err);
     return err;
     }
@@ -478,7 +469,6 @@
             TRACE_PRN_N1(_L("TMS->DNL: FrameModeRqrdForEC [%d]"), frmodereq);
             }
         }
-
     TRACE_PRN_IF_ERR(err);
     return err;
     }
@@ -502,7 +492,6 @@
             TRACE_PRN_N1(_L("TMS->DNL: SetFrameMode [%d]"), frmode);
             }
         }
-
     TRACE_PRN_IF_ERR(err);
     return err;
     }
@@ -523,7 +512,6 @@
         TRACE_PRN_N1(_L("TMS->DNL: GetFrameMode [%d]"), frmode);
         err = TMS_RESULT_SUCCESS;
         }
-
     TRACE_PRN_IF_ERR(err);
     return err;
     }
@@ -542,7 +530,6 @@
         err = iErrConcealmentIntfc->ConcealErrorForNextBuffer();
         TRACE_PRN_N(_L("TMS->DNL: ConcealErrorForNextBuffer"));
         }
-
     TRACE_PRN_IF_ERR(err);
     return err;
     }
@@ -569,7 +556,6 @@
             TRACE_PRN_N1(_L("TMS->DNL: SetCng [%d]"), cng);
             }
         }
-
     TRACE_PRN_IF_ERR(err);
     return err;
     }
@@ -596,7 +582,6 @@
             TRACE_PRN_N1(_L("TMS->DNL: GetCng [%d]"), cng);
             }
         }
-
     TRACE_PRN_IF_ERR(err);
     return err;
     }
@@ -619,7 +604,6 @@
             TRACE_PRN_N1(_L("TMS->DNL: SetPlc [%d]"), plc);
             }
         }
-
     TRACE_PRN_IF_ERR(err);
     return err;
     }
@@ -640,7 +624,6 @@
         err = TMS_RESULT_SUCCESS;
         TRACE_PRN_N1(_L("TMS->DNL: GetPlc [%d]"), plc);
         }
-
     TRACE_PRN_IF_ERR(err);
     return err;
     }
@@ -662,7 +645,6 @@
             TRACE_PRN_N(_L("TMS->DNL: BadLsfNextBuffer"));
             }
         }
-
     TRACE_PRN_IF_ERR(err);
     return err;
     }
@@ -759,37 +741,30 @@
 void TMSIPDownlink::InitializeComplete(TInt aError)
     {
     TRACE_PRN_FN_ENT;
+    gint status = aError;
 
-    gint err = aError;
-
-    if (err == TMS_RESULT_SUCCESS && iDevSound)
+    if (status == TMS_RESULT_SUCCESS && iDevSound)
         {
         TMMFCapabilities conf;
         conf = iDevSound->Config();
         conf.iRate = EMMFSampleRate8000Hz;
         conf.iChannels = EMMFMono;
-        TRAP(err, iDevSound->SetConfigL(conf));
-        if (err == TMS_RESULT_SUCCESS)
+        TRAP(status, iDevSound->SetConfigL(conf));
+        if (status == TMS_RESULT_SUCCESS)
             {
             // We are ready to stream even in case of later CI setting failure
             iStatus = EReady;
             iMaxVolume = iDevSound->MaxVolume();
             }
 
-        // Init Custom Interface API to the decoder
-        err = SetCodecCi();
-        if (err != TMS_RESULT_SUCCESS)
-            {
-            // DEBUG only
-            // Can ignore error - although decoder is not fully configured but
-            // it can still run in the default mode.
-            TRACE_PRN_IF_ERR(err);
-            }
+        // Init Custom Interface API to the Decoder. Any return error can
+        // be ignored as codec can still run in the default mode even if not
+        // fully configured.
+        SetCodecCi();
         }
 
-    // TODO: Notify client
-
-    TRACE_PRN_IF_ERR(err);
+    iObserver.DownlinkInitCompleted(status);
+    TRACE_PRN_IF_ERR(status);
     TRACE_PRN_FN_EXT;
     }
 
@@ -800,16 +775,11 @@
 // The state of recorder is rolled back to EReady.
 // -----------------------------------------------------------------------------
 //
-void TMSIPDownlink::PlayError(TInt /*aError*/)
+void TMSIPDownlink::PlayError(TInt aError)
     {
-    //TRACE_PRN_IF_ERR(aError);
-
-#ifdef _DEBUG
-    iSamplesPlayedCount = 0;
-#endif
     iStatus = EReady;
-
-    // TODO: Notify client
+    iObserver.DownlinkStarted(aError);
+    TRACE_PRN_IF_ERR(aError);
     }
 
 // End of file