|
1 /* |
|
2 * Copyright (c) 2006 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef MCCVIDEOSINKIMPL_H |
|
22 #define MCCVIDEOSINKIMPL_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32std.h> |
|
26 #include <w32std.h> |
|
27 #include <in_sock.h> |
|
28 #include <es_sock.h> |
|
29 #include <mmf/common/mmfcontrollerframeworkbase.h> |
|
30 #include <videoplayer.h> |
|
31 |
|
32 #include "rtpdef.h" |
|
33 #include "rtpheader.h" |
|
34 #include "CXPSPktSinkObserver.h" |
|
35 #include "mmccevents.h" |
|
36 #include "mmccinterfacedef.h" |
|
37 |
|
38 // Minimun packet size allowed, smaller packets are dropped. |
|
39 const TInt KMccMinPacketSize = 4; |
|
40 |
|
41 |
|
42 // MACROS |
|
43 |
|
44 // DATA TYPES |
|
45 |
|
46 // FUNCTION PROTOTYPES |
|
47 |
|
48 // FORWARD DECLARATIONS |
|
49 class CVideoPlayerUtility2; |
|
50 class MVideoLoadingObserver; |
|
51 class MVideoPlayerUtilityObserver; |
|
52 class TRtpSdesParams; |
|
53 class TSetupParameters; |
|
54 class RWsSession; |
|
55 class RWindowGroup; |
|
56 class RWindow; |
|
57 class CWsScreenDevice; |
|
58 class TMccCodecInfo; |
|
59 class TMccVideoSinkSetting; |
|
60 class CXPSPacketSink; |
|
61 class CMccVideoSinkUser; |
|
62 class MAsyncEventHandler; |
|
63 class MDataSource; |
|
64 class CMccRedrawHandler; |
|
65 |
|
66 // CLASS DECLARATION |
|
67 |
|
68 |
|
69 /** |
|
70 * IP DL Media Interface class which is a wrapper of CVideoPlayerUtility class and |
|
71 * provides services for downlink audio/video streaming and playing. |
|
72 * |
|
73 * @lib |
|
74 * @since |
|
75 */ |
|
76 class CMccVideoSinkImpl : |
|
77 public CBase, |
|
78 public MVideoPlayerUtilityObserver, |
|
79 public MVideoLoadingObserver, |
|
80 public MXPSPktSinkObserver |
|
81 { |
|
82 public: |
|
83 |
|
84 enum TMccVideoSinkState |
|
85 { |
|
86 ENotSet, |
|
87 EOpening, |
|
88 EOpened, |
|
89 EPrepared, |
|
90 EPlaying, |
|
91 EPaused, |
|
92 EStopped |
|
93 }; |
|
94 |
|
95 public: // Constructors and destructor |
|
96 |
|
97 /** |
|
98 * Two-phased constructor. |
|
99 * @since |
|
100 * @param TMccVideoSinkSetting aSettings - settings for the sink |
|
101 * @return CMccVideoSinkImpl* - Pointer to the interface object created; NULL if in error |
|
102 */ |
|
103 static CMccVideoSinkImpl* NewL( const TMccVideoSinkSetting& aSettings, |
|
104 TUint32 aEndpointId ); |
|
105 |
|
106 |
|
107 /** |
|
108 * Destructor. |
|
109 */ |
|
110 virtual ~CMccVideoSinkImpl(); |
|
111 |
|
112 public: |
|
113 |
|
114 TInt SinkThreadLogon( MAsyncEventHandler& aEventHandler ); |
|
115 |
|
116 /** |
|
117 * Log off current user |
|
118 * @return ETrue if there's no more users for the sink |
|
119 */ |
|
120 TBool SinkThreadLogoff(); |
|
121 |
|
122 void SetCurrentUser( MAsyncEventHandler* aEventHandler ); |
|
123 |
|
124 public: // New functions |
|
125 |
|
126 /** |
|
127 * Open the Video Play Engine. |
|
128 * @since |
|
129 * @param TInt aIapId - [input] An IAP Id. Default is KUserDefaultIap, which will cause |
|
130 * the access point selection window popped up. |
|
131 * @leave Can leave with one of the system wide error codes |
|
132 * @reutrn None. |
|
133 */ |
|
134 void OpenL(); |
|
135 |
|
136 /** |
|
137 * Make the Video Play Engine do preparation for playing. |
|
138 * @since Series-60 2.1 |
|
139 * @reutrn None. |
|
140 */ |
|
141 void Prepare(); |
|
142 |
|
143 /** |
|
144 * The parameters needed for remote setup and swis communication. |
|
145 * @since |
|
146 * @param TInetAddr& aRemoteAddrAudio - [input] Remote IP address and RTP port number to use |
|
147 * for audio stream |
|
148 * @param TInetAddr& aRemoteAddrVideo - [input] Remote IP address and RTP port number to use |
|
149 * for video stream |
|
150 * @param TDesC8& aSdpText - [input] Whole content of finalized SDP (Session Description Protocol) text |
|
151 * |
|
152 * @param TTimeIntervalMicroSeconds32& aPausedTimeOut - [input] The time for detection of downlink |
|
153 * audio/video packet traffic has been paused by uplink. |
|
154 * @param TTimeIntervalMicroSeconds32& aDisconnectedTimeOut - [input] The time for detection of downlink |
|
155 * audio/video packet traffic has been disconnected. |
|
156 * @return TInt - KErrNone if successful; system-wide error code otherwise |
|
157 */ |
|
158 void RemoteSetupL(); |
|
159 |
|
160 /** |
|
161 * Start to receive and play downlink audio/video streams. |
|
162 * @since |
|
163 * @param None |
|
164 * @return TInt - KErrNone if successful; system-wide error code otherwise |
|
165 */ |
|
166 void StartL(); |
|
167 |
|
168 /** |
|
169 * Stop receiving and playing of downlink audio/video streams. |
|
170 * @since |
|
171 * @param None |
|
172 * @return None |
|
173 */ |
|
174 void Stop(); |
|
175 |
|
176 /** |
|
177 * Pause receiving and playing of downlink audio/video streams. |
|
178 * @since |
|
179 * @param None |
|
180 * @return None |
|
181 */ |
|
182 void PauseL(); |
|
183 |
|
184 /** |
|
185 * Close and shut down the IP DL Media subsystem. |
|
186 * @since |
|
187 * @param None |
|
188 * @return None |
|
189 */ |
|
190 void Close(); |
|
191 |
|
192 /** |
|
193 * Set the Display Window. This is used to provide the video controller with an area of |
|
194 * the display to render the current video frame. |
|
195 * @since |
|
196 * @param RWsSession& aWs - [input] A session with the window server |
|
197 * @param CWsScreenDevice& aScreenDevice - [input] The screen device |
|
198 * @param RWindowBase& aWindow - [input] The window to display |
|
199 * @param const TRect& aWindowRect - [input] The rectangle to display |
|
200 * @param const TRect& aClipRect - [input] The clip rectangle |
|
201 * @leave Can leave with one of the system wide error codes |
|
202 * @return None |
|
203 */ |
|
204 void SetDisplayWindowL( RWsSession& aWs, |
|
205 CWsScreenDevice& aScreenDevice, |
|
206 RWindow& aWindow ); |
|
207 |
|
208 /** |
|
209 * Get the current audio playback priority and preference settings. |
|
210 * @since |
|
211 * @param TInt& aPriority - [output] A priority value between EMdaPriorityMin and |
|
212 * EMdaPriorityMax |
|
213 * @param TInt& aPreference - [output] Time vs. quality preference |
|
214 * as enumerated in TMdaPriorityPreference |
|
215 * @return None |
|
216 */ |
|
217 void Priority( TInt& aPriority, TInt& aPreference ); |
|
218 |
|
219 /** |
|
220 * Set audio playback priority. This is used to arbitrate between simultaneous |
|
221 * accesses of the sound hardware. |
|
222 * @since |
|
223 * @param TInt aPriority - [input] A priority value between EMdaPriorityMin and |
|
224 * EMdaPriorityMax |
|
225 * @param TInt aPreference - [input] Time vs. quality preference |
|
226 * as enumerated in TMdaPriorityPreference |
|
227 * @return None |
|
228 */ |
|
229 void SetPriority( TInt aPriority, TInt aPreference ); |
|
230 |
|
231 /** |
|
232 * Get the audio playback volume. |
|
233 * @since |
|
234 * @param None |
|
235 * @return TInt - Current volume setting between 0 and value returned by GetMaxVolume() |
|
236 */ |
|
237 TInt Volume() const; |
|
238 |
|
239 /** |
|
240 * Get the maximum audio playback volume. |
|
241 * @since |
|
242 * @param None |
|
243 * @return TInt - Maximum volume setting value |
|
244 */ |
|
245 TInt MaxVolume() const; |
|
246 |
|
247 /** |
|
248 * Set the audio playback volume. |
|
249 * @since |
|
250 * @param TInt aVolume - [input] The volume between 0 and the maximum value returned by |
|
251 * GetMaxVolume() |
|
252 * @return None |
|
253 */ |
|
254 void SetVolumeL( TInt aVolume ); |
|
255 |
|
256 /** |
|
257 * Set the max audio volume. This should correlate to values given in SetVolumeL |
|
258 * @since |
|
259 * @param TInt aMaxVolume |
|
260 * @return None |
|
261 */ |
|
262 void SetMaxVolume( TInt aMaxVolume ); |
|
263 |
|
264 /** |
|
265 * Get the audio stereo balance. |
|
266 * @since |
|
267 * @param None |
|
268 * @return TInt - Balance setting between KMMFBalanceMaxLeft and KMMFBalanceMaxRight |
|
269 */ |
|
270 TInt Balance() const; |
|
271 |
|
272 /** |
|
273 * Set the audio stereo balance. |
|
274 * @since |
|
275 * @param TInt aBalance - [input] Balance between KMMFBalanceMaxLeft and KMMFBalanceMaxRight |
|
276 * @return None |
|
277 */ |
|
278 void SetBalanceL( TInt aBalance ); |
|
279 |
|
280 /** |
|
281 * Register call back function for video loading |
|
282 * @since Series-60 2.1 |
|
283 * @param MVideoLoadingObserver& aCallback - [input] Call back observer of video loading |
|
284 * @return None |
|
285 */ |
|
286 void RegisterForVideoLoadingNotification( MVideoLoadingObserver& aCallback ); |
|
287 |
|
288 /** |
|
289 * Version of IP DL Media subsystem. |
|
290 * @since |
|
291 * @param None |
|
292 * @return TVersion - Version of current subsystem |
|
293 */ |
|
294 TVersion Version() const; |
|
295 |
|
296 |
|
297 public: // From MXPSPktSinkObserver |
|
298 |
|
299 /** |
|
300 * Call back function from helix |
|
301 */ |
|
302 void RestorePacketSupply( TUint aStreamId ); |
|
303 |
|
304 public: |
|
305 |
|
306 void FormatVideoSDPInfoL( const TMccCodecInfo& aVideoCodec ); |
|
307 |
|
308 void FormatAudioSDPInfoL( const TMccCodecInfo& aAudioCodec ); |
|
309 |
|
310 void EmptyBufferL( CMMFBuffer* aBuffer, |
|
311 MDataSource* aSupplier, |
|
312 TMediaId aMediaId, |
|
313 TRtpRecvHeader& aHeaderInfo ); |
|
314 |
|
315 void UpdateSettingsL( const TMccVideoSinkSetting& aSettings, |
|
316 TBool aForceUpdate = EFalse ); |
|
317 |
|
318 void GetCurrentSettings( TMccVideoSinkSetting& aSettings ) const; |
|
319 |
|
320 void GetActualPrerollL( TInt& aPreroll ); |
|
321 |
|
322 TReal GetVideoFrameRate(); |
|
323 |
|
324 void SetVideoFrameRate( TReal aFrameRate ); |
|
325 |
|
326 private: |
|
327 |
|
328 /** |
|
329 * C++ default constructor. |
|
330 */ |
|
331 CMccVideoSinkImpl( TUint32 aEndpointId ); |
|
332 |
|
333 /** |
|
334 * By default Symbian 2nd phase constructor is private. |
|
335 */ |
|
336 void ConstructL( const TMccVideoSinkSetting& aSettings ); |
|
337 |
|
338 /** |
|
339 * Forward Open Complete event to the observer which is set up in NewL() |
|
340 */ |
|
341 void MvpuoOpenComplete( TInt aError ); |
|
342 |
|
343 /** |
|
344 * Forward Prepare Complete event to the observer which is set in NewL() |
|
345 */ |
|
346 void MvpuoPrepareComplete( TInt aError ); |
|
347 |
|
348 /** |
|
349 * Forward Frame Ready event to the observer which is set in NewL() |
|
350 */ |
|
351 void MvpuoFrameReady( CFbsBitmap& aFrame,TInt aError ); |
|
352 |
|
353 /** |
|
354 * Forward Play Complete event to the observer which is set in NewL() |
|
355 */ |
|
356 void MvpuoPlayComplete( TInt aError ); |
|
357 |
|
358 /** |
|
359 * Forward all the other events except "Paused, Resumed, Disconnected" defined |
|
360 * in MIdmObserver class to the observer which is set in NewL(); |
|
361 * For "Paused, Resumed, Disconnected" events, call their corresponding functions |
|
362 * in the same MIdmObserver object set in NewL(). |
|
363 */ |
|
364 void MvpuoEvent( const TMMFEvent& aEvent ); |
|
365 |
|
366 /** |
|
367 * Reserved for the future custom command sending. |
|
368 */ |
|
369 TInt SendCommand( const TDesC8& aDataTo1, const TDesC8& aDataTo2 ); |
|
370 |
|
371 /** |
|
372 * Reserved for the future custom command sending. |
|
373 */ |
|
374 TInt SendCommand( const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom ); |
|
375 |
|
376 void MvloLoadingStarted(); |
|
377 void MvloLoadingComplete(); |
|
378 |
|
379 TBool SetVideoSinkState( TMccVideoSinkState aState ); |
|
380 |
|
381 HBufC8* CreateModesetDesL( TUint aBitrateMask ); |
|
382 |
|
383 void SendStreamEventToAllClients( TMccEventType aEventType, |
|
384 TInt aError = KErrNone, |
|
385 TBool aAllEndpoints = EFalse ); |
|
386 |
|
387 void SendStreamEventToClient( TMccEventType aEventType, |
|
388 MAsyncEventHandler* aEventHandler, |
|
389 TInt aError = KErrNone, |
|
390 TBool aAllEndpoints = EFalse ); |
|
391 |
|
392 private: |
|
393 |
|
394 TInt ResolveStreamId( TMediaId aMediaId, TUint& aStreamId ); |
|
395 |
|
396 TInt ResolveStreamId( MAsyncEventHandler* aUser, TUint& aStreamId ); |
|
397 |
|
398 TUint ResolveStreamId( TInt aUserIndex ); |
|
399 |
|
400 TUint GenerateStreamId(); |
|
401 |
|
402 TInt FindVideoSinkUserEntryByMediaType( TUid aMediaType ); |
|
403 |
|
404 TInt FindStreamIdForVideoSinkUser( CMccVideoSinkUser& aEntry, |
|
405 TUint& aStreamId ); |
|
406 |
|
407 CMccVideoSinkUser* FindVideoSinkUserEntryForCurrent(); |
|
408 |
|
409 void RemoveVideoSinkUser( MAsyncEventHandler* aUser, TUint aStreamId ); |
|
410 |
|
411 static TBool VideoSinkUserMatch( const CMccVideoSinkUser& aUser1, |
|
412 const CMccVideoSinkUser& aUser2 ); |
|
413 |
|
414 void ConstructSdpL(); |
|
415 |
|
416 void HandleAudioSdpL(); |
|
417 |
|
418 void HandleVideoSdpL(); |
|
419 |
|
420 TBool AnalyzeTimeStampL( CMccVideoSinkUser& aUser, TRtpRecvHeader& aHeaderInfo ); |
|
421 |
|
422 void DoResetL( TBool aFullReset = ETrue, CMccVideoSinkUser* aUser = NULL ); |
|
423 |
|
424 TBool IsPlayerOpened() const; |
|
425 |
|
426 void ResetPacketSink(); |
|
427 |
|
428 TBool IsStartedOnce( const CMccVideoSinkUser* aUser ); |
|
429 |
|
430 void SetStartedOnce( CMccVideoSinkUser* aUser, TBool aIsStartedOnce ); |
|
431 |
|
432 void SetRotationL( TMccVideoRotation aRotation, TBool aForceUpdate ); |
|
433 |
|
434 TBool ResetOngoing() const; |
|
435 |
|
436 HBufC8* GetFmtpLC( const TMccCodecInfo& aCodecInfo ); |
|
437 |
|
438 void DoPauseL( const CMccVideoSinkUser* aUser = NULL ); |
|
439 |
|
440 void DoPlay( const CMccVideoSinkUser* aUser = NULL ); |
|
441 |
|
442 void DoPauseForUser( const CMccVideoSinkUser* aUser ); |
|
443 |
|
444 TBool MultipleMediaTypes(); |
|
445 |
|
446 TBool RealTimeMode(); |
|
447 |
|
448 void AddUserL( MAsyncEventHandler& aEventHandler ); |
|
449 |
|
450 void DoMvloLoadingComplete( TBool aSimulated = EFalse ); |
|
451 |
|
452 void DoMvloLoadingStarted( TBool aSimulated = EFalse ); |
|
453 |
|
454 TBool AllUsersReady(); |
|
455 |
|
456 private: // Data |
|
457 |
|
458 RWsSession iRwSession; |
|
459 RWindowGroup* iRwGroup; |
|
460 RWindow* iRw; |
|
461 CWsScreenDevice* iDev; |
|
462 CWindowGc* iGc; |
|
463 CVideoPlayerUtility2* iVideoPlayer; |
|
464 CXPSPacketSink* iPacketSink; |
|
465 |
|
466 HBufC8* iSdp; |
|
467 |
|
468 TUint32 iEndpointId; |
|
469 |
|
470 TMccVideoSinkState iState; |
|
471 |
|
472 RPointerArray<CMccVideoSinkUser> iUsers; |
|
473 |
|
474 MAsyncEventHandler* iCurrentUser; |
|
475 |
|
476 TUint iHelixStreamId; |
|
477 |
|
478 HBufC* iServerName; |
|
479 |
|
480 TMccVideoSinkSetting iSettings; |
|
481 |
|
482 TReal iVolumeAdaptation; |
|
483 |
|
484 TInt iVolume; |
|
485 |
|
486 TInt iMccMaxVolume; |
|
487 |
|
488 TInt iPreroll; |
|
489 |
|
490 TBool iPrerollSet; |
|
491 |
|
492 CMccRedrawHandler* iRedrawHandler; |
|
493 |
|
494 TUint32 iNumPacketsEnqueued; |
|
495 |
|
496 TTimeIntervalMicroSeconds iPos; |
|
497 |
|
498 CMccVideoSinkUser* iSearchTermUser; |
|
499 |
|
500 TBool iSimulatedStreamingEventSent; |
|
501 TBool iSimulatedBufferingEventSent; |
|
502 |
|
503 private: |
|
504 #ifdef TEST_EUNIT |
|
505 friend class UT_CMccVideoSinkImpl; |
|
506 friend class UT_CMccVideoSink; |
|
507 #endif |
|
508 |
|
509 }; // end of CMccVideoSinkImpl |
|
510 |
|
511 |
|
512 #endif // MCCVIDEOSINKIMPL_H |