os/mm/devsoundextensions/mmfcustominterfaces/G711DecoderIntfc/G711DecoderIntfcMsgHdlr/src/G711DecoderIntfcMsgHdlr.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). 
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description:   Message handler for G711 decoder interface
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
sl@0
    20
// INCLUDE FILES
sl@0
    21
#include    "G711DecoderIntfcMsgHdlr.h"
sl@0
    22
#include    "G711DecoderIntfcMsgs.h"
sl@0
    23
#include    <G711DecoderIntfc.h>
sl@0
    24
sl@0
    25
// EXTERNAL DATA STRUCTURES
sl@0
    26
sl@0
    27
// EXTERNAL FUNCTION PROTOTYPES  
sl@0
    28
sl@0
    29
// CONSTANTS
sl@0
    30
sl@0
    31
// MACROS
sl@0
    32
sl@0
    33
// LOCAL CONSTANTS AND MACROS
sl@0
    34
sl@0
    35
// MODULE DATA STRUCTURES
sl@0
    36
sl@0
    37
// LOCAL FUNCTION PROTOTYPES
sl@0
    38
sl@0
    39
// FORWARD DECLARATIONS
sl@0
    40
sl@0
    41
// ============================= LOCAL FUNCTIONS ===============================
sl@0
    42
sl@0
    43
// ============================ MEMBER FUNCTIONS ===============================
sl@0
    44
sl@0
    45
// -----------------------------------------------------------------------------
sl@0
    46
// CG711DecoderIntfcMsgHdlr::CG711DecoderIntfcMsgHdlr
sl@0
    47
// C++ default constructor can NOT contain any code, that
sl@0
    48
// might leave.
sl@0
    49
// -----------------------------------------------------------------------------
sl@0
    50
//
sl@0
    51
CG711DecoderIntfcMsgHdlr::CG711DecoderIntfcMsgHdlr(
sl@0
    52
                             CG711DecoderIntfc* aG711DecoderIntfcCI) :
sl@0
    53
	CMMFObject(KUidG711DecoderIntfc)
sl@0
    54
    {
sl@0
    55
    iG711DecoderIntfcCI = aG711DecoderIntfcCI;
sl@0
    56
    }
sl@0
    57
sl@0
    58
// -----------------------------------------------------------------------------
sl@0
    59
// CG711DecoderIntfcMsgHdlr::ConstructL
sl@0
    60
// Symbian 2nd phase constructor can leave.
sl@0
    61
// -----------------------------------------------------------------------------
sl@0
    62
//
sl@0
    63
void CG711DecoderIntfcMsgHdlr::ConstructL()
sl@0
    64
    {
sl@0
    65
    }
sl@0
    66
sl@0
    67
// -----------------------------------------------------------------------------
sl@0
    68
// CG711DecoderIntfcMsgHdlr::NewL
sl@0
    69
// Two-phased constructor.
sl@0
    70
// -----------------------------------------------------------------------------
sl@0
    71
//
sl@0
    72
EXPORT_C CG711DecoderIntfcMsgHdlr* CG711DecoderIntfcMsgHdlr::NewL(
sl@0
    73
                                                TAny*  aG711DecoderIntfcCI)
sl@0
    74
    {
sl@0
    75
    CG711DecoderIntfc* errorConcealmentIntfcCI = 
sl@0
    76
                              (CG711DecoderIntfc*)aG711DecoderIntfcCI;
sl@0
    77
    CG711DecoderIntfcMsgHdlr* self = 
sl@0
    78
            new (ELeave) CG711DecoderIntfcMsgHdlr(errorConcealmentIntfcCI);
sl@0
    79
    CleanupStack::PushL( self );
sl@0
    80
    self->ConstructL();
sl@0
    81
    CleanupStack::Pop( self );
sl@0
    82
sl@0
    83
    return self;
sl@0
    84
    }
sl@0
    85
sl@0
    86
// Destructor
sl@0
    87
EXPORT_C CG711DecoderIntfcMsgHdlr::~CG711DecoderIntfcMsgHdlr()
sl@0
    88
	{
sl@0
    89
	delete iG711DecoderIntfcCI;
sl@0
    90
	}
sl@0
    91
sl@0
    92
// ---------------------------------------------------------
sl@0
    93
// CG711DecoderIntfcMsgHdlr::HandleRequest
sl@0
    94
// Handles the messages from the proxy.
sl@0
    95
// Calls a subfunction which determines which custom interface to call.
sl@0
    96
// A subfunction is used to contain multiple leaving functions for a single
sl@0
    97
// trap.
sl@0
    98
// (other items were commented in a header).
sl@0
    99
// ---------------------------------------------------------
sl@0
   100
//
sl@0
   101
EXPORT_C void CG711DecoderIntfcMsgHdlr::HandleRequest(
sl@0
   102
                                                       TMMFMessage& aMessage)
sl@0
   103
	{
sl@0
   104
	ASSERT(aMessage.Destination().InterfaceId() == KUidG711DecoderIntfc);
sl@0
   105
	TRAPD(error,DoHandleRequestL(aMessage));
sl@0
   106
	if(error)
sl@0
   107
		{
sl@0
   108
		aMessage.Complete(error);
sl@0
   109
		}
sl@0
   110
	}
sl@0
   111
sl@0
   112
// ---------------------------------------------------------
sl@0
   113
// CG711DecoderIntfcMsgHdlr::DoHandleRequestL
sl@0
   114
// Determines which custom interface to call.
sl@0
   115
// (other items were commented in a header).
sl@0
   116
