videoplayback/videoplaybackview/inc/videoplaybackcontrolscontroller.h
changeset 44 518105d52e45
child 49 824471cb468a
equal deleted inserted replaced
42:17f382c040b1 44:518105d52e45
       
     1 /*
       
     2 * Copyright (c) 2009 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:  Implementation of VideoPlaybackControlsController
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: da1mmcf#23 %
       
    19 
       
    20 
       
    21 
       
    22 #ifndef VIDEOPLAYBACKCONTROLSCONTROLLER_H_
       
    23 #define VIDEOPLAYBACKCONTROLSCONTROLLER_H_
       
    24 
       
    25 // INCLUDES
       
    26 #include <QObject>
       
    27 #include <QPixmap>
       
    28 
       
    29 #include <mpxplaybackframeworkdefs.h>
       
    30 
       
    31 #include "mpxvideo_debug.h"
       
    32 #include "videoplaybackcontrol.hrh"
       
    33 #include "mpxcommonvideoplaybackview.hrh"
       
    34 #include "videoplaybackviewfiledetails.h"
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 class QTimer;
       
    38 class QString;
       
    39 class HbAction;
       
    40 class ThumbnailManager;
       
    41 class HbVolumeSliderPopup ;
       
    42 class CMPXVideoViewWrapper;
       
    43 class VideoBasePlaybackView;
       
    44 class VideoPlaybackControlPolicy;
       
    45 class VideoPlaybackDocumentLoader;
       
    46 class VideoPlaybackFullScreenControl;
       
    47 class VideoPlaybackControlsController;
       
    48 class VideoPlaybackControlConfiguration;
       
    49 class VideoServices;
       
    50 
       
    51 
       
    52 // DATA TYPES
       
    53 
       
    54 enum TTimerAction
       
    55 {
       
    56     ETimerCancel,
       
    57     ETimerReset
       
    58 };
       
    59 
       
    60 enum TThumbNailState
       
    61 {
       
    62     EThumbNailEmpty,
       
    63     EThumbNailNotAvailable,
       
    64     EThumbNailRequsted,
       
    65     EThumbNailSet
       
    66 };
       
    67 
       
    68 enum TPlaybackViewMode
       
    69 {
       
    70     EFullScreenView,
       
    71     EDetailsView,
       
    72     EAudioOnlyView
       
    73 };
       
    74 
       
    75 const int KControlsTimeOut = 4000;
       
    76 const int KRNLogoTimeOut = 600;
       
    77 
       
    78 const QString KPLAYBACKVIEW_DOCML = ":/videoplaybackview/videoplaybackview.docml";
       
    79 
       
    80 
       
    81 // CLASS DECLARATION
       
    82 
       
    83 class VideoPlaybackControlsController : public QObject
       
    84 {
       
    85     Q_OBJECT
       
    86 
       
    87     public:
       
    88 
       
    89         /**
       
    90         * constructor.
       
    91         */
       
    92         VideoPlaybackControlsController(
       
    93                 VideoBasePlaybackView *view,
       
    94                 CMPXVideoViewWrapper *viewWrapper,
       
    95                 VideoPlaybackViewFileDetails *details );
       
    96 
       
    97         /**
       
    98         * Destructor.
       
    99         */
       
   100         virtual ~VideoPlaybackControlsController();
       
   101 
       
   102     public:
       
   103 
       
   104         /**
       
   105         * Handle event from container
       
   106         */
       
   107         void handleEvent( TVideoPlaybackControlCommandIds event, int value = 0 );
       
   108 
       
   109         /**
       
   110         * Command handling function.
       
   111         * Call HandleCommandL() of container
       
   112         */
       
   113         void handleCommand( TMPXVideoPlaybackViewCommandIds command, int value = 0 );
       
   114 
       
   115         /*
       
   116         * Return ETrue if TV-out cable gets connected
       
   117         */
       
   118         inline bool isTvOutConnected();
       
   119 
       
   120         /**
       
   121         * Reset or cancel timers for the controls
       
   122         */
       
   123         void resetDisappearingTimers( TTimerAction timerAction );
       
   124 
       
   125         /**
       
   126         * Return state
       
   127         */
       
   128         inline TMPXPlaybackState state();
       
   129 
       
   130         /**
       
   131         * Return file details
       
   132         */
       
   133         inline VideoPlaybackViewFileDetails* fileDetails();
       
   134 
       
   135         //
       
   136         //  Add the file details to the controls controller when available
       
   137         //
       
   138         void addFileDetails( VideoPlaybackViewFileDetails* details );
       
   139 
       
   140         inline VideoPlaybackDocumentLoader* layoutLoader();
       
   141 
       
   142         inline VideoBasePlaybackView* view();
       
   143 
       
   144         void updateVideoRectDone();
       
   145 
       
   146         inline TPlaybackViewMode viewMode();
       
   147 
       
   148         void changeViewMode( TPlaybackViewMode viewMode, bool transitionEffect = true );
       
   149 
       
   150         inline bool isAttachOperation();
       
   151 
       
   152         bool isRNLogoBitmapInControlList();
       
   153         
       
   154         bool shouldShowRNLogo();
       
   155 
       
   156     private:
       
   157         /**
       
   158         * Initialize controller
       
   159         */
       
   160         void initializeController();
       
   161 
       
   162         /**
       
   163         * Update controls
       
   164         */
       
   165         void handleStateChange( TMPXPlaybackState newState );
       
   166 
       
   167         /**
       
   168         * Show Controls and reset the timers
       
   169         */
       
   170         void showControls();
       
   171 
       
   172         /**
       
   173         * Return ETrue if any control is visible
       
   174         */
       
   175         bool isVisible();
       
   176 
       
   177         /**
       
   178         * Append a control based on control index
       
   179         */
       
   180         void appendControl( TVideoPlaybackControls controlIndex );
       
   181 
       
   182         /**
       
   183         * Set changed volume
       
   184         */
       
   185         void volumeChanged( int volume );
       
   186 
       
   187         /**
       
   188         * Set changed duration
       
   189         */
       
   190         void durationChanged( int duration);
       
   191 
       
   192         /**
       
   193         * Set changed position
       
   194         */
       
   195         void positionChanged( int position );
       
   196 
       
   197         /**
       
   198         * Set changed position
       
   199         */
       
   200         void aspectRatioChanged( int aspectRatio );
       
   201 
       
   202         /*
       
   203          *  Sets the download size on the progress bar
       
   204          */
       
   205         void setDownloadSize( int size );
       
   206 
       
   207         /*
       
   208          *  Updates the download ratio on the progress bar
       
   209          */
       
   210         void updateDownloadPosition( int newSize );
       
   211 
       
   212         /**
       
   213         * Set changed state on the controls
       
   214         */
       
   215         void updateState();
       
   216 
       
   217         /**
       
   218         * Check whether this clip is real format or not
       
   219         */
       
   220         bool realFormat( QString filename );
       
   221 
       
   222         /**
       
   223         * Check whether this clip is real format or not for streaming/live streaming
       
   224         */
       
   225         bool realFormatForStreaming( const TDesC& des );
       
   226 
       
   227         /**
       
   228         * Check whether this clip is real format or not for local/progressive donwload
       
   229         */
       
   230         bool realFormatForLocal();
       
   231         
       
   232         /**
       
   233         * Handle errors
       
   234         */
       
   235         void handleErrors(); 
       
   236         
       
   237         /**
       
   238 		* Return true if control is visible
       
   239 		*/
       
   240 		bool isSoftKeyVisible();
       
   241 
       
   242         /**
       
   243         * Handle tvout connected/disconnected event
       
   244         */
       
   245 		void handleTvOutEvent( bool connected, 
       
   246 		                       TVideoPlaybackControlCommandIds event );
       
   247 
       
   248 		void updateVideoRect(  bool transitionEffect = true );
       
   249 
       
   250 		void showVolumeControls();
       
   251 
       
   252 		void setDefaultBitmap();
       
   253 
       
   254 		void generateThumbNail();
       
   255 
       
   256     signals:
       
   257 
       
   258         /**
       
   259         * Signals the file path of the current video to VideoServices
       
   260         *
       
   261         * @param filePath of the video
       
   262         */
       
   263         void attachVideoPath( const QString& );
       
   264 
       
   265     private slots:
       
   266         void hideAllControls();
       
   267         void skipToNextVideoItem();
       
   268         void skipToPreviousVideoItem();
       
   269         void handleTappedOnScreen();
       
   270         void handleThumbnailReady( QPixmap tnData, void *internal , int id, int error );
       
   271         void controlsListUpdated();
       
   272         void attachVideo();
       
   273         void sendVideo();
       
   274         void handleRNLogoVisibleChanged();
       
   275         void handleRNLogoTimeout();
       
   276         void handleOrientationChanged( Qt::Orientation orientation );
       
   277 
       
   278     private:
       
   279         VideoBasePlaybackView                     *mView;
       
   280         CMPXVideoViewWrapper                      *mViewWrapper;
       
   281         VideoPlaybackViewFileDetails              *mFileDetails;
       
   282 
       
   283         QList<VideoPlaybackFullScreenControl*> mControls;
       
   284 
       
   285         VideoPlaybackControlPolicy                *mControlsPolicy;
       
   286         VideoPlaybackControlConfiguration         *mControlsConfig;
       
   287 
       
   288         QTimer                                    *mControlsTimer;
       
   289         QTimer                                    *mRNLogoTimer;
       
   290 
       
   291         VideoPlaybackDocumentLoader               *mLoader;
       
   292         HbVolumeSliderPopup                       *mVolumeControl;
       
   293 
       
   294         ThumbnailManager                          *mThumbnailManager;
       
   295         VideoServices                             *mVideoServices;
       
   296 
       
   297         bool                                       mViewTransitionIsGoingOn;
       
   298         bool                                       mIsAttachOperation;
       
   299         
       
   300         TThumbNailState                            mThumbNailState;
       
   301 
       
   302         TMPXPlaybackState                          mState;
       
   303         TPlaybackViewMode                          mViewMode;
       
   304         Qt::Orientation                            mOrientation;
       
   305 };
       
   306 
       
   307 // INLINE METHODS
       
   308 // -------------------------------------------------------------------------------------------------
       
   309 //   VideoPlaybackControlsController::state
       
   310 // -------------------------------------------------------------------------------------------------
       
   311 //
       
   312 inline
       
   313 TMPXPlaybackState VideoPlaybackControlsController::state()
       
   314 {
       
   315     return mState;
       
   316 }
       
   317 
       
   318 // -------------------------------------------------------------------------------------------------
       
   319 //   VideoPlaybackControlsController::fileDetails
       
   320 // -------------------------------------------------------------------------------------------------
       
   321 //
       
   322 inline
       
   323 VideoPlaybackViewFileDetails* VideoPlaybackControlsController::fileDetails()
       
   324 {
       
   325     return mFileDetails;
       
   326 }
       
   327 
       
   328 // -------------------------------------------------------------------------------------------------
       
   329 //   VideoPlaybackControlsController::isTvOutConnected
       
   330 // -------------------------------------------------------------------------------------------------
       
   331 //
       
   332 inline
       
   333 bool VideoPlaybackControlsController::isTvOutConnected()
       
   334 {
       
   335     MPX_DEBUG(_L("VideoPlaybackControlsController::isTvOutConnected(%d)"),
       
   336             mFileDetails->mTvOutConnected);
       
   337 
       
   338     return mFileDetails->mTvOutConnected;
       
   339 }
       
   340 
       
   341 // -------------------------------------------------------------------------------------------------
       
   342 //   VideoPlaybackControlsController::layoutLoader
       
   343 // -------------------------------------------------------------------------------------------------
       
   344 //
       
   345 inline
       
   346 VideoPlaybackDocumentLoader* VideoPlaybackControlsController::layoutLoader()
       
   347 {
       
   348     return mLoader;
       
   349 }
       
   350 
       
   351 // -------------------------------------------------------------------------------------------------
       
   352 //   VideoPlaybackControlsController::view
       
   353 // -------------------------------------------------------------------------------------------------
       
   354 //
       
   355 inline
       
   356 VideoBasePlaybackView* VideoPlaybackControlsController::view()
       
   357 {
       
   358     return mView;
       
   359 }
       
   360 
       
   361 // -------------------------------------------------------------------------------------------------
       
   362 //   VideoPlaybackControlsController::viewMode
       
   363 // -------------------------------------------------------------------------------------------------
       
   364 //
       
   365 inline
       
   366 TPlaybackViewMode VideoPlaybackControlsController::viewMode()
       
   367 {
       
   368     return mViewMode;
       
   369 }
       
   370 
       
   371 // -------------------------------------------------------------------------------------------------
       
   372 // VideoPlaybackControlsController::isAttachOperation
       
   373 // -------------------------------------------------------------------------------------------------
       
   374 //
       
   375 inline
       
   376 bool VideoPlaybackControlsController::isAttachOperation()
       
   377 {        
       
   378     MPX_DEBUG(_L("VideoPlaybackControlsController::isAttachOperation() ret %d"), 
       
   379         mIsAttachOperation );
       
   380     
       
   381     return mIsAttachOperation;
       
   382 }
       
   383 
       
   384 #endif /*MPXVIDEOPLAYBACKCONTROLSCONTROLLER_P_H_*/
       
   385 
       
   386 // End of File