| 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.h>
|
|---|
| 23 | #include <phonon/mediaobjectinterface.h>
|
|---|
| 24 | #include <QScopedPointer>
|
|---|
| 25 | #include <QTimer>
|
|---|
| 26 | #include <QString>
|
|---|
| 27 |
|
|---|
| 28 | // For recognizer
|
|---|
| 29 | #include <apgcli.h>
|
|---|
| 30 |
|
|---|
| 31 | #include "abstractplayer.h"
|
|---|
| 32 | #include "mmf_medianode.h"
|
|---|
| 33 | #include "defs.h"
|
|---|
| 34 |
|
|---|
| 35 | QT_BEGIN_NAMESPACE
|
|---|
| 36 |
|
|---|
| 37 | class QResource;
|
|---|
| 38 |
|
|---|
| 39 | namespace Phonon
|
|---|
| 40 | {
|
|---|
| 41 | namespace MMF
|
|---|
| 42 | {
|
|---|
| 43 | class AbstractPlayer;
|
|---|
| 44 | class AbstractVideoOutput;
|
|---|
| 45 |
|
|---|
| 46 | /**
|
|---|
| 47 | * @short Facade class which wraps MMF client utility instance
|
|---|
| 48 | */
|
|---|
| 49 | class MediaObject : public MediaNode
|
|---|
| 50 | , public MediaObjectInterface
|
|---|
| 51 | {
|
|---|
| 52 | Q_OBJECT
|
|---|
| 53 | Q_INTERFACES(Phonon::MediaObjectInterface)
|
|---|
| 54 |
|
|---|
| 55 | public:
|
|---|
| 56 | MediaObject(QObject *parent);
|
|---|
| 57 | virtual ~MediaObject();
|
|---|
| 58 |
|
|---|
| 59 | // MediaObjectInterface
|
|---|
| 60 | virtual void play();
|
|---|
| 61 | virtual void pause();
|
|---|
| 62 | virtual void stop();
|
|---|
| 63 | virtual void seek(qint64 milliseconds);
|
|---|
| 64 | virtual qint32 tickInterval() const;
|
|---|
| 65 | virtual void setTickInterval(qint32 interval);
|
|---|
| 66 | virtual bool hasVideo() const;
|
|---|
| 67 | virtual bool isSeekable() const;
|
|---|
| 68 | virtual qint64 currentTime() const;
|
|---|
| 69 | virtual Phonon::State state() const;
|
|---|
| 70 | virtual QString errorString() const;
|
|---|
| 71 | virtual Phonon::ErrorType errorType() const;
|
|---|
| 72 | virtual qint64 totalTime() const;
|
|---|
| 73 | virtual MediaSource source() const;
|
|---|
| 74 | virtual void setSource(const MediaSource &);
|
|---|
| 75 | virtual void setNextSource(const MediaSource &source);
|
|---|
| 76 | virtual qint32 prefinishMark() const;
|
|---|
| 77 | virtual void setPrefinishMark(qint32);
|
|---|
| 78 | virtual qint32 transitionTime() const;
|
|---|
| 79 | virtual void setTransitionTime(qint32);
|
|---|
| 80 |
|
|---|
| 81 | // MediaNode
|
|---|
| 82 | void connectMediaObject(MediaObject *mediaObject);
|
|---|
| 83 | void disconnectMediaObject(MediaObject *mediaObject);
|
|---|
| 84 |
|
|---|
| 85 | /**
|
|---|
| 86 | * This class owns the AbstractPlayer, and will delete it upon
|
|---|
| 87 | * destruction.
|
|---|
| 88 | */
|
|---|
| 89 | AbstractPlayer *abstractPlayer() const;
|
|---|
| 90 |
|
|---|
| 91 | void setVideoOutput(AbstractVideoOutput* videoOutput);
|
|---|
| 92 |
|
|---|
| 93 | int openFileHandle(const QString &fileName);
|
|---|
| 94 | RFile* file() const;
|
|---|
| 95 | QResource* resource() const;
|
|---|
| 96 | int currentIAP() const;
|
|---|
| 97 |
|
|---|
| 98 | public Q_SLOTS:
|
|---|
| 99 | void volumeChanged(qreal volume);
|
|---|
| 100 | void switchToNextSource();
|
|---|
| 101 |
|
|---|
| 102 | Q_SIGNALS:
|
|---|
| 103 | void abstractPlayerChanged(AbstractPlayer *player);
|
|---|
| 104 | void totalTimeChanged(qint64 length);
|
|---|
| 105 | void hasVideoChanged(bool hasVideo);
|
|---|
| 106 | void seekableChanged(bool seekable);
|
|---|
| 107 | void bufferStatus(int);
|
|---|
| 108 | void aboutToFinish();
|
|---|
| 109 | void prefinishMarkReached(qint32 remaining);
|
|---|
| 110 | // TODO: emit metaDataChanged from MediaObject
|
|---|
| 111 | void metaDataChanged(const QMultiMap<QString, QString>& metaData);
|
|---|
| 112 | void currentSourceChanged(const MediaSource& source);
|
|---|
| 113 | void stateChanged(Phonon::State newState,
|
|---|
| 114 | Phonon::State oldState);
|
|---|
| 115 | void finished();
|
|---|
| 116 | void tick(qint64 time);
|
|---|
| 117 |
|
|---|
| 118 | protected:
|
|---|
| 119 | bool eventFilter(QObject *watched, QEvent *event);
|
|---|
| 120 |
|
|---|
| 121 | private Q_SLOTS:
|
|---|
| 122 | void handlePrefinishMarkReached(qint32);
|
|---|
| 123 |
|
|---|
| 124 | private:
|
|---|
| 125 | void switchToSource(const MediaSource &source);
|
|---|
| 126 | void createPlayer(const MediaSource &source);
|
|---|
| 127 | bool openRecognizer();
|
|---|
| 128 | void setIAPIdFromNameL(const QString& iapString);
|
|---|
| 129 |
|
|---|
| 130 | // Audio / video media type recognition
|
|---|
| 131 | MediaType fileMediaType(const QString& fileName);
|
|---|
| 132 | MediaType bufferMediaType(const uchar *data, qint64 size);
|
|---|
| 133 | // TODO: urlMediaType function
|
|---|
| 134 |
|
|---|
| 135 | static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &);
|
|---|
| 136 |
|
|---|
| 137 | private:
|
|---|
| 138 |
|
|---|
| 139 | // Audio / video media type recognition
|
|---|
| 140 | bool m_recognizerOpened;
|
|---|
| 141 | RApaLsSession m_recognizer;
|
|---|
| 142 | RFs m_fileServer;
|
|---|
| 143 |
|
|---|
| 144 | MediaSource m_source;
|
|---|
| 145 | MediaSource m_nextSource;
|
|---|
| 146 | bool m_nextSourceSet;
|
|---|
| 147 |
|
|---|
| 148 | RFile* m_file;
|
|---|
| 149 | QResource* m_resource;
|
|---|
| 150 |
|
|---|
| 151 | QScopedPointer<AbstractPlayer> m_player;
|
|---|
| 152 | int m_iap;
|
|---|
| 153 |
|
|---|
| 154 | };
|
|---|
| 155 | }
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | QT_END_NAMESPACE
|
|---|
| 159 |
|
|---|
| 160 | #endif
|
|---|