os/mm/devsound/sounddevbt/src/A2dpBlueTooth/headsetaudioif/RTPStreamer.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef __RTPSTREAMER_H__
    17 #define __RTPSTREAMER_H__
    18 
    19 #include <e32base.h>
    20 #include <es_sock.h> //RSocketServer, RSocket
    21 #include <rtp.h>
    22 
    23 const TUint KRTPHeaderSize = 12;
    24 const TUint KSendBucketSize = 4;//sets number of internally buffered audio frames	
    25 
    26 class CMMFCodec; //fwd ref
    27 class CAudioBufferArray;
    28 class TSBCFrameParameters;
    29 class CA2dpCodecUtilities;
    30 
    31 /**
    32 Callback class implemented by CA2dpBTHeadsetAudioInterface to get error events
    33 back from CActiveRTPStreamer
    34 */
    35 class MRTPStreamerObserver
    36 	{
    37 public:
    38 /**
    39 Callback when the CRtpSendPackets detects an error condition
    40 event
    41 
    42 @internalComponent
    43 @param aError standard SymbianOS error
    44 */
    45 	void virtual RTPStreamerEvent(TInt aError) = 0;
    46 	};
    47 
    48 		
    49 /**
    50 RTP Streamer used by the CA2dpBTHeadsetAudioInterface.
    51 This class is used by the CA2dpBTHeadsetAudioInterface in order to stream
    52 buffers of audio to the headset.  The CActiveRTPStreamer can buffer a number
    53 of buffers internally set by the KSendBucketSize.
    54 
    55 @internalComponent
    56 */
    57 NONSHARABLE_CLASS(CActiveRTPStreamer) : public CTimer
    58 	{
    59 public:
    60 	static CActiveRTPStreamer*	NewL(RSocket& aSock, MRTPStreamerObserver& aRTPStreamerObserver);
    61 	~CActiveRTPStreamer();
    62 	
    63 	//callbacks from RTP	
    64 	static void RTPCallback(CActiveRTPStreamer* aStreamer, const TRtpEvent& aEvent);
    65 	static void RTPSendSourceCallback(CActiveRTPStreamer* aStreamer, const TRtpEvent& aEvent);
    66 	
    67 	void SetCodec(CMMFCodec& aCodec);
    68 	void SetAudioConfiguration(const CA2dpAudioCodecConfiguration& aAudioCodecConfiguration);
    69 	void Send(const TDesC8& aData, TRequestStatus& aStatus);
    70 	void Pause();
    71 	void Resume();
    72 	void CancelLastSendBuffer();
    73 	void FlushPendingSendBuffers();
    74 	TUint BytesSent() const;
    75 	void ResetBytesSent();
    76 private:
    77 	CActiveRTPStreamer(MRTPStreamerObserver& aRTPStreamerObserver);
    78 	void ConstructL(RSocket& aSock);	
    79 	void InitializeForSendL(const TDesC8& aData);
    80 	TUint CodecProcessPayloadL(const TDesC8& aData, TDes8& aPayload);
    81 	void PacketSent(TRtpEventType aEvent);
    82 	void RTPSessionEvent(const TRtpEvent& aEvent);
    83 	void CompleteSendRequestStatus(TInt aError);
    84 	
    85 	//CActive
    86 	void RunL();
    87 	void DoCancel();
    88 private:	
    89 	MRTPStreamerObserver& iRTPStreamerObserver;
    90 	CAudioBufferArray*	iAudioBufferArray; //this class is owned
    91 	TTimeIntervalMicroSeconds32	iRTPPacketDuration;
    92 	RRtpSession			iRTPSession;
    93 	RRtpSendSource		iRTPSendSource;
    94 	TRtpEventType		iRTPEventType;
    95 	TBool				iRtpCanSend;
    96 	TRequestStatus*		iSendStatus;
    97 	TUint iMaxMTULength;
    98 	TUint iFrameLength;
    99 	TUint iBufferLength;
   100 	TUint iNumberOfInputBytesToMakeRTPPacket;
   101 	TUint8 iPayloadType;
   102 	TUint iTimeStampIncrement;
   103 	TUint iTimeStamp;
   104 	TBuf8<4> iMediaPayloadHeader;
   105 	TUint iBitRate;
   106 	TUint iBytesSent;
   107 	TBool iBufferParamsInitialized;
   108 	TBool iPaused;
   109 	TInt iUnrecoverableError;
   110 	TUint iSendBufferSize;
   111 	
   112 	//these classes aren't owned
   113 	CMMFCodec* iCodec;
   114 	CA2dpAudioCodecConfiguration* iA2dpAudioCodecConfiguration;	
   115 	};
   116 
   117 #endif
   118