sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef __RTPSTREAMER_H__ sl@0: #define __RTPSTREAMER_H__ sl@0: sl@0: #include sl@0: #include //RSocketServer, RSocket sl@0: #include sl@0: sl@0: const TUint KRTPHeaderSize = 12; sl@0: const TUint KSendBucketSize = 4;//sets number of internally buffered audio frames sl@0: sl@0: class CMMFCodec; //fwd ref sl@0: class CAudioBufferArray; sl@0: class TSBCFrameParameters; sl@0: class CA2dpCodecUtilities; sl@0: sl@0: /** sl@0: Callback class implemented by CA2dpBTHeadsetAudioInterface to get error events sl@0: back from CActiveRTPStreamer sl@0: */ sl@0: class MRTPStreamerObserver sl@0: { sl@0: public: sl@0: /** sl@0: Callback when the CRtpSendPackets detects an error condition sl@0: event sl@0: sl@0: @internalComponent sl@0: @param aError standard SymbianOS error sl@0: */ sl@0: void virtual RTPStreamerEvent(TInt aError) = 0; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: RTP Streamer used by the CA2dpBTHeadsetAudioInterface. sl@0: This class is used by the CA2dpBTHeadsetAudioInterface in order to stream sl@0: buffers of audio to the headset. The CActiveRTPStreamer can buffer a number sl@0: of buffers internally set by the KSendBucketSize. sl@0: sl@0: @internalComponent sl@0: */ sl@0: NONSHARABLE_CLASS(CActiveRTPStreamer) : public CTimer sl@0: { sl@0: public: sl@0: static CActiveRTPStreamer* NewL(RSocket& aSock, MRTPStreamerObserver& aRTPStreamerObserver); sl@0: ~CActiveRTPStreamer(); sl@0: sl@0: //callbacks from RTP sl@0: static void RTPCallback(CActiveRTPStreamer* aStreamer, const TRtpEvent& aEvent); sl@0: static void RTPSendSourceCallback(CActiveRTPStreamer* aStreamer, const TRtpEvent& aEvent); sl@0: sl@0: void SetCodec(CMMFCodec& aCodec); sl@0: void SetAudioConfiguration(const CA2dpAudioCodecConfiguration& aAudioCodecConfiguration); sl@0: void Send(const TDesC8& aData, TRequestStatus& aStatus); sl@0: void Pause(); sl@0: void Resume(); sl@0: void CancelLastSendBuffer(); sl@0: void FlushPendingSendBuffers(); sl@0: TUint BytesSent() const; sl@0: void ResetBytesSent(); sl@0: private: sl@0: CActiveRTPStreamer(MRTPStreamerObserver& aRTPStreamerObserver); sl@0: void ConstructL(RSocket& aSock); sl@0: void InitializeForSendL(const TDesC8& aData); sl@0: TUint CodecProcessPayloadL(const TDesC8& aData, TDes8& aPayload); sl@0: void PacketSent(TRtpEventType aEvent); sl@0: void RTPSessionEvent(const TRtpEvent& aEvent); sl@0: void CompleteSendRequestStatus(TInt aError); sl@0: sl@0: //CActive sl@0: void RunL(); sl@0: void DoCancel(); sl@0: private: sl@0: MRTPStreamerObserver& iRTPStreamerObserver; sl@0: CAudioBufferArray* iAudioBufferArray; //this class is owned sl@0: TTimeIntervalMicroSeconds32 iRTPPacketDuration; sl@0: RRtpSession iRTPSession; sl@0: RRtpSendSource iRTPSendSource; sl@0: TRtpEventType iRTPEventType; sl@0: TBool iRtpCanSend; sl@0: TRequestStatus* iSendStatus; sl@0: TUint iMaxMTULength; sl@0: TUint iFrameLength; sl@0: TUint iBufferLength; sl@0: TUint iNumberOfInputBytesToMakeRTPPacket; sl@0: TUint8 iPayloadType; sl@0: TUint iTimeStampIncrement; sl@0: TUint iTimeStamp; sl@0: TBuf8<4> iMediaPayloadHeader; sl@0: TUint iBitRate; sl@0: TUint iBytesSent; sl@0: TBool iBufferParamsInitialized; sl@0: TBool iPaused; sl@0: TInt iUnrecoverableError; sl@0: TUint iSendBufferSize; sl@0: sl@0: //these classes aren't owned sl@0: CMMFCodec* iCodec; sl@0: CA2dpAudioCodecConfiguration* iA2dpAudioCodecConfiguration; sl@0: }; sl@0: sl@0: #endif sl@0: