src/3rdparty/phonon/mmf/abstractvideoplayer.h
changeset 19 fcece45ef507
child 37 758a864f9613
equal deleted inserted replaced
18:2f34d5167611 19:fcece45ef507
       
     1 /*  This file is part of the KDE project.
       
     2 
       
     3 Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 
       
     5 This library is free software: you can redistribute it and/or modify
       
     6 it under the terms of the GNU Lesser General Public License as published by
       
     7 the Free Software Foundation, either version 2.1 or 3 of the License.
       
     8 
       
     9 This library is distributed in the hope that it will be useful,
       
    10 but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 GNU Lesser General Public License for more details.
       
    13 
       
    14 You should have received a copy of the GNU Lesser General Public License
       
    15 along with this library.  If not, see <http://www.gnu.org/licenses/>.
       
    16 
       
    17 */
       
    18 
       
    19 #ifndef PHONON_MMF_ABSTRACTVIDEOPLAYER_H
       
    20 #define PHONON_MMF_ABSTRACTVIDEOPLAYER_H
       
    21 
       
    22 #include <videoplayer.h> // from epoc32/include
       
    23 
       
    24 #include <QSize>
       
    25 
       
    26 #include "abstractmediaplayer.h"
       
    27 #include "abstractvideooutput.h"
       
    28 #include "defs.h"
       
    29 
       
    30 QT_BEGIN_NAMESPACE
       
    31 
       
    32 namespace Phonon
       
    33 {
       
    34 namespace MMF
       
    35 {
       
    36 /**
       
    37  * @short ABC for classes which wrap the MMF video player utility
       
    38  *
       
    39  * On devices which use the legacy graphics subsystem which does not
       
    40  * support surfaces, video rendering is done via Direct Screen Access using
       
    41  * the CVideoPlayerUtility API.  On devices with a graphics subsystem which
       
    42  * does support surfaces, video rendering is done using the
       
    43  * CVideoPlayerUtility2 API.  Because CVideoPlayerUtility2 inherits from
       
    44  * CVideoPlayerUtility, AbstractVideoPlayer holds a pointer to the latter.
       
    45  *
       
    46  * @see DsaVideoPlayer, SurfaceVideoPlayer
       
    47  */
       
    48 class AbstractVideoPlayer
       
    49     :   public AbstractMediaPlayer
       
    50     ,   public MVideoPlayerUtilityObserver
       
    51     ,   public MVideoLoadingObserver
       
    52 {
       
    53     Q_OBJECT
       
    54 
       
    55 public:
       
    56     ~AbstractVideoPlayer();
       
    57 
       
    58     typedef CVideoPlayerUtility NativePlayer;
       
    59     NativePlayer *nativePlayer() const;
       
    60 
       
    61     // AbstractPlayer
       
    62     virtual void doPlay();
       
    63     virtual void doPause();
       
    64     virtual void doStop();
       
    65     virtual void doSeek(qint64 milliseconds);
       
    66     virtual int setDeviceVolume(int mmfVolume);
       
    67     virtual int openFile(RFile &file);
       
    68     virtual int openUrl(const QString &url);
       
    69     virtual int bufferStatus() const;
       
    70     virtual void close();
       
    71 
       
    72     // MediaObjectInterface
       
    73     virtual bool hasVideo() const;
       
    74     virtual qint64 currentTime() const;
       
    75     virtual qint64 totalTime() const;
       
    76 
       
    77     // AbstractPlayer
       
    78     virtual void videoOutputChanged();
       
    79 
       
    80     // AbstractMediaPlayer
       
    81     virtual int numberOfMetaDataEntries() const;
       
    82     virtual QPair<QString, QString> metaDataEntry(int index) const;
       
    83 
       
    84 public Q_SLOTS:
       
    85     void videoWindowChanged();
       
    86     void aspectRatioChanged();
       
    87     void scaleModeChanged();
       
    88 
       
    89 protected:
       
    90     AbstractVideoPlayer(MediaObject *parent, const AbstractPlayer *player);
       
    91     void construct();
       
    92     virtual void initVideoOutput();
       
    93     void updateScaleFactors(const QSize &windowSize, bool apply = true);
       
    94 
       
    95     // Called when a video parameter changes.  If the underlying native API is
       
    96     // ready to handle the change, it is propagated immediately, otherwise the
       
    97     // change is recorded in m_pendingChanged and handled later by
       
    98     // handlePendingParametersChanged().
       
    99     void parametersChanged(VideoParameters parameter);
       
   100 
       
   101     // Implementation must initialize the m_player pointer.
       
   102     virtual void createPlayer() = 0;
       
   103 
       
   104     // Called from the MvpuoPrepareComplete callback.  Allows derived class to
       
   105     // calculate clipping rectangles and scale factors prior to starting
       
   106     // playback.
       
   107     virtual void prepareCompleted() = 0;
       
   108 
       
   109     // Called when native video window handle changes.  Derived class may defer
       
   110     // propagation of this change to the MMF video player utility by calling
       
   111     // parametersChanged().
       
   112     virtual void handleVideoWindowChanged() = 0;
       
   113 
       
   114     // Called when the derived class must handle changes which have been made
       
   115     // to video parameters such as window handle, screen rectangle and scale
       
   116     // factors.  Guaranteed to be called only when the underlying MMF video
       
   117     // player object is ready to handle changes to these parameters.
       
   118     virtual void handleParametersChanged(VideoParameters parameters) = 0;
       
   119 
       
   120 private:
       
   121     void getVideoClipParametersL(TInt aError);
       
   122 
       
   123     // Called when native player API enters a state in which it is able to
       
   124     // handle pending changes such as new video window handle, updated scale
       
   125     // factors etc.
       
   126     void handlePendingParametersChanged();
       
   127 
       
   128 private:
       
   129     // MVideoPlayerUtilityObserver
       
   130     virtual void MvpuoOpenComplete(TInt aError);
       
   131     virtual void MvpuoPrepareComplete(TInt aError);
       
   132     virtual void MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError);
       
   133     virtual void MvpuoPlayComplete(TInt aError);
       
   134     virtual void MvpuoEvent(const TMMFEvent &aEvent);
       
   135 
       
   136     // MVideoLoadingObserver
       
   137     virtual void MvloLoadingStarted();
       
   138     virtual void MvloLoadingComplete();
       
   139 
       
   140 protected:
       
   141     QScopedPointer<NativePlayer>        m_player;
       
   142 
       
   143     // Not owned
       
   144     RWsSession&                         m_wsSession;
       
   145     CWsScreenDevice&                    m_screenDevice;
       
   146     RWindowBase*                        m_window;
       
   147 
       
   148     // Scaling factors for video display, expressed as percentages
       
   149     TReal32                             m_scaleWidth;
       
   150     TReal32                             m_scaleHeight;
       
   151 
       
   152     // Dimensions of the video clip
       
   153     QSize                               m_videoFrameSize;
       
   154 
       
   155 private:
       
   156     // Bitmask of parameters which have changed while the MMF video player
       
   157     // object is not yet ready to receive these changes.
       
   158     // See handlePendingParametersChanged().
       
   159     VideoParameters                     m_pendingChanges;
       
   160 
       
   161     // Duration of the video clip
       
   162     qint64                              m_totalTime;
       
   163 
       
   164 };
       
   165 
       
   166 }
       
   167 }
       
   168 
       
   169 QT_END_NAMESPACE
       
   170 
       
   171 #endif