|
1 /* |
|
2 * Copyright (c) 2002-2008 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 Keepalive mechanism |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef MCCRTPKEEPALIVE_H |
|
22 #define MCCRTPKEEPALIVE_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include "rtpdef.h" |
|
27 #include "rtpapi.h" |
|
28 #include "rtpheader.h" |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 // MACROS |
|
33 |
|
34 // DATA TYPES |
|
35 |
|
36 // FUNCTION PROTOTYPES |
|
37 |
|
38 // FORWARD DECLARATIONS |
|
39 class MAsyncEventHandler; |
|
40 class MMccResources; |
|
41 class MMccRtpInterface; |
|
42 class CMccRtpMediaClock; |
|
43 |
|
44 // CLASS DECLARATION |
|
45 |
|
46 /** |
|
47 * |
|
48 */ |
|
49 NONSHARABLE_CLASS( CMccRtpKeepalive ) : public CActive |
|
50 { |
|
51 public: // enums |
|
52 |
|
53 enum TMccRtpKeepaliveState |
|
54 { |
|
55 EIdle, |
|
56 ESending, |
|
57 EWaitingTimer, |
|
58 ESendingPending |
|
59 }; |
|
60 |
|
61 public: // Constructors and destructor |
|
62 |
|
63 /** |
|
64 * Two-phased constructor. |
|
65 */ |
|
66 static CMccRtpKeepalive* NewL( MAsyncEventHandler& aEventHandler, |
|
67 CRtpAPI& aRtpAPI, |
|
68 TRtpId aRtpSessionId, |
|
69 TUint8 aKeepalivePayloadType, |
|
70 TUint8 aKeepaliveInterval, |
|
71 const TDesC8& aKeepaliveData, |
|
72 TBool aRemoteAddressSet ); |
|
73 |
|
74 /** |
|
75 * Destructor |
|
76 */ |
|
77 virtual ~CMccRtpKeepalive(); |
|
78 |
|
79 public: // New functions |
|
80 |
|
81 /** |
|
82 * Start sending keepalive packets. |
|
83 * |
|
84 * @since Series 60 3.2 |
|
85 * @param aUser rtp interface instance |
|
86 * @param aRtpMediaClock rtp media clock instance |
|
87 * @return void |
|
88 */ |
|
89 void StartKeepaliveL( MMccRtpInterface& aUser, |
|
90 CMccRtpMediaClock& aRtpMediaClock ); |
|
91 |
|
92 /** |
|
93 * Stop sending keepalive packets. |
|
94 * |
|
95 * @since Series 60 3.2 |
|
96 * @param aUser rtp interface instance |
|
97 * @param aRefCount array index to rtp interface intance array |
|
98 * @return One of the standard system-wide error codes. |
|
99 */ |
|
100 TInt StopKeepalive( MMccRtpInterface& aUser, TInt& aRefCount ); |
|
101 |
|
102 /** |
|
103 * Reset keepalive timer. |
|
104 * |
|
105 * @since Series 60 3.2 |
|
106 * @param None |
|
107 * @return void |
|
108 */ |
|
109 void ResetKeepaliveTimer(); |
|
110 |
|
111 /** |
|
112 * Getter function for rtp stream id. |
|
113 * |
|
114 * @since Series 60 3.2 |
|
115 * @param None |
|
116 * @return rtp stream Id. |
|
117 */ |
|
118 TRtpId StreamId() const; |
|
119 |
|
120 TUint8 PayloadType() const; |
|
121 |
|
122 TInt RemoteAddressSet(); |
|
123 |
|
124 /** |
|
125 * Function for checking if there is a sink in the array. |
|
126 * |
|
127 * @since Series 60 3.2 |
|
128 * @return ETrue if sink exits |
|
129 */ |
|
130 TBool IsForSink(); |
|
131 |
|
132 /** |
|
133 * Update session keepalive parameters |
|
134 * |
|
135 * @since Series 60 3.2 |
|
136 * @param aKeepalivePT payload type for keepalive |
|
137 * @param aKeepaliveInterval interval to execute packet sending |
|
138 * @param aKeepaliveData data to add in keepalive packets |
|
139 * @return void |
|
140 */ |
|
141 void UpdateParamsL( TUint8 aKeepalivePT, |
|
142 TUint8 aKeepaliveInterval, |
|
143 const TDesC8& aKeepaliveData ); |
|
144 |
|
145 protected: // New functions |
|
146 |
|
147 protected: // Functions from CActive |
|
148 |
|
149 void RunL(); |
|
150 |
|
151 void DoCancel(); |
|
152 |
|
153 TInt RunError( TInt aError ); |
|
154 |
|
155 private: // New functions |
|
156 |
|
157 TBool ResolveActivity(); |
|
158 |
|
159 TInt ToggleKeepaliveSending( TBool aIsActive ); |
|
160 |
|
161 TInt StartSending(); |
|
162 |
|
163 TInt Send(); |
|
164 |
|
165 TUint16 Random() const; |
|
166 |
|
167 void SendErrorToClient( TInt aError ); |
|
168 |
|
169 private: // Constructors |
|
170 |
|
171 /** |
|
172 * C++ default constructor. |
|
173 */ |
|
174 CMccRtpKeepalive( MAsyncEventHandler& aEventHandler, |
|
175 CRtpAPI& aRtpAPI, |
|
176 TRtpId aRtpSessionId, |
|
177 TBool aRemoteAddressSet ); |
|
178 |
|
179 /** |
|
180 * By default Symbian 2nd phase constructor is private. |
|
181 */ |
|
182 void ConstructL( TUint8 aKeepalivePayloadType, |
|
183 TUint8 aKeepaliveInterval, |
|
184 const TDesC8& aKeepaliveData ); |
|
185 |
|
186 public: // Data |
|
187 |
|
188 protected: // Data |
|
189 |
|
190 private: // Data |
|
191 |
|
192 // Callback for errors |
|
193 MAsyncEventHandler& iEventHandler; |
|
194 |
|
195 // RTP stack API reference |
|
196 CRtpAPI& iRtpAPI; |
|
197 |
|
198 TRtpId iRtpSessionId; |
|
199 |
|
200 // Stream id for the RTP Keepalive transmit stream |
|
201 TRtpId iRtpStreamId; |
|
202 |
|
203 RTimer iTimer; |
|
204 |
|
205 TMccRtpKeepaliveState iCurrentState; |
|
206 |
|
207 TRtpSSRC iSSRC; |
|
208 |
|
209 TRtpSequence iSequenceNum; |
|
210 |
|
211 TRtpSendHeader iRtpHeaderInfo; |
|
212 |
|
213 TInt iKeepaliveInterval; |
|
214 |
|
215 HBufC8* iKeepaliveData; |
|
216 |
|
217 TTime iInitialTime; |
|
218 TTime iCurrentTime; |
|
219 |
|
220 RPointerArray<MMccRtpInterface> iUsers; |
|
221 |
|
222 TBool iRemoteAddressSet; |
|
223 |
|
224 /** |
|
225 * Boolean indicating if rtp sink exists. |
|
226 */ |
|
227 TBool iRtpSinkExists; |
|
228 |
|
229 /** |
|
230 * Rtp sink index in iUsers array. |
|
231 */ |
|
232 TUint iRtpSinkIndex; |
|
233 |
|
234 /** |
|
235 * Rtp media clock instance |
|
236 * Not own. |
|
237 */ |
|
238 CMccRtpMediaClock* iRtpMediaClock; |
|
239 |
|
240 /** |
|
241 * Boolean indicating if pre audio keep alive packet is sent |
|
242 */ |
|
243 TBool iPreAudioPacketSent; |
|
244 |
|
245 |
|
246 public: // Friend classes |
|
247 |
|
248 protected: // Friend classes |
|
249 |
|
250 private: // Friend classes |
|
251 |
|
252 #ifdef TEST_EUNIT |
|
253 friend class UT_CMccRtpKeepalive; |
|
254 #endif |
|
255 }; |
|
256 |
|
257 #endif // MCCRTPKEEPALIVE_H |
|
258 |
|
259 // End of File |