src/3rdparty/phonon/mmf/mediaobject.h
changeset 0 1918ee327afb
child 3 41300fa6a67c
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     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_MEDIAOBJECT_H
       
    20 #define PHONON_MMF_MEDIAOBJECT_H
       
    21 
       
    22 #include <Phonon/MediaSource>
       
    23 #include <Phonon/MediaObjectInterface>
       
    24 #include <QScopedPointer>
       
    25 #include <QTimer>
       
    26 
       
    27 // For recognizer
       
    28 #include <apgcli.h>
       
    29 
       
    30 #include "abstractplayer.h"
       
    31 #include "mmf_medianode.h"
       
    32 #include "defs.h"
       
    33 #include "volumeobserver.h"
       
    34 
       
    35 QT_BEGIN_NAMESPACE
       
    36 
       
    37 namespace Phonon
       
    38 {
       
    39 namespace MMF
       
    40 {
       
    41 class AbstractPlayer;
       
    42 class VideoOutput;
       
    43 
       
    44 /**
       
    45  * @short Facade class which wraps MMF client utility instance
       
    46  */
       
    47 class MediaObject : public MediaNode
       
    48                   , public MediaObjectInterface
       
    49                   , public VolumeObserver
       
    50 {
       
    51     Q_OBJECT
       
    52     Q_INTERFACES(Phonon::MediaObjectInterface)
       
    53 
       
    54 public:
       
    55     MediaObject(QObject *parent);
       
    56     virtual ~MediaObject();
       
    57 
       
    58     // MediaObjectInterface
       
    59     virtual void play();
       
    60     virtual void pause();
       
    61     virtual void stop();
       
    62     virtual void seek(qint64 milliseconds);
       
    63     virtual qint32 tickInterval() const;
       
    64     virtual void setTickInterval(qint32 interval);
       
    65     virtual bool hasVideo() const;
       
    66     virtual bool isSeekable() const;
       
    67     virtual qint64 currentTime() const;
       
    68     virtual Phonon::State state() const;
       
    69     virtual QString errorString() const;
       
    70     virtual Phonon::ErrorType errorType() const;
       
    71     virtual qint64 totalTime() const;
       
    72     virtual MediaSource source() const;
       
    73     virtual void setSource(const MediaSource &);
       
    74     virtual void setNextSource(const MediaSource &source);
       
    75     virtual qint32 prefinishMark() const;
       
    76     virtual void setPrefinishMark(qint32);
       
    77     virtual qint32 transitionTime() const;
       
    78     virtual void setTransitionTime(qint32);
       
    79 
       
    80     // VolumeObserver
       
    81     void volumeChanged(qreal volume);
       
    82 
       
    83     /**
       
    84      * This class owns the AbstractPlayer, and will delete it upon
       
    85      * destruction.
       
    86      */
       
    87     AbstractPlayer *abstractPlayer() const;
       
    88 
       
    89     void setVideoOutput(VideoOutput* videoOutput);
       
    90 
       
    91     virtual bool activateOnMediaObject(MediaObject *);
       
    92 
       
    93 Q_SIGNALS:
       
    94     void totalTimeChanged(qint64 length);
       
    95     void hasVideoChanged(bool hasVideo);
       
    96     void seekableChanged(bool seekable);
       
    97     // TODO: emit bufferStatus from MediaObject
       
    98     void bufferStatus(int);
       
    99     // TODO: emit aboutToFinish from MediaObject
       
   100     void aboutToFinish();
       
   101     // TODO: emit prefinishMarkReached from MediaObject
       
   102     void prefinishMarkReached(qint32);
       
   103     // TODO: emit metaDataChanged from MediaObject
       
   104     void metaDataChanged(const QMultiMap<QString, QString>& metaData);
       
   105     void currentSourceChanged(const MediaSource& source);
       
   106     void stateChanged(Phonon::State oldState,
       
   107                       Phonon::State newState);
       
   108     void finished();
       
   109     void tick(qint64 time);
       
   110 
       
   111 private:
       
   112     void createPlayer(const MediaSource &source);
       
   113     bool openRecognizer();
       
   114 
       
   115     // Audio / video media type recognition
       
   116     MediaType fileMediaType(const QString& fileName);
       
   117     // TODO: urlMediaType function
       
   118 
       
   119     static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &);
       
   120 
       
   121 private:
       
   122 
       
   123     // Audio / video media type recognition
       
   124     bool                                m_recognizerOpened;
       
   125     RApaLsSession                       m_recognizer;
       
   126     RFs                                 m_fileServer;
       
   127 
       
   128     // Storing the file handle here to work around KErrInUse error
       
   129     // from MMF player utility OpenFileL functions
       
   130     RFile                               m_file;
       
   131 
       
   132     QScopedPointer<AbstractPlayer>      m_player;
       
   133 
       
   134 };
       
   135 }
       
   136 }
       
   137 
       
   138 QT_END_NAMESPACE
       
   139 
       
   140 #endif