os/mm/devsound/sounddevbt/src/A2dpBlueTooth/headsetaudioif/RTPStreamer.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/devsound/sounddevbt/src/A2dpBlueTooth/headsetaudioif/RTPStreamer.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,118 @@
     1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifndef __RTPSTREAMER_H__
    1.20 +#define __RTPSTREAMER_H__
    1.21 +
    1.22 +#include <e32base.h>
    1.23 +#include <es_sock.h> //RSocketServer, RSocket
    1.24 +#include <rtp.h>
    1.25 +
    1.26 +const TUint KRTPHeaderSize = 12;
    1.27 +const TUint KSendBucketSize = 4;//sets number of internally buffered audio frames	
    1.28 +
    1.29 +class CMMFCodec; //fwd ref
    1.30 +class CAudioBufferArray;
    1.31 +class TSBCFrameParameters;
    1.32 +class CA2dpCodecUtilities;
    1.33 +
    1.34 +/**
    1.35 +Callback class implemented by CA2dpBTHeadsetAudioInterface to get error events
    1.36 +back from CActiveRTPStreamer
    1.37 +*/
    1.38 +class MRTPStreamerObserver
    1.39 +	{
    1.40 +public:
    1.41 +/**
    1.42 +Callback when the CRtpSendPackets detects an error condition
    1.43 +event
    1.44 +
    1.45 +@internalComponent
    1.46 +@param aError standard SymbianOS error
    1.47 +*/
    1.48 +	void virtual RTPStreamerEvent(TInt aError) = 0;
    1.49 +	};
    1.50 +
    1.51 +		
    1.52 +/**
    1.53 +RTP Streamer used by the CA2dpBTHeadsetAudioInterface.
    1.54 +This class is used by the CA2dpBTHeadsetAudioInterface in order to stream
    1.55 +buffers of audio to the headset.  The CActiveRTPStreamer can buffer a number
    1.56 +of buffers internally set by the KSendBucketSize.
    1.57 +
    1.58 +@internalComponent
    1.59 +*/
    1.60 +NONSHARABLE_CLASS(CActiveRTPStreamer) : public CTimer
    1.61 +	{
    1.62 +public:
    1.63 +	static CActiveRTPStreamer*	NewL(RSocket& aSock, MRTPStreamerObserver& aRTPStreamerObserver);
    1.64 +	~CActiveRTPStreamer();
    1.65 +	
    1.66 +	//callbacks from RTP	
    1.67 +	static void RTPCallback(CActiveRTPStreamer* aStreamer, const TRtpEvent& aEvent);
    1.68 +	static void RTPSendSourceCallback(CActiveRTPStreamer* aStreamer, const TRtpEvent& aEvent);
    1.69 +	
    1.70 +	void SetCodec(CMMFCodec& aCodec);
    1.71 +	void SetAudioConfiguration(const CA2dpAudioCodecConfiguration& aAudioCodecConfiguration);
    1.72 +	void Send(const TDesC8& aData, TRequestStatus& aStatus);
    1.73 +	void Pause();
    1.74 +	void Resume();
    1.75 +	void CancelLastSendBuffer();
    1.76 +	void FlushPendingSendBuffers();
    1.77 +	TUint BytesSent() const;
    1.78 +	void ResetBytesSent();
    1.79 +private:
    1.80 +	CActiveRTPStreamer(MRTPStreamerObserver& aRTPStreamerObserver);
    1.81 +	void ConstructL(RSocket& aSock);	
    1.82 +	void InitializeForSendL(const TDesC8& aData);
    1.83 +	TUint CodecProcessPayloadL(const TDesC8& aData, TDes8& aPayload);
    1.84 +	void PacketSent(TRtpEventType aEvent);
    1.85 +	void RTPSessionEvent(const TRtpEvent& aEvent);
    1.86 +	void CompleteSendRequestStatus(TInt aError);
    1.87 +	
    1.88 +	//CActive
    1.89 +	void RunL();
    1.90 +	void DoCancel();
    1.91 +private:	
    1.92 +	MRTPStreamerObserver& iRTPStreamerObserver;
    1.93 +	CAudioBufferArray*	iAudioBufferArray; //this class is owned
    1.94 +	TTimeIntervalMicroSeconds32	iRTPPacketDuration;
    1.95 +	RRtpSession			iRTPSession;
    1.96 +	RRtpSendSource		iRTPSendSource;
    1.97 +	TRtpEventType		iRTPEventType;
    1.98 +	TBool				iRtpCanSend;
    1.99 +	TRequestStatus*		iSendStatus;
   1.100 +	TUint iMaxMTULength;
   1.101 +	TUint iFrameLength;
   1.102 +	TUint iBufferLength;
   1.103 +	TUint iNumberOfInputBytesToMakeRTPPacket;
   1.104 +	TUint8 iPayloadType;
   1.105 +	TUint iTimeStampIncrement;
   1.106 +	TUint iTimeStamp;
   1.107 +	TBuf8<4> iMediaPayloadHeader;
   1.108 +	TUint iBitRate;
   1.109 +	TUint iBytesSent;
   1.110 +	TBool iBufferParamsInitialized;
   1.111 +	TBool iPaused;
   1.112 +	TInt iUnrecoverableError;
   1.113 +	TUint iSendBufferSize;
   1.114 +	
   1.115 +	//these classes aren't owned
   1.116 +	CMMFCodec* iCodec;
   1.117 +	CA2dpAudioCodecConfiguration* iA2dpAudioCodecConfiguration;	
   1.118 +	};
   1.119 +
   1.120 +#endif
   1.121 +