devsoundextensions/mmfcustominterfaces/G711DecoderIntfc/G711DecoderIntfcMsgHdlr/src/G711DecoderIntfcMsgHdlr.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 G711 decoder interface
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "G711DecoderIntfcMsgHdlr.h"
       
    22 #include    "G711DecoderIntfcMsgs.h"
       
    23 #include    <G711DecoderIntfc.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 // CG711DecoderIntfcMsgHdlr::CG711DecoderIntfcMsgHdlr
       
    47 // C++ default constructor can NOT contain any code, that
       
    48 // might leave.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 CG711DecoderIntfcMsgHdlr::CG711DecoderIntfcMsgHdlr(
       
    52                              CG711DecoderIntfc* aG711DecoderIntfcCI) :
       
    53 	CMMFObject(KUidG711DecoderIntfc)
       
    54     {
       
    55     iG711DecoderIntfcCI = aG711DecoderIntfcCI;
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CG711DecoderIntfcMsgHdlr::ConstructL
       
    60 // Symbian 2nd phase constructor can leave.
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 void CG711DecoderIntfcMsgHdlr::ConstructL()
       
    64     {
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CG711DecoderIntfcMsgHdlr::NewL
       
    69 // Two-phased constructor.
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 EXPORT_C CG711DecoderIntfcMsgHdlr* CG711DecoderIntfcMsgHdlr::NewL(
       
    73                                                 TAny*  aG711DecoderIntfcCI)
       
    74     {
       
    75     CG711DecoderIntfc* errorConcealmentIntfcCI = 
       
    76                               (CG711DecoderIntfc*)aG711DecoderIntfcCI;
       
    77     CG711DecoderIntfcMsgHdlr* self = 
       
    78             new (ELeave) CG711DecoderIntfcMsgHdlr(errorConcealmentIntfcCI);
       
    79     CleanupStack::PushL( self );
       
    80     self->ConstructL();
       
    81     CleanupStack::Pop( self );
       
    82 
       
    83     return self;
       
    84     }
       
    85 
       
    86 // Destructor
       
    87 EXPORT_C CG711DecoderIntfcMsgHdlr::~CG711DecoderIntfcMsgHdlr()
       
    88 	{
       
    89 	delete iG711DecoderIntfcCI;
       
    90 	}
       
    91 
       
    92 // ---------------------------------------------------------
       
    93 // CG711DecoderIntfcMsgHdlr::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 CG711DecoderIntfcMsgHdlr::HandleRequest(
       
   102                                                        TMMFMessage& aMessage)
       
   103 	{
       
   104 	ASSERT(aMessage.Destination().InterfaceId() == KUidG711DecoderIntfc);
       
   105 	TRAPD(error,DoHandleRequestL(aMessage));
       
   106 	if(error)
       
   107 		{
       
   108 		aMessage.Complete(error);
       
   109 		}
       
   110 	}
       
   111 
       
   112 // ---------------------------------------------------------
       
   113 // CG711DecoderIntfcMsgHdlr::DoHandleRequestL
       
   114 // Determines which custom interface to call.
       
   115 // (other items were commented in a header).
       
   116 // ---------------------------------------------------------
       
   117 //
       
   118 void CG711DecoderIntfcMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage)
       
   119 	{
       
   120 	switch(aMessage.Function())
       
   121 		{
       
   122 		case EG711dimSetDecoderMode:
       
   123 			{
       
   124     		DoSetDecoderModeL(aMessage);
       
   125 			break;
       
   126 			}
       
   127 		case EG711dimSetCng:
       
   128 			{
       
   129     		DoSetCngL(aMessage);
       
   130 			break;
       
   131 			}
       
   132 		case EG711dimGetCng:
       
   133 			{
       
   134     		DoGetCngL(aMessage);
       
   135 			break;
       
   136 			}
       
   137 		case EG711dimSetPlc:
       
   138 			{
       
   139     		DoSetPlcL(aMessage);
       
   140 			break;
       
   141 			}
       
   142 		default:
       
   143 			{
       
   144 			aMessage.Complete(KErrNotSupported);
       
   145 			}
       
   146 		}
       
   147 	}
       
   148 
       
   149 // ---------------------------------------------------------
       
   150 // CG711DecoderIntfcMsgHdlr::DoSetDecoderModeL
       
   151 // Handles the message from the proxy and calls the custom interface method.
       
   152 // The data passed from the proxy is read from the message and passed to
       
   153 // the custom interface.
       
   154 // (other items were commented in a header).
       
   155 // ---------------------------------------------------------
       
   156 //
       
   157 void CG711DecoderIntfcMsgHdlr::DoSetDecoderModeL(TMMFMessage& aMessage)
       
   158     {
       
   159 	TPckgBuf<CG711DecoderIntfc::TDecodeMode> pckgBuf;
       
   160 	aMessage.ReadData1FromClientL(pckgBuf);
       
   161 	TInt status = iG711DecoderIntfcCI->SetDecoderMode(pckgBuf());
       
   162     aMessage.Complete(status);
       
   163     }
       
   164     
       
   165 // ---------------------------------------------------------
       
   166 // CG711DecoderIntfcMsgHdlr::DoSetCngL
       
   167 // Handles the message from the proxy and calls the custom interface method.
       
   168 // The data passed from the proxy is read from the message and passed to
       
   169 // the custom interface.
       
   170 // (other items were commented in a header).
       
   171 // ---------------------------------------------------------
       
   172 //
       
   173 void CG711DecoderIntfcMsgHdlr::DoSetCngL(TMMFMessage& aMessage)
       
   174     {
       
   175 	TPckgBuf<TBool> pckgBuf;
       
   176 	aMessage.ReadData1FromClientL(pckgBuf);
       
   177 	TInt status = iG711DecoderIntfcCI->SetCng(pckgBuf());
       
   178     aMessage.Complete(status);
       
   179     }
       
   180     
       
   181 // ---------------------------------------------------------
       
   182 // CG711DecoderIntfcMsgHdlr::DoGetCngL
       
   183 // Handles the message from the proxy and calls the custom interface method.
       
   184 // The custom interface returns the data requested and this function
       
   185 // writes it back to the proxy.
       
   186 // (other items were commented in a header).
       
   187 // ---------------------------------------------------------
       
   188 //
       
   189 void CG711DecoderIntfcMsgHdlr::DoGetCngL(TMMFMessage& aMessage)
       
   190     {
       
   191 	TBool cng;
       
   192 	TInt status = iG711DecoderIntfcCI->GetCng(cng);
       
   193 	if (status == KErrNone)
       
   194     	{
       
   195     	TPckgBuf<TBool> pckgBuf;
       
   196 	    pckgBuf() = cng;
       
   197     	aMessage.WriteDataToClientL(pckgBuf);
       
   198     	}
       
   199     aMessage.Complete(status);
       
   200     }
       
   201     
       
   202 // ---------------------------------------------------------
       
   203 // CG711DecoderIntfcMsgHdlr::DoSetPlcL
       
   204 // Handles the message from the proxy and calls the custom interface method.
       
   205 // The data passed from the proxy is read from the message and passed to
       
   206 // the custom interface.
       
   207 // (other items were commented in a header).
       
   208 // ---------------------------------------------------------
       
   209 //
       
   210 void CG711DecoderIntfcMsgHdlr::DoSetPlcL(TMMFMessage& aMessage)
       
   211     {
       
   212 	TPckgBuf<TBool> pckgBuf;
       
   213 	aMessage.ReadData1FromClientL(pckgBuf);
       
   214 	TInt status = iG711DecoderIntfcCI->SetPlc(pckgBuf());
       
   215     aMessage.Complete(status);
       
   216     }
       
   217     
       
   218 
       
   219 
       
   220 // End of File