| 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 | QT_BEGIN_NAMESPACE
|
|---|
| 29 |
|
|---|
| 30 | namespace Phonon
|
|---|
| 31 | {
|
|---|
| 32 | namespace QT7
|
|---|
| 33 | {
|
|---|
| 34 | class QuickTimeVideoPlayer;
|
|---|
| 35 | class QuickTimeAudioPlayer;
|
|---|
| 36 | class QuickTimeMetaData;
|
|---|
| 37 | class AudioGraph;
|
|---|
| 38 | class MediaObjectAudioNode;
|
|---|
| 39 |
|
|---|
| 40 | class MediaObject : public MediaNode,
|
|---|
| 41 | public Phonon::MediaObjectInterface, public Phonon::AddonInterface
|
|---|
| 42 | {
|
|---|
| 43 | Q_OBJECT
|
|---|
| 44 | Q_INTERFACES(Phonon::MediaObjectInterface Phonon::AddonInterface)
|
|---|
| 45 |
|
|---|
| 46 | public:
|
|---|
| 47 | MediaObject(QObject *parent);
|
|---|
| 48 | ~MediaObject();
|
|---|
| 49 |
|
|---|
| 50 | QStringList availableAudioStreams() const;
|
|---|
| 51 | QStringList availableVideoStreams() const;
|
|---|
| 52 | QStringList availableSubtitleStreams() const;
|
|---|
| 53 | QString currentAudioStream(const QObject *audioPath) const;
|
|---|
| 54 | QString currentVideoStream(const QObject *videoPath) const;
|
|---|
| 55 | QString currentSubtitleStream(const QObject *videoPath) const;
|
|---|
| 56 |
|
|---|
| 57 | void setCurrentAudioStream(const QString &streamName,const QObject *audioPath);
|
|---|
| 58 | void setCurrentVideoStream(const QString &streamName,const QObject *videoPath);
|
|---|
| 59 | void setCurrentSubtitleStream(const QString &streamName,const QObject *videoPath);
|
|---|
| 60 |
|
|---|
| 61 | void play();
|
|---|
| 62 | void pause();
|
|---|
| 63 | void stop();
|
|---|
| 64 | void seek(qint64 milliseconds);
|
|---|
| 65 |
|
|---|
| 66 | qint32 tickInterval() const;
|
|---|
| 67 | void setTickInterval(qint32 interval);
|
|---|
| 68 | bool hasVideo() const;
|
|---|
| 69 | bool isSeekable() const;
|
|---|
| 70 | qint64 currentTime() const;
|
|---|
| 71 | Phonon::State state() const;
|
|---|
| 72 |
|
|---|
| 73 | QString errorString() const;
|
|---|
| 74 | Phonon::ErrorType errorType() const;
|
|---|
| 75 |
|
|---|
| 76 | qint64 totalTime() const;
|
|---|
| 77 | MediaSource source() const;
|
|---|
| 78 | void setSource(const MediaSource &);
|
|---|
| 79 | void setNextSource(const MediaSource &source);
|
|---|
| 80 | qint32 prefinishMark() const;
|
|---|
| 81 | void setPrefinishMark(qint32);
|
|---|
| 82 | qint32 transitionTime() const;
|
|---|
| 83 | void setTransitionTime(qint32);
|
|---|
| 84 | bool hasInterface(Interface interface) const;
|
|---|
| 85 | QVariant interfaceCall(Interface interface, int command, const QList<QVariant> &arguments = QList<QVariant>());
|
|---|
| 86 |
|
|---|
| 87 | QuickTimeVideoPlayer* videoPlayer() const;
|
|---|
| 88 | QuickTimeAudioPlayer* audioPlayer() const;
|
|---|
| 89 |
|
|---|
| 90 | void setVolumeOnMovie(float volume);
|
|---|
| 91 | bool setAudioDeviceOnMovie(int id);
|
|---|
| 92 |
|
|---|
| 93 | int videoOutputCount();
|
|---|
| 94 |
|
|---|
| 95 | signals:
|
|---|
| 96 | void stateChanged(Phonon::State,Phonon::State);
|
|---|
| 97 | void tick(qint64);
|
|---|
| 98 | void seekableChanged(bool);
|
|---|
| 99 | void hasVideoChanged(bool);
|
|---|
| 100 | void bufferStatus(int);
|
|---|
| 101 | void finished();
|
|---|
| 102 | void aboutToFinish();
|
|---|
| 103 | void prefinishMarkReached(qint32);
|
|---|
| 104 | void totalTimeChanged(qint64);
|
|---|
| 105 | void metaDataChanged(QMultiMap<QString,QString>);
|
|---|
| 106 | void currentSourceChanged(const MediaSource &newSource);
|
|---|
| 107 |
|
|---|
| 108 | protected:
|
|---|
| 109 | void mediaNodeEvent(const MediaNodeEvent *event);
|
|---|
| 110 | bool event(QEvent *event);
|
|---|
| 111 |
|
|---|
| 112 | private:
|
|---|
| 113 | enum AudioSystem {AS_Unset, AS_Video, AS_Graph, AS_Silent} m_audioSystem;
|
|---|
| 114 | Phonon::State m_state;
|
|---|
| 115 |
|
|---|
| 116 | QuickTimeVideoPlayer *m_videoPlayer;
|
|---|
| 117 | QuickTimeAudioPlayer *m_audioPlayer;
|
|---|
| 118 | QuickTimeVideoPlayer *m_nextVideoPlayer;
|
|---|
| 119 | QuickTimeAudioPlayer *m_nextAudioPlayer;
|
|---|
| 120 | MediaObjectAudioNode *m_mediaObjectAudioNode;
|
|---|
| 121 | QuickTimeMetaData *m_metaData;
|
|---|
| 122 |
|
|---|
| 123 | qint32 m_tickInterval;
|
|---|
| 124 | qint32 m_transitionTime;
|
|---|
| 125 | quint32 m_prefinishMark;
|
|---|
| 126 | quint32 m_currentTime;
|
|---|
| 127 | float m_percentageLoaded;
|
|---|
| 128 |
|
|---|
| 129 | int m_tickTimer;
|
|---|
| 130 | int m_bufferTimer;
|
|---|
| 131 | int m_rapidTimer;
|
|---|
| 132 |
|
|---|
| 133 | bool m_waitNextSwap;
|
|---|
| 134 | int m_swapTimeLeft;
|
|---|
| 135 | QTime m_swapTime;
|
|---|
| 136 |
|
|---|
| 137 | void synchAudioVideo();
|
|---|
| 138 | void updateCurrentTime();
|
|---|
| 139 | void swapCurrentWithNext(qint32 transitionTime);
|
|---|
| 140 | bool setState(Phonon::State state);
|
|---|
| 141 | void pause_internal();
|
|---|
| 142 | void play_internal();
|
|---|
| 143 | void setupAudioSystem();
|
|---|
| 144 | void updateTimer(int &timer, int interval);
|
|---|
| 145 | void bufferAudioVideo();
|
|---|
| 146 | void updateRapidly();
|
|---|
| 147 | void updateCrossFade();
|
|---|
| 148 | void updateAudioBuffers();
|
|---|
| 149 | void updateLipSynch(int allowedOffset);
|
|---|
| 150 | void updateVideoFrames();
|
|---|
| 151 | void updateBufferStatus();
|
|---|
| 152 | void setMute(bool mute);
|
|---|
| 153 | void inspectAudioGraphRecursive(AudioConnection *connection, int &effectCount, int &outputCount);
|
|---|
| 154 | void inspectVideoGraphRecursive(MediaNode *node, int &effectCount, int &outputCount);
|
|---|
| 155 | void inspectGraph();
|
|---|
| 156 | bool isCrossFading();
|
|---|
| 157 |
|
|---|
| 158 | QString m_errorString;
|
|---|
| 159 | Phonon::ErrorType m_errorType;
|
|---|
| 160 | bool checkForError();
|
|---|
| 161 |
|
|---|
| 162 | int m_audioEffectCount;
|
|---|
| 163 | int m_audioOutputCount;
|
|---|
| 164 | int m_videoEffectCount;
|
|---|
| 165 | int m_videoOutputCount;
|
|---|
| 166 | };
|
|---|
| 167 |
|
|---|
| 168 | }} //namespace Phonon::QT7
|
|---|
| 169 |
|
|---|
| 170 | QT_END_NAMESPACE
|
|---|
| 171 | #endif // Phonon_QT7_MEDIAOBJECT_H
|
|---|