32 #include "upnpitemresolverfactory.h" // UPnPItemResolverFactory |
32 #include "upnpitemresolverfactory.h" // UPnPItemResolverFactory |
33 #include "upnpitemutility.h" // UPnPItemUtility::BelongsToClass |
33 #include "upnpitemutility.h" // UPnPItemUtility::BelongsToClass |
34 |
34 |
35 // upnpframework / commonui |
35 // upnpframework / commonui |
36 #include "upnpcommonui.h" // common UI for upnp video player dlg |
36 #include "upnpcommonui.h" // common UI for upnp video player dlg |
|
37 #include "upnprenderingstatemachine.h" // rendering state machine |
37 |
38 |
38 // command internal |
39 // command internal |
39 #include "upnpimagerenderingengineobserver.h" // the observer interface |
40 #include "upnpimagerenderingengineobserver.h" // the observer interface |
40 #include "upnpimagerenderingengine.h" // myself |
41 #include "upnpimagerenderingengine.h" // self |
41 #include "upnpperiodic.h" |
42 #include "upnpperiodic.h" |
42 |
43 |
43 _LIT( KComponentLogfile, "upnpcommand.log"); |
44 _LIT( KComponentLogfile, "upnpcommand.log"); |
44 #include "upnplog.h" |
45 #include "upnplog.h" |
45 |
46 |
46 // CONSTANT DEFINITIONS |
47 // CONSTANT DEFINITIONS |
47 const TInt KReactionTimerMicrosec = 100000; // 100 millisec. |
48 const TInt KReactionTimerMicrosec = 100000; // 100 millisec. |
48 |
|
49 |
49 |
50 // -------------------------------------------------------------------------- |
50 // -------------------------------------------------------------------------- |
51 // CUpnpImageRenderingEngine::NewL |
51 // CUpnpImageRenderingEngine::NewL |
52 // -------------------------------------------------------------------------- |
52 // -------------------------------------------------------------------------- |
53 // |
53 // |
97 // |
98 // |
98 void CUpnpImageRenderingEngine::ConstructL() |
99 void CUpnpImageRenderingEngine::ConstructL() |
99 { |
100 { |
100 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::ConstructL" ); |
101 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::ConstructL" ); |
101 iTimer = CUPnPPeriodic::NewL( CActive::EPriorityStandard ); |
102 iTimer = CUPnPPeriodic::NewL( CActive::EPriorityStandard ); |
102 |
103 iRenderingStateMachine = |
103 iWlanActive = ETrue; |
104 CUpnpRenderingStateMachine::NewL( iRenderingSession ); |
|
105 iRenderingStateMachine->SetObserver( *this ); |
|
106 iRenderingStateMachine->SyncL(); |
104 } |
107 } |
105 |
108 |
106 // -------------------------------------------------------------------------- |
109 // -------------------------------------------------------------------------- |
107 // Destructor. |
110 // Destructor. |
108 // -------------------------------------------------------------------------- |
111 // -------------------------------------------------------------------------- |
109 // |
112 // |
110 CUpnpImageRenderingEngine::~CUpnpImageRenderingEngine() |
113 CUpnpImageRenderingEngine::~CUpnpImageRenderingEngine() |
111 { |
114 { |
112 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine: Destructor" ); |
115 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine:\ |
113 |
116 Destructor" ); |
114 Cleanup(); |
117 Cleanup(); |
115 |
118 |
116 // Stop observing the rendering session |
119 // Stop observing the rendering session |
117 iRenderingSession.RemoveObserver(); |
120 iRenderingSession.RemoveObserver(); |
118 |
121 |
119 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::~CUpnpImageRenderingEngine delete iCurrentResolver" ); |
122 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\ |
|
123 ~CUpnpImageRenderingEngine delete iCurrentResolver" ); |
120 MUPnPItemResolver* tempCurrentResolver = iCurrentResolver; |
124 MUPnPItemResolver* tempCurrentResolver = iCurrentResolver; |
121 iCurrentResolver = NULL; |
125 iCurrentResolver = NULL; |
122 delete tempCurrentResolver; |
126 delete tempCurrentResolver; |
123 |
127 |
124 if( iTimer ) |
128 if ( iRenderingStateMachine ) |
|
129 { |
|
130 iRenderingStateMachine->RemoveObserver(); |
|
131 delete iRenderingStateMachine; |
|
132 iRenderingStateMachine = NULL; |
|
133 } |
|
134 |
|
135 if( iTimer ) |
125 { |
136 { |
126 iTimer->Cancel(); |
137 iTimer->Cancel(); |
127 delete iTimer; |
138 delete iTimer; |
128 iTimer = 0; |
139 iTimer = 0; |
129 } |
140 } |
147 { |
158 { |
148 iTimer->Cancel(); |
159 iTimer->Cancel(); |
149 } |
160 } |
150 |
161 |
151 iBufferingNewImage = EFalse; |
162 iBufferingNewImage = EFalse; |
152 |
|
153 // Delete resolvers |
163 // Delete resolvers |
154 // Delete for resolvers is done using temporary variables so that we can |
164 // Delete for resolvers is done using temporary variables so that we can |
155 // first nullify the members and then delete the actual objects. |
165 // first nullify the members and then delete the actual objects. |
156 // This is because local resolver deletion uses active scheduler loops |
166 // This is because local resolver deletion uses active scheduler loops |
157 // and therefore other asynchronous events may orrur. So we may end |
167 // and therefore other asynchronous events may orrur. So we may end |
158 // up here in Cleanup again, during the resolver is being deleted. |
168 // up here in Cleanup again, during the resolver is being deleted. |
159 // if deletion is done the conventional way, the objects get deleted |
169 // if deletion is done the conventional way, the objects get deleted |
160 // twice, which is not what we want. :-) |
170 // twice, which is not what we want. :-) |
161 |
171 |
162 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::Cleanup delete iBufferedResolver" ); |
172 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\ |
|
173 Cleanup delete iBufferedResolver" ); |
163 MUPnPItemResolver* tempBufferedResolver = iBufferedResolver; |
174 MUPnPItemResolver* tempBufferedResolver = iBufferedResolver; |
164 iBufferedResolver = NULL; |
175 iBufferedResolver = NULL; |
165 delete tempBufferedResolver; |
176 delete tempBufferedResolver; |
166 |
177 |
167 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::Cleanup end" ); |
178 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::Cleanup end" ); |
289 User::Leave( KErrCancel ); |
286 User::Leave( KErrCancel ); |
290 } |
287 } |
291 |
288 |
292 switch( iState ) |
289 switch( iState ) |
293 { |
290 { |
294 case EIdle: // fall through |
291 case EIdle: |
295 { |
292 { |
296 StartResolvingL(); |
293 StartResolvingL(); |
297 break; |
294 break; |
298 } |
295 } |
299 case EResolvingItem: // fall through |
296 case EResolvingItem: // fall through |
300 case EResolveComplete: |
297 case EResolveComplete: // fall through |
301 case ESettingUri: // fall through |
|
302 case EStartingPlay: |
|
303 { |
298 { |
304 // indicate that new image is being buffered. It will be popped |
299 // indicate that new image is being buffered. It will be popped |
305 // from buffer in next callback. |
300 // from buffer in next callback. |
306 iBufferingNewImage = ETrue; |
301 iBufferingNewImage = ETrue; |
307 break; |
302 break; |
308 } |
303 } |
309 case EPlaying: |
304 case ERendering: |
310 { |
305 { |
311 // indicate that new image is being buffered. Send stop signal. |
306 // indicate that new image is being buffered. Send stop signal. |
312 // new item will be handled after stop completed. |
307 // new item will be handled after stop completed. |
313 iBufferingNewImage = ETrue; |
308 if( !iBufferingNewImage ) |
314 iRenderingSession.StopL(); |
309 { |
315 iState = EStopping; |
310 iBufferingNewImage = ETrue; |
316 break; |
311 iRenderingStateMachine->CommandL( Upnp::EStop, 0, NULL ); |
317 } |
312 } |
318 case EStopping: |
313 else |
319 { |
314 { |
320 // indicate that new image is being buffered. It will be popped |
315 // stop already sent, wait for response and do nothing |
321 // from buffer in next callback. |
316 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::RunTimerL,\ |
322 iBufferingNewImage = ETrue; |
317 wait for stop" ); |
|
318 } |
323 break; |
319 break; |
324 } |
320 } |
325 case EShuttingDown: |
321 case EShuttingDown: |
326 { |
322 { |
327 // command not allowed in this state |
323 // command not allowed in this state |
328 break; |
324 break; |
329 } |
325 } |
330 default: |
326 default: |
331 { |
327 { |
332 __PANICD( __FILE__, __LINE__ ); |
328 __PANIC( __FILE__, __LINE__ ); |
333 break; |
329 break; |
334 } |
330 } |
335 } |
331 } |
336 } |
332 } |
337 |
333 |
|
334 // -------------------------------------------------------------------------- |
|
335 // CUpnpImageRenderingEngine::RunError |
|
336 // Exception occurred in the timer body |
|
337 // -------------------------------------------------------------------------- |
|
338 // |
|
339 TInt CUpnpImageRenderingEngine::RunError( TInt aError ) |
|
340 { |
|
341 __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::\ |
|
342 RunError aError %d", aError ); |
|
343 Cleanup(); |
|
344 SendRenderAck( aError ); |
|
345 return KErrNone; |
|
346 } |
|
347 |
338 // -------------------------------------------------------------------------- |
348 // -------------------------------------------------------------------------- |
339 // CUpnpImageRenderingEngine::StartResolvingL |
349 // CUpnpImageRenderingEngine::StartResolvingL |
340 // Handles the start up of the item resolving. |
350 // Handles the start up of the item resolving. |
341 // -------------------------------------------------------------------------- |
351 // -------------------------------------------------------------------------- |
342 // |
352 // |
376 // CUpnpImageRenderingEngine::ResolveComplete |
386 // CUpnpImageRenderingEngine::ResolveComplete |
377 // Indicates that resolving of an item is complete. |
387 // Indicates that resolving of an item is complete. |
378 // -------------------------------------------------------------------------- |
388 // -------------------------------------------------------------------------- |
379 // |
389 // |
380 void CUpnpImageRenderingEngine::ResolveComplete( |
390 void CUpnpImageRenderingEngine::ResolveComplete( |
381 const MUPnPItemResolver& aResolver, |
391 const MUPnPItemResolver& aResolver, |
382 TInt aError ) |
392 TInt aError ) |
383 { |
393 { |
384 __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::ResolveComplete\ |
394 __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::ResolveComplete\ |
385 in state %d", iState ); |
395 aError %d", aError ); |
386 |
396 |
387 // if engine is shutting down, no need to check these |
397 // if engine is shutting down, no need to check these |
388 if ( iState == EResolvingItem ) |
398 if ( iState == EResolvingItem ) |
389 { |
399 { |
390 __ASSERTD( &aResolver == iCurrentResolver, __FILE__, __LINE__ ); |
400 __ASSERT( &aResolver == iCurrentResolver, __FILE__, __LINE__ ); |
|
401 |
391 if( iBufferingNewImage ) |
402 if( iBufferingNewImage ) |
392 { |
403 { |
393 TRAP( aError, StartResolvingL() ); |
404 TRAP( aError, StartResolvingL() ); |
394 } |
405 } |
395 else if( aError == KErrNone ) |
406 else if( aError == KErrNone ) |
396 { |
407 { |
397 iState = EResolveComplete; |
408 iState = ERendering; |
|
409 const CUpnpItem& item = iCurrentResolver->Item(); |
|
410 |
|
411 if ( UPnPItemUtility::BelongsToClass( item, KClassImage ) ) |
|
412 { |
|
413 __LOG1( "[UpnpCommand]\t play image item of resolver 0x%d", |
|
414 TInt(iCurrentResolver) ); |
|
415 Cycle(); |
|
416 } |
|
417 else if ( UPnPItemUtility::BelongsToClass( item, KClassVideo ) ) |
|
418 { |
|
419 __LOG( "[UpnpCommand]\t video, inform observer to play it" ); |
|
420 aError = iObserver.RenderAck( KErrNotSupported, &item ); |
|
421 } |
|
422 } |
398 |
423 |
399 // Now that we have the full metadata of the item available, we |
|
400 // can start the rendering |
|
401 TRAP( aError, InitiateShowingL() ); |
|
402 } |
|
403 // error handling |
424 // error handling |
404 if( aError != KErrNone && iState != EShuttingDown ) |
425 if( aError != KErrNone && iState != EShuttingDown ) |
405 { |
426 { |
406 SendRenderAck( aError ); |
427 SendRenderAck( aError ); |
407 } |
428 } |
419 } |
440 } |
420 |
441 |
421 } |
442 } |
422 |
443 |
423 // -------------------------------------------------------------------------- |
444 // -------------------------------------------------------------------------- |
424 // CUpnpImageRenderingEngine::InitiateShowingL |
|
425 // Handles the initiation of rendering (SetUri or video player launching). |
|
426 // -------------------------------------------------------------------------- |
|
427 void CUpnpImageRenderingEngine::InitiateShowingL() |
|
428 { |
|
429 __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::InitiateShowingL\ |
|
430 in state %d", |
|
431 iState ); |
|
432 __ASSERTD( iCurrentResolver, __FILE__, __LINE__ ); |
|
433 |
|
434 if ( UPnPItemUtility::BelongsToClass( |
|
435 iCurrentResolver->Item(), KClassImage ) ) |
|
436 { |
|
437 // Send the setUri action |
|
438 iRenderingSession.SetURIL( |
|
439 iCurrentResolver->Resource().Value(), |
|
440 iCurrentResolver->Item() ); |
|
441 // update the state |
|
442 iState = ESettingUri; |
|
443 } |
|
444 else |
|
445 { |
|
446 User::Leave( KErrNotSupported ); |
|
447 } |
|
448 } |
|
449 |
|
450 |
|
451 // -------------------------------------------------------------------------- |
|
452 // CUpnpImageRenderingEngine::SetURIResult |
445 // CUpnpImageRenderingEngine::SetURIResult |
453 // UPnP AV Controller calls this method as a result for the 'set uri' request. |
446 // UPnP AV Controller calls this method as a result for the 'set uri' request. |
454 // -------------------------------------------------------------------------- |
447 // -------------------------------------------------------------------------- |
455 // |
448 // |
456 void CUpnpImageRenderingEngine::SetURIResult( TInt aError ) |
449 void CUpnpImageRenderingEngine::SetURIResult( TInt aError ) |
457 { |
450 { |
458 __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::SetURIResult\ |
451 __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::SetURIResult\ |
459 in state %d", |
452 in aError %d", aError ); |
460 iState ); |
453 |
461 |
454 if ( iState == ERendering ) |
462 if ( iState == ESettingUri ) |
455 { |
463 { |
456 if( iBufferingNewImage && aError == KErrNone) |
464 //need check the aError in case of SetURIL cause a error. |
457 { |
465 if( aError != KErrNone ) |
458 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\ |
466 { |
459 SetURIResult - pass cancel to rendering state machine" ); |
467 Cleanup(); |
460 iRenderingStateMachine->SetURIResult( KErrCancel ); |
468 return; |
|
469 } |
|
470 __ASSERTD( iCurrentResolver, __FILE__, __LINE__ ); |
|
471 if( iBufferingNewImage ) |
|
472 { |
|
473 TRAP( aError, StartResolvingL() ); |
|
474 } |
461 } |
475 else if( aError == KErrNone ) |
462 else if( aError == KErrNone ) |
476 { |
463 { |
477 TRAP( aError, iRenderingSession.PlayL() ); |
464 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\ |
478 if( aError == KErrNone ) |
465 SetURIResult - pass uri result to rendering state machine" ); |
479 { |
466 iRenderingStateMachine->SetURIResult( aError ); |
480 // Update the state |
|
481 iState = EStartingPlay; |
|
482 } |
|
483 } |
|
484 // error handling |
|
485 if( aError != KErrNone ) |
|
486 { |
|
487 SendRenderAck( aError ); |
|
488 } |
467 } |
489 } |
468 } |
490 else if ( iState == EShuttingDown ) |
469 else if ( iState == EShuttingDown ) |
491 { |
470 { |
492 // do nothing |
471 // do nothing |
493 } |
472 } |
494 else |
|
495 { |
|
496 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine: state error." ); |
|
497 __PANICD( __FILE__, __LINE__ ); |
|
498 iState = EIdle; |
|
499 } |
|
500 |
|
501 } |
473 } |
502 |
474 |
503 // -------------------------------------------------------------------------- |
475 // -------------------------------------------------------------------------- |
504 // CUpnpImageRenderingEngine::InteractOperationComplete |
476 // CUpnpImageRenderingEngine::InteractOperationComplete |
505 // Called by UpnpAvController to indicate that play is complete. |
477 // Called by UpnpAvController to indicate that play is complete. |
508 void CUpnpImageRenderingEngine::InteractOperationComplete( |
480 void CUpnpImageRenderingEngine::InteractOperationComplete( |
509 TInt aError, |
481 TInt aError, |
510 TUPnPAVInteractOperation aOperation ) |
482 TUPnPAVInteractOperation aOperation ) |
511 { |
483 { |
512 __LOG2( "[UpnpCommand]\t CUpnpImageRenderingEngine::\ |
484 __LOG2( "[UpnpCommand]\t CUpnpImageRenderingEngine::\ |
513 InteractOperationComplete (%d) in state %d", aOperation, iState ); |
485 InteractOperationComplete aOperation %d aError %d", aOperation, aError ); |
514 |
486 if ( iState != EShuttingDown ) |
515 if ( iState == EStartingPlay ) |
487 { |
516 { |
488 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\ |
517 __ASSERTD( iCurrentResolver, __FILE__, __LINE__ ); |
489 InteractOperationComplete - pass operation to rendering state machine" ); |
518 if( aOperation == EUPnPAVPlay && iBufferingNewImage ) |
490 iRenderingStateMachine->InteractOperationComplete( |
519 { |
491 aError, aOperation ); |
520 // New image in buffer! call stop, then play new item. |
492 } |
521 TRAP( aError, iRenderingSession.StopL() ); |
493 } |
522 if ( aError == KErrNone ) |
|
523 { |
|
524 iState = EStopping; |
|
525 } |
|
526 } |
|
527 else if ( aOperation == EUPnPAVPlay && aError == KErrNone ) |
|
528 { |
|
529 // update status |
|
530 iState = EPlaying; |
|
531 // response for play request |
|
532 SendRenderAck( KErrNone ); |
|
533 } |
|
534 // error handling |
|
535 if ( aError != KErrNone ) |
|
536 { |
|
537 SendRenderAck( aError ); |
|
538 } |
|
539 } |
|
540 else if ( iState == EPlaying ) |
|
541 { |
|
542 if( aOperation == EUPnPAVPlayUser ) |
|
543 { |
|
544 // state change event notification |
|
545 // no need to do anything here |
|
546 } |
|
547 else if( aOperation == EUPnPAVStopUser ) |
|
548 { |
|
549 // user stop notification |
|
550 // state to idle, so that no stop event will be sent |
|
551 // if starting to process new item |
|
552 iState = EIdle; |
|
553 } |
|
554 } |
|
555 else if ( iState == EStopping ) |
|
556 { |
|
557 __ASSERTD( iCurrentResolver, __FILE__, __LINE__ ); |
|
558 if( aOperation == EUPnPAVStop && iBufferingNewImage ) |
|
559 { |
|
560 TRAP( aError, StartResolvingL() ); |
|
561 } |
|
562 else if ( aOperation == EUPnPAVStop && aError == KErrNone ) |
|
563 { |
|
564 // succesful stop - go IDLE |
|
565 iState = EIdle; |
|
566 } |
|
567 // error handling |
|
568 if ( aError != KErrNone ) |
|
569 { |
|
570 SendRenderAck( aError ); |
|
571 } |
|
572 } |
|
573 else if ( iState == EShuttingDown ) |
|
574 { |
|
575 if ( aOperation == EUPnPAVStop || aOperation == EUPnPAVPlay ) |
|
576 { |
|
577 iState = EIdle; |
|
578 } |
|
579 } |
|
580 |
|
581 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::InteractOperationComplete end " ); |
|
582 } |
|
583 |
|
584 |
|
585 |
|
586 |
494 |
587 // -------------------------------------------------------------------------- |
495 // -------------------------------------------------------------------------- |
588 // CUpnpImageRenderingEngine::MediaRendererDisappeared |
496 // CUpnpImageRenderingEngine::MediaRendererDisappeared |
589 // Notifies that the Media Renderer we have a session with has disappeared. |
497 // Notifies that the Media Renderer we have a session with has disappeared. |
590 // Session is now unusable and must be closed. |
498 // Session is now unusable and must be closed. |
609 } |
517 } |
610 iState = EShuttingDown; // avoid all callbacks |
518 iState = EShuttingDown; // avoid all callbacks |
611 iObserver.EngineShutdown( KErrDisconnected ); |
519 iObserver.EngineShutdown( KErrDisconnected ); |
612 } |
520 } |
613 } |
521 } |
614 |
|
615 // -------------------------------------------------------------------------- |
|
616 // CUpnpImageRenderingEngine::RunError |
|
617 // Exception occurred in the timer body |
|
618 // -------------------------------------------------------------------------- |
|
619 // |
|
620 TInt CUpnpImageRenderingEngine::RunError( TInt aError ) |
|
621 { |
|
622 __LOG2( "[UpnpCommand]\t CUpnpImageRenderingEngine::\ |
|
623 RunError in state %d aError %d", iState, aError ); |
|
624 Cleanup(); |
|
625 SendRenderAck( aError ); |
|
626 return KErrNone; |
|
627 } |
|
628 |
|
629 |
|
630 |
522 |
631 // -------------------------------------------------------------------------- |
523 // -------------------------------------------------------------------------- |
632 // CUpnpImageRenderingEngine::SendRenderAck |
524 // CUpnpImageRenderingEngine::SendRenderAck |
633 // Exception occurred in the timer body |
525 // Exception occurred in the timer body |
634 // -------------------------------------------------------------------------- |
526 // -------------------------------------------------------------------------- |
674 // CUpnpImageRenderingEngine::IsWlanActive |
566 // CUpnpImageRenderingEngine::IsWlanActive |
675 // If connection to renderer is lost, checks if wlan is still active |
567 // If connection to renderer is lost, checks if wlan is still active |
676 // -------------------------------------------------------------------------- |
568 // -------------------------------------------------------------------------- |
677 // |
569 // |
678 TBool CUpnpImageRenderingEngine::IsWlanActive() |
570 TBool CUpnpImageRenderingEngine::IsWlanActive() |
679 { |
571 { |
|
572 __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::\ |
|
573 IsWlanActive iWlanActive=%d ", iWlanActive ); |
680 return iWlanActive; |
574 return iWlanActive; |
681 } |
575 } |
|
576 |
|
577 // -------------------------------------------------------------------------- |
|
578 // CUpnpImageRenderingEngine::Cycle |
|
579 // Cycles next item by checking resolver status. |
|
580 // -------------------------------------------------------------------------- |
|
581 // |
|
582 void CUpnpImageRenderingEngine::Cycle() |
|
583 { |
|
584 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::Cycle" ); |
|
585 |
|
586 TRAPD( err, iRenderingStateMachine->CommandL( |
|
587 Upnp::EPlay, 0, &iCurrentResolver->Item() ) ); |
|
588 |
|
589 if ( KErrNone != err ) |
|
590 { |
|
591 SendRenderAck( err ); |
|
592 } |
|
593 } |
|
594 |
|
595 |
|
596 // -------------------------------------------------------------------------- |
|
597 // CUpnpImageRenderingEngine::RendererSyncReady |
|
598 // Callback from rendering state machine when sync is ready. |
|
599 // -------------------------------------------------------------------------- |
|
600 // |
|
601 void CUpnpImageRenderingEngine::RendererSyncReady( TInt aError, |
|
602 Upnp::TState aState ) |
|
603 { |
|
604 __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::\ |
|
605 RendererSyncReady aError=%d ", aError ); |
|
606 |
|
607 if( aState != Upnp::EStopped ) |
|
608 { |
|
609 // Renderer is used by another controlpoint. Cannot continue. |
|
610 iState = EShuttingDown; // avoid all callbacks |
|
611 iObserver.EngineShutdown( KErrInUse ); |
|
612 } |
|
613 else if ( KErrNone != aError ) |
|
614 { |
|
615 // notify observer if error. currently there will not |
|
616 // any error from rendering state machine but may be |
|
617 // in future. |
|
618 SendRenderAck( aError ); |
|
619 } |
|
620 } |
|
621 |
|
622 // -------------------------------------------------------------------------- |
|
623 // CUpnpImageRenderingEngine::RenderingStateChanged |
|
624 // Callback from rendering state machine when rendering state changes. |
|
625 // -------------------------------------------------------------------------- |
|
626 // |
|
627 void CUpnpImageRenderingEngine::RenderingStateChanged( TInt aError, |
|
628 Upnp::TState aState , TBool aActionResponse, TInt /*aStateParam*/ ) |
|
629 { |
|
630 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\ |
|
631 RenderingStateChanged" ); |
|
632 |
|
633 __LOG3( "[UpnpCommand]\t aError=%d aState=0x%x aActionResponse=%d", |
|
634 aError, aState, aActionResponse ); |
|
635 |
|
636 if ( Upnp::EStopped == aState ) |
|
637 { |
|
638 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\ |
|
639 RenderingStateChanged - image play stopped" ); |
|
640 |
|
641 iState = EIdle; |
|
642 |
|
643 // new image waiting -> start resolving |
|
644 if( iBufferingNewImage ) |
|
645 { |
|
646 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\ |
|
647 RenderingStateChanged - start resolving new image"); |
|
648 TRAP( aError, StartResolvingL() ); |
|
649 } |
|
650 } |
|
651 else if ( Upnp::EPlaying == aState ) |
|
652 { |
|
653 // new image waiting -> wait for stop |
|
654 // stop has already been sent |
|
655 if( iBufferingNewImage ) |
|
656 { |
|
657 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\ |
|
658 RenderingStateChanged to play - new image -> wait for stop"); |
|
659 } |
|
660 |
|
661 // image playing -> inform observer |
|
662 else if( aActionResponse && KErrNone == aError ) |
|
663 { |
|
664 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\ |
|
665 RenderingStateChanged - image play started "); |
|
666 SendRenderAck( aError ); |
|
667 } |
|
668 } |
|
669 |
|
670 // Error handling |
|
671 if ( KErrNone != aError ) |
|
672 { |
|
673 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\ |
|
674 RenderingStateChanged - Error situation" ); |
|
675 SendRenderAck( aError ); |
|
676 } |
|
677 } |
|
678 |
|
679 // -------------------------------------------------------------------------- |
|
680 // CUpnpImageRenderingEngine::RendererSyncReady |
|
681 // Callback from rendering state machine when rendering position is sync. |
|
682 // -------------------------------------------------------------------------- |
|
683 // |
|
684 void CUpnpImageRenderingEngine::PositionSync( TInt /*aError*/, |
|
685 Upnp::TPositionMode /*aMode*/, |
|
686 TInt /*aDuration*/, |
|
687 TInt /*aPosition*/ ) |
|
688 { |
|
689 __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\ |
|
690 PositionSync" ); |
|
691 } |
682 |
692 |
683 // End of File |
693 // End of File |