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