TBool CMidiCustomCommandParser::DoPercussionKeyNameL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig2> pckg;
	aMessage.ReadData1FromClientL(pckg);

	// Prevent memory leaks by deleting old key name - something must have gone wrong in the client
	// if it already exists
	delete iPercussionKeyName;
	iPercussionKeyName = NULL;

	const TDesC& percussionKeyName = iImplementor.MmcPercussionKeyNameL(pckg().iNote, pckg().iBankId, pckg().iCustom, pckg().iInstrumentId);

	iPercussionKeyName = CBufFlat::NewL(32);
	RBufWriteStream stream;
	stream.Open(*iPercussionKeyName);
	CleanupClosePushL(stream);
	stream << percussionKeyName;
	CleanupStack::PopAndDestroy();//s

	// Write the size of the descriptor back to the client
	TPckgBuf<TInt> descriptorSizePckg(iPercussionKeyName->Ptr(0).Length());	
	aMessage.WriteDataToClientL(descriptorSizePckg);	
	
	return ETrue;
	}
// -----------------------------------------------------------------------------
// CRa8CustomInterfaceMsgHdlr::DoFrameNumberL
// Handles the message from the proxy and calls the custom interface method.
// The data passed from the proxy is read from the message and passed to
// the custom interface.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CRa8CustomInterfaceMsgHdlr::DoFrameNumberL(TMMFMessage& aMessage)
    {
	TInt frame = iRa8CustomInterface->FrameNumber();
	TPckgBuf<TInt> pckg(frame);
	aMessage.WriteDataToClientL(pckg);
    aMessage.Complete(KErrNone);
    }
