0
|
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 |
namespace 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 |
|
|
85 |
private:
|
|
86 |
QByteArray m_buffer;
|
|
87 |
quint64 m_pos;
|
|
88 |
quint64 m_size;
|
|
89 |
bool m_seekable;
|
|
90 |
};
|
|
91 |
}
|
|
92 |
}
|
|
93 |
|
|
94 |
QT_END_NAMESPACE
|
|
95 |
|
|
96 |
#endif
|