src/3rdparty/phonon/qt7/mediaobject.h
changeset 0 1918ee327afb
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 #ifndef Phonon_QT7_MEDIAOBJECT_H
       
    19 #define Phonon_QT7_MEDIAOBJECT_H
       
    20 
       
    21 #include <QtCore/QStringList>
       
    22 #include <QtCore/QTime>
       
    23 #include <phonon/mediaobjectinterface.h>
       
    24 #include <phonon/addoninterface.h>
       
    25 
       
    26 #include "medianode.h"
       
    27 
       
    28 #if QT_ALLOW_QUICKTIME
       
    29     #include <QuickTime/QuickTime.h>
       
    30 #endif
       
    31 
       
    32 QT_BEGIN_NAMESPACE
       
    33 
       
    34 namespace Phonon
       
    35 {
       
    36 namespace QT7
       
    37 {
       
    38     class QuickTimeVideoPlayer;
       
    39     class QuickTimeAudioPlayer;
       
    40     class QuickTimeMetaData;
       
    41     class AudioGraph;
       
    42     class MediaObjectAudioNode;
       
    43 
       
    44     class MediaObject : public MediaNode,
       
    45         public Phonon::MediaObjectInterface
       
    46 #ifndef QT_NO_PHONON_MEDIACONTROLLER
       
    47         , public Phonon::AddonInterface
       
    48 #endif
       
    49     {
       
    50         Q_OBJECT
       
    51         Q_INTERFACES(Phonon::MediaObjectInterface Phonon::AddonInterface)
       
    52 
       
    53     public:
       
    54         MediaObject(QObject *parent);
       
    55         ~MediaObject();
       
    56 
       
    57         QStringList availableAudioStreams() const;
       
    58         QStringList availableVideoStreams() const;
       
    59         QStringList availableSubtitleStreams() const;
       
    60         QString currentAudioStream(const QObject *audioPath) const;
       
    61         QString currentVideoStream(const QObject *videoPath) const;
       
    62         QString currentSubtitleStream(const QObject *videoPath) const;
       
    63 
       
    64         void setCurrentAudioStream(const QString &streamName,const QObject *audioPath);
       
    65         void setCurrentVideoStream(const QString &streamName,const QObject *videoPath);
       
    66         void setCurrentSubtitleStream(const QString &streamName,const QObject *videoPath);
       
    67 
       
    68         void play();
       
    69         void pause();
       
    70         void stop();
       
    71         void seek(qint64 milliseconds);
       
    72 
       
    73         qint32 tickInterval() const;
       
    74         void setTickInterval(qint32 interval);
       
    75         bool hasVideo() const;
       
    76         bool isSeekable() const;
       
    77         qint64 currentTime() const;
       
    78         Phonon::State state() const;
       
    79 
       
    80         QString errorString() const;
       
    81         Phonon::ErrorType errorType() const;
       
    82 
       
    83         qint64 totalTime() const;
       
    84         MediaSource source() const;
       
    85         void setSource(const MediaSource &);
       
    86         void setNextSource(const MediaSource &source);
       
    87         qint32 prefinishMark() const;
       
    88         void setPrefinishMark(qint32);
       
    89         qint32 transitionTime() const;
       
    90         void setTransitionTime(qint32);
       
    91         bool hasInterface(Interface interface) const;
       
    92         QVariant interfaceCall(Interface interface, int command, const QList<QVariant> &arguments = QList<QVariant>());
       
    93 
       
    94         QuickTimeVideoPlayer* videoPlayer() const;
       
    95         QuickTimeAudioPlayer* audioPlayer() const;
       
    96 
       
    97         void setVolumeOnMovie(float volume);
       
    98         bool setAudioDeviceOnMovie(int id);
       
    99 
       
   100 		int videoOutputCount();
       
   101 
       
   102 #if QT_ALLOW_QUICKTIME
       
   103         void displayLinkEvent();
       
   104 #endif
       
   105 
       
   106     signals:
       
   107         void stateChanged(Phonon::State,Phonon::State);
       
   108         void tick(qint64);
       
   109         void seekableChanged(bool);
       
   110         void hasVideoChanged(bool);
       
   111         void bufferStatus(int);
       
   112         void finished();
       
   113         void aboutToFinish();
       
   114         void prefinishMarkReached(qint32);
       
   115         void totalTimeChanged(qint64);
       
   116         void metaDataChanged(QMultiMap<QString,QString>);
       
   117         void currentSourceChanged(const MediaSource &newSource);
       
   118 
       
   119         // Add-on interface:
       
   120         void availableSubtitlesChanged();
       
   121         void availableAudioChannelsChanged();
       
   122         void titleChanged(int);
       
   123         void availableTitlesChanged(int);
       
   124         void chapterChanged(int);
       
   125         void availableChaptersChanged(int);
       
   126         void angleChanged(int);
       
   127         void availableAnglesChanged(int);
       
   128 
       
   129     protected:
       
   130         void mediaNodeEvent(const MediaNodeEvent *event);
       
   131         bool event(QEvent *event);
       
   132 
       
   133     private:
       
   134         enum AudioSystem {AS_Unset, AS_Video, AS_Graph, AS_Silent} m_audioSystem;
       
   135         Phonon::State m_state;
       
   136 
       
   137         QuickTimeVideoPlayer *m_videoPlayer;
       
   138         QuickTimeAudioPlayer *m_audioPlayer;
       
   139         QuickTimeVideoPlayer *m_nextVideoPlayer;
       
   140         QuickTimeAudioPlayer *m_nextAudioPlayer;
       
   141         MediaObjectAudioNode *m_mediaObjectAudioNode;
       
   142 
       
   143 #if QT_ALLOW_QUICKTIME
       
   144         CVDisplayLinkRef m_displayLink;
       
   145         QMutex m_displayLinkMutex;
       
   146         bool m_pendingDisplayLinkEvent;
       
   147         void startDisplayLink();
       
   148         void stopDisplayLink();
       
   149 #endif
       
   150 
       
   151         qint32 m_tickInterval;
       
   152         qint32 m_transitionTime;
       
   153         quint32 m_prefinishMark;
       
   154         quint32 m_currentTime;
       
   155         float m_percentageLoaded;
       
   156 
       
   157         int m_tickTimer;
       
   158         int m_videoTimer;
       
   159         int m_audioTimer;
       
   160         int m_rapidTimer;
       
   161 
       
   162         bool m_waitNextSwap;
       
   163         int m_swapTimeLeft;
       
   164         QTime m_swapTime;
       
   165         bool m_autoplayTitles;
       
   166 
       
   167         void synchAudioVideo();
       
   168         void updateCurrentTime();
       
   169         void swapCurrentWithNext(qint32 transitionTime);
       
   170         bool setState(Phonon::State state);
       
   171         void pause_internal();
       
   172         void play_internal();
       
   173         void setupAudioSystem();
       
   174         void restartAudioVideoTimers();
       
   175         void updateRapidly();
       
   176         void updateCrossFade();
       
   177         void updateAudioBuffers();
       
   178         void updateLipSynch(int allowedOffset);
       
   179         void updateVideoFrames();
       
   180         void updateBufferStatus();
       
   181         void setMute(bool mute);
       
   182 		void inspectAudioGraphRecursive(AudioConnection *connection, int &effectCount, int &outputCount);
       
   183 		void inspectVideoGraphRecursive(MediaNode *node, int &effectCount, int &outputCount);
       
   184         void inspectGraph();
       
   185         bool isCrossFading();
       
   186         void setCurrentTrack(int track);
       
   187 
       
   188         QString m_errorString;
       
   189         Phonon::ErrorType m_errorType;
       
   190         bool checkForError();
       
   191 
       
   192 	    int m_audioEffectCount;
       
   193 	    int m_audioOutputCount;
       
   194 	    int m_videoEffectCount;
       
   195 	    int m_videoOutputCount;
       
   196     };
       
   197 
       
   198 }} //namespace Phonon::QT7
       
   199 
       
   200 QT_END_NAMESPACE
       
   201 #endif // Phonon_QT7_MEDIAOBJECT_H