mobilemessaging/smilui/mediainc/SmilVideoRenderer.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *       SMIL Player media renderer for playing video files
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef SMILVIDEORENDER_H
       
    22 #define SMILVIDEORENDER_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include <videoplayer.h>
       
    26 #include "SmilMediaRendererBase.h"
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class CFbsBitmap;
       
    30 
       
    31 // CLASS DECLARATION
       
    32 
       
    33 /**
       
    34 * SMIL Player media renderer for playing video files
       
    35 *
       
    36 * @lib smilmediarenderer.lib
       
    37 * @since 2.0
       
    38 */
       
    39 NONSHARABLE_CLASS(CSmilVideoRenderer) : public CSmilMediaRendererBase,
       
    40                                         public MVideoPlayerUtilityObserver,
       
    41                                         public MVideoLoadingObserver
       
    42     {
       
    43     public: // Constructors and destructor
       
    44 
       
    45         /**
       
    46         * Factory method that creates this object.
       
    47         *
       
    48         * @param    aFileHandle    IN File handle to the media file
       
    49         * @param    aMedia         IN SMIL engine side object representing
       
    50         *                             this media file
       
    51         * @param    aDrmCommon     IN DRM Common
       
    52         * @param    aDrmHelper     IN DRM Helper
       
    53         *
       
    54         * @return   pointer to instance
       
    55         */
       
    56         static CSmilVideoRenderer* NewL( RFile& aFileHandle,
       
    57                                          MSmilMedia* aMedia,
       
    58                                          DRMCommon& aDrmCommon,
       
    59                                          CDRMHelper& aDrmHelper );
       
    60 
       
    61         /**
       
    62         * Destructor.
       
    63         */
       
    64         virtual ~CSmilVideoRenderer();
       
    65 
       
    66     public: // Functions from base classes
       
    67 
       
    68         /**
       
    69         * From MSmilMediaRenderer Returns if renderer is visual 
       
    70         * (i.e. draws something to the screen).
       
    71         *
       
    72         * @since 2.0
       
    73         * 
       
    74         * @return Returns ETrue since the media type is visual.
       
    75         */
       
    76         TBool IsVisual() const;
       
    77 
       
    78         /**
       
    79         * From MSmilMediaRenderer Returns if renderer is non-transparent
       
    80         * (i.e. fills all the pixels on specied region).
       
    81         *
       
    82         * @since 2.0
       
    83         *
       
    84         * @return Returns ETrue.
       
    85         *
       
    86         */
       
    87         TBool IsOpaque() const;
       
    88 
       
    89         /**
       
    90         * From MSmilMediaRenderer Returns the unscalable size of the
       
    91         * visual media object.
       
    92         *
       
    93         * @since 2.0
       
    94         * 
       
    95         * @return Width in pixels.
       
    96         */
       
    97         TInt IntrinsicWidth() const;
       
    98 
       
    99         /**
       
   100         * From MSmilMediaRenderer Returns the unscalable size of the
       
   101         * visual media object.
       
   102         *
       
   103         * @since 2.0
       
   104         * 
       
   105         * @return Height in pixels.
       
   106         */
       
   107         TInt IntrinsicHeight() const;
       
   108 
       
   109         /**
       
   110         * From MSmilMediaRenderer Returns the duration of the media object.
       
   111         *
       
   112         * @since 2.0
       
   113         *
       
   114         * @return Returns duration of video.
       
   115         */
       
   116         TSmilTime IntrinsicDuration() const;
       
   117             
       
   118         /**
       
   119         * From MSmilMediaRenderer Called by the engine to signal that
       
   120         * the media is going to be played soon.
       
   121         *
       
   122         * @since 2.0
       
   123         *
       
   124         * @return void
       
   125         */
       
   126         void PrepareMediaL();        
       
   127 
       
   128         /**
       
   129         * From MSmilMediaRenderer Called by the engine to seek the media
       
   130         * to given position in its local timeline.
       
   131         *
       
   132         * @since 2.0
       
   133         * 
       
   134         * @param aTime  IN  Seek position.
       
   135         *
       
   136         * @return void
       
   137         */
       
   138         void SeekMediaL( const TSmilTime& aTime );
       
   139 
       
   140         /**
       
   141         * From MSmilMediaRenderer Called by the engine to start media
       
   142         * playback and to make visual media visible.
       
   143         *
       
   144         * @since 2.0
       
   145         * 
       
   146         * @return void
       
   147         */
       
   148         void ShowMediaL();
       
   149 
       
   150         /**
       
   151         * From MSmilMediaRenderer Called by the engine to stop media
       
   152         * playback and remove visual media from the screen.
       
   153         *
       
   154         * @since 2.0
       
   155         *
       
   156         * @return void
       
   157         */
       
   158         void HideMedia();
       
   159 
       
   160         /**
       
   161         * From MSmilMediaRenderer Called by the engine to pause media playback.
       
   162         *
       
   163         * @since 2.0
       
   164         *
       
   165         * @return void
       
   166         */
       
   167         void FreezeMedia();
       
   168 
       
   169         /**
       
   170         * From MSmilMediaRenderer Called by the engine to continue paused
       
   171         * media playback.
       
   172         *
       
   173         * @since 2.0
       
   174         *
       
   175         * @return void
       
   176         */
       
   177         void ResumeMedia();
       
   178 
       
   179         /**
       
   180         * From MSmilMediaRenderer Set volume of the audio media.
       
   181         *
       
   182         * @since 2.0
       
   183         *
       
   184         * @param aVolume    IN  A percentage value from maximum value that
       
   185         *                       the volume should be set.
       
   186         * @return void
       
   187         */
       
   188         void SetVolume( TInt aVolume );
       
   189 
       
   190         /**
       
   191         * From MSmilMediaRenderer Called by the engine to make a media
       
   192         * renderer draw its content.
       
   193         *
       
   194         * @since 2.0
       
   195         *
       
   196         * @param aGc    IN      Graphical context performing the drawing.
       
   197         * @param aRect  IN      Target rectangle.
       
   198         * @param aTransitionFilter IN Transition effects if present.
       
   199         * @param aFocus IN      Focus indication if focussed.
       
   200         *
       
   201         * @return void
       
   202         */
       
   203         void Draw( CGraphicsContext& aGc,
       
   204                    const TRect& aRect,
       
   205                    CSmilTransitionFilter* aTransitionFilter,
       
   206                    const MSmilFocus* aFocus);
       
   207         
       
   208         /**
       
   209         * From MVideoPlayerUtilityObserver
       
   210         *
       
   211         * @since 2.0
       
   212         *
       
   213         * @param aError IN
       
   214         *
       
   215         * @return void
       
   216         */
       
   217         void MvpuoOpenComplete( TInt aError );
       
   218 
       
   219         /**
       
   220         * From MVideoPlayerUtilityObserver
       
   221         *
       
   222         * @since 2.0
       
   223         *
       
   224         * @param aError IN
       
   225         *
       
   226         * @return void
       
   227         */
       
   228         void MvpuoPrepareComplete( TInt aError );
       
   229 
       
   230         /**
       
   231         * From MVideoPlayerUtilityObserver
       
   232         *
       
   233         * @since 2.0
       
   234         *
       
   235         * @param aFrame IN
       
   236         * @param aError IN
       
   237         *
       
   238         * @return void
       
   239         */
       
   240         void MvpuoFrameReady( CFbsBitmap& aFrame, TInt aError );
       
   241 
       
   242         /**
       
   243         * From MVideoPlayerUtilityObserver
       
   244         *
       
   245         * @since 2.0
       
   246         *
       
   247         * @param aError IN
       
   248         *
       
   249         * @return void
       
   250         */
       
   251         void MvpuoPlayComplete(TInt aError);
       
   252             
       
   253         /**
       
   254         * From MVideoPlayerUtilityObserver
       
   255         *
       
   256         * @since 2.0
       
   257         *
       
   258         * @param aEvent IN
       
   259         *
       
   260         * @return void
       
   261         */
       
   262         void MvpuoEvent( const TMMFEvent& aEvent );
       
   263         
       
   264         /**
       
   265         * From MVideoLoadingObserver
       
   266         *
       
   267         * @since 2.0
       
   268         *
       
   269         * @return void
       
   270         */
       
   271         void MvloLoadingStarted();
       
   272     
       
   273         /**
       
   274         * From MVideoLoadingObserver
       
   275         *
       
   276         * @since 2.0
       
   277         *
       
   278         * @return void
       
   279         */
       
   280         void MvloLoadingComplete();
       
   281     
       
   282     private: // From CCoeControl
       
   283     
       
   284         /**
       
   285         * Draws the control.
       
   286         */
       
   287         void Draw( const TRect& aRect ) const;
       
   288         
       
   289     private:
       
   290 
       
   291         /**
       
   292         * C++ default constructor.
       
   293         */
       
   294         CSmilVideoRenderer();
       
   295         
       
   296         /**
       
   297         * Constructor.
       
   298         */
       
   299         CSmilVideoRenderer( MSmilMedia* aMedia,
       
   300                             DRMCommon& aDrmCommon,
       
   301                             CDRMHelper& aDrmHelper );
       
   302 
       
   303         /**
       
   304         * 2nd phase constructor
       
   305         */
       
   306         void ConstructL( RFile& aFileHandle );    
       
   307 
       
   308         /**
       
   309         * LoadVideoL
       
   310         */
       
   311         void LoadVideoL();
       
   312 
       
   313         /**
       
   314         * DoSetVolumeL
       
   315         *
       
   316         * @param aVolume
       
   317         */
       
   318         void DoSetVolumeL( TInt aVolume );
       
   319         
       
   320         /**
       
   321         * AdjustRects
       
   322         */
       
   323          void AdjustRects( TRect& aRect, TRect& aClipRect ) const;
       
   324 
       
   325         /**
       
   326         * UpdateDrawingArea
       
   327         */
       
   328         void UpdateDrawingArea();
       
   329     
       
   330         /**
       
   331         * IsClipEndingL
       
   332         */
       
   333         TBool IsClipEndingL() const;
       
   334     
       
   335         /**
       
   336         * UpdateSoftKeyVisibility
       
   337         */
       
   338         void UpdateSoftKeyVisibility();
       
   339         
       
   340         /**
       
   341         * DoPause
       
   342         */
       
   343         void DoPause();
       
   344         
       
   345         /**
       
   346         * Returns control rectangle relative to parent control rectangle.
       
   347         */
       
   348         TRect ControlRect() const;
       
   349          
       
   350         /**
       
   351         * Returns video rectangle relative to screen.
       
   352         */ 
       
   353         TRect VideoRect() const; 
       
   354         
       
   355         /**
       
   356         * Returns ETrue if presentation is playing.
       
   357         */
       
   358         TBool PresentationPlaying() const;
       
   359         
       
   360         /**
       
   361         * Performs reopening steps.
       
   362         */
       
   363         void DoLatePreparationL();
       
   364 
       
   365         /**
       
   366         * Returns ETrue if video is played for the whole presentation
       
   367         * from it's start to end.
       
   368         */
       
   369         TBool PlayedForWholePresentation() const;
       
   370         
       
   371         /**
       
   372         * Performs resuming.
       
   373         */
       
   374         void DoResumeL();
       
   375         
       
   376     private: // data
       
   377 
       
   378         enum TState
       
   379             {
       
   380             ENotReady = 0,
       
   381             EReady,
       
   382             ELoading,
       
   383             EPlaying,
       
   384             EPaused,
       
   385             EHidden,
       
   386             EError
       
   387             };
       
   388 
       
   389         // Playback engine.
       
   390         CVideoPlayerUtility* iVideoPlayer;
       
   391         
       
   392         // Duration.
       
   393         TSmilTime iIntrinsicDuration;
       
   394 
       
   395         // Internal state.
       
   396         TInt iState;
       
   397         
       
   398         // Internal error code.
       
   399         TInt iError;
       
   400 
       
   401         // Current clipping rectangle.
       
   402         TRect iCurrentClipRect;
       
   403         
       
   404         // Operation start time.
       
   405         TTime iStartTime;
       
   406     
       
   407         // Determines whether to use late preparation.
       
   408         TBool iLatePreparation;
       
   409     
       
   410         // Specifies the time taken by some operation.
       
   411         TTimeIntervalMicroSeconds iProcessingDelay;
       
   412         
       
   413         // Handle to media file. 
       
   414         // Duplicate made because of late preparation
       
   415         RFile iMediaFile;
       
   416         
       
   417         // Parent control for video control
       
   418         CCoeControl* iParent;
       
   419 
       
   420         // Position where pausing happened.
       
   421         TTimeIntervalMicroSeconds iPausePosition;
       
   422         
       
   423         // Old volume to remember 
       
   424         TInt iOldVolume;
       
   425     };
       
   426 
       
   427 #endif // SMILVIDEORENDER_H
       
   428