os/mm/devsoundextensions/mmfcustominterfaces/IlbcEncoderIntfc/IlbcEncoderIntfcMsgHdlr/src/IlbcEncoderIntfcMsgHdlr.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 Ilbc encoder 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    "IlbcEncoderIntfcMsgHdlr.h"
sl@0
    22
#include    "IlbcEncoderIntfcMsgs.h"
sl@0
    23
#include    <IlbcEncoderIntfc.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
// CIlbcEncoderIntfcMsgHdlr::CIlbcEncoderIntfcMsgHdlr
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
CIlbcEncoderIntfcMsgHdlr::CIlbcEncoderIntfcMsgHdlr(
sl@0
    52
                             CIlbcEncoderIntfc* aIlbcEncoderIntfcCI) :
sl@0
    53
	CMMFObject(KUidIlbcEncoderIntfc)
sl@0
    54
    {
sl@0
    55
    iIlbcEncoderIntfcCI = aIlbcEncoderIntfcCI;
sl@0
    56
    }
sl@0
    57
sl@0
    58
// -----------------------------------------------------------------------------
sl@0
    59
// CIlbcEncoderIntfcMsgHdlr::ConstructL
sl@0
    60
// Symbian 2nd phase constructor can leave.
sl@0
    61
// -----------------------------------------------------------------------------
sl@0
    62
//
sl@0
    63
void CIlbcEncoderIntfcMsgHdlr::ConstructL()
sl@0
    64
    {
sl@0
    65
    }
sl@0
    66
sl@0
    67
// -----------------------------------------------------------------------------
sl@0
    68
// CIlbcEncoderIntfcMsgHdlr::NewL
sl@0
    69
// Two-phased constructor.
sl@0
    70
// -----------------------------------------------------------------------------
sl@0
    71
//
sl@0
    72
EXPORT_C CIlbcEncoderIntfcMsgHdlr* CIlbcEncoderIntfcMsgHdlr::NewL(
sl@0
    73
                                                TAny*  aIlbcEncoderIntfcCI)
sl@0
    74
    {
sl@0
    75
    CIlbcEncoderIntfc* errorConcealmentIntfcCI = 
sl@0
    76
                              (CIlbcEncoderIntfc*)aIlbcEncoderIntfcCI;
sl@0
    77
    CIlbcEncoderIntfcMsgHdlr* self = 
sl@0
    78
            new (ELeave) CIlbcEncoderIntfcMsgHdlr(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 CIlbcEncoderIntfcMsgHdlr::~CIlbcEncoderIntfcMsgHdlr()
sl@0
    88
	{
sl@0
    89
	delete iIlbcEncoderIntfcCI;
sl@0
    90
	}
sl@0
    91
sl@0
    92
// ---------------------------------------------------------
sl@0
    93
// CIlbcEncoderIntfcMsgHdlr::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 CIlbcEncoderIntfcMsgHdlr::HandleRequest(
sl@0
   102
                                                       TMMFMessage& aMessage)
sl@0
   103
	{
sl@0
   104
	ASSERT(aMessage.Destination().InterfaceId() == KUidIlbcEncoderIntfc);
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
// CIlbcEncoderIntfcMsgHdlr::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 CIlbcEncoderIntfcMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage)
sl@0
   119
	{
sl@0
   120
	switch(aMessage.Function())
sl@0
   121
		{
sl@0
   122
		case EIlbceimSetEncoderMode:
sl@0
   123
			{
sl@0
   124
    		DoSetEncoderModeL(aMessage);
sl@0
   125
			break;
sl@0
   126
			}
sl@0
   127
		case EIlbceimSetVadMode:
sl@0
   128
			{
sl@0
   129
			DoSetVadModeL(aMessage);
sl@0
   130
			break;
sl@0
   131
			}
sl@0
   132
		case EIlbceimGetVadMode:
sl@0
   133
			{
sl@0
   134
			DoGetVadModeL(aMessage);
sl@0
   135
			break;
sl@0
   136
			}
sl@0
   137
		default:
sl@0
   138
			{
sl@0
   139
			aMessage.Complete(KErrNotSupported);
sl@0
   140
			}
sl@0
   141
		}
sl@0
   142
	}
sl@0
   143
sl@0
   144
// ---------------------------------------------------------
sl@0
   145
// CIlbcEncoderIntfcMsgHdlr::DoSetEncoderModeL
sl@0
   146
// Handles the message from the proxy and calls the custom interface method.
sl@0
   147
// The data passed from the proxy is read from the message and passed to
sl@0
   148
// the custom interface.
sl@0
   149
// (other items were commented in a header).
sl@0
   150
// ---------------------------------------------------------
sl@0
   151
//
sl@0
   152
void CIlbcEncoderIntfcMsgHdlr::DoSetEncoderModeL(TMMFMessage& aMessage)
sl@0
   153
    {
sl@0
   154
	TPckgBuf<CIlbcEncoderIntfc::TEncodeMode> pckgBuf;
sl@0
   155
	aMessage.ReadData1FromClientL(pckgBuf);
sl@0
   156
	TInt status = iIlbcEncoderIntfcCI->SetEncoderMode(pckgBuf());
sl@0
   157
    aMessage.Complete(status);
sl@0
   158
    }
sl@0
   159
sl@0
   160
// ---------------------------------------------------------
sl@0
   161
// CIlbcEncoderIntfcMsgHdlr::DoSetVadModeL
sl@0
   162
// Handles the message from the proxy and calls the custom interface method.
sl@0
   163
// The data passed from the proxy is read from the message and passed to
sl@0
   164
// the custom interface.
sl@0
   165
// (other items were commented in a header).
sl@0
   166
// ---------------------------------------------------------
sl@0
   167
//
sl@0
   168
void CIlbcEncoderIntfcMsgHdlr::DoSetVadModeL(TMMFMessage& aMessage)
sl@0
   169
	{
sl@0
   170
	TPckgBuf<TBool> pckgBuf;
sl@0
   171
	aMessage.ReadData1FromClientL(pckgBuf);
sl@0
   172
	TInt status = iIlbcEncoderIntfcCI->SetVadMode(pckgBuf());
sl@0
   173
    aMessage.Complete(status);
sl@0
   174
	}
sl@0
   175
sl@0
   176
// ---------------------------------------------------------
sl@0
   177
// CIlbcEncoderIntfcMsgHdlr::DoGetVadModeL
sl@0
   178
// Handles the message from the proxy and calls the custom interface.
sl@0
   179
// The custom interface returns the data requested and this function
sl@0
   180
// writes it back to the proxy.
sl@0
   181
// (other items were commented in a header).
sl@0
   182
// ---------------------------------------------------------
sl@0
   183
//
sl@0
   184
void CIlbcEncoderIntfcMsgHdlr::DoGetVadModeL(TMMFMessage& aMessage)
sl@0
   185
	{
sl@0
   186
	TBool vadMode;
sl@0
   187
	TInt status = iIlbcEncoderIntfcCI->GetVadMode(vadMode);
sl@0
   188
	if (status == KErrNone)
sl@0
   189
    	{
sl@0
   190
    	TPckgBuf<TBool> pckgBuf;
sl@0
   191
	    pckgBuf() = vadMode;
sl@0
   192
    	aMessage.WriteDataToClientL(pckgBuf);
sl@0
   193
    	}
sl@0
   194
    aMessage.Complete(status);
sl@0
   195
	}
sl@0
   196
sl@0
   197
    
sl@0
   198
sl@0
   199
sl@0
   200
// End of File