// ---------------------------------------------------------
sl@0
   117
//
sl@0
   118
void CG711DecoderIntfcMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage)
sl@0
   119
	{
sl@0
   120
	switch(aMessage.Function())
sl@0
   121
		{
sl@0
   122
		case EG711dimSetDecoderMode:
sl@0
   123
			{
sl@0
   124
    		DoSetDecoderModeL(aMessage);
sl@0
   125
			break;
sl@0
   126
			}
sl@0
   127
		case EG711dimSetCng:
sl@0
   128
			{
sl@0
   129
    		DoSetCngL(aMessage);
sl@0
   130
			break;
sl@0
   131
			}
sl@0
   132
		case EG711dimGetCng:
sl@0
   133
			{
sl@0
   134
    		DoGetCngL(aMessage);
sl@0
   135
			break;
sl@0
   136
			}
sl@0
   137
		case EG711dimSetPlc:
sl@0
   138
			{
sl@0
   139
    		DoSetPlcL(aMessage);
sl@0
   140
			break;
sl@0
   141
			}
sl@0
   142
		default:
sl@0
   143
			{
sl@0
   144
			aMessage.Complete(KErrNotSupported);
sl@0
   145
			}
sl@0
   146
		}
sl@0
   147
	}
sl@0
   148
sl@0
   149
// ---------------------------------------------------------
sl@0
   150
// CG711DecoderIntfcMsgHdlr::DoSetDecoderModeL
sl@0
   151
// Handles the message from the proxy and calls the custom interface method.
sl@0
   152
// The data passed from the proxy is read from the message and passed to
sl@0
   153
// the custom interface.
sl@0
   154
// (other items were commented in a header).
sl@0
   155
// ---------------------------------------------------------
sl@0
   156
//
sl@0
   157
void CG711DecoderIntfcMsgHdlr::DoSetDecoderModeL(TMMFMessage& aMessage)
sl@0
   158
    {
sl@0
   159
	TPckgBuf<CG711DecoderIntfc::TDecodeMode> pckgBuf;
sl@0
   160
	aMessage.ReadData1FromClientL(pckgBuf);
sl@0
   161
	TInt status = iG711DecoderIntfcCI->SetDecoderMode(pckgBuf());
sl@0
   162
    aMessage.Complete(status);
sl@0
   163
    }
sl@0
   164
    
sl@0
   165
// ---------------------------------------------------------
sl@0
   166
// CG711DecoderIntfcMsgHdlr::DoSetCngL
sl@0
   167
// Handles the message from the proxy and calls the custom interface method.
sl@0
   168
// The data passed from the proxy is read from the message and passed to
sl@0
   169
// the custom interface.
sl@0
   170
// (other items were commented in a header).
sl@0
   171
// ---------------------------------------------------------
sl@0
   172
//
sl@0
   173
void CG711DecoderIntfcMsgHdlr::DoSetCngL(TMMFMessage& aMessage)
sl@0
   174
    {
sl@0
   175
	TPckgBuf<TBool> pckgBuf;
sl@0
   176
	aMessage.ReadData1FromClientL(pckgBuf);
sl@0
   177
	TInt status = iG711DecoderIntfcCI->SetCng(pckgBuf());
sl@0
   178
    aMessage.Complete(status);
sl@0
   179
    }
sl@0
   180
    
sl@0
   181
// ---------------------------------------------------------
sl@0
   182
// CG711DecoderIntfcMsgHdlr::DoGetCngL
sl@0
   183
// Handles the message from the proxy and calls the custom interface method.
sl@0
   184
// The custom interface returns the data requested and this function
sl@0
   185
// writes it back to the proxy.
sl@0
   186
// (other items were commented in a header).
sl@0
   187
// ---------------------------------------------------------
sl@0
   188
//
sl@0
   189
void CG711DecoderIntfcMsgHdlr::DoGetCngL(TMMFMessage& aMessage)
sl@0
   190
    {
sl@0
   191
	TBool cng;
sl@0
   192
	TInt status = iG711DecoderIntfcCI->GetCng(cng);
sl@0
   193
	if (status == KErrNone)
sl@0
   194
    	{
sl@0
   195
    	TPckgBuf<TBool> pckgBuf;
sl@0
   196
	    pckgBuf() = cng;
sl@0
   197
    	aMessage.WriteDataToClientL(pckgBuf);
sl@0
   198
    	}
sl@0
   199
    aMessage.Complete(status);
sl@0
   200
    }
sl@0
   201
    
sl@0
   202
// ---------------------------------------------------------
sl@0
   203
// CG711DecoderIntfcMsgHdlr::DoSetPlcL
sl@0
   204
// Handles the message from the proxy and calls the custom interface method.
sl@0
   205
// The data passed from the proxy is read from the message and passed to
sl@0
   206
// the custom interface.
sl@0
   207
// (other items were commented in a header).
sl@0
   208
// ---------------------------------------------------------
sl@0
   209
//
sl@0
   210
void CG711DecoderIntfcMsgHdlr::DoSetPlcL(TMMFMessage& aMessage)
sl@0
   211
    {
sl@0
   212
	TPckgBuf<TBool> pckgBuf;
sl@0
   213
	aMessage.ReadData1FromClientL(pckgBuf);
sl@0
   214
	TInt status = iG711DecoderIntfcCI->SetPlc(pckgBuf());
sl@0
   215
    aMessage.Complete(status);
sl@0
   216
    }
sl@0
   217
    
sl@0
   218
sl@0
   219
sl@0
   220
// End of File