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