upnpframework/upnpcommand/inc/upnpimagerenderingengine.h
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Engine for rendering images remotely
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef UPNP_IMAGERENDERINGENGINE_H
       
    20 #define UPNP_IMAGERENDERINGENGINE_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include "upnpavrenderingsessionobserver.h" // base class
       
    25 #include "upnpitemresolverobserver.h" // base class
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class MUPnPAVController;
       
    29 class MUPnPAVRenderingSession;
       
    30 class MUpnpImageRenderingEngineObserver;
       
    31 class MUPnPItemResolver;
       
    32 class CUPnPPeriodic;
       
    33 
       
    34 /**
       
    35 * This class defines the UpnpShowTask used in UpnpCommand component.
       
    36 *
       
    37 * @since S60 3.2
       
    38 */
       
    39 class CUpnpImageRenderingEngine
       
    40     : public CBase
       
    41     , public MUPnPItemResolverObserver
       
    42     , public MUPnPAVRenderingSessionObserver
       
    43     {
       
    44 
       
    45     public: // construction
       
    46 
       
    47         /**
       
    48          * static constructor
       
    49          * @param aAVController avcontroller resource
       
    50          * @param aSession the rendering session to work with
       
    51          * @param aObserver the client for this engine
       
    52          */
       
    53         static CUpnpImageRenderingEngine* NewL(
       
    54             MUPnPAVController& aAVController,
       
    55             MUPnPAVRenderingSession& aSession,
       
    56             MUpnpImageRenderingEngineObserver& aObserver);
       
    57 
       
    58         /**
       
    59          * destructor
       
    60          */
       
    61         virtual ~CUpnpImageRenderingEngine();
       
    62 
       
    63     private: // private part of construction
       
    64 
       
    65         /**
       
    66          * constructor
       
    67          */
       
    68         CUpnpImageRenderingEngine(
       
    69             MUPnPAVController& aAVController,
       
    70             MUPnPAVRenderingSession& aSession,
       
    71             MUpnpImageRenderingEngineObserver& aObserver);
       
    72         
       
    73      
       
    74         /**
       
    75          * Second phase constructor
       
    76          */
       
    77         void ConstructL();
       
    78         
       
    79         
       
    80         /**
       
    81          * Cleans up used resources
       
    82          */
       
    83         void Cleanup();
       
    84 
       
    85     public: // the interface
       
    86 
       
    87         /**
       
    88          * Requests to start rendering. This will cause the engine to query
       
    89          * the media to render using the callback interface.
       
    90          * This method can be called in all states and all conditions
       
    91          * and subsequently very fast. The engine will keep track of
       
    92          * states and indicate errors etc.
       
    93          */
       
    94         void PlayL();
       
    95 
       
    96         /**
       
    97          * Requests to stop rendering. This method can be called in all states.
       
    98          */
       
    99         void StopL();
       
   100 
       
   101 
       
   102     protected: // Call back methods of MUPnPAVRenderingSessionObserver
       
   103 
       
   104         /**
       
   105          * UPnP AV Controller calls this method to return the result for the
       
   106          * 'set uri' request.
       
   107          *
       
   108          * @since Series 60 3.1
       
   109          * @param aError error code
       
   110          * @return None
       
   111          */
       
   112         void SetURIResult( TInt aError );
       
   113 
       
   114         /**
       
   115          * UPnP AV Controller calls this method to indicate that the requested
       
   116          * interaction operation (play, stop, etc.) is complete. In other
       
   117          * words, the target rendering device has changed it's state 
       
   118          * accordingly.
       
   119          *
       
   120          * @since Series 60 3.1
       
   121          * @param aError (TInt) error code
       
   122          * @param aOperation (TAVInteractOperation) operation Id
       
   123          */
       
   124         void InteractOperationComplete( TInt aError,
       
   125             TUPnPAVInteractOperation aOperation );
       
   126 
       
   127         /**
       
   128          * Notifies that the Media Renderer we have a session with has
       
   129          * disappeared. Session is now unusable and must be closed. 
       
   130          *
       
   131          * @since Series 60 3.1
       
   132          * @param aReason (TUPnPDeviceDisconnectedReason) reason code
       
   133          */
       
   134         void MediaRendererDisappeared(
       
   135             TUPnPDeviceDisconnectedReason aReason );
       
   136 
       
   137         // Methods that are not used
       
   138         void VolumeResult(
       
   139                         TInt /*aError*/,
       
   140                         TInt /*aVolumeLevel*/,
       
   141                         TBool /*aActionResponse*/) {}
       
   142         void MuteResult(
       
   143                         TInt /*aError*/,
       
   144                         TBool /*aMute*/,
       
   145                         TBool /*aActionResponse*/ ) {}
       
   146         void PositionInfoResult(
       
   147                         TInt /*aError*/,
       
   148                         const TDesC8& /*aTrackPosition*/,
       
   149                         const TDesC8& /*aTrackLength*/ ) {}
       
   150         void SetNextURIResult(
       
   151                         TInt /*aError*/ ) {}
       
   152             
       
   153         void ReserveLocalMSServicesCompleted( TInt /*aError*/ ) {}
       
   154 
       
   155     protected: // Methods from MUPnPItemResolverObserver
       
   156 
       
   157         /**
       
   158          * See UpnpAvControllerHelper API for more info.
       
   159          */
       
   160         void ResolveComplete(
       
   161             const MUPnPItemResolver& aResolver, TInt aError );
       
   162 
       
   163     public: // methods for the timer
       
   164 
       
   165         /**
       
   166          * the timeout callback
       
   167          */
       
   168         static TInt Timer( TAny* aArg );
       
   169 
       
   170         /**
       
   171          * handles the timeout internally
       
   172          */
       
   173         void RunTimerL();
       
   174 
       
   175         /**
       
   176          * handles errors in the timeout callback body
       
   177          */
       
   178         TInt RunError( TInt );
       
   179         
       
   180          /**
       
   181          * checks if wlan is active
       
   182          */       
       
   183         TBool IsWlanActive();
       
   184         
       
   185     private: // Private methods
       
   186 
       
   187         /**
       
   188          * Handles the initiation of rendering (SetUri or video player 
       
   189          * launching).
       
   190          *
       
   191          * @since S60 3.2
       
   192          */
       
   193         void InitiateShowingL();
       
   194 
       
   195         /**
       
   196          * Handles the start up of the item resolving.
       
   197          *
       
   198          * @since S60 3.2
       
   199          */
       
   200         void StartResolvingL();
       
   201         
       
   202         
       
   203         /**
       
   204          * Sends an acknowledgement
       
   205 		 */
       
   206 		void SendRenderAck( TInt aError );
       
   207 
       
   208     private: // Data members
       
   209 
       
   210         // avcontroller
       
   211         MUPnPAVController&          iAVController;
       
   212     
       
   213         // the rendering session
       
   214         MUPnPAVRenderingSession&    iRenderingSession;
       
   215 
       
   216         // The observer interface
       
   217         MUpnpImageRenderingEngineObserver&  iObserver;
       
   218 
       
   219         // internal states
       
   220         enum TRenderingState
       
   221             {
       
   222             EIdle = 100,            // doing nothing
       
   223             EResolvingItem,         // resolving (preparing the item to be played)
       
   224             EResolveComplete,       // resolve done succesfully. Starting to play
       
   225             EStopping,              // calling Stop (for previoysly playing item)
       
   226             ESettingUri,            // calling SetAVTransportURI
       
   227             EStartingPlay,          // calling Play
       
   228             EPlaying,               // play OK, just displaying the image :-)
       
   229             EShuttingDown
       
   230             };
       
   231 
       
   232         // internal state
       
   233         TRenderingState             iState;
       
   234 
       
   235         // current resolver. owned.
       
   236         MUPnPItemResolver*          iCurrentResolver;
       
   237 
       
   238         // Buffered next resolver. Owned.
       
   239         MUPnPItemResolver*          iBufferedResolver;
       
   240 
       
   241         // flag that indicates a new image is in buffer
       
   242         TBool                       iBufferingNewImage;
       
   243 
       
   244 		// timer support
       
   245 		CUPnPPeriodic*              iTimer;
       
   246 		
       
   247 		TBool                       iWlanActive;
       
   248 
       
   249 	};
       
   250 
       
   251 
       
   252 #endif // UPNP_IMAGERENDERINGENGINE_H
       
   253 
       
   254 // End of File