|
1 /* |
|
2 * Copyright (c) 2003 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 // INCLUDES FILES |
|
22 #include <w32std.h> |
|
23 #include <AudioPreference.h> |
|
24 #include <mmcccodecinformationfactory.h> |
|
25 #include <mmcccodecinformation.h> |
|
26 #include "mccvideosinkimpl.h" |
|
27 #include "mmcccodech263.h" |
|
28 #include "mccvideosourcesinklogs.h" |
|
29 #include "mccinternalevents.h" |
|
30 #include "CXPSPacketSink.h" |
|
31 #include "mmcccodecamr.h" |
|
32 #include "mccvideosinkuser.h" |
|
33 #include "mccdef.h" |
|
34 #include "mccredrawhandler.h" |
|
35 #include "mccinternaldef.h" |
|
36 #include <videoplayer2.h> |
|
37 |
|
38 // CONSTANTS |
|
39 |
|
40 |
|
41 _LIT8( KMccSdpInboundStart, |
|
42 "v=0\r\n\ |
|
43 o=- 63327476467155000 63327476467155000 IN IP4 0.0.0.0\r\n\ |
|
44 s=-\r\n\ |
|
45 c=IN IP4 0.0.0.0\r\n\ |
|
46 t=0 0\r\n" ); |
|
47 |
|
48 _LIT8( KMccSdpInboundAudio, |
|
49 "m=audio 25001 RTP/AVP %d\r\n\ |
|
50 a=rtpmap:%d %S/8000\r\n\ |
|
51 a=ptime:%d\r\n\ |
|
52 a=maxptime:%d\r\n\ |
|
53 a=fmtp:%d octet-align=%d; mode-set=%S\r\n" ); |
|
54 |
|
55 _LIT8( KMccSdpInboundVideo, |
|
56 "m=video 25002 RTP/AVP %d\r\n\ |
|
57 a=rtpmap:%d %S/90000\r\n\ |
|
58 a=fmtp:%d %S\r\n\ |
|
59 a=XpsPyldBufSize:integer;%d\r\n\ |
|
60 a=FrameWidth:integer;%d\r\n\ |
|
61 a=FrameHeight:integer;%d\r\n" ); |
|
62 |
|
63 _LIT8( KMccSdpInboundPreroll, "a=DisableMinPrerollCheck:integer;1\r\n\ |
|
64 a=Preroll:integer;%d\r\n" ); |
|
65 |
|
66 _LIT8( KMccSdpInboundDisableVideoClock, "a=DisableVideoClock:integer;1\r\n" ); |
|
67 |
|
68 |
|
69 _LIT( KMccWindowGroupName,"32MccVideoWindow" ); |
|
70 _LIT( KMccHelixSource,"MccDataSource%d"); |
|
71 // NOTE: filepath separator changed to unix style because of problem at Helix side |
|
72 _LIT( KMccPacketSource, "file://c:/notinuse.xps?XPSServer=%S" ); |
|
73 |
|
74 // MACROS |
|
75 |
|
76 #define MCC_BITRATE_IN_MASK( bitratemask, bitrate ) bitrate == ( bitratemask & bitrate ) |
|
77 |
|
78 // ================= MEMBER FUNCTIONS ======================= |
|
79 |
|
80 |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // C++ default constructor can NOT contain any code, that |
|
84 // might leave. |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 CMccVideoSinkImpl::CMccVideoSinkImpl( TUint32 aEndpointId ) : |
|
88 iEndpointId( aEndpointId ), |
|
89 iVolumeAdaptation( 0 ), |
|
90 iPreroll( 0 ), |
|
91 iPrerollSet( EFalse ) |
|
92 { |
|
93 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::CMccVideoSinkImpl" ) |
|
94 |
|
95 iSettings.iVideoFrameRate = KMccDefaultVideoFrameRate; |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // Symbian 2nd phase constructor can leave. |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 void CMccVideoSinkImpl::ConstructL( const TMccVideoSinkSetting& aSettings ) |
|
103 { |
|
104 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::ConstructL" ) |
|
105 |
|
106 iSettings = aSettings; |
|
107 |
|
108 SetVideoFrameRate( aSettings.iVideoFrameRate ); |
|
109 |
|
110 const TInt KMccVideoSinkMaxSdpLen = 800; |
|
111 iSdp = HBufC8::NewL( KMccVideoSinkMaxSdpLen ); |
|
112 |
|
113 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::ConstructL, init Helix" ) |
|
114 iPacketSink = CXPSPacketSink::New(); |
|
115 __ASSERT_ALWAYS(iPacketSink, User::Leave( KErrNotReady ) ); |
|
116 |
|
117 const TInt KMaxTUintAsDesLen = 12; |
|
118 iServerName = |
|
119 HBufC::NewL( KMccHelixSource().Length() + KMaxTUintAsDesLen ); |
|
120 iServerName->Des().AppendFormat( KMccHelixSource, (TUint32)this ); |
|
121 |
|
122 iPacketSink->Init( *iServerName, this ); |
|
123 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::ConstructL, init Helix complete" ) |
|
124 |
|
125 iSearchTermUser = CMccVideoSinkUser::NewL( |
|
126 NULL, KNullUid, 0, iSettings.iVideoFrameRate, *iPacketSink ); |
|
127 |
|
128 User::LeaveIfError( iRwSession.Connect() ); |
|
129 |
|
130 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::ConstructL connected to ws" ) |
|
131 __V_SOURCESINK_CONTROLL_INT2( "CMccVideoSinkImpl window pos:", |
|
132 iSettings.iLocation.iX, " ", iSettings.iLocation.iY ) |
|
133 __V_SOURCESINK_CONTROLL_INT2( "CMccVideoSinkImpl window size (w,h):", |
|
134 iSettings.iSize.iWidth, " ", iSettings.iSize.iHeight ) |
|
135 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl window ordinal pos:", |
|
136 iSettings.iWindowOrdinalPosition ) |
|
137 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl window ordinal priority:", |
|
138 iSettings.iWindowOrdinalPriority ) |
|
139 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl rotation:", |
|
140 iSettings.iRotation ) |
|
141 |
|
142 // Create window group |
|
143 TInt groupId = iRwSession.GetFocusWindowGroup(); |
|
144 iRwGroup = new (ELeave) RWindowGroup( iRwSession ); |
|
145 |
|
146 User::LeaveIfError( iRwGroup->Construct( groupId, EFalse ) ); |
|
147 iRwGroup->SetName( KMccWindowGroupName ); |
|
148 |
|
149 // TBD: use also iWindowOrdinalPriority |
|
150 iRwGroup->SetOrdinalPosition( iSettings.iWindowOrdinalPosition ); |
|
151 |
|
152 // Create screen device |
|
153 iDev = new (ELeave) CWsScreenDevice( iRwSession ); |
|
154 User::LeaveIfError( iDev->Construct( iSettings.iDeviceIndex ) ); |
|
155 |
|
156 // Create window |
|
157 iRw = new (ELeave) RWindow( iRwSession ); |
|
158 |
|
159 User::LeaveIfError( iRw->Construct( *iRwGroup, (TUint32)iRw ) ); |
|
160 |
|
161 iRw->SetPosition( iSettings.iLocation ); |
|
162 iRw->SetSize( iSettings.iSize ); |
|
163 |
|
164 iRw->SetOrdinalPosition( iSettings.iWindowOrdinalPosition ); |
|
165 |
|
166 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl: creating graphics context ..." ) |
|
167 User::LeaveIfError( iDev->CreateContext( iGc ) ); |
|
168 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl: graphics context created!" ) |
|
169 |
|
170 |
|
171 iRw->Activate(); |
|
172 |
|
173 iRwSession.Flush(); |
|
174 |
|
175 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl: creating redraw handler" ) |
|
176 |
|
177 iRedrawHandler = CMccRedrawHandler::NewL( iRwSession, *iRw, *iGc ); |
|
178 |
|
179 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl: created redraw handler" ) |
|
180 |
|
181 // Videoplayer needs to be created last, otherwise destruction |
|
182 // order causes problems |
|
183 iVideoPlayer = CVideoPlayerUtility2::NewL( |
|
184 *this, |
|
185 iSettings.iPriority.iPriority, |
|
186 iSettings.iPriority.iPref ); |
|
187 |
|
188 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl: created CVideoPlayerUtility2" ) |
|
189 |
|
190 // Wait for MvpuoOpenComplete before adding display window |
|
191 |
|
192 RegisterForVideoLoadingNotification( *this ); |
|
193 } |
|
194 |
|
195 // --------------------------------------------------------------------------- |
|
196 // Two-phased constructor. |
|
197 // --------------------------------------------------------------------------- |
|
198 // |
|
199 CMccVideoSinkImpl* CMccVideoSinkImpl::NewL( |
|
200 const TMccVideoSinkSetting& aSettings, |
|
201 TUint32 aEndpointId ) |
|
202 { |
|
203 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::NewL" ) |
|
204 CMccVideoSinkImpl* self = new ( ELeave ) CMccVideoSinkImpl( aEndpointId ); |
|
205 |
|
206 CleanupStack::PushL( self ); |
|
207 |
|
208 self->ConstructL( aSettings ); |
|
209 |
|
210 CleanupStack::Pop( self ); // self |
|
211 |
|
212 return self; |
|
213 } |
|
214 |
|
215 // --------------------------------------------------------------------------- |
|
216 // Destructor |
|
217 // --------------------------------------------------------------------------- |
|
218 // |
|
219 CMccVideoSinkImpl::~CMccVideoSinkImpl() |
|
220 { |
|
221 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::~CMccVideoSinkImpl" ) |
|
222 |
|
223 SetCurrentUser( NULL ); |
|
224 |
|
225 delete iSdp; |
|
226 |
|
227 if ( iPacketSink ) |
|
228 { |
|
229 for ( TInt i = 0; i < iUsers.Count(); i++ ) |
|
230 { |
|
231 iPacketSink->StreamEnd( iUsers[ i ]->iStreamId ); |
|
232 } |
|
233 iPacketSink->Reset(); |
|
234 } |
|
235 |
|
236 |
|
237 iUsers.ResetAndDestroy(); |
|
238 |
|
239 delete iPacketSink; |
|
240 |
|
241 if( iVideoPlayer ) |
|
242 { |
|
243 Stop(); |
|
244 iVideoPlayer->Close(); |
|
245 } |
|
246 |
|
247 delete iVideoPlayer; |
|
248 |
|
249 delete iRedrawHandler; |
|
250 |
|
251 delete iGc; |
|
252 delete iDev; |
|
253 |
|
254 delete iRw; |
|
255 delete iRwGroup; |
|
256 iRwSession.Close(); |
|
257 |
|
258 delete iServerName; |
|
259 |
|
260 delete iSearchTermUser; |
|
261 |
|
262 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::~CMccVideoSinkImpl, exit" ) |
|
263 } |
|
264 |
|
265 // --------------------------------------------------------------------------- |
|
266 // CMccVideoSinkImpl::SinkThreadLogon() |
|
267 // --------------------------------------------------------------------------- |
|
268 // |
|
269 TInt CMccVideoSinkImpl::SinkThreadLogon( MAsyncEventHandler& aEventHandler ) |
|
270 { |
|
271 // Give zero stream id at beginning, correct id is set later |
|
272 TRAPD( err, AddUserL( aEventHandler ) ); |
|
273 return err; |
|
274 } |
|
275 |
|
276 // --------------------------------------------------------------------------- |
|
277 // CMccVideoSinkImpl::SinkThreadLogoff() |
|
278 // --------------------------------------------------------------------------- |
|
279 // |
|
280 TBool CMccVideoSinkImpl::SinkThreadLogoff() |
|
281 { |
|
282 if ( iCurrentUser ) |
|
283 { |
|
284 TUint streamId( 0 ); |
|
285 if ( ResolveStreamId( iCurrentUser, streamId ) == KErrNone ) |
|
286 { |
|
287 RemoveVideoSinkUser( iCurrentUser, streamId ); |
|
288 } |
|
289 iCurrentUser = NULL; |
|
290 } |
|
291 return ( iUsers.Count() == 0 ); |
|
292 } |
|
293 |
|
294 // --------------------------------------------------------------------------- |
|
295 // CMccVideoSinkImpl::SetCurrentUser() |
|
296 // --------------------------------------------------------------------------- |
|
297 // |
|
298 void CMccVideoSinkImpl::SetCurrentUser( MAsyncEventHandler* aEventHandler ) |
|
299 { |
|
300 iCurrentUser = aEventHandler; |
|
301 } |
|
302 |
|
303 // --------------------------------------------------------------------------- |
|
304 // CMccVideoSinkImpl::OpenL() |
|
305 // --------------------------------------------------------------------------- |
|
306 // |
|
307 void CMccVideoSinkImpl::OpenL() |
|
308 { |
|
309 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::OpenL" ) |
|
310 if ( SetVideoSinkState( EOpening ) ) |
|
311 { |
|
312 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::OpenL, doing setup" ) |
|
313 |
|
314 RemoteSetupL(); |
|
315 |
|
316 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::OpenL, opening" ) |
|
317 __ASSERT_ALWAYS( iVideoPlayer, User::Leave( KErrArgument ) ); |
|
318 __ASSERT_ALWAYS( iPacketSink, User::Leave( KErrArgument ) ); |
|
319 |
|
320 const TUid KUidController = { 0x101F8514 }; //RNAVCONTROLLER.DLL |
|
321 |
|
322 HBufC* url = |
|
323 HBufC::NewLC( KMccPacketSource().Length() + iServerName->Length() ); |
|
324 url->Des().AppendFormat( KMccPacketSource, &*iServerName ); |
|
325 iVideoPlayer->OpenUrlL( *url, 0, KNullDesC8, KUidController ); |
|
326 CleanupStack::PopAndDestroy( url ); |
|
327 } |
|
328 else if ( iState == EOpened ) |
|
329 { |
|
330 // If already opened, prepare can be called immediately |
|
331 Prepare(); |
|
332 } |
|
333 else |
|
334 { |
|
335 __V_SOURCESINK_CONTROLL( |
|
336 "CMccVideoSinkImpl::OpenL, waiting for opening" ) |
|
337 } |
|
338 |
|
339 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::OpenL, exit" ) |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------------------------- |
|
343 // CMccVideoSinkImpl::Prepare() |
|
344 // --------------------------------------------------------------------------- |
|
345 // |
|
346 void CMccVideoSinkImpl::Prepare() |
|
347 { |
|
348 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::Prepare" ) |
|
349 |
|
350 if ( SetVideoSinkState( EPrepared ) && iVideoPlayer ) |
|
351 { |
|
352 iVideoPlayer->Prepare(); |
|
353 |
|
354 // Wait for async completion |
|
355 } |
|
356 } |
|
357 |
|
358 |
|
359 // --------------------------------------------------------------------------- |
|
360 // CMccVideoSinkImpl::RemoteSetupL() |
|
361 // --------------------------------------------------------------------------- |
|
362 // |
|
363 void CMccVideoSinkImpl::RemoteSetupL() |
|
364 { |
|
365 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::RemoteSetup" ) |
|
366 |
|
367 __ASSERT_ALWAYS( iVideoPlayer && iPacketSink, User::Leave( KErrNotReady ) ); |
|
368 |
|
369 ConstructSdpL(); |
|
370 |
|
371 __V_SOURCESINK_CONTROLL_INT1( "Sending SDP to helix, len= ", iSdp->Length() ) |
|
372 |
|
373 TUint numStreams( iUsers.Count() ); |
|
374 __V_SOURCESINK_CONTROLL_INT1( |
|
375 "CMccVideoSinkImpl::RemoteSetup, num streams:", numStreams ); |
|
376 |
|
377 User::LeaveIfError( iPacketSink->SetSessionDescription( *iSdp, numStreams ) ); |
|
378 |
|
379 for ( TInt i = 0; i < iUsers.Count(); i++ ) |
|
380 { |
|
381 CMccVideoSinkUser& entry = *iUsers[ i ]; |
|
382 |
|
383 __V_SOURCESINK_CONTROLL_INT1( |
|
384 "CMccVideoSinkImpl::RemoteSetup, stream:", entry.iStreamId ); |
|
385 __V_SOURCESINK_CONTROLL_INT1( |
|
386 "CMccVideoSinkImpl::RemoteSetup, queuesize defined:", |
|
387 entry.IsQueueSizeDefined() ); |
|
388 __V_SOURCESINK_CONTROLL_INT1( |
|
389 "CMccVideoSinkImpl::RemoteSetup, queuesize:", entry.QueueSize() ); |
|
390 User::LeaveIfError( |
|
391 iPacketSink->ConfigStream( entry.iStreamId, entry.QueueSize() ) ); |
|
392 } |
|
393 |
|
394 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::RemoteSetup, exit" ) |
|
395 } |
|
396 |
|
397 // --------------------------------------------------------------------------- |
|
398 // CMccVideoSinkImpl::StartL() |
|
399 // --------------------------------------------------------------------------- |
|
400 // |
|
401 void CMccVideoSinkImpl::StartL() |
|
402 { |
|
403 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::StartL" ) |
|
404 |
|
405 if ( SetVideoSinkState( EPlaying ) ) |
|
406 { |
|
407 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::StartL, playing" ) |
|
408 |
|
409 CMccVideoSinkUser* userEntry = FindVideoSinkUserEntryForCurrent(); |
|
410 |
|
411 UpdateSettingsL( iSettings, ETrue ); |
|
412 |
|
413 DoPlay(); |
|
414 |
|
415 // No need to wait any async completion |
|
416 if ( IsStartedOnce( userEntry ) ) |
|
417 { |
|
418 SendStreamEventToClient( KMccStreamResumed, iCurrentUser ); |
|
419 } |
|
420 else |
|
421 { |
|
422 iRedrawHandler->BlackDrawingL( ETrue ); |
|
423 SendStreamEventToClient( KMccStreamStarted, iCurrentUser ); |
|
424 SetStartedOnce( userEntry, ETrue ); |
|
425 } |
|
426 } |
|
427 |
|
428 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::StartL, exit" ) |
|
429 } |
|
430 |
|
431 // --------------------------------------------------------------------------- |
|
432 // CMccVideoSinkImpl::Stop() |
|
433 // --------------------------------------------------------------------------- |
|
434 // |
|
435 void CMccVideoSinkImpl::Stop() |
|
436 { |
|
437 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::Stop" ) |
|
438 |
|
439 TBool playerOpened( IsPlayerOpened() ); |
|
440 |
|
441 if ( SetVideoSinkState( EStopped ) && iVideoPlayer ) |
|
442 { |
|
443 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::Stop, hiding window disabled" ) |
|
444 |
|
445 // Stopping the player before opening has completed can cause crash |
|
446 if ( playerOpened ) |
|
447 { |
|
448 iVideoPlayer->Stop(); |
|
449 } |
|
450 |
|
451 // No need to wait any async completion |
|
452 SendStreamEventToClient( KMccStreamStopped, iCurrentUser ); |
|
453 |
|
454 CMccVideoSinkUser* userEntry = FindVideoSinkUserEntryForCurrent(); |
|
455 SetStartedOnce( userEntry, EFalse ); |
|
456 |
|
457 DoPauseForUser( userEntry ); |
|
458 } |
|
459 |
|
460 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::Stop, exit" ) |
|
461 } |
|
462 |
|
463 // --------------------------------------------------------------------------- |
|
464 // CMccVideoSinkImpl::Pause() |
|
465 // --------------------------------------------------------------------------- |
|
466 // |
|
467 void CMccVideoSinkImpl::PauseL() |
|
468 { |
|
469 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::PauseL" ) |
|
470 __ASSERT_ALWAYS( iVideoPlayer, User::Leave( KErrArgument ) ); |
|
471 |
|
472 if ( SetVideoSinkState( EPaused ) ) |
|
473 { |
|
474 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::PauseL, pausing" ) |
|
475 |
|
476 DoPauseL(); |
|
477 |
|
478 DoResetL(); |
|
479 |
|
480 // No need to wait any async completion |
|
481 SendStreamEventToClient( KMccStreamPaused, iCurrentUser ); |
|
482 } |
|
483 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::PauseL, exit" ) |
|
484 } |
|
485 |
|
486 // --------------------------------------------------------------------------- |
|
487 // CMccVideoSinkImpl::Close() |
|
488 // --------------------------------------------------------------------------- |
|
489 // |
|
490 void CMccVideoSinkImpl::Close() |
|
491 { |
|
492 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::Close" ) |
|
493 if ( iVideoPlayer ) |
|
494 { |
|
495 iVideoPlayer->Close(); |
|
496 } |
|
497 } |
|
498 |
|
499 // --------------------------------------------------------------------------- |
|
500 // CMccVideoSinkImpl::SetDisplayWindowL() |
|
501 // --------------------------------------------------------------------------- |
|
502 // |
|
503 void CMccVideoSinkImpl::SetDisplayWindowL( |
|
504 RWsSession& aWs, |
|
505 CWsScreenDevice& aScreenDevice, |
|
506 RWindow& aWindow ) |
|
507 { |
|
508 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::SetDisplayWindowL" ) |
|
509 __ASSERT_ALWAYS( iVideoPlayer, User::Leave( KErrArgument ) ); |
|
510 iVideoPlayer->RemoveDisplayWindow( aWindow ); |
|
511 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::SetDisplayWindowL, removed old" ) |
|
512 iVideoPlayer->AddDisplayWindowL( aWs, aScreenDevice, aWindow ); |
|
513 |
|
514 iVideoPlayer->SetAutoScaleL( aWindow, EAutoScaleBestFit ); |
|
515 |
|
516 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::SetDisplayWindowL, added new" ) |
|
517 } |
|
518 |
|
519 // --------------------------------------------------------------------------- |
|
520 // CMccVideoSinkImpl::Priority() |
|
521 // --------------------------------------------------------------------------- |
|
522 // |
|
523 void CMccVideoSinkImpl::Priority( TInt& aPriority, |
|
524 TInt& aPreference ) |
|
525 { |
|
526 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::Priority" ) |
|
527 |
|
528 aPriority = iSettings.iPriority.iPriority; |
|
529 aPreference = iSettings.iPriority.iPref; |
|
530 } |
|
531 |
|
532 // --------------------------------------------------------------------------- |
|
533 // CMccVideoSinkImpl::SetPriority() |
|
534 // --------------------------------------------------------------------------- |
|
535 // |
|
536 void CMccVideoSinkImpl::SetPriority( TInt aPriority, |
|
537 TInt aPreference ) |
|
538 { |
|
539 if ( iSettings.iPriority.iPriority != aPriority || |
|
540 iSettings.iPriority.iPref != aPreference ) |
|
541 { |
|
542 __V_SOURCESINK_CONTROLL_INT1( |
|
543 "CMccVideoSinkImpl::SetPriority, mmf priority:", aPriority ) |
|
544 __V_SOURCESINK_CONTROLL_INT1( |
|
545 "CMccVideoSinkImpl::SetPriority, mmf preference:", aPreference ) |
|
546 |
|
547 iSettings.iPriority.iPriority = aPriority; |
|
548 iSettings.iPriority.iPref = aPreference; |
|
549 |
|
550 if ( IsPlayerOpened() && iVideoPlayer ) |
|
551 { |
|
552 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::SetPriority, setting" ) |
|
553 |
|
554 |
|
555 TRAPD( err, iVideoPlayer->SetPriorityL( iSettings.iPriority.iPriority, |
|
556 iSettings.iPriority.iPref ) ); |
|
557 if ( err ) |
|
558 { |
|
559 __V_SOURCESINK_CONTROLL_INT1( |
|
560 "CMccVideoSinkImpl::SetPriority, failed with err:", err ) |
|
561 err++; |
|
562 } |
|
563 } |
|
564 } |
|
565 } |
|
566 |
|
567 // --------------------------------------------------------------------------- |
|
568 // CMccVideoSinkImpl::Volume() |
|
569 // --------------------------------------------------------------------------- |
|
570 // |
|
571 TInt CMccVideoSinkImpl::Volume() const |
|
572 { |
|
573 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::Volume" ) |
|
574 |
|
575 if ( iVideoPlayer ) |
|
576 { |
|
577 return iVideoPlayer->Volume(); |
|
578 } |
|
579 else |
|
580 { |
|
581 return KErrArgument; |
|
582 } |
|
583 } |
|
584 |
|
585 // --------------------------------------------------------------------------- |
|
586 // CMccVideoSinkImpl::MaxVolume() |
|
587 // --------------------------------------------------------------------------- |
|
588 // |
|
589 TInt CMccVideoSinkImpl::MaxVolume() const |
|
590 { |
|
591 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::MaxVolume" ) |
|
592 |
|
593 if ( iVideoPlayer ) |
|
594 { |
|
595 return iVideoPlayer->MaxVolume(); |
|
596 } |
|
597 else |
|
598 { |
|
599 return KErrArgument; |
|
600 } |
|
601 } |
|
602 |
|
603 // --------------------------------------------------------------------------- |
|
604 // CMccVideoSinkImpl::SetVolumeL() |
|
605 // --------------------------------------------------------------------------- |
|
606 // |
|
607 void CMccVideoSinkImpl::SetVolumeL( TInt aVolume ) |
|
608 { |
|
609 __V_SOURCESINK_CONTROLL_INT1( |
|
610 "CMccVideoSinkImpl::SetVolumeL, vol:", aVolume ) |
|
611 __ASSERT_ALWAYS( iVideoPlayer, User::Leave( KErrArgument ) ); |
|
612 |
|
613 iVolume = aVolume; |
|
614 |
|
615 if ( iVolumeAdaptation == 0 && iMccMaxVolume != 0 && IsPlayerOpened() ) |
|
616 { |
|
617 TInt playerMaxVolume = iVideoPlayer->MaxVolume(); |
|
618 |
|
619 __V_SOURCESINK_CONTROLL_INT1( |
|
620 "CMccVideoSinkImpl::SetVolumeL, player max volume:", |
|
621 playerMaxVolume ) |
|
622 |
|
623 iVolumeAdaptation = TReal( playerMaxVolume ) / iMccMaxVolume; |
|
624 |
|
625 __V_SOURCESINK_CONTROLL_REAL( |
|
626 "CMccVideoSinkImpl::SetVolumeL, vol adapt:", iVolumeAdaptation ) |
|
627 } |
|
628 |
|
629 if ( iVolumeAdaptation != 0 ) |
|
630 { |
|
631 aVolume = (TInt) ( iVolume * iVolumeAdaptation ); |
|
632 |
|
633 __V_SOURCESINK_CONTROLL_INT1( |
|
634 "CMccVideoSinkImpl::SetVolumeL, after adaptation:", aVolume ) |
|
635 |
|
636 iVideoPlayer->SetVolumeL( aVolume ); |
|
637 } |
|
638 |
|
639 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::SetVolumeL, exit" ) |
|
640 } |
|
641 |
|
642 // --------------------------------------------------------------------------- |
|
643 // CMccVideoSinkImpl::SetMaxVolume() |
|
644 // --------------------------------------------------------------------------- |
|
645 // |
|
646 void CMccVideoSinkImpl::SetMaxVolume( TInt aMaxVolume ) |
|
647 { |
|
648 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl::SetMaxVolume, max vol:", aMaxVolume ) |
|
649 |
|
650 iMccMaxVolume = aMaxVolume; |
|
651 } |
|
652 |
|
653 // --------------------------------------------------------------------------- |
|
654 // CMccVideoSinkImpl::Balance() |
|
655 // --------------------------------------------------------------------------- |
|
656 // |
|
657 TInt CMccVideoSinkImpl::Balance() const |
|
658 { |
|
659 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::Balance" ) |
|
660 |
|
661 if ( iVideoPlayer ) |
|
662 { |
|
663 return iVideoPlayer->Balance(); |
|
664 } |
|
665 else |
|
666 { |
|
667 return KErrArgument; |
|
668 } |
|
669 } |
|
670 |
|
671 // --------------------------------------------------------------------------- |
|
672 // CMccVideoSinkImpl::SetBalanceL() |
|
673 // --------------------------------------------------------------------------- |
|
674 // |
|
675 void CMccVideoSinkImpl::SetBalanceL( TInt aBalance ) |
|
676 { |
|
677 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::SetBalanceL" ) |
|
678 __ASSERT_ALWAYS( iVideoPlayer, User::Leave( KErrArgument ) ); |
|
679 iVideoPlayer->SetBalanceL(aBalance); |
|
680 } |
|
681 |
|
682 // --------------------------------------------------------------------------- |
|
683 // CMccVideoSinkImpl::RegisterForVideoLoadingNotification() |
|
684 // --------------------------------------------------------------------------- |
|
685 // |
|
686 void CMccVideoSinkImpl::RegisterForVideoLoadingNotification( |
|
687 MVideoLoadingObserver& aCallback ) |
|
688 { |
|
689 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::RegisterForVideoLoadingNotification" ) |
|
690 |
|
691 if ( iVideoPlayer ) |
|
692 { |
|
693 iVideoPlayer->RegisterForVideoLoadingNotification( aCallback ); |
|
694 } |
|
695 } |
|
696 |
|
697 // --------------------------------------------------------------------------- |
|
698 // CMccVideoSinkImpl::Version() |
|
699 // --------------------------------------------------------------------------- |
|
700 // |
|
701 TVersion CMccVideoSinkImpl::Version() const |
|
702 { |
|
703 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::Version" ) |
|
704 return TVersion(0, 1, 0); |
|
705 } |
|
706 |
|
707 // --------------------------------------------------------------------------- |
|
708 // CMccVideoSinkImpl::FormatVideoSDPInfoL |
|
709 // --------------------------------------------------------------------------- |
|
710 // |
|
711 void CMccVideoSinkImpl::FormatVideoSDPInfoL( const TMccCodecInfo& aVideoCodec ) |
|
712 { |
|
713 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::FormatVideoSDPInfoL" ) |
|
714 |
|
715 // Update payload type since it might not have been provided at |
|
716 // initialization phase |
|
717 iSettings.iVideoPayloadType = aVideoCodec.iPayloadType; |
|
718 |
|
719 CMccVideoSinkUser* userEntry = FindVideoSinkUserEntryForCurrent(); |
|
720 __ASSERT_ALWAYS( userEntry, User::Leave( KErrNotFound ) ); |
|
721 userEntry->iMediaType = KUidMediaTypeVideo; |
|
722 userEntry->SetCodecInfoL( aVideoCodec ); |
|
723 } |
|
724 |
|
725 // --------------------------------------------------------------------------- |
|
726 // CMccVideoSinkImpl::FormatAudioSDPInfoL |
|
727 // --------------------------------------------------------------------------- |
|
728 // |
|
729 void CMccVideoSinkImpl::FormatAudioSDPInfoL( const TMccCodecInfo& aAudioCodec ) |
|
730 { |
|
731 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::FormatAudioSDPInfoL" ) |
|
732 |
|
733 // Update payload type since it might not have been provided at |
|
734 // initialization phase |
|
735 iSettings.iAudioPayloadType = aAudioCodec.iPayloadType; |
|
736 |
|
737 CMccVideoSinkUser* userEntry = FindVideoSinkUserEntryForCurrent(); |
|
738 __ASSERT_ALWAYS( userEntry, User::Leave( KErrNotFound ) ); |
|
739 userEntry->iMediaType = KUidMediaTypeAudio; |
|
740 userEntry->SetCodecInfoL( aAudioCodec ); |
|
741 } |
|
742 |
|
743 // --------------------------------------------------------------------------- |
|
744 // void CMccVideoSinkImpl::EmptyBufferL |
|
745 // |
|
746 // --------------------------------------------------------------------------- |
|
747 // |
|
748 void CMccVideoSinkImpl::EmptyBufferL( CMMFBuffer* aBuffer, |
|
749 MDataSource* /*aSupplier*/, |
|
750 TMediaId aMediaId, |
|
751 TRtpRecvHeader& aHeaderInfo ) |
|
752 { |
|
753 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::EmptyBufferL" ) |
|
754 |
|
755 if ( iState != EPlaying ) |
|
756 { |
|
757 __V_SOURCESINK_CONTROLL( |
|
758 "CMccVideoSinkImpl::EmptyBufferL, not playing, ignore buffer!" ) |
|
759 return; |
|
760 } |
|
761 |
|
762 TInt index = FindVideoSinkUserEntryByMediaType( aMediaId.iMediaType ); |
|
763 __ASSERT_ALWAYS( index != KErrNotFound, User::Leave( KErrNotFound ) ); |
|
764 |
|
765 CMccVideoSinkUser& user = *iUsers[ index ]; |
|
766 |
|
767 __V_SOURCESINK_CONTROLL_INT1( |
|
768 "CMccVideoSinkImpl::EmptyBufferL, streamId:", user.iStreamId ) |
|
769 |
|
770 CMMFDataBuffer* buf = static_cast<CMMFDataBuffer*>( aBuffer ); |
|
771 |
|
772 TInt dataSize = buf->Data().Length(); |
|
773 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl::EmptyBufferL, data size:", |
|
774 dataSize ) |
|
775 |
|
776 if ( AnalyzeTimeStampL( user, aHeaderInfo ) && |
|
777 user.PacketOverflowState() != CMccVideoSinkUser::EOccured && |
|
778 dataSize >= KMccMinPacketSize ) |
|
779 { |
|
780 iRedrawHandler->BlackDrawingL( EFalse ); |
|
781 |
|
782 __V_SOURCESINK_CONTROLL( |
|
783 "CMccVideoSinkImpl::EmptyBufferL, sending packet to helix" ) |
|
784 |
|
785 CMccVideoJitterBuffer::TMccPacketBufferingStatus bufferingStatus = |
|
786 user.EnqueueL( aHeaderInfo, buf->Data() ); |
|
787 |
|
788 if ( bufferingStatus == CMccVideoJitterBuffer::EPlaying ) |
|
789 { |
|
790 DoMvloLoadingComplete( ETrue ); |
|
791 } |
|
792 else |
|
793 { |
|
794 DoMvloLoadingStarted( ETrue ); |
|
795 } |
|
796 |
|
797 iNumPacketsEnqueued++; |
|
798 } |
|
799 else |
|
800 { |
|
801 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::EmptyBufferL, packet dropped" ) |
|
802 } |
|
803 |
|
804 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::EmptyBufferL, exit" ) |
|
805 } |
|
806 |
|
807 // --------------------------------------------------------------------------- |
|
808 // CMccVideoSinkImpl::UpdateSettingsL() |
|
809 // --------------------------------------------------------------------------- |
|
810 // |
|
811 void CMccVideoSinkImpl::UpdateSettingsL( |
|
812 const TMccVideoSinkSetting& aSettings, |
|
813 TBool aForceUpdate ) |
|
814 { |
|
815 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::UpdateSettingsL" ) |
|
816 |
|
817 __ASSERT_ALWAYS( iVideoPlayer, User::Leave( KErrNotReady ) ); |
|
818 |
|
819 if ( aForceUpdate || |
|
820 iSettings.iWindowOrdinalPosition != aSettings.iWindowOrdinalPosition || |
|
821 iSettings.iWindowOrdinalPriority != aSettings.iWindowOrdinalPriority || |
|
822 iSettings.iLocation != aSettings.iLocation || |
|
823 iSettings.iSize != aSettings.iSize || |
|
824 iSettings.iDeviceIndex != aSettings.iDeviceIndex || |
|
825 iSettings.iRotation != aSettings.iRotation ) |
|
826 { |
|
827 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::UpdateSettingsL, settings changed" ) |
|
828 |
|
829 __V_SOURCESINK_CONTROLL_INT2( "CMccVideoSinkImpl window pos:", |
|
830 aSettings.iLocation.iX, " ", aSettings.iLocation.iY ) |
|
831 __V_SOURCESINK_CONTROLL_INT2( "CMccVideoSinkImpl window size (w,h):", |
|
832 aSettings.iSize.iWidth, " ", aSettings.iSize.iHeight ) |
|
833 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl window ordinal pos:", |
|
834 aSettings.iWindowOrdinalPosition ) |
|
835 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl window ordinal priority:", |
|
836 aSettings.iWindowOrdinalPriority ) |
|
837 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl rotation:", |
|
838 aSettings.iRotation ) |
|
839 |
|
840 __ASSERT_ALWAYS( iRw && iRwGroup && iDev, User::Leave( KErrNotReady ) ); |
|
841 |
|
842 // TBD: use also aSettings.iWindowOrdinalPriority |
|
843 iRwGroup->SetOrdinalPosition( aSettings.iWindowOrdinalPosition ); |
|
844 |
|
845 iRw->SetPosition( aSettings.iLocation ); |
|
846 iRw->SetSize( aSettings.iSize ); |
|
847 iRw->SetOrdinalPosition( aSettings.iWindowOrdinalPosition ); |
|
848 |
|
849 iRwSession.Flush(); |
|
850 |
|
851 SetDisplayWindowL( iRwSession, *iDev, *iRw ); |
|
852 |
|
853 SetRotationL( aSettings.iRotation, aForceUpdate ); |
|
854 |
|
855 __V_SOURCESINK_CONTROLL( |
|
856 "CMccVideoSinkImpl::UpdateSettingsL, videoplyer updated" ) |
|
857 } |
|
858 |
|
859 // Store new settings |
|
860 iSettings = aSettings; |
|
861 |
|
862 SetVideoFrameRate( aSettings.iVideoFrameRate ); |
|
863 |
|
864 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::UpdateSettingsL, exit" ) |
|
865 } |
|
866 |
|
867 // --------------------------------------------------------------------------- |
|
868 // CMccVideoSinkImpl::GetCurrentSettings() |
|
869 // --------------------------------------------------------------------------- |
|
870 // |
|
871 void CMccVideoSinkImpl::GetCurrentSettings( TMccVideoSinkSetting& aSettings ) const |
|
872 { |
|
873 aSettings = iSettings; |
|
874 } |
|
875 |
|
876 // --------------------------------------------------------------------------- |
|
877 // CMccVideoSinkImpl::RestorePacketSupply() |
|
878 // --------------------------------------------------------------------------- |
|
879 // |
|
880 void CMccVideoSinkImpl::RestorePacketSupply( TUint aStreamId ) |
|
881 { |
|
882 __V_SOURCESINK_CONTROLL_INT1( |
|
883 "CMccVideoSinkImpl::RestorePacketSupply, streamId:", aStreamId ) |
|
884 iSearchTermUser->Set( 0, KNullUid, aStreamId ); |
|
885 TIdentityRelation<CMccVideoSinkUser> comparison( VideoSinkUserMatch ); |
|
886 TInt index = iUsers.Find( iSearchTermUser, comparison ); |
|
887 if ( index != KErrNotFound ) |
|
888 { |
|
889 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::RestorePacketSupply, found entry") |
|
890 |
|
891 iUsers[ index ]->SetPacketOverflow( CMccVideoSinkUser::ERecovered ); |
|
892 } |
|
893 |
|
894 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::RestorePacketSupply, exit" ) |
|
895 } |
|
896 |
|
897 |
|
898 // --------------------------------------------------------------------------- |
|
899 // CMccVideoSinkImpl::MvloLoadingStarted() |
|
900 // --------------------------------------------------------------------------- |
|
901 // |
|
902 void CMccVideoSinkImpl::MvloLoadingStarted() |
|
903 { |
|
904 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::MvloLoadingStarted" ) |
|
905 |
|
906 DoMvloLoadingStarted(); |
|
907 } |
|
908 |
|
909 // --------------------------------------------------------------------------- |
|
910 // CMccVideoSinkImpl::MvloLoadingComplete() |
|
911 // --------------------------------------------------------------------------- |
|
912 // |
|
913 void CMccVideoSinkImpl::MvloLoadingComplete() |
|
914 { |
|
915 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::MvloLoadingComplete" ) |
|
916 |
|
917 DoMvloLoadingComplete(); |
|
918 } |
|
919 |
|
920 // --------------------------------------------------------------------------- |
|
921 // CMccVideoSinkImpl::MvpuoOpenComplete() |
|
922 // --------------------------------------------------------------------------- |
|
923 // |
|
924 void CMccVideoSinkImpl::MvpuoOpenComplete( TInt aError ) |
|
925 { |
|
926 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::MvpuoOpenComplete" ) |
|
927 |
|
928 if ( !aError && ( iState != EStopped ) ) |
|
929 { |
|
930 iState = EOpened; |
|
931 SetPriority( iSettings.iPriority.iPriority, iSettings.iPriority.iPref ); |
|
932 TRAP( aError, |
|
933 { |
|
934 SetDisplayWindowL( iRwSession, *iDev, *iRw ); |
|
935 SetVolumeL( iVolume ); |
|
936 SetRotationL( iSettings.iRotation, ETrue ); |
|
937 } ); |
|
938 |
|
939 if ( !aError ) |
|
940 { |
|
941 Prepare(); |
|
942 } |
|
943 } |
|
944 |
|
945 if ( aError ) |
|
946 { |
|
947 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl::MvpuoOpenComplete, error:", |
|
948 aError ) |
|
949 |
|
950 SendStreamEventToAllClients( KMccStreamPrepared, aError ); |
|
951 } |
|
952 } |
|
953 |
|
954 // --------------------------------------------------------------------------- |
|
955 // CMccVideoSinkImpl::MvpuoPrepareComplete() |
|
956 // --------------------------------------------------------------------------- |
|
957 // |
|
958 void CMccVideoSinkImpl::MvpuoPrepareComplete( TInt aError ) |
|
959 { |
|
960 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl::MvpuoPrepareComplete(), \ |
|
961 aError=", aError) |
|
962 |
|
963 SendStreamEventToAllClients( KMccStreamPrepared, aError ); |
|
964 } |
|
965 |
|
966 // --------------------------------------------------------------------------- |
|
967 // CMccVideoSinkImpl::MvpuoFrameReady() |
|
968 // --------------------------------------------------------------------------- |
|
969 // |
|
970 void CMccVideoSinkImpl::MvpuoFrameReady( CFbsBitmap& /*aFrame*/, |
|
971 #ifdef _DEBUG |
|
972 TInt aError |
|
973 #else |
|
974 TInt /*aError*/ |
|
975 #endif |
|
976 ) |
|
977 { |
|
978 #ifdef _DEBUG |
|
979 |
|
980 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl::MvpuoFrameReady, \ |
|
981 aError=", aError ) |
|
982 #endif |
|
983 } |
|
984 |
|
985 // --------------------------------------------------------------------------- |
|
986 // CMccVideoSinkImpl::MvpuoPlayComplete() |
|
987 // --------------------------------------------------------------------------- |
|
988 // |
|
989 void CMccVideoSinkImpl::MvpuoPlayComplete( TInt aError ) |
|
990 { |
|
991 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl::MvpuoPlayComplete(), \ |
|
992 aError=", aError) |
|
993 |
|
994 if ( aError ) |
|
995 { |
|
996 SendStreamEventToAllClients( KMccStreamStopped, aError ); |
|
997 } |
|
998 } |
|
999 |
|
1000 // --------------------------------------------------------------------------- |
|
1001 // CMccVideoSinkImpl::MvpuoEvent() |
|
1002 // --------------------------------------------------------------------------- |
|
1003 // |
|
1004 void CMccVideoSinkImpl::MvpuoEvent( const TMMFEvent& aEvent ) |
|
1005 { |
|
1006 __V_SOURCESINK_CONTROLL_INT2( "CMccVideoSinkImpl::MvpuoEvent(), \ |
|
1007 aEvent.iEventType=", (TInt)aEvent.iEventType.iUid, "aEvent.iErrorCode", |
|
1008 aEvent.iErrorCode) |
|
1009 |
|
1010 if ( aEvent.iEventType == KMMFEventCategoryVideoPlayerGeneralError /*&& |
|
1011 aEvent.iErrorCode == KConnectionDone*/ ) |
|
1012 { |
|
1013 // NOP |
|
1014 } |
|
1015 } |
|
1016 |
|
1017 // ----------------------------------------------------------------------------- |
|
1018 // CMccVideoSinkImpl::SetVideoSinkState |
|
1019 // ----------------------------------------------------------------------------- |
|
1020 // |
|
1021 TBool CMccVideoSinkImpl::SetVideoSinkState( TMccVideoSinkState aState ) |
|
1022 { |
|
1023 __V_SOURCESINK_CONTROLL_INT1( |
|
1024 "CMccVideoSinkImpl::SetVideoSinkState, state:", aState ) |
|
1025 |
|
1026 TBool controlSink( iState != aState ); |
|
1027 |
|
1028 TMccEventType eventType = KMccEventNone; |
|
1029 |
|
1030 switch ( aState ) |
|
1031 { |
|
1032 case EOpening: |
|
1033 { |
|
1034 // No event to client |
|
1035 if ( AllUsersReady() ) |
|
1036 { |
|
1037 iState = aState; |
|
1038 } |
|
1039 else |
|
1040 { |
|
1041 // All users not ready, don't start opening yet |
|
1042 controlSink = EFalse; |
|
1043 } |
|
1044 break; |
|
1045 } |
|
1046 case EOpened: |
|
1047 { |
|
1048 // No event to client |
|
1049 iState = aState; |
|
1050 break; |
|
1051 } |
|
1052 case EPrepared: |
|
1053 { |
|
1054 eventType = KMccStreamPrepared; |
|
1055 iState = aState; |
|
1056 break; |
|
1057 } |
|
1058 case EPlaying: |
|
1059 { |
|
1060 CMccVideoSinkUser* userEntry = FindVideoSinkUserEntryForCurrent(); |
|
1061 if ( IsStartedOnce( userEntry ) ) |
|
1062 { |
|
1063 eventType = KMccStreamResumed; |
|
1064 } |
|
1065 else |
|
1066 { |
|
1067 eventType = KMccStreamStarted; |
|
1068 |
|
1069 if ( !controlSink ) |
|
1070 { |
|
1071 SetStartedOnce( userEntry, ETrue ); |
|
1072 } |
|
1073 } |
|
1074 iState = aState; |
|
1075 break; |
|
1076 } |
|
1077 case EPaused: |
|
1078 { |
|
1079 eventType = KMccStreamPaused; |
|
1080 iState = aState; |
|
1081 break; |
|
1082 } |
|
1083 case EStopped: |
|
1084 { |
|
1085 eventType = KMccStreamStopped; |
|
1086 CMccVideoSinkUser* userEntry = FindVideoSinkUserEntryForCurrent(); |
|
1087 SetStartedOnce( userEntry, EFalse ); |
|
1088 iState = aState; |
|
1089 break; |
|
1090 } |
|
1091 default: |
|
1092 { |
|
1093 break; |
|
1094 } |
|
1095 } |
|
1096 |
|
1097 if ( eventType != KMccEventNone && !controlSink ) |
|
1098 { |
|
1099 SendStreamEventToClient( eventType, iCurrentUser ); |
|
1100 } |
|
1101 |
|
1102 return controlSink; |
|
1103 } |
|
1104 |
|
1105 // ----------------------------------------------------------------------------- |
|
1106 // CMccVideoSinkImpl::CreateModesetDesL() |
|
1107 // ----------------------------------------------------------------------------- |
|
1108 // |
|
1109 HBufC8* CMccVideoSinkImpl::CreateModesetDesL( TUint aBitrateMask ) |
|
1110 { |
|
1111 _LIT8( KModesetDelim, "," ); |
|
1112 const TInt KModeValMaxLength = 2; |
|
1113 const TInt KModesMaxAmount = 8; |
|
1114 const TInt KModesetDelimLength = KModesetDelim().Length(); |
|
1115 |
|
1116 HBufC8* modeset = |
|
1117 HBufC8::NewL( KModesMaxAmount * |
|
1118 ( KModeValMaxLength + KModesetDelimLength ) ); |
|
1119 |
|
1120 TPtr8 modesetPtr( modeset->Des() ); |
|
1121 |
|
1122 TBool allModes( |
|
1123 MCC_BITRATE_IN_MASK( aBitrateMask, KMccAllowedAmrNbBitrateAll ) ); |
|
1124 |
|
1125 if ( allModes || |
|
1126 MCC_BITRATE_IN_MASK( aBitrateMask, KMccAllowedAmrNbBitrate475 ) ) |
|
1127 { |
|
1128 modesetPtr.AppendNum( KAMRMode0 ); |
|
1129 modesetPtr.Append( KModesetDelim ); |
|
1130 } |
|
1131 if ( allModes || |
|
1132 MCC_BITRATE_IN_MASK( aBitrateMask, KMccAllowedAmrNbBitrate515 ) ) |
|
1133 { |
|
1134 modesetPtr.AppendNum( KAMRMode1 ); |
|
1135 modesetPtr.Append( KModesetDelim ); |
|
1136 } |
|
1137 if ( allModes || |
|
1138 MCC_BITRATE_IN_MASK( aBitrateMask, KMccAllowedAmrNbBitrate590 ) ) |
|
1139 { |
|
1140 modesetPtr.AppendNum( KAMRMode2 ); |
|
1141 modesetPtr.Append( KModesetDelim ); |
|
1142 } |
|
1143 if ( allModes || |
|
1144 MCC_BITRATE_IN_MASK( aBitrateMask, KMccAllowedAmrNbBitrate670 ) ) |
|
1145 { |
|
1146 modesetPtr.AppendNum( KAMRMode3 ); |
|
1147 modesetPtr.Append( KModesetDelim ); |
|
1148 } |
|
1149 if ( allModes || |
|
1150 MCC_BITRATE_IN_MASK( aBitrateMask, KMccAllowedAmrNbBitrate740 ) ) |
|
1151 { |
|
1152 modesetPtr.AppendNum( KAMRMode4 ); |
|
1153 modesetPtr.Append( KModesetDelim ); |
|
1154 } |
|
1155 if ( allModes || |
|
1156 MCC_BITRATE_IN_MASK( aBitrateMask, KMccAllowedAmrNbBitrate795 ) ) |
|
1157 { |
|
1158 modesetPtr.AppendNum( KAMRMode5 ); |
|
1159 modesetPtr.Append( KModesetDelim ); |
|
1160 } |
|
1161 if ( allModes || |
|
1162 MCC_BITRATE_IN_MASK( aBitrateMask, KMccAllowedAmrNbBitrate102 ) ) |
|
1163 { |
|
1164 modesetPtr.AppendNum( KAMRMode6 ); |
|
1165 modesetPtr.Append( KModesetDelim ); |
|
1166 } |
|
1167 if ( allModes || |
|
1168 MCC_BITRATE_IN_MASK( aBitrateMask, KMccAllowedAmrNbBitrate122 ) ) |
|
1169 { |
|
1170 modesetPtr.AppendNum( KAMRMode7 ); |
|
1171 modesetPtr.Append( KModesetDelim ); |
|
1172 } |
|
1173 |
|
1174 if ( modesetPtr.Length() - KModesetDelimLength >= 0 ) |
|
1175 { |
|
1176 // Remove last delimiter |
|
1177 modesetPtr.Delete( modesetPtr.Length() - KModesetDelimLength, |
|
1178 KModesetDelimLength ); |
|
1179 } |
|
1180 |
|
1181 return modeset; |
|
1182 } |
|
1183 |
|
1184 // ----------------------------------------------------------------------------- |
|
1185 // CMccVideoSinkImpl::SendStreamEventToAllClients() |
|
1186 // ----------------------------------------------------------------------------- |
|
1187 // |
|
1188 void CMccVideoSinkImpl::SendStreamEventToAllClients( |
|
1189 TMccEventType aEventType, |
|
1190 TInt aError, |
|
1191 TBool aAllEndpoints ) |
|
1192 { |
|
1193 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::SendStreamEventToAllClients" ) |
|
1194 |
|
1195 for ( TInt i = 0; i < iUsers.Count(); i++ ) |
|
1196 { |
|
1197 SendStreamEventToClient( aEventType, |
|
1198 iUsers[ i ]->iAsyncEventHandler, |
|
1199 aError, |
|
1200 aAllEndpoints ); |
|
1201 } |
|
1202 } |
|
1203 |
|
1204 // ----------------------------------------------------------------------------- |
|
1205 // CMccVideoSinkImpl::SendStreamEventToClient() |
|
1206 // ----------------------------------------------------------------------------- |
|
1207 // |
|
1208 void CMccVideoSinkImpl::SendStreamEventToClient( |
|
1209 TMccEventType aEventType, |
|
1210 MAsyncEventHandler* aEventHandler, |
|
1211 TInt aError, |
|
1212 TBool aAllEndpoints ) |
|
1213 { |
|
1214 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::SendStreamEventToClient" ) |
|
1215 |
|
1216 if ( aEventHandler ) |
|
1217 { |
|
1218 aEventType = aError ? KMccStreamError : aEventType; |
|
1219 |
|
1220 TUint32 endpointId = |
|
1221 aAllEndpoints ? 0 : iEndpointId; |
|
1222 |
|
1223 TMccEvent event( 0, |
|
1224 0, |
|
1225 0, |
|
1226 endpointId, |
|
1227 KMccEventCategoryStream, |
|
1228 aEventType, |
|
1229 aError, |
|
1230 KNullDesC8 ); |
|
1231 |
|
1232 TMccInternalEvent internalEvent( KMccVideoSinkUid, |
|
1233 EMccInternalEventNone, |
|
1234 event ); |
|
1235 |
|
1236 aEventHandler->SendEventToClient( internalEvent ); |
|
1237 } |
|
1238 else |
|
1239 { |
|
1240 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::SendStreamEventToClient, \ |
|
1241 aEventHandler=NULL" ) |
|
1242 } |
|
1243 } |
|
1244 |
|
1245 // ----------------------------------------------------------------------------- |
|
1246 // CMccVideoSinkImpl::ResolveStreamId() |
|
1247 // ----------------------------------------------------------------------------- |
|
1248 // |
|
1249 TInt CMccVideoSinkImpl::ResolveStreamId( TMediaId aMediaId, TUint& aStreamId ) |
|
1250 { |
|
1251 iSearchTermUser->Set( 0, aMediaId.iMediaType, 0 ); |
|
1252 return FindStreamIdForVideoSinkUser( *iSearchTermUser, aStreamId ); |
|
1253 } |
|
1254 |
|
1255 // ----------------------------------------------------------------------------- |
|
1256 // CMccVideoSinkImpl::ResolveStreamId() |
|
1257 // ----------------------------------------------------------------------------- |
|
1258 // |
|
1259 TInt CMccVideoSinkImpl::ResolveStreamId( |
|
1260 MAsyncEventHandler* aUser, |
|
1261 TUint& aStreamId ) |
|
1262 { |
|
1263 iSearchTermUser->Set( aUser, KNullUid, 0 ); |
|
1264 return FindStreamIdForVideoSinkUser( *iSearchTermUser, aStreamId ); |
|
1265 } |
|
1266 |
|
1267 // --------------------------------------------------------------------------- |
|
1268 // CMccVideoSinkImpl::GenerateStreamId |
|
1269 // --------------------------------------------------------------------------- |
|
1270 // |
|
1271 TUint CMccVideoSinkImpl::GenerateStreamId() |
|
1272 { |
|
1273 return iHelixStreamId++; |
|
1274 } |
|
1275 |
|
1276 // --------------------------------------------------------------------------- |
|
1277 // CMccVideoSinkImpl::FindVideoSinkUserEntryByMediaType |
|
1278 // --------------------------------------------------------------------------- |
|
1279 // |
|
1280 TInt CMccVideoSinkImpl::FindVideoSinkUserEntryByMediaType( TUid aMediaType ) |
|
1281 { |
|
1282 iSearchTermUser->Set( NULL, aMediaType, 0 ); |
|
1283 TIdentityRelation<CMccVideoSinkUser> comparison( VideoSinkUserMatch ); |
|
1284 return iUsers.Find( iSearchTermUser, comparison ); |
|
1285 } |
|
1286 |
|
1287 // --------------------------------------------------------------------------- |
|
1288 // CMccVideoSinkImpl::FindStreamIdForVideoSinkUser |
|
1289 // --------------------------------------------------------------------------- |
|
1290 // |
|
1291 TInt CMccVideoSinkImpl::FindStreamIdForVideoSinkUser( |
|
1292 CMccVideoSinkUser& aEntry, |
|
1293 TUint& aStreamId ) |
|
1294 { |
|
1295 TInt err( KErrNotFound ); |
|
1296 |
|
1297 TIdentityRelation<CMccVideoSinkUser> comparison( VideoSinkUserMatch ); |
|
1298 TInt index = iUsers.Find( &aEntry, comparison ); |
|
1299 if ( index != KErrNotFound ) |
|
1300 { |
|
1301 aStreamId = iUsers[ index ]->iStreamId; |
|
1302 err = KErrNone; |
|
1303 } |
|
1304 return err; |
|
1305 } |
|
1306 |
|
1307 // --------------------------------------------------------------------------- |
|
1308 // CMccVideoSinkImpl::FindVideoSinkUserEntryForCurrent |
|
1309 // --------------------------------------------------------------------------- |
|
1310 // |
|
1311 CMccVideoSinkUser* CMccVideoSinkImpl::FindVideoSinkUserEntryForCurrent() |
|
1312 { |
|
1313 iSearchTermUser->Set( iCurrentUser, KNullUid, 0 ); |
|
1314 TIdentityRelation<CMccVideoSinkUser> comparison( VideoSinkUserMatch ); |
|
1315 TInt index = iUsers.Find( iSearchTermUser, comparison ); |
|
1316 if ( index != KErrNotFound ) |
|
1317 { |
|
1318 return iUsers[ index ]; |
|
1319 } |
|
1320 return NULL; |
|
1321 } |
|
1322 |
|
1323 // --------------------------------------------------------------------------- |
|
1324 // CMccVideoSinkImpl::RemoveVideoSinkUser |
|
1325 // --------------------------------------------------------------------------- |
|
1326 // |
|
1327 void CMccVideoSinkImpl::RemoveVideoSinkUser( |
|
1328 MAsyncEventHandler* aUser, TUint aStreamId ) |
|
1329 { |
|
1330 iSearchTermUser->Set( aUser, KNullUid, aStreamId ); |
|
1331 TIdentityRelation<CMccVideoSinkUser> comparison( VideoSinkUserMatch ); |
|
1332 TInt index = iUsers.Find( iSearchTermUser, comparison ); |
|
1333 if ( index != KErrNotFound ) |
|
1334 { |
|
1335 delete iUsers[ index ]; |
|
1336 iUsers.Remove( index ); |
|
1337 } |
|
1338 |
|
1339 // If there's no more users for this stream id, packet sink is notified |
|
1340 // about stream ending |
|
1341 iSearchTermUser->Set( NULL, KNullUid, aStreamId ); |
|
1342 index = iUsers.Find( iSearchTermUser, comparison ); |
|
1343 if ( iPacketSink && index == KErrNotFound ) |
|
1344 { |
|
1345 iPacketSink->StreamEnd( aStreamId ); |
|
1346 } |
|
1347 } |
|
1348 |
|
1349 // --------------------------------------------------------------------------- |
|
1350 // CMccVideoSinkImpl::VideoSinkUserMatch |
|
1351 // --------------------------------------------------------------------------- |
|
1352 // |
|
1353 TBool CMccVideoSinkImpl::VideoSinkUserMatch( |
|
1354 const CMccVideoSinkUser& aUser1, |
|
1355 const CMccVideoSinkUser& aUser2 ) |
|
1356 { |
|
1357 // First argument is always the search term |
|
1358 |
|
1359 TBool match( EFalse ); |
|
1360 if ( aUser1.iAsyncEventHandler ) |
|
1361 { |
|
1362 match = ( aUser1.iAsyncEventHandler == aUser2.iAsyncEventHandler ); |
|
1363 } |
|
1364 else if ( aUser1.iMediaType != KNullUid ) |
|
1365 { |
|
1366 match = ( aUser1.iMediaType == aUser2.iMediaType ); |
|
1367 } |
|
1368 else |
|
1369 { |
|
1370 match = ( aUser1.iStreamId == aUser2.iStreamId ); |
|
1371 } |
|
1372 return match; |
|
1373 } |
|
1374 |
|
1375 // --------------------------------------------------------------------------- |
|
1376 // CMccVideoSinkImpl::ConstructSdpL |
|
1377 // --------------------------------------------------------------------------- |
|
1378 // |
|
1379 void CMccVideoSinkImpl::ConstructSdpL() |
|
1380 { |
|
1381 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::ConstructSdpL" ) |
|
1382 |
|
1383 __ASSERT_ALWAYS( iSdp, User::Leave( KErrNotReady ) ); |
|
1384 |
|
1385 iSdp->Des().Copy( KMccSdpInboundStart ); |
|
1386 |
|
1387 |
|
1388 // Check amount of mediatypes before constructing sdp as |
|
1389 // sdp contents are affected on that information |
|
1390 TBool multipleMediaTypes( MultipleMediaTypes() ); |
|
1391 for ( TInt i = 0; i < iUsers.Count(); i++ ) |
|
1392 { |
|
1393 iUsers[ i ]->SetMultipleMediaTypesL( multipleMediaTypes ); |
|
1394 } |
|
1395 |
|
1396 HandleAudioSdpL(); |
|
1397 |
|
1398 HandleVideoSdpL(); |
|
1399 |
|
1400 __V_SOURCESINK_CONTROLL_STR8( "SDP:", *iSdp ) |
|
1401 |
|
1402 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::ConstructSdpL, exit" ) |
|
1403 } |
|
1404 |
|
1405 // --------------------------------------------------------------------------- |
|
1406 // CMccVideoSinkImpl::HandleAudioSdpL |
|
1407 // --------------------------------------------------------------------------- |
|
1408 // |
|
1409 void CMccVideoSinkImpl::HandleAudioSdpL() |
|
1410 { |
|
1411 TInt audioEntry = FindVideoSinkUserEntryByMediaType( KUidMediaTypeAudio ); |
|
1412 if ( audioEntry == KErrNotFound ) |
|
1413 { |
|
1414 __V_SOURCESINK_CONTROLL( |
|
1415 "CMccVideoSinkImpl::HandleAudioSdpL, no audio codec defined" ) |
|
1416 return; |
|
1417 } |
|
1418 |
|
1419 // Set correct stream id |
|
1420 iUsers[ audioEntry ]->iStreamId = GenerateStreamId(); |
|
1421 |
|
1422 // Form sdp from codec information |
|
1423 TMccCodecInfo& audioCodec = iUsers[ audioEntry ]->CodecInfo(); |
|
1424 |
|
1425 HBufC8* modeset = CreateModesetDesL( audioCodec.iBitrateMask ); |
|
1426 |
|
1427 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl::HandleAudioSdpL, AudioPayloadType:", |
|
1428 iSettings.iAudioPayloadType ) |
|
1429 |
|
1430 iSdp->Des().AppendFormat( KMccSdpInboundAudio, |
|
1431 iSettings.iAudioPayloadType, |
|
1432 iSettings.iAudioPayloadType, |
|
1433 &audioCodec.iSdpName, |
|
1434 audioCodec.iPtime, |
|
1435 audioCodec.iMaxPtime, |
|
1436 iSettings.iAudioPayloadType, |
|
1437 ( audioCodec.iCodecMode == KAmrCodecModeOctetAlign ), |
|
1438 &*modeset ); |
|
1439 |
|
1440 |
|
1441 delete modeset; |
|
1442 |
|
1443 iSdp->Des().AppendFormat( |
|
1444 KMccSdpInboundPreroll, iUsers[ audioEntry ]->GetPreroll() ); |
|
1445 } |
|
1446 |
|
1447 // --------------------------------------------------------------------------- |
|
1448 // CMccVideoSinkImpl::HandleVideoSdpL |
|
1449 // --------------------------------------------------------------------------- |
|
1450 // |
|
1451 void CMccVideoSinkImpl::HandleVideoSdpL() |
|
1452 { |
|
1453 TUint streamId( 0 ); |
|
1454 TBool firstUserHandled( EFalse ); |
|
1455 for ( TInt i = 0; i < iUsers.Count(); i++ ) |
|
1456 { |
|
1457 CMccVideoSinkUser& user = *iUsers[ i ]; |
|
1458 if ( user.iMediaType == KUidMediaTypeVideo ) |
|
1459 { |
|
1460 if ( !firstUserHandled ) |
|
1461 { |
|
1462 streamId = GenerateStreamId(); |
|
1463 |
|
1464 // Form sdp from codec information |
|
1465 TMccCodecInfo& videoCodec = user.CodecInfo(); |
|
1466 |
|
1467 // Helix uses width and height info for loading appropriate |
|
1468 // video decoder |
|
1469 TInt frameWidth = KH263FrameWidth; |
|
1470 TInt frameHeight = KH263FrameHeight; |
|
1471 |
|
1472 __V_SOURCESINK_CONTROLL_INT1( |
|
1473 "CMccVideoSinkImpl::HandleVideoSdpL, VideoPayloadType:", |
|
1474 iSettings.iVideoPayloadType ) |
|
1475 |
|
1476 HBufC8* fmtp = GetFmtpLC( videoCodec ); |
|
1477 iSdp->Des().AppendFormat( KMccSdpInboundVideo, |
|
1478 iSettings.iVideoPayloadType, |
|
1479 iSettings.iVideoPayloadType, |
|
1480 &videoCodec.iSdpName, |
|
1481 iSettings.iVideoPayloadType, |
|
1482 &*fmtp, |
|
1483 user.GetPayloadSize(), |
|
1484 frameWidth, |
|
1485 frameHeight ); |
|
1486 CleanupStack::PopAndDestroy( fmtp ); |
|
1487 |
|
1488 |
|
1489 iPreroll = user.GetPreroll(); |
|
1490 |
|
1491 if ( RealTimeMode() ) |
|
1492 { |
|
1493 __V_SOURCESINK_CONTROLL( |
|
1494 "CMccVideoSinkImpl::HandleVideoSdpL, disable clock" ) |
|
1495 iSdp->Des().Append( KMccSdpInboundDisableVideoClock ); |
|
1496 |
|
1497 // Currently, preroll needs to be set to some value |
|
1498 // until disable video clock feature is working fully |
|
1499 // at Helix side, once supported fully, preroll value |
|
1500 // will not have any effect. |
|
1501 const TInt KMccVideoSinkRealTimeTransitionPreroll = 500; |
|
1502 iPreroll = KMccVideoSinkRealTimeTransitionPreroll; |
|
1503 } |
|
1504 |
|
1505 __V_SOURCESINK_CONTROLL_INT1( |
|
1506 "CMccVideoSinkImpl::HandleVideoSdpL, iPreroll ", iPreroll ) |
|
1507 iPrerollSet = ETrue; |
|
1508 iSdp->Des().AppendFormat( KMccSdpInboundPreroll, iPreroll ); |
|
1509 |
|
1510 firstUserHandled = ETrue; |
|
1511 } |
|
1512 |
|
1513 // Set correct stream id (all video users will have the same id) |
|
1514 user.iStreamId = streamId; |
|
1515 } |
|
1516 } |
|
1517 } |
|
1518 |
|
1519 // --------------------------------------------------------------------------- |
|
1520 // CMccVideoSinkImpl::AnalyzeTimeStampL |
|
1521 // Checks whether rtp packet belongs to currently played stream. Check is done |
|
1522 // based on timestamp monitoring. If this is new stream, helix needs to be |
|
1523 // resetted as it cannot cope with stream change. Helix is resetted |
|
1524 // immediately if one of media types is detected to be from new stream. |
|
1525 // Packets of other media types need to be dropped until also new stream |
|
1526 // in those begins. |
|
1527 // --------------------------------------------------------------------------- |
|
1528 // |
|
1529 TBool CMccVideoSinkImpl::AnalyzeTimeStampL( |
|
1530 CMccVideoSinkUser& aUser, |
|
1531 TRtpRecvHeader& aHeaderInfo ) |
|
1532 { |
|
1533 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::AnalyzeTimeStampL" ) |
|
1534 |
|
1535 aUser.CalculateAverageTimeStampDifference(); |
|
1536 |
|
1537 if ( aUser.IsResetNeeded( aHeaderInfo ) ) |
|
1538 { |
|
1539 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::AnalyzeTimeStampL, reset needed" ) |
|
1540 |
|
1541 if ( ResetOngoing() ) |
|
1542 { |
|
1543 // XPS was resetted already earlier, allow queueing for this user |
|
1544 aUser.Reset( ETrue ); |
|
1545 } |
|
1546 else |
|
1547 { |
|
1548 DoResetL( ETrue, &aUser ); |
|
1549 |
|
1550 // Other media types cannot pass their data until new stream |
|
1551 // in them begin |
|
1552 for ( TInt i = 0; i < iUsers.Count(); i++ ) |
|
1553 { |
|
1554 if ( iUsers[ i ] != &aUser ) |
|
1555 { |
|
1556 iUsers[ i ]->SetAllowFrame( EFalse ); |
|
1557 } |
|
1558 } |
|
1559 } |
|
1560 |
|
1561 } |
|
1562 |
|
1563 aUser.AddTimeStamp( (TInt64)aHeaderInfo.iTimestamp, aHeaderInfo.iSeqNum ); |
|
1564 |
|
1565 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::AnalyzeTimeStampL, exit" ) |
|
1566 |
|
1567 return aUser.AllowFrame(); |
|
1568 } |
|
1569 |
|
1570 // --------------------------------------------------------------------------- |
|
1571 // CMccVideoSinkImpl::DoResetL |
|
1572 // --------------------------------------------------------------------------- |
|
1573 // |
|
1574 void CMccVideoSinkImpl::DoResetL( TBool aFullReset, CMccVideoSinkUser* aUser ) |
|
1575 { |
|
1576 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::DoResetL" ) |
|
1577 |
|
1578 // Start from scratch. |
|
1579 // |
|
1580 |
|
1581 if ( iVideoPlayer ) |
|
1582 { |
|
1583 // If playing, have to pause, otherwise set position will not work |
|
1584 if ( iState == EPlaying ) |
|
1585 { |
|
1586 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::DoResetL, mode 1" ) |
|
1587 DoPauseL( aUser ); |
|
1588 ResetPacketSink(); |
|
1589 iVideoPlayer->SetPositionL( TTimeIntervalMicroSeconds( 0 ) ); |
|
1590 DoPlay( aUser ); |
|
1591 } |
|
1592 else |
|
1593 { |
|
1594 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::DoResetL, mode 2" ) |
|
1595 ResetPacketSink(); |
|
1596 iVideoPlayer->SetPositionL( TTimeIntervalMicroSeconds( 0 ) ); |
|
1597 } |
|
1598 } |
|
1599 |
|
1600 if ( aUser ) |
|
1601 { |
|
1602 aUser->Reset( aFullReset ); |
|
1603 } |
|
1604 else |
|
1605 { |
|
1606 for ( TInt i = 0; i < iUsers.Count(); i++ ) |
|
1607 { |
|
1608 iUsers[ i ]->Reset( aFullReset ); |
|
1609 } |
|
1610 } |
|
1611 |
|
1612 iNumPacketsEnqueued = 0; |
|
1613 |
|
1614 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::DoResetL, exit" ) |
|
1615 } |
|
1616 |
|
1617 // --------------------------------------------------------------------------- |
|
1618 // CMccVideoSinkImpl::IsPlayerOpened |
|
1619 // --------------------------------------------------------------------------- |
|
1620 // |
|
1621 TBool CMccVideoSinkImpl::IsPlayerOpened() const |
|
1622 { |
|
1623 return ( iState > EOpening ); |
|
1624 } |
|
1625 |
|
1626 // --------------------------------------------------------------------------- |
|
1627 // CMccVideoSinkImpl::ResetPacketSink |
|
1628 // --------------------------------------------------------------------------- |
|
1629 // |
|
1630 void CMccVideoSinkImpl::ResetPacketSink() |
|
1631 { |
|
1632 if ( iPacketSink ) |
|
1633 { |
|
1634 iPacketSink->Reset(); |
|
1635 } |
|
1636 } |
|
1637 |
|
1638 // --------------------------------------------------------------------------- |
|
1639 // CMccVideoSinkImpl::IsStartedOnce |
|
1640 // --------------------------------------------------------------------------- |
|
1641 // |
|
1642 TBool CMccVideoSinkImpl::IsStartedOnce( const CMccVideoSinkUser* aUser ) |
|
1643 { |
|
1644 return ( aUser && aUser->iStartedOnce ); |
|
1645 } |
|
1646 |
|
1647 // --------------------------------------------------------------------------- |
|
1648 // CMccVideoSinkImpl::SetStartedOnce |
|
1649 // --------------------------------------------------------------------------- |
|
1650 // |
|
1651 void CMccVideoSinkImpl::SetStartedOnce( |
|
1652 CMccVideoSinkUser* aUser, |
|
1653 TBool aIsStartedOnce ) |
|
1654 { |
|
1655 if ( aUser ) |
|
1656 { |
|
1657 aUser->iStartedOnce = aIsStartedOnce; |
|
1658 } |
|
1659 } |
|
1660 |
|
1661 // --------------------------------------------------------------------------- |
|
1662 // CMccVideoSinkImpl::SetRotationL |
|
1663 // --------------------------------------------------------------------------- |
|
1664 // |
|
1665 void CMccVideoSinkImpl::SetRotationL( |
|
1666 TMccVideoRotation aRotation, |
|
1667 TBool aForceUpdate ) |
|
1668 { |
|
1669 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSinkImpl::SetRotationL, rotation:", |
|
1670 aRotation ) |
|
1671 __ASSERT_ALWAYS( iVideoPlayer, User::Leave( KErrArgument ) ); |
|
1672 |
|
1673 if ( aForceUpdate || ( aRotation != iSettings.iRotation ) ) |
|
1674 { |
|
1675 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::SetRotationL, setting" ) |
|
1676 |
|
1677 // Enums for videoplayer rotation and mcc rotation are identical |
|
1678 iVideoPlayer->SetRotationL( *iRw, static_cast<TVideoRotation>( aRotation ) ); |
|
1679 } |
|
1680 |
|
1681 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::SetRotationL, exit" ) |
|
1682 } |
|
1683 |
|
1684 |
|
1685 // --------------------------------------------------------------------------- |
|
1686 // CMccVideoSinkImpl::GetActualPrerollL |
|
1687 // --------------------------------------------------------------------------- |
|
1688 // |
|
1689 void CMccVideoSinkImpl::GetActualPrerollL( TInt& aPreroll ) |
|
1690 { |
|
1691 __V_SOURCESINK_CONTROLL_INT1( |
|
1692 "CMccVideoSinkImpl::GetActualPrerollL, iPrerollSet:", iPrerollSet ) |
|
1693 TInt videoEntry = FindVideoSinkUserEntryByMediaType( KUidMediaTypeVideo ); |
|
1694 if ( videoEntry == KErrNotFound ) |
|
1695 { |
|
1696 __V_SOURCESINK_CONTROLL( |
|
1697 "CMccVideoSinkImpl::GetActualPrerollL, no video codec defined" ) |
|
1698 return; |
|
1699 } |
|
1700 |
|
1701 aPreroll = iUsers[ videoEntry ]->GetActualPreroll(); |
|
1702 } |
|
1703 |
|
1704 // --------------------------------------------------------------------------- |
|
1705 // CMccVideoSinkImpl::GetVideoFrameRate |
|
1706 // --------------------------------------------------------------------------- |
|
1707 // |
|
1708 TReal CMccVideoSinkImpl::GetVideoFrameRate() |
|
1709 { |
|
1710 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::GetVideoFrameRate" ) |
|
1711 return iSettings.iVideoFrameRate; |
|
1712 } |
|
1713 |
|
1714 // --------------------------------------------------------------------------- |
|
1715 // CMccVideoSinkImpl::SetVideoFrameRate |
|
1716 // --------------------------------------------------------------------------- |
|
1717 // |
|
1718 void CMccVideoSinkImpl::SetVideoFrameRate( TReal aFrameRate ) |
|
1719 { |
|
1720 __V_SOURCESINK_CONTROLL_INT1( |
|
1721 "CMccVideoSinkImpl::SetVideoFrameRate, framerate:", (TUint32) aFrameRate ) |
|
1722 |
|
1723 if ( aFrameRate > 0 ) |
|
1724 { |
|
1725 iSettings.iVideoFrameRate = aFrameRate; |
|
1726 |
|
1727 for ( TInt i = 0; i < iUsers.Count(); i++ ) |
|
1728 { |
|
1729 TRAP_IGNORE( iUsers[ i ]->SetFrameRateL( iSettings.iVideoFrameRate ) ) |
|
1730 } |
|
1731 } |
|
1732 else |
|
1733 { |
|
1734 iSettings.iVideoFrameRate = KMccDefaultVideoFrameRate; |
|
1735 } |
|
1736 |
|
1737 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::SetVideoFrameRate, exit" ) |
|
1738 } |
|
1739 |
|
1740 // --------------------------------------------------------------------------- |
|
1741 // CMccVideoSinkImpl::ResetOngoing |
|
1742 // --------------------------------------------------------------------------- |
|
1743 // |
|
1744 TBool CMccVideoSinkImpl::ResetOngoing() const |
|
1745 { |
|
1746 for ( TInt i = 0; i < iUsers.Count(); i++ ) |
|
1747 { |
|
1748 if ( !iUsers[ i ]->AllowFrame() ) |
|
1749 { |
|
1750 return ETrue; |
|
1751 } |
|
1752 } |
|
1753 return EFalse; |
|
1754 } |
|
1755 |
|
1756 // --------------------------------------------------------------------------- |
|
1757 // CMccVideoSinkImpl::GetFmtpLC |
|
1758 // --------------------------------------------------------------------------- |
|
1759 // |
|
1760 HBufC8* CMccVideoSinkImpl::GetFmtpLC( const TMccCodecInfo& aCodecInfo ) |
|
1761 { |
|
1762 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::GetFmtpLC" ) |
|
1763 |
|
1764 CMccCodecInformationFactory* factory = CMccCodecInformationFactory::NewL(); |
|
1765 CleanupStack::PushL( factory ); |
|
1766 CMccCodecInformation* codec = |
|
1767 factory->CreateCodecInformationL( aCodecInfo.iSdpName ); |
|
1768 CleanupStack::PushL( codec ); |
|
1769 codec->SetValues( aCodecInfo ); |
|
1770 HBufC8* fmtp = codec->GetFmtpL().AllocL(); |
|
1771 CleanupStack::PopAndDestroy( codec ); |
|
1772 CleanupStack::PopAndDestroy( factory ); |
|
1773 CleanupStack::PushL( fmtp ); |
|
1774 return fmtp; |
|
1775 } |
|
1776 |
|
1777 // --------------------------------------------------------------------------- |
|
1778 // CMccVideoSinkImpl::DoPauseL |
|
1779 // --------------------------------------------------------------------------- |
|
1780 // |
|
1781 void CMccVideoSinkImpl::DoPauseL( const CMccVideoSinkUser* aUser ) |
|
1782 { |
|
1783 if ( !RealTimeMode() ) |
|
1784 { |
|
1785 iVideoPlayer->PauseL(); |
|
1786 } |
|
1787 |
|
1788 DoPauseForUser( aUser ); |
|
1789 } |
|
1790 |
|
1791 // --------------------------------------------------------------------------- |
|
1792 // CMccVideoSinkImpl::DoPauseForUser |
|
1793 // --------------------------------------------------------------------------- |
|
1794 // |
|
1795 void CMccVideoSinkImpl::DoPauseForUser( const CMccVideoSinkUser* aUser ) |
|
1796 { |
|
1797 for ( TInt i = 0; i < iUsers.Count(); i++ ) |
|
1798 { |
|
1799 if ( !aUser || aUser == iUsers[ i ] ) |
|
1800 { |
|
1801 iUsers[ i ]->Pause(); |
|
1802 } |
|
1803 } |
|
1804 } |
|
1805 |
|
1806 // --------------------------------------------------------------------------- |
|
1807 // CMccVideoSinkImpl::DoPlay |
|
1808 // --------------------------------------------------------------------------- |
|
1809 // |
|
1810 void CMccVideoSinkImpl::DoPlay( const CMccVideoSinkUser* aUser ) |
|
1811 { |
|
1812 for ( TInt i = 0; i < iUsers.Count(); i++ ) |
|
1813 { |
|
1814 if ( !aUser || aUser == iUsers[ i ] ) |
|
1815 { |
|
1816 iUsers[ i ]->Play(); |
|
1817 } |
|
1818 } |
|
1819 |
|
1820 iVideoPlayer->Play(); |
|
1821 } |
|
1822 |
|
1823 // --------------------------------------------------------------------------- |
|
1824 // CMccVideoSinkImpl::MultipleMediaTypes |
|
1825 // --------------------------------------------------------------------------- |
|
1826 // |
|
1827 TBool CMccVideoSinkImpl::MultipleMediaTypes() |
|
1828 { |
|
1829 TInt audioEntry = FindVideoSinkUserEntryByMediaType( KUidMediaTypeAudio ); |
|
1830 TInt videoEntry = FindVideoSinkUserEntryByMediaType( KUidMediaTypeVideo ); |
|
1831 return ( audioEntry != KErrNotFound && videoEntry != KErrNotFound ); |
|
1832 } |
|
1833 |
|
1834 // --------------------------------------------------------------------------- |
|
1835 // CMccVideoSinkImpl::RealTimeMode |
|
1836 // --------------------------------------------------------------------------- |
|
1837 // |
|
1838 TBool CMccVideoSinkImpl::RealTimeMode() |
|
1839 { |
|
1840 TBool realTimeMode( EFalse ); |
|
1841 if ( !MultipleMediaTypes() ) |
|
1842 { |
|
1843 for ( TInt i = 0; i < iUsers.Count() && !realTimeMode; i++ ) |
|
1844 { |
|
1845 // If preroll is zero, real time mode is used |
|
1846 if ( iUsers[ i ]->GetPreroll() == 0 ) |
|
1847 { |
|
1848 realTimeMode = ETrue; |
|
1849 } |
|
1850 } |
|
1851 } |
|
1852 |
|
1853 return realTimeMode; |
|
1854 } |
|
1855 |
|
1856 // --------------------------------------------------------------------------- |
|
1857 // CMccVideoSinkImpl::AddUserL |
|
1858 // --------------------------------------------------------------------------- |
|
1859 // |
|
1860 void CMccVideoSinkImpl::AddUserL( MAsyncEventHandler& aEventHandler ) |
|
1861 { |
|
1862 __ASSERT_ALWAYS( iPacketSink, User::Leave( KErrNotReady ) ); |
|
1863 CMccVideoSinkUser* user = CMccVideoSinkUser::NewLC( |
|
1864 &aEventHandler, KNullUid, 0, iSettings.iVideoFrameRate, *iPacketSink ); |
|
1865 iUsers.AppendL( user ); |
|
1866 CleanupStack::Pop( user ); |
|
1867 } |
|
1868 |
|
1869 // --------------------------------------------------------------------------- |
|
1870 // CMccVideoSinkImpl::DoMvloLoadingComplete |
|
1871 // If in realtime mode, helix gives loading completion istantly after starting |
|
1872 // whichis not desired as buffering is done at MCC side. In that case |
|
1873 // loading completion is not notified until MCC jitter buffer completes |
|
1874 // loading (i.e. play threshold is reached). |
|
1875 // --------------------------------------------------------------------------- |
|
1876 // |
|
1877 void CMccVideoSinkImpl::DoMvloLoadingComplete( TBool aSimulated ) |
|
1878 { |
|
1879 if ( RealTimeMode() ) |
|
1880 { |
|
1881 if ( aSimulated && !iSimulatedStreamingEventSent ) |
|
1882 { |
|
1883 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::DoMvloLoadingComplete, simulate" ) |
|
1884 |
|
1885 SendStreamEventToAllClients( KMccStreamPlaying, KErrNone, ETrue ); |
|
1886 |
|
1887 iSimulatedBufferingEventSent = EFalse; |
|
1888 iSimulatedStreamingEventSent = ETrue; |
|
1889 } |
|
1890 } |
|
1891 else if ( !aSimulated ) |
|
1892 { |
|
1893 SendStreamEventToAllClients( KMccStreamPlaying, KErrNone, ETrue ); |
|
1894 } |
|
1895 else |
|
1896 { |
|
1897 // NOP |
|
1898 } |
|
1899 } |
|
1900 |
|
1901 // --------------------------------------------------------------------------- |
|
1902 // CMccVideoSinkImpl::DoMvloLoadingComplete |
|
1903 // If in realtime mode, helix gives loading started instantly after starting |
|
1904 // it (even before passing in any packets). Loading starting is not notified |
|
1905 // until first packet has been passed to MCC video jitterbuffer. |
|
1906 // --------------------------------------------------------------------------- |
|
1907 // |
|
1908 void CMccVideoSinkImpl::DoMvloLoadingStarted( TBool aSimulated ) |
|
1909 { |
|
1910 if ( RealTimeMode() ) |
|
1911 { |
|
1912 if ( aSimulated && !iSimulatedBufferingEventSent ) |
|
1913 { |
|
1914 __V_SOURCESINK_CONTROLL( "CMccVideoSinkImpl::DoMvloLoadingStarted, simulate" ) |
|
1915 |
|
1916 SendStreamEventToAllClients( KMccStreamBuffering, KErrNone, ETrue ); |
|
1917 |
|
1918 iSimulatedBufferingEventSent = ETrue; |
|
1919 iSimulatedStreamingEventSent = EFalse; |
|
1920 } |
|
1921 } |
|
1922 else if ( !aSimulated ) |
|
1923 { |
|
1924 SendStreamEventToAllClients( KMccStreamBuffering, KErrNone, ETrue ); |
|
1925 } |
|
1926 else |
|
1927 { |
|
1928 // NOP |
|
1929 } |
|
1930 } |
|
1931 |
|
1932 // --------------------------------------------------------------------------- |
|
1933 // CMccVideoSinkImpl::AllUsersReady |
|
1934 // Check if some user hasn't yet configured its settings |
|
1935 // --------------------------------------------------------------------------- |
|
1936 // |
|
1937 TBool CMccVideoSinkImpl::AllUsersReady() |
|
1938 { |
|
1939 TBool allUsersReady( ETrue ); |
|
1940 for ( TInt i = 0; i < iUsers.Count(); i++ ) |
|
1941 { |
|
1942 if ( iUsers[ i ]->iMediaType == KNullUid ) |
|
1943 { |
|
1944 allUsersReady = EFalse; |
|
1945 } |
|
1946 } |
|
1947 return allUsersReady; |
|
1948 } |
|
1949 |
|
1950 // End of file |
|
1951 |