devsoundextensions/mmfcustominterfaces/IlbcDecoderIntfc/IlbcDecoderIntfcMsgHdlr/src/IlbcDecoderIntfcMsgHdlr.cpp
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:   Message handler for Ilbc decoder interface
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "IlbcDecoderIntfcMsgHdlr.h"
       
    22 #include    "IlbcDecoderIntfcMsgs.h"
       
    23 #include    <IlbcDecoderIntfc.h>
       
    24 
       
    25 // EXTERNAL DATA STRUCTURES
       
    26 
       
    27 // EXTERNAL FUNCTION PROTOTYPES  
       
    28 
       
    29 // CONSTANTS
       
    30 
       
    31 // MACROS
       
    32 
       
    33 // LOCAL CONSTANTS AND MACROS
       
    34 
       
    35 // MODULE DATA STRUCTURES
       
    36 
       
    37 // LOCAL FUNCTION PROTOTYPES
       
    38 
       
    39 // FORWARD DECLARATIONS
       
    40 
       
    41 // ============================= LOCAL FUNCTIONS ===============================
       
    42 
       
    43 // ============================ MEMBER FUNCTIONS ===============================
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CIlbcDecoderIntfcMsgHdlr::CIlbcDecoderIntfcMsgHdlr
       
    47 // C++ default constructor can NOT contain any code, that
       
    48 // might leave.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 CIlbcDecoderIntfcMsgHdlr::CIlbcDecoderIntfcMsgHdlr(
       
    52                              CIlbcDecoderIntfc* aIlbcDecoderIntfcCI) :
       
    53 	CMMFObject(KUidIlbcDecoderIntfc)
       
    54     {
       
    55     iIlbcDecoderIntfcCI = aIlbcDecoderIntfcCI;
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CIlbcDecoderIntfcMsgHdlr::ConstructL
       
    60 // Symbian 2nd phase constructor can leave.
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 void CIlbcDecoderIntfcMsgHdlr::ConstructL()
       
    64     {
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CIlbcDecoderIntfcMsgHdlr::NewL
       
    69 // Two-phased constructor.
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 EXPORT_C CIlbcDecoderIntfcMsgHdlr* CIlbcDecoderIntfcMsgHdlr::NewL(
       
    73                                                 TAny*  aIlbcDecoderIntfcCI)
       
    74     {
       
    75     CIlbcDecoderIntfc* errorConcealmentIntfcCI = 
       
    76                               (CIlbcDecoderIntfc*)aIlbcDecoderIntfcCI;
       
    77     CIlbcDecoderIntfcMsgHdlr* self = 
       
    78             new (ELeave) CIlbcDecoderIntfcMsgHdlr(errorConcealmentIntfcCI);
       
    79     CleanupStack::PushL( self );
       
    80     self->ConstructL();
       
    81     CleanupStack::Pop( self );
       
    82 
       
    83     return self;
       
    84     }
       
    85 
       
    86 // Destructor
       
    87 EXPORT_C CIlbcDecoderIntfcMsgHdlr::~CIlbcDecoderIntfcMsgHdlr()
       
    88 	{
       
    89 	delete iIlbcDecoderIntfcCI;
       
    90 	}
       
    91 
       
    92 // ---------------------------------------------------------
       
    93 // CIlbcDecoderIntfcMsgHdlr::HandleRequest
       
    94 // Handles the messages from the proxy.
       
    95 // Calls a subfunction which determines which custom interface to call.
       
    96 // A subfunction is used to contain multiple leaving functions for a single
       
    97 // trap.
       
    98 // (other items were commented in a header).
       
    99 // ---------------------------------------------------------
       
   100 //
       
   101 EXPORT_C void CIlbcDecoderIntfcMsgHdlr::HandleRequest(
       
   102                                                        TMMFMessage& aMessage)
       
   103 	{
       
   104 	ASSERT(aMessage.Destination().InterfaceId() == KUidIlbcDecoderIntfc);
       
   105 	TRAPD(error,DoHandleRequestL(aMessage));
       
   106 	if(error)
       
   107 		{
       
   108 		aMessage.Complete(error);
       
   109 		}
       
   110 	}
       
   111 
       
   112 // ---------------------------------------------------------
       
   113 // CIlbcDecoderIntfcMsgHdlr::DoHandleRequestL
       
   114 // Determines which custom interface to call.
       
   115 // (other items were commented in a header).
       
   116 // ---------------------------------------------------------
       
   117 //
       
   118 void CIlbcDecoderIntfcMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage)
       
   119 	{
       
   120 	switch(aMessage.Function())
       
   121 		{
       
   122 		case EIlbcdimSetDecoderMode:
       
   123 			{
       
   124     		DoSetDecoderModeL(aMessage);
       
   125 			break;
       
   126 			}
       
   127 		case EIlbcdimSetCng:
       
   128 			{
       
   129     		DoSetCngL(aMessage);
       
   130 			break;
       
   131 			}
       
   132 		case EIlbcdimGetCng:
       
   133 			{
       
   134     		DoGetCngL(aMessage);
       
   135 			break;
       
   136 			}
       
   137 		default:
       
   138 			{
       
   139 			aMessage.Complete(KErrNotSupported);
       
   140 			}
       
   141 		}
       
   142 	}
       
   143 
       
   144 // ---------------------------------------------------------
       
   145 // CIlbcDecoderIntfcMsgHdlr::DoSetDecoderModeL
       
   146 // Handles the message from the proxy and calls the custom interface method.
       
   147 // The data passed from the proxy is read from the message and passed to
       
   148 // the custom interface.
       
   149 // (other items were commented in a header).
       
   150 // ---------------------------------------------------------
       
   151 //
       
   152 void CIlbcDecoderIntfcMsgHdlr::DoSetDecoderModeL(TMMFMessage& aMessage)
       
   153     {
       
   154 	TPckgBuf<CIlbcDecoderIntfc::TDecodeMode> pckgBuf;
       
   155 	aMessage.ReadData1FromClientL(pckgBuf);
       
   156 	TInt status = iIlbcDecoderIntfcCI->SetDecoderMode(pckgBuf());
       
   157     aMessage.Complete(status);
       
   158     }
       
   159 
       
   160 // ---------------------------------------------------------
       
   161 // CIlbcDecoderIntfcMsgHdlr::DoSetCngL
       
   162 // Handles the message from the proxy and calls the custom interface method.
       
   163 // The data passed from the proxy is read from the message and passed to
       
   164 // the custom interface.
       
   165 // (other items were commented in a header).
       
   166 // ---------------------------------------------------------
       
   167 //
       
   168 void CIlbcDecoderIntfcMsgHdlr::DoSetCngL(TMMFMessage& aMessage)
       
   169     {
       
   170 	TPckgBuf<TBool> pckgBuf;
       
   171 	aMessage.ReadData1FromClientL(pckgBuf);
       
   172 	TInt status = iIlbcDecoderIntfcCI->SetCng(pckgBuf());
       
   173     aMessage.Complete(status);
       
   174     }
       
   175     
       
   176 // ---------------------------------------------------------
       
   177 // CIlbcDecoderIntfcMsgHdlr::DoGetCngL
       
   178 // Handles the message from the proxy and calls the custom interface method.
       
   179 // The custom interface returns the data requested and this function
       
   180 // writes it back to the proxy.
       
   181 // (other items were commented in a header).
       
   182 // ---------------------------------------------------------
       
   183 //
       
   184 void CIlbcDecoderIntfcMsgHdlr::DoGetCngL(TMMFMessage& aMessage)
       
   185     {
       
   186 	TBool cng;
       
   187 	TInt status = iIlbcDecoderIntfcCI->GetCng(cng);
       
   188 	if (status == KErrNone)
       
   189     	{
       
   190     	TPckgBuf<TBool> pckgBuf;
       
   191 	    pckgBuf() = cng;
       
   192     	aMessage.WriteDataToClientL(pckgBuf);
       
   193     	}
       
   194     aMessage.Complete(status);
       
   195     }
       
   196     
       
   197     
       
   198 
       
   199 
       
   200 // End of File