source: trunk/src/3rdparty/phonon/gstreamer/streamreader.h@ 5

Last change on this file since 5 was 2, checked in by Dmitry A. Kuminov, 17 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 2.4 KB
Line 
1/* This file is part of the KDE project.
2
3Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4
5This library is free software: you can redistribute it and/or modify
6it under the terms of the GNU Lesser General Public License as published by
7the Free Software Foundation, either version 2.1 or 3 of the License.
8
9This library is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU Lesser General Public License for more details.
13
14You should have received a copy of the GNU Lesser General Public License
15along 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
24QT_BEGIN_NAMESPACE
25
26namespace Phonon
27{
28 class MediaSource;
29 namespace Gstreamer
30 {
31 class StreamReader : public Phonon::StreamInterface
32 {
33 public:
34
35 StreamReader(const Phonon::MediaSource &source)
36 : m_pos(0)
37 , m_size(0)
38 , m_seekable(false)
39 {
40 connectToSource(source);
41 }
42
43 int currentBufferSize() const
44 {
45 return m_buffer.size();
46 }
47
48 void writeData(const QByteArray &data) {
49 m_pos += data.size();
50 m_buffer += data;
51 }
52
53 void setCurrentPos(qint64 pos)
54 {
55 m_pos = pos;
56 seekStream(pos);
57 m_buffer.clear();
58 }
59
60 quint64 currentPos() const
61 {
62 return m_pos;
63 }
64
65 bool read(quint64 offset, int length, char * buffer);
66
67 void endOfData() {}
68
69 void setStreamSize(qint64 newSize) {
70 m_size = newSize;
71 }
72
73 qint64 streamSize() const {
74 return m_size;
75 }
76
77 void setStreamSeekable(bool s) {
78 m_seekable = s;
79 }
80
81 bool streamSeekable() const {
82 return m_seekable;
83 }
84
85private:
86 QByteArray m_buffer;
87 quint64 m_pos;
88 quint64 m_size;
89 bool m_seekable;
90 };
91 }
92}
93
94QT_END_NAMESPACE
95
96#endif
Note: See TracBrowser for help on using the repository browser.