upnpframework/upnpcommand/inc/upnpimagerenderingengine.h
branchnew development branch with rendering state machine and other goodies
changeset 38 5360b7ddc251
parent 0 7f85d04be362
equal deleted inserted replaced
32:3785f754ee62 38:5360b7ddc251
     1 /*
     1 /*
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    21 
    21 
    22 // INCLUDES
    22 // INCLUDES
    23 #include <e32base.h>
    23 #include <e32base.h>
    24 #include "upnpavrenderingsessionobserver.h" // base class
    24 #include "upnpavrenderingsessionobserver.h" // base class
    25 #include "upnpitemresolverobserver.h" // base class
    25 #include "upnpitemresolverobserver.h" // base class
       
    26 #include "upnprenderingstatemachineobserver.h" // base class
    26 
    27 
    27 // FORWARD DECLARATIONS
    28 // FORWARD DECLARATIONS
    28 class MUPnPAVController;
    29 class MUPnPAVController;
    29 class MUPnPAVRenderingSession;
    30 class MUPnPAVRenderingSession;
    30 class MUpnpImageRenderingEngineObserver;
    31 class MUpnpImageRenderingEngineObserver;
    31 class MUPnPItemResolver;
    32 class MUPnPItemResolver;
       
    33 class CUpnpRenderingStateMachine;
    32 class CUPnPPeriodic;
    34 class CUPnPPeriodic;
    33 
    35 
    34 /**
    36 /**
    35 * This class defines the UpnpShowTask used in UpnpCommand component.
    37 * This class defines the UpnpShowTask used in UpnpCommand component.
    36 *
    38 *
    38 */
    40 */
    39 class CUpnpImageRenderingEngine
    41 class CUpnpImageRenderingEngine
    40     : public CBase
    42     : public CBase
    41     , public MUPnPItemResolverObserver
    43     , public MUPnPItemResolverObserver
    42     , public MUPnPAVRenderingSessionObserver
    44     , public MUPnPAVRenderingSessionObserver
       
    45     , public MUpnpRenderingStateMachineObserver
    43     {
    46     {
       
    47     
    44 
    48 
    45     public: // construction
    49     public: // construction
    46 
    50 
    47         /**
    51         /**
    48          * static constructor
    52          * static constructor
    73      
    77      
    74         /**
    78         /**
    75          * Second phase constructor
    79          * Second phase constructor
    76          */
    80          */
    77         void ConstructL();
    81         void ConstructL();
    78         
       
    79         
       
    80         /**
       
    81          * Cleans up used resources
       
    82          */
       
    83         void Cleanup();
       
    84 
    82 
    85     public: // the interface
    83     public: // the interface
    86 
    84 
    87         /**
    85         /**
    88          * Requests to start rendering. This will cause the engine to query
    86          * Requests to start rendering. This will cause the engine to query
    92          * states and indicate errors etc.
    90          * states and indicate errors etc.
    93          */
    91          */
    94         void PlayL();
    92         void PlayL();
    95 
    93 
    96         /**
    94         /**
    97          * Requests to stop rendering. This method can be called in all states.
    95          * Requests to stop rendering.
    98          */
    96          */
    99         void StopL();
    97         void StopL();
   100 
    98 
   101 
    99 
   102     protected: // Call back methods of MUPnPAVRenderingSessionObserver
   100     protected: // Call back methods of MUPnPAVRenderingSessionObserver
   157         /**
   155         /**
   158          * See UpnpAvControllerHelper API for more info.
   156          * See UpnpAvControllerHelper API for more info.
   159          */
   157          */
   160         void ResolveComplete(
   158         void ResolveComplete(
   161             const MUPnPItemResolver& aResolver, TInt aError );
   159             const MUPnPItemResolver& aResolver, TInt aError );
   162 
   160     
       
   161     protected: // from MUpnpRenderingStateMachineObserver
       
   162         
       
   163          /**
       
   164           * Indicates state machine has been synchronised with the renderer
       
   165           *
       
   166           * @since Series 60 3.2
       
   167           * @param aError error that occurred during sync
       
   168           */
       
   169         void RendererSyncReady( TInt aError,
       
   170                             Upnp::TState aState );
       
   171         
       
   172         /**
       
   173          * Indicates renderer state has changed either by request 
       
   174          * or spontanelously.
       
   175          *
       
   176          * @since Series 60 3.2
       
   177          * @param aError the error code
       
   178          * @param aState the new state
       
   179          * @param aUserOriented ETrue if this responds to a request
       
   180          * @param aStateParam extra info depending on the state change
       
   181          */
       
   182         void RenderingStateChanged(
       
   183                             TInt aError,
       
   184                             Upnp::TState aState,
       
   185                             TBool aUserOriented,
       
   186                             TInt aStateParam );
       
   187         /**
       
   188          * Synchronises UI with media duration and current position
       
   189          * this callback can be either automatic or explicitly requested
       
   190          *
       
   191          * @since Series 60 3.2
       
   192          * @param aError error that occurred during position sync
       
   193          * @param aMode mode in which the track is progressing
       
   194          * @param aDuration media duration in milliseconds
       
   195          * @param aPosition current position in milliseconds
       
   196          */
       
   197         void PositionSync( TInt aError,
       
   198                             Upnp::TPositionMode aMode,
       
   199                             TInt aDuration, TInt aPosition );
       
   200             
   163     public: // methods for the timer
   201     public: // methods for the timer
   164 
   202 
   165         /**
   203         /**
   166          * the timeout callback
   204          * the timeout callback
   167          */
   205          */
   173         void RunTimerL();
   211         void RunTimerL();
   174 
   212 
   175         /**
   213         /**
   176          * handles errors in the timeout callback body
   214          * handles errors in the timeout callback body
   177          */
   215          */
   178         TInt RunError( TInt );
   216         TInt RunError( TInt aError );
   179         
   217         
   180          /**
   218          /**
   181          * checks if wlan is active
   219           * checks if wlan is active
   182          */       
   220           */
   183         TBool IsWlanActive();
   221         TBool IsWlanActive();
   184         
   222         
   185     private: // Private methods
   223     private: // Private methods
   186 
   224 
   187         /**
   225         /**
   188          * Handles the initiation of rendering (SetUri or video player 
   226          * Handles the start up of the item resolving.
   189          * launching).
       
   190          *
   227          *
   191          * @since S60 3.2
   228          * @since S60 3.2
   192          */
   229          * @param none
   193         void InitiateShowingL();
   230          * @return none
   194 
   231          */
   195         /**
   232         void StartResolvingL();
   196          * Handles the start up of the item resolving.
   233         
       
   234         
       
   235         /**
       
   236          * Sends an acknowledgement
   197          *
   237          *
   198          * @since S60 3.2
   238          * @since S60 3.2
   199          */
   239          * @param aError error code
   200         void StartResolvingL();
   240          * @return none
   201         
   241         */
   202         
   242         void SendRenderAck( TInt aError );
   203         /**
   243         
   204          * Sends an acknowledgement
   244         /**
   205 		 */
   245          * Cycles next item by checking resolver status
   206 		void SendRenderAck( TInt aError );
   246          *
   207 
   247          * @since S60 3.2
       
   248          * @param none
       
   249          * @return none
       
   250          */
       
   251         void Cycle();
       
   252         
       
   253         /**
       
   254          * Cleans up used resources
       
   255          *
       
   256          * @since S60 3.2
       
   257          * @param none
       
   258          * @return none
       
   259          */
       
   260         void Cleanup();
       
   261         
   208     private: // Data members
   262     private: // Data members
   209 
   263 
   210         // avcontroller
   264         // avcontroller
   211         MUPnPAVController&          iAVController;
   265         MUPnPAVController&                  iAVController;
   212     
   266     
   213         // the rendering session
   267         // the rendering session
   214         MUPnPAVRenderingSession&    iRenderingSession;
   268         MUPnPAVRenderingSession&            iRenderingSession;
   215 
   269 
   216         // The observer interface
   270         // The observer interface
   217         MUpnpImageRenderingEngineObserver&  iObserver;
   271         MUpnpImageRenderingEngineObserver&  iObserver;
   218 
   272 
   219         // internal states
   273         // internal states
   220         enum TRenderingState
   274         enum TRenderingState
   221             {
   275             {
   222             EIdle = 100,            // doing nothing
   276             EIdle = 100,     // doing nothing
   223             EResolvingItem,         // resolving (preparing the item to be played)
   277             EResolvingItem,  // resolving (preparing the item to be played)
   224             EResolveComplete,       // resolve done succesfully. Starting to play
   278             EResolveComplete,// resolve done succesfully. Starting to play
   225             EStopping,              // calling Stop (for previoysly playing item)
   279             ERendering,      // Check accurate state from statemachine
   226             ESettingUri,            // calling SetAVTransportURI
       
   227             EStartingPlay,          // calling Play
       
   228             EPlaying,               // play OK, just displaying the image :-)
       
   229             EShuttingDown
   280             EShuttingDown
   230             };
   281             };
   231 
   282 
   232         // internal state
   283         // internal state
   233         TRenderingState             iState;
   284         TRenderingState                     iState;
   234 
       
   235         // current resolver. owned.
   285         // current resolver. owned.
   236         MUPnPItemResolver*          iCurrentResolver;
   286         MUPnPItemResolver*                  iCurrentResolver;
   237 
   287 
   238         // Buffered next resolver. Owned.
   288         // Buffered next resolver. Owned.
   239         MUPnPItemResolver*          iBufferedResolver;
   289         MUPnPItemResolver*                  iBufferedResolver;
   240 
   290 
   241         // flag that indicates a new image is in buffer
   291         // flag that indicates a new image is in buffer
   242         TBool                       iBufferingNewImage;
   292         TBool                               iBufferingNewImage;
   243 
   293 
   244 		// timer support
   294         // timer support
   245 		CUPnPPeriodic*              iTimer;
   295         CUPnPPeriodic*                      iTimer;
   246 		
   296 
   247 		TBool                       iWlanActive;
   297         // Flag if WLan active or not
   248 
   298         TBool                               iWlanActive;
   249 	};
   299         
       
   300 
       
   301         // the rendering state machine
       
   302         CUpnpRenderingStateMachine*         iRenderingStateMachine;
       
   303 
       
   304     };
   250 
   305 
   251 
   306 
   252 #endif // UPNP_IMAGERENDERINGENGINE_H
   307 #endif // UPNP_IMAGERENDERINGENGINE_H
   253 
   308 
   254 // End of File
   309 // End of File