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