|
1 /* |
|
2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: RTP sender |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #ifndef MCCRTPSENDER_H |
|
23 #define MCCRTPSENDER_H |
|
24 |
|
25 // INCLUDES |
|
26 #include <e32base.h> |
|
27 #include "rtpapi.h" |
|
28 #include "rtpheader.h" |
|
29 #include "mccexpirationhandler.h" |
|
30 |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CMccRtpSendItem; |
|
34 class CMccTimerManager; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 // |
|
38 |
|
39 class MMccRtpSenderObserver |
|
40 { |
|
41 public: |
|
42 virtual void SendErrorOccured( TInt aError ) = 0; |
|
43 }; |
|
44 |
|
45 class CMccRtpSender : public CActive, public MMccExpirationHandler |
|
46 { |
|
47 public: |
|
48 |
|
49 /** |
|
50 * Create asynchronous rtp sender. |
|
51 * |
|
52 * @param aObserver |
|
53 * @param aRtpApi |
|
54 * @param aSessionId |
|
55 * @param aDoMarkerBasedCleanup |
|
56 */ |
|
57 static CMccRtpSender* NewL( MMccRtpSenderObserver& aObserver, |
|
58 CRtpAPI& aRtpApi, |
|
59 TRtpId aSessionId, |
|
60 TBool aDoMarkerBasedCleanup ); |
|
61 |
|
62 ~CMccRtpSender(); |
|
63 |
|
64 /** |
|
65 * Send rtp packet asynchronously. If previous send is pending, packet |
|
66 * is queued unless the queue is full. In that case the packet is discarded. |
|
67 * |
|
68 * @param aRtpStreamId |
|
69 * @param aRtpHeader |
|
70 * @param aData |
|
71 */ |
|
72 void SendRtpPacketL( TRtpId aRtpStreamId, |
|
73 const TRtpSendHeader& aRtpHeader, |
|
74 const TDesC8& aData ); |
|
75 |
|
76 /** |
|
77 * Send a non-RTP (control) data packet. |
|
78 * @param aSessionId RTP Session ID |
|
79 * @param aUseRtpSocket Whether to use RTP or RTCP socket |
|
80 * @param aData Non-RTP data packet to send |
|
81 */ |
|
82 void SendDataL( TRtpId aSessionId, TBool aUseRtpSocket, |
|
83 const TDesC8& aData ); |
|
84 |
|
85 /** |
|
86 * Cancels pending send operation and empties the queue. |
|
87 */ |
|
88 void Clear(); |
|
89 |
|
90 protected: // From CActive |
|
91 |
|
92 void RunL(); |
|
93 |
|
94 void DoCancel(); |
|
95 |
|
96 TInt RunError( TInt aError ); |
|
97 |
|
98 protected: // From MMccExpirationHandler |
|
99 |
|
100 void TimerExpiredL( TMccTimerId aTimerId, TAny* aTimerParam ); |
|
101 |
|
102 private: |
|
103 |
|
104 void ConstructL(); |
|
105 |
|
106 CMccRtpSender( MMccRtpSenderObserver& aObserver, |
|
107 CRtpAPI& aRtpApi, |
|
108 TRtpId aSessionId, |
|
109 TBool aDoMarkerBasedCleanup ); |
|
110 |
|
111 void SendPacketL(); |
|
112 |
|
113 void RemovePacket( TBool aDoQueueCleanup = EFalse ); |
|
114 |
|
115 TBool ErrorReport( TInt aError ); |
|
116 |
|
117 TBool CheckDiscarding( const TRtpSendHeader& aRtpHeader ); |
|
118 |
|
119 /** |
|
120 * If packet for which aRtpHeader belongs was zero marker frame, |
|
121 * that packet and everything related to that frame is removed from |
|
122 * queue. If full frame couldn't yet be removed, upcoming parts |
|
123 * of the frame are discarded once they are tried to be sent. |
|
124 * |
|
125 * @param aItemIndex |
|
126 * @param aRtpHeader |
|
127 * @return ETrue if queue item in aItemIndex was deleted, otherwise |
|
128 * return EFalse |
|
129 */ |
|
130 TBool DoQueueCleanup( TInt aItemIndex, const TRtpSendHeader& aRtpHeader ); |
|
131 |
|
132 private: |
|
133 |
|
134 MMccRtpSenderObserver& iObserver; |
|
135 |
|
136 CRtpAPI& iRtpApi; |
|
137 |
|
138 TRtpId iSessionId; |
|
139 |
|
140 CMccTimerManager* iTimeoutTimer; |
|
141 |
|
142 RPointerArray<CMccRtpSendItem> iSendQueue; |
|
143 |
|
144 TBool iDoMarkerBasedCleanup; |
|
145 |
|
146 TBool iDiscarding; |
|
147 |
|
148 TUint32 iTimeoutTimeMilliseconds; |
|
149 |
|
150 TMccTimerId iTimerId; |
|
151 |
|
152 #ifdef TEST_EUNIT |
|
153 public: |
|
154 friend class UT_CMccRtpSender; |
|
155 #endif |
|
156 |
|
157 }; |
|
158 |
|
159 class CMccRtpSendItem : public CBase |
|
160 { |
|
161 public: |
|
162 |
|
163 static CMccRtpSendItem* NewLC( TRtpId aRtpStreamId, |
|
164 const TRtpSendHeader& aRtpHeader, |
|
165 const TDesC8& aData ); |
|
166 |
|
167 static CMccRtpSendItem* NewLC( TRtpId aSessionId, |
|
168 TBool aUseRtpSocket, const TDesC8& aData ); |
|
169 |
|
170 ~CMccRtpSendItem(); |
|
171 |
|
172 const TDesC8& DataPtr() const; |
|
173 |
|
174 TRtpId RtpStreamId() const; |
|
175 |
|
176 const TRtpSendHeader& RtpHeader() const; |
|
177 |
|
178 TRtpId SessionId() const; |
|
179 |
|
180 TBool UseRtpSocket() const; |
|
181 |
|
182 private: |
|
183 |
|
184 void ConstructL( const TDesC8& aData ); |
|
185 |
|
186 CMccRtpSendItem( TRtpId aRtpStreamId, const TRtpSendHeader& aRtpHeader ); |
|
187 |
|
188 CMccRtpSendItem( TRtpId aSessionId, TBool aUseRtpSocket ); |
|
189 |
|
190 private: |
|
191 |
|
192 HBufC8* iData; |
|
193 |
|
194 TRtpId iRtpStreamId; |
|
195 TRtpSendHeader iRtpHeader; |
|
196 |
|
197 TPtrC8 iDataPtr; |
|
198 |
|
199 TRtpId iSessionId; |
|
200 TBool iUseRtpSocket; |
|
201 |
|
202 private: // Friend classes |
|
203 |
|
204 #ifdef TEST_EUNIT |
|
205 friend class UT_CMccRtpSender; |
|
206 #endif |
|
207 }; |
|
208 |
|
209 #endif // MCCRTPSENDER_H |
|
210 |
|
211 // End of File |