TBool CMidiCustomCommandParser::DoDurationMicroBeatsL(TMMFMessage& aMessage)
	{
	TInt64 duration;
	iImplementor.MmcDurationMicroBeatsL(duration);
	TPckgBuf<TMMFMidiConfig2> pckg;
	pckg().iDurationMicroBeats = duration;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoPitchTranspositionCentsL(TMMFMessage& aMessage)
	{
	TInt pitch;
	iImplementor.MmcPitchTranspositionCentsL(pitch);
	TPckgBuf<TMMFMidiConfig1> pckg;
	pckg().iPitch = pitch;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoTempoMicroBeatsPerMinuteL(TMMFMessage& aMessage)
	{
	TInt microBeatsPerMinute;
	iImplementor.MmcTempoMicroBeatsPerMinuteL(microBeatsPerMinute);
	TPckgBuf<TMMFMidiConfig1> pckg;
	pckg().iTempo = microBeatsPerMinute;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoGetBalanceL(TMMFMessage& aMessage)
	{
	TInt balance;
	iImplementor.MmcGetBalanceL(balance);
	TPckgBuf<TMMFMidiConfig1> pckg;
	pckg().iBalance = balance;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoPositionMicroBeatsL(TMMFMessage& aMessage)
	{
	TInt64 microBeats = 0;
	iImplementor.MmcPositionMicroBeatsL(microBeats);
	TPckgBuf<TMMFMidiConfig2> pckg;
	pckg().iPositionMicroBeats = microBeats;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoMaxVolumeL(TMMFMessage& aMessage)
	{
	TInt maxVol;
	iImplementor.MmcMaxVolumeL(maxVol);
	TPckgBuf<TMMFMidiConfig1> pckg;
	pckg().iMaxVolume = maxVol;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoChannelsSupportedL(TMMFMessage& aMessage)
	{
	TInt channels;
	iImplementor.MmcChannelsSupportedL(channels);
	TPckgBuf<TMMFMidiConfig2> pckg;
	pckg().iChannel = channels;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoStopTimeL(TMMFMessage& aMessage)
	{
	TTimeIntervalMicroSeconds stopTime;
	iImplementor.MmcStopTimeL(stopTime);
	TPckgBuf<TMMFMidiConfig2> pckg;
	pckg().iStopTime = stopTime;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoMaxPolyphonyL(TMMFMessage& aMessage)
	{
	TInt maxNotes;
	iImplementor.MmcMaxPolyphonyL(maxNotes);
	TPckgBuf<TMMFMidiConfig1> pckg;
	pckg().iMaxNotes = maxNotes;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoGetRepeatsL(TMMFMessage& aMessage)
	{
	TInt numRepeats;
	iImplementor.MmcGetRepeatsL(numRepeats);
	TPckgBuf<TMMFMidiConfig1> pckg;
	pckg().iNumRepeats = numRepeats;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoMinPlaybackRateL(TMMFMessage& aMessage)
	{
	TInt minRate;
	iImplementor.MmcMinPlaybackRateL(minRate);
	TPckgBuf<TMMFMidiConfig3> pckg;
	pckg().iPlayBackMinRate = minRate;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoNumberOfInstrumentsL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig2> pckg;
	aMessage.ReadData1FromClientL(pckg);
	TInt numInstruments;
	iImplementor.MmcNumberOfInstrumentsL(pckg().iBankId, pckg().iCustom, numInstruments);	
	pckg().iNumInstruments = numInstruments;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoChannelVolumeL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig2> pckg;
	aMessage.ReadData1FromClientL(pckg);
	TReal32 channelVol;
	iImplementor.MmcChannelVolumeL(pckg().iChannel, channelVol);
	pckg().iChannelVol = channelVol;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoSetPitchTranspositionL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig1> pckg;
	aMessage.ReadData1FromClientL(pckg);
	TInt centsApplied;
	iImplementor.MmcSetPitchTranspositionL(pckg().iPitch, centsApplied);
	pckg().iPitch = centsApplied;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoMimeTypeL(TMMFMessage& aMessage)
	{
	HBufC8* mimeType = HBufC8::NewL(KMimeTypeLength);
	TPtr8 des = mimeType->Des();
	CleanupStack::PushL(mimeType);
	iImplementor.MmcMimeTypeL(des);
	aMessage.WriteDataToClientL(des);
	CleanupStack::PopAndDestroy();//mimeType
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoCustomBankLoadedL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig2> pckg;
	aMessage.ReadData1FromClientL(pckg);
	TBool bankLoaded;
	iImplementor.MmcCustomBankLoadedL(pckg().iBankId, bankLoaded);
	pckg().iBankLoaded = bankLoaded;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoLoadCustomBankDataL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig2> pckg;
	aMessage.ReadData1FromClientL(pckg);
	TInt bankId;
	iImplementor.MmcLoadCustomBankDataL(*(pckg().iBankData), bankId);
	pckg().iBankId = bankId;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoSendMessageWithTimeStampL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig3> pckg;
	aMessage.ReadData1FromClientL(pckg);
	TInt bytesProcessed;
	iImplementor.MmcSendMessageL(*(pckg().iMidiMessage), pckg().iTimeStamp, bytesProcessed);
	pckg().iBytesProcessed = bytesProcessed;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoIsChannelMuteL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig2> pckg;
	aMessage.ReadData1FromClientL(pckg);
	TBool mute;
	iImplementor.MmcIsChannelMuteL(pckg().iChannel, mute);
	pckg().iMuted = mute;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoGetInstrumentIdL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig2> pckg;
	aMessage.ReadData1FromClientL(pckg);
	TInt instrumentId;
	iImplementor.MmcGetInstrumentIdL(pckg().iBankId, pckg().iCustom, pckg().iInstrumentIndex, instrumentId);
	pckg().iInstrumentId = instrumentId;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoCopyPercussionKeyNameL(TMMFMessage& aMessage)
	{
	if (!iPercussionKeyName)
		User::Leave(KErrNotReady);

	// Copy the instrument name back to the client
	aMessage.WriteDataToClientL(iPercussionKeyName->Ptr(0));
	delete iPercussionKeyName;
	iPercussionKeyName = NULL;
	return ETrue;
	}
// ---------------------------------------------------------
// CErrorConcealmentIntfcMsgHdlr::DoFrameModeRqrdForEcL
// Handles the message from the proxy and calls the custom interface method.
// The custom interface returns the data requested and this function
// writes it back to the proxy.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CErrorConcealmentIntfcMsgHdlr::DoFrameModeRqrdForEcL(TMMFMessage& aMessage)
    {
	TBool frameModeRqrd;
	TInt status = iErrorConcealmentIntfcCI->FrameModeRqrdForEC(frameModeRqrd);
	if (status == KErrNone)
    	{
    	TPckgBuf<TBool> pckg;
	    pckg() = frameModeRqrd;
    	aMessage.WriteDataToClientL(pckg);
    	}
    aMessage.Complete(status);
    }
// ---------------------------------------------------------
// CIlbcEncoderIntfcMsgHdlr::DoGetVadModeL
// Handles the message from the proxy and calls the custom interface.
// The custom interface returns the data requested and this function
// writes it back to the proxy.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CIlbcEncoderIntfcMsgHdlr::DoGetVadModeL(TMMFMessage& aMessage)
	{
	TBool vadMode;
	TInt status = iIlbcEncoderIntfcCI->GetVadMode(vadMode);
	if (status == KErrNone)
    	{
    	TPckgBuf<TBool> pckgBuf;
	    pckgBuf() = vadMode;
    	aMessage.WriteDataToClientL(pckgBuf);
    	}
    aMessage.Complete(status);
	}
TInt CStreamControlCustomCommandParser::DoGetRandomSeekingSupported(TMMFMessage& aMessage)
    {
    TInt status;
    TBool supported;
    status = iImplementor.MscGetRandomSeekingSupported(supported);
    TPckgBuf<TBool> pckg(supported);
    TRAPD(err, aMessage.WriteDataToClientL(pckg));
    if(err)
        {
            status = err;
        }
    return status;
    }