|
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 Datasink |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #ifndef MCCRTPDATASINK_H |
|
23 #define MCCRTPDATASINK_H |
|
24 |
|
25 // INCLUDES |
|
26 #include "rtpapi.h" |
|
27 #include "mccdatasink.h" |
|
28 #include "mccrtpinterface.h" |
|
29 #include "rtpdatasink.h" |
|
30 #include "mccrtpsender.h" |
|
31 |
|
32 #ifdef FTD_ENABLED |
|
33 #include <e32msgqueue.h> |
|
34 #include "Mccstreamstats.h" |
|
35 #endif |
|
36 |
|
37 // CONSTANTS |
|
38 |
|
39 // MACROS |
|
40 |
|
41 // DATA TYPES |
|
42 |
|
43 // FUNCTION PROTOTYPES |
|
44 |
|
45 // FORWARD DECLARATIONS |
|
46 class MDataSource; |
|
47 |
|
48 // CLASS DECLARATION |
|
49 |
|
50 /** |
|
51 * Mcc RTP DataSink send RTP packet using to RtpAPI |
|
52 * |
|
53 * @lib MccRtpSourceSink.dll |
|
54 * @since Series 60 3.0 |
|
55 */ |
|
56 class CMccRtpDataSink : public CMccDataSink, |
|
57 public MMccRtpInterface, |
|
58 public MMccRtpDataSink, |
|
59 public MMccRtpSenderObserver |
|
60 { |
|
61 public: // Constructors and destructor |
|
62 |
|
63 /** |
|
64 * Two-phased constructor. Virtual function from MDataSink |
|
65 */ |
|
66 static MDataSink* NewSinkL( TUid aImplementationUid, |
|
67 const TDesC8& aInitData ); |
|
68 |
|
69 /** |
|
70 * Destructor. |
|
71 */ |
|
72 virtual ~CMccRtpDataSink(); |
|
73 |
|
74 public: // New functions |
|
75 |
|
76 /** |
|
77 * Returns Synchronization source. |
|
78 * @since Series 60 3.0 |
|
79 * @param None |
|
80 * @return Synchronization source value |
|
81 */ |
|
82 inline TRtpSSRC GetSSRC() const |
|
83 { |
|
84 return iSSRC; |
|
85 } |
|
86 |
|
87 /** |
|
88 * Sets rtp media clock instance for data sink. Instance is forwarded |
|
89 * to rtp keep alive sender. |
|
90 * |
|
91 * @since Series 60 3.0 |
|
92 * @param aRtpMediaClock media clock instance |
|
93 * @return void |
|
94 */ |
|
95 virtual void SetMediaClock( CMccRtpMediaClock& aRtpMediaClock ); |
|
96 |
|
97 /** |
|
98 * Mutes/Unmutes RTP sink. When mute is enabled, only packets with |
|
99 * exception payload type are sent. |
|
100 * |
|
101 * @since Series 60 3.2 |
|
102 * @param aMuteOn When ETrue mute is enabled |
|
103 * @param aExceptionPt Payload to send regardless of mute state |
|
104 */ |
|
105 virtual void Mute( TBool aMuteOn, TUint8 aExceptionPt ); |
|
106 |
|
107 public: // From CMccDataSink |
|
108 |
|
109 virtual void SetCurrentUser( MAsyncEventHandler* aEventHandler ); |
|
110 |
|
111 public: // From MDataSink |
|
112 |
|
113 /** |
|
114 * From MDataSink. Pure virtual function that must be implemented. |
|
115 * Out of usage. Leave KErrNotSupported. |
|
116 * @since Series 60 3.0 |
|
117 * @param "aBuffer" Out of usage |
|
118 * @param "aSupplier" Out of usage |
|
119 * @param "aMediaId" Out of usage |
|
120 * @return void |
|
121 */ |
|
122 void EmptyBufferL( CMMFBuffer* aBuffer, |
|
123 MDataSource* aSupplier, |
|
124 TMediaId aMediaId ); |
|
125 |
|
126 /** |
|
127 * From MDataSink Method to 'logon' the data source to |
|
128 * the same thread that source will be supplying data in. |
|
129 * @since Series 60 3.0 |
|
130 * @param aEventHandler for send event to datasource when buffer is embtied. |
|
131 * @return KErrNone if successful, otherwise a system wide error code. |
|
132 */ |
|
133 TInt SinkThreadLogon( MAsyncEventHandler& aEventHandler ); |
|
134 |
|
135 /** |
|
136 * From MDataSink Method to 'logoff' the data source from |
|
137 * the same thread that source supplies data in. |
|
138 * @since Series 60 3.0 |
|
139 * @param None |
|
140 * @return void |
|
141 */ |
|
142 void SinkThreadLogoff(); |
|
143 |
|
144 /** |
|
145 * From MDataSink pure virtual function that must be implemented. |
|
146 * Returns the data type as a fourCC code of the data sink. |
|
147 * @since Series 60 3.0 |
|
148 * @param "aMediaId" This identifies the type of media eg audio and the stream id. |
|
149 * This parameter is required in cases where the sink can accept data |
|
150 * of more than one media type. |
|
151 * @return the datatype code ( codec ). |
|
152 */ |
|
153 TFourCC SinkDataTypeCode( TMediaId aMediaId ); |
|
154 |
|
155 /** |
|
156 * From MDataSink pure virtual function that must be implemented. |
|
157 * Sets the data type as a fourCC code for the data sink. |
|
158 * @since Series 60 3.0 |
|
159 * @param "aSinkFourCC" This specifies the data type as a fourCC code to set the sink to |
|
160 * @param "aMediaId" This identifies the type of media eg audio and the stream id. |
|
161 * @return KErrNone if successful. |
|
162 * @return KErrLocked if Sink thread locked. Codec must to be set before thread logon. |
|
163 * @return KErrNotSupported if the sink does not support media type. |
|
164 */ |
|
165 TInt SetSinkDataTypeCode( TFourCC aCodec, TMediaId aMedia ); |
|
166 |
|
167 /** |
|
168 * From MDataSink pure virtual function that must be implemented. |
|
169 * Out of usage. Function leaves with KErrNotSupported. |
|
170 * @since Series 60 3.0 |
|
171 * @param "aCodec" Out of usage |
|
172 * @param aMedia Out of usage |
|
173 * @return void |
|
174 */ |
|
175 void BufferFilledL( CMMFBuffer* aBuffer ); |
|
176 |
|
177 /** |
|
178 * From MDataSink pure virtual function that must be implemented. |
|
179 * Method to indicate whether the data sink can create a buffer. |
|
180 * @deprecated |
|
181 * |
|
182 * @since Series 60 3.0 |
|
183 * @param "aBuffer" Out of usage |
|
184 * @return False |
|
185 */ |
|
186 TBool CanCreateSinkBuffer(); |
|
187 |
|
188 /** |
|
189 * From MDataSink pure virtual function that must be implemented. |
|
190 * Out of usage. Function leaves with KErrNotSupported. |
|
191 * @deprecated |
|
192 * |
|
193 * @since Series 60 3.0 |
|
194 * @param "aMediaId" Out of usage. |
|
195 * @param "aReference" Out of useage. |
|
196 * @return |
|
197 */ |
|
198 CMMFBuffer* CreateSinkBufferL( TMediaId /*aMediaId*/, |
|
199 TBool& aReference ); |
|
200 |
|
201 /** |
|
202 * From MDataSink. This is a virtual function that a derived data sink |
|
203 * can implement if any data sink specific 'priming' is required |
|
204 * @since Series 60 3.0 |
|
205 * @param None |
|
206 * @return void |
|
207 */ |
|
208 void SinkPrimeL(); |
|
209 |
|
210 /** |
|
211 * From MDataSink. This is a virtual function that a derived data sink can implement if |
|
212 * any data sink specific action is required prior to 'playing'ie the |
|
213 * start of data transfer |
|
214 * @since Series 60 3.0 |
|
215 * @param None |
|
216 * @return void |
|
217 */ |
|
218 void SinkPlayL(); |
|
219 |
|
220 /** |
|
221 * From MDataSink. This is a virtual function that a derived data sink can implement if |
|
222 * any data sink specific action is required to 'pause' |
|
223 * @since Series 60 3.0 |
|
224 * @param None |
|
225 * @return void |
|
226 */ |
|
227 void SinkPauseL(); |
|
228 |
|
229 /** |
|
230 * From MDataSink. This is a virtual function that a derived data sink can implement if |
|
231 * any data sink specific action is required to 'stop' |
|
232 * @since Series 60 3.0 |
|
233 * @param None |
|
234 * @return void |
|
235 */ |
|
236 void SinkStopL(); |
|
237 |
|
238 /** |
|
239 * From MDataSink. Used for custom command receiving. |
|
240 * @since Series 60 3.0 |
|
241 * @param aMessage The message specifying the custom command. |
|
242 * @return void |
|
243 */ |
|
244 void SinkCustomCommand( TMMFMessage& aMessage ); |
|
245 |
|
246 |
|
247 |
|
248 public: // From MMccRtpInterface |
|
249 |
|
250 |
|
251 /** |
|
252 * From CRtpInterface Sends media signals (RTCP) |
|
253 * @since Series 60 3.0 |
|
254 * @param aSignal Signal to be sent |
|
255 * @return void |
|
256 */ |
|
257 virtual void SendMediaSignallingL( const TMccEvent& aEvent ); |
|
258 |
|
259 /** |
|
260 * Sends Non-RTCP data |
|
261 * @param aData - [input] Data to send |
|
262 * @return One of the standard system-wide error codes. |
|
263 */ |
|
264 virtual void SendRTCPDataL( const TDesC8& aData ); |
|
265 |
|
266 virtual TBool HandleBySsrc( const TRtpSSRC& aSsrc ); |
|
267 |
|
268 TRtpId RtpStreamId(); |
|
269 |
|
270 virtual TBool IsSink() const; |
|
271 |
|
272 virtual TBool IsSending() const; |
|
273 |
|
274 void DoCreateSrtpStreamL(); |
|
275 |
|
276 |
|
277 public: // From MMccRtpDataSink |
|
278 |
|
279 /** |
|
280 * From MMccRtpDataSink. Empties specified buffer. |
|
281 * |
|
282 * @since Series 60 3.0 |
|
283 * @param aBuffer Buffer containing the RTP packet |
|
284 * @param aSupplier Data source to notify when buffer is emptied |
|
285 * @param aMediaId Identifies the media type of a particular stream |
|
286 * @param aHeaderInfo RTP packet header |
|
287 * @return void |
|
288 */ |
|
289 void EmptyBufferL( CMMFBuffer* aBuffer, |
|
290 MDataSource* aSupplier, |
|
291 TMediaId aMediaId, |
|
292 TRtpSendHeader& aHeaderInfo ); |
|
293 |
|
294 |
|
295 protected: // Functions from base classes |
|
296 |
|
297 /** |
|
298 * Method to perform any sink construction dependant on the sink construction |
|
299 * initialisation data aInitData |
|
300 * |
|
301 * This is a pure virtual function that a derrived data sink must implement |
|
302 * |
|
303 * @param "aInitData" |
|
304 * Sink specific initialisation data required for sink construction |
|
305 */ |
|
306 void ConstructSinkL( const TDesC8& aInitData ); |
|
307 |
|
308 protected: // From CMccRtpInterface |
|
309 |
|
310 /** |
|
311 * From CMccRtpInterface |
|
312 */ |
|
313 void DoCreateStreamL(); |
|
314 |
|
315 protected: // From MMccRtpSenderObserver |
|
316 |
|
317 void SendErrorOccured( TInt aError ); |
|
318 |
|
319 private: |
|
320 |
|
321 /** |
|
322 * C++ default constructor. |
|
323 */ |
|
324 CMccRtpDataSink(); |
|
325 |
|
326 void SendStreamEventToClient( TMccEventType aEventType, |
|
327 TInt aError = KErrNone ); |
|
328 |
|
329 TMccRtpUser* FindRtpUserEntryForCurrent( MAsyncEventHandler& aEventHandler ); |
|
330 |
|
331 void RemoveCurrentRtpUser(); |
|
332 |
|
333 static TBool RtpUserMatch( const TMccRtpUser& aUser1, |
|
334 const TMccRtpUser& aUser2 ); |
|
335 |
|
336 TBool SendingAllowed( const TRtpSendHeader& aHeaderInfo ) const; |
|
337 |
|
338 private: // From MSRTPReKeyingObserver |
|
339 |
|
340 /** |
|
341 * FROM SRTP API |
|
342 * |
|
343 * This function is called by SRTP when a master key is stale and |
|
344 * needs to be refreshed. |
|
345 */ |
|
346 void SRTPMasterKeyStaleEvent(const CSRTPStream& aStream); |
|
347 |
|
348 /** |
|
349 * FROM SRTP API |
|
350 * |
|
351 * This function is called by SRTP Stream initiated with |
|
352 * CSRTPSession when a master key is stale and |
|
353 * needs to be refreshed. |
|
354 */ |
|
355 void SRTPMasterKeyStaleEvent(const CSRTPSession& aSession ); |
|
356 |
|
357 private: // Data |
|
358 |
|
359 // Pointer to buffer, which datapath has requested to be emptied |
|
360 CMMFDataBuffer* iBufferToBeEmptied; // Uses |
|
361 |
|
362 // Pointer to datasource for notify when buffer is emptied |
|
363 MDataSource* iDataSource; // Uses |
|
364 |
|
365 // Synchronization source identifier. |
|
366 TRtpSSRC iSSRC; |
|
367 |
|
368 // Stream ID for media packets |
|
369 TRtpId iRtpStreamId; |
|
370 |
|
371 // Registered users for sink |
|
372 RArray<TMccRtpUser> iUsers; |
|
373 |
|
374 // flag for secure key expired |
|
375 TBool iSecureKeyExpired; |
|
376 |
|
377 // flag indicating is mute enabled |
|
378 TBool iMuteOn; |
|
379 |
|
380 // payload to sent regardless of mute state |
|
381 TUint8 iExceptionPt; |
|
382 |
|
383 CMccRtpSender* iSender; |
|
384 |
|
385 TMediaId iMedia; |
|
386 |
|
387 #ifdef FTD_ENABLED |
|
388 |
|
389 // Message queue carrying stream statistics |
|
390 RMsgQueue<TMccStreamStats> iStreamStatsQueue; |
|
391 |
|
392 // Number of packets sent |
|
393 TUint32 iPacketsSent; |
|
394 |
|
395 #endif |
|
396 |
|
397 #ifdef TEST_EUNIT |
|
398 public: |
|
399 friend class UT_CMccRtpDataSink; |
|
400 #endif |
|
401 }; |
|
402 |
|
403 #endif // MCCRTPDATASINK_H |
|
404 |
|
405 // End of File |