1 /* This file is part of the KDE project. 2 3 Copyright (C) 2011 Harald Sitter <sitter@kde.org> 4 Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 5 6 This library is free software: you can redistribute it and/or modify 7 it under the terms of the GNU Lesser General Public License as published by 8 the Free Software Foundation, either version 2.1 or 3 of the License. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public License 16 along with this library. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef PHONON_GSTREAMER_STREAMREADER_H 20 #define PHONON_GSTREAMER_STREAMREADER_H 21 22 #include <phonon/streaminterface.h> 23 24 #include <QtCore/QMutex> 25 #include <QtCore/QWaitCondition> 26 27 #include "mediaobject.h" 28 29 #ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM 30 31 namespace Phonon 32 { 33 34 class MediaSource; 35 36 namespace Gstreamer 37 { 38 39 class StreamReader : public QObject, Phonon::StreamInterface 40 { 41 Q_INTERFACES(Phonon::StreamInterface); 42 Q_OBJECT 43 public: 44 StreamReader(const Phonon::MediaSource &source, Pipeline *parent); 45 ~StreamReader(); 46 47 /* 48 * Overloads for StreamInterface 49 */ 50 int currentBufferSize() const; 51 void writeData(const QByteArray &data); 52 GstFlowReturn read(quint64 offset, int length, char * buffer); 53 54 bool atEnd() const; 55 56 void endOfData(); 57 void start(); 58 void stop(); 59 60 void setCurrentPos(qint64 pos); 61 quint64 currentPos() const; 62 63 void setStreamSize(qint64 newSize); 64 qint64 streamSize() const; 65 66 void setStreamSeekable(bool seekable); 67 bool streamSeekable() const; 68 69 private: 70 quint64 m_pos; 71 quint64 m_size; 72 bool m_eos; 73 bool m_locked; 74 bool m_seekable; 75 Pipeline *m_pipeline; 76 QByteArray m_buffer; 77 QMutex m_mutex; 78 QWaitCondition m_waitingForData; 79 }; 80 81 } 82 } 83 84 #endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM 85 86 #endif // PHONON_GSTREAMER_STREAMREADER_H 87