| 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_IODEVICEREADER_H
|
|---|
| 19 | #define PHONON_IODEVICEREADER_H
|
|---|
| 20 |
|
|---|
| 21 | #include <phonon/mediasource.h>
|
|---|
| 22 | #include <phonon/streaminterface.h>
|
|---|
| 23 |
|
|---|
| 24 | QT_BEGIN_NAMESPACE
|
|---|
| 25 |
|
|---|
| 26 | #ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM
|
|---|
| 27 |
|
|---|
| 28 | namespace Phonon
|
|---|
| 29 | {
|
|---|
| 30 | class MediaSource;
|
|---|
| 31 | namespace Gstreamer
|
|---|
| 32 | {
|
|---|
| 33 | class StreamReader : public Phonon::StreamInterface
|
|---|
| 34 | {
|
|---|
| 35 | public:
|
|---|
| 36 |
|
|---|
| 37 | StreamReader(const Phonon::MediaSource &source)
|
|---|
| 38 | : m_pos(0)
|
|---|
| 39 | , m_size(0)
|
|---|
| 40 | , m_seekable(false)
|
|---|
| 41 | {
|
|---|
| 42 | connectToSource(source);
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | int currentBufferSize() const
|
|---|
| 46 | {
|
|---|
| 47 | return m_buffer.size();
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | void writeData(const QByteArray &data) {
|
|---|
| 51 | m_pos += data.size();
|
|---|
| 52 | m_buffer += data;
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | void setCurrentPos(qint64 pos)
|
|---|
| 56 | {
|
|---|
| 57 | m_pos = pos;
|
|---|
| 58 | seekStream(pos);
|
|---|
| 59 | m_buffer.clear();
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | quint64 currentPos() const
|
|---|
| 63 | {
|
|---|
| 64 | return m_pos;
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | bool read(quint64 offset, int length, char * buffer);
|
|---|
| 68 |
|
|---|
| 69 | void endOfData() {}
|
|---|
| 70 |
|
|---|
| 71 | void setStreamSize(qint64 newSize) {
|
|---|
| 72 | m_size = newSize;
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | qint64 streamSize() const {
|
|---|
| 76 | return m_size;
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | void setStreamSeekable(bool s) {
|
|---|
| 80 | m_seekable = s;
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | bool streamSeekable() const {
|
|---|
| 84 | return m_seekable;
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | private:
|
|---|
| 88 | QByteArray m_buffer;
|
|---|
| 89 | quint64 m_pos;
|
|---|
| 90 | quint64 m_size;
|
|---|
| 91 | bool m_seekable;
|
|---|
| 92 | };
|
|---|
| 93 | }
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | #endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM
|
|---|
| 97 |
|
|---|
| 98 | QT_END_NAMESPACE
|
|---|
| 99 |
|
|---|
| 100 | #endif
|
|---|