mmserv/tms/tmscallserver/src/ipcallstreambase.cpp
changeset 0 71ca22bcf22a
child 3 4f62049db6ac
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description: Telephony Multimedia Service
       
    15  *
       
    16  */
       
    17 
       
    18 #include <e32math.h>
       
    19 #include <mmcccodecinformation.h>
       
    20 #include "tmsutility.h"
       
    21 #include "tmsshared.h"
       
    22 #include "ipcallstream.h"
       
    23 
       
    24 using namespace TMS;
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // IPCallStreamBase::~IPCallStreamBase
       
    28 // Destructor
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 IPCallStreamBase::~IPCallStreamBase()
       
    32     {
       
    33     TRACE_PRN_FN_ENT;
       
    34 
       
    35     if (iChunk.Handle() > 0)
       
    36         {
       
    37         iChunk.Close();
       
    38         }
       
    39 
       
    40 #ifndef __USE_GSTREAMER__
       
    41     delete iDevSound;
       
    42 #endif //__USE_GSTREAMER__
       
    43     TRACE_PRN_FN_EXT;
       
    44     }
       
    45 
       
    46 #ifndef __USE_GSTREAMER__
       
    47 // -----------------------------------------------------------------------------
       
    48 // IPCallStreamBase::InitDevSoundL
       
    49 //
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 void IPCallStreamBase::InitDevSoundL(const TMMFState aDevSoundState,
       
    53         const TMMFPrioritySettings priority)
       
    54     {
       
    55     TRACE_PRN_FN_ENT;
       
    56 
       
    57     if (!iDevSound)
       
    58         {
       
    59         // Create D/S recording/playing device
       
    60         iDevSound = CMMFDevSound::NewL();
       
    61         }
       
    62 
       
    63     if (iDevSound)
       
    64         {
       
    65         iDevSound->InitializeL(*this, TFourCC(iCodecID), aDevSoundState);
       
    66         iDevSound->SetPrioritySettings(priority);
       
    67         }
       
    68     }
       
    69 #endif //__USE_GSTREAMER__
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // IPCallStreamBase::SetMsgQueue
       
    73 //
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 void IPCallStreamBase::SetMsgQueue(const RMsgQueue<TmsMsgBuf> aMsgQueue)
       
    77     {
       
    78     iMsgQueue = aMsgQueue;
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // IPCallStreamBase::ConfigureMedia
       
    83 //
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 gint IPCallStreamBase::ConfigureMedia(const guint32 aCodecID)
       
    87     {
       
    88     gint framelen = 0;
       
    89 
       
    90     switch (aCodecID)
       
    91         {
       
    92         case KMccFourCCIdG711:
       
    93             iMediaType = "audio/x-alaw";
       
    94             // iMediaType = "audio/x-mulaw";
       
    95             framelen = KTMSG711FrameLen10ms; //TODO: may be H/W specific!
       
    96             //framelen = KTMSG711FrameLen20ms;
       
    97             break;
       
    98         case KMccFourCCIdG729:
       
    99             iMediaType = "audio/g729";
       
   100             framelen = KTMSG729FrameLen;
       
   101             break;
       
   102         case KMccFourCCIdILBC:
       
   103             iMediaType = "audio/ilbc";
       
   104             framelen = KTMSILBCFrameLen20ms;
       
   105             //framelen = KTMSILBCFrameLen30ms;
       
   106             break;
       
   107         case KMccFourCCIdAMRNB:
       
   108             iMediaType = "audio/amr";
       
   109             framelen = KTMSAMRNBFrameLen;
       
   110             //framelen = KTMSAMRNBFrameLenFM;
       
   111             break;
       
   112         case KMMFFourCCCodePCM16:
       
   113         default:
       
   114             iMediaType = "audio/x-raw-int";
       
   115             framelen = KTMSPCM16FrameLen;
       
   116 #ifdef __WINSCW__
       
   117             framelen *= 4; //16kB
       
   118 #endif
       
   119             break;
       
   120         }
       
   121 
       
   122     //TODO: DEVLON TEST
       
   123     if (iCodecID != KMMFFourCCCodePCM16)
       
   124         {
       
   125         framelen *= 10;
       
   126         }
       
   127     //TODO: DEVLON TEST
       
   128 
       
   129     return framelen;
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // IPCallStreamBase::DoChunk
       
   134 // Checks, adjusts and creates global RChunk.
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 gint IPCallStreamBase::DoChunk(const gint aDataLen, TmsMsgBuf& aMsgBuffer)
       
   138     {
       
   139     gint status(KErrNone);
       
   140 
       
   141     // If chunk already created, try to reuse it
       
   142     if (iChunk.Handle())
       
   143         {
       
   144         // committed size is smaller but chunk is large enough to hold data
       
   145         if ((iChunk.Size() < aDataLen) && (aDataLen <= iChunk.MaxSize()))
       
   146             {
       
   147             status = iChunk.Adjust(aDataLen);
       
   148             TRACE_PRN_N1(_L("IP_CALL: DoChunk->Chunk Adjusted [%d]"), aDataLen);
       
   149             }
       
   150         else if (aDataLen > iChunk.MaxSize())
       
   151             {
       
   152             iChunk.Close();
       
   153             TRACE_PRN_N(_L("IP_CALL: DoChunk->Chunk Closed"));
       
   154             }
       
   155         }
       
   156     RET_ERR_IF_ERR(status);
       
   157 
       
   158     // Request kernel to create global RChunk if needed
       
   159     aMsgBuffer.iBool = FALSE;
       
   160     if (!iChunk.Handle())
       
   161         {
       
   162         // TODO consider using some max instead
       
   163         status = iChunk.CreateGlobal(KNullDesC, aDataLen, aDataLen);
       
   164         // Mark to re-open chunk handle
       
   165         aMsgBuffer.iBool = TRUE;
       
   166         aMsgBuffer.iUint32 = Math::Random();
       
   167         TRACE_PRN_N2(_L("IP_CALL: DoChunk->Chunk Created [%d]key[%d]"),
       
   168                 aDataLen, aMsgBuffer.iUint32);
       
   169         }
       
   170     TRACE_PRN_IF_ERR(status);
       
   171     return status;
       
   172     }
       
   173 
       
   174 // End of file