1
/* This file is part of the KDE project
2
Copyright (C) 2006 Tim Beaulen <tbscope@gmail.com>
3
Copyright (C) 2006-2007 Matthias Kretz <kretz@kde.org>
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License as published by the Free Software Foundation; either
8
version 2 of the License, or (at your option) any later version.
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 GNU
13
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
Boston, MA 02110-1301, USA.
21
#ifndef PHONON_XINE_BYTESTREAM_H
22
#define PHONON_XINE_BYTESTREAM_H
24
#include "mediaobject.h"
28
#include "xineengine.h"
29
#include <phonon/StreamInterface>
31
#include <QSharedData>
33
#include <QCoreApplication>
35
#include <QWaitCondition>
40
extern const char Error__off_t_needs_to_have_64_bits[sizeof(off_t) == 8 ? 1 : -1];
47
class ByteStream : public QObject, public StreamInterface, public QSharedData
51
static ByteStream *fromMrl(const QByteArray &mrl);
52
ByteStream(const MediaSource &, MediaObject *parent);
55
QByteArray mrl() const;
57
// does not block, but might change later
58
bool streamSeekable() const { return m_seekable; }
60
// blocks until the size is known
61
qint64 streamSize() const;
68
void writeData(const QByteArray &data);
70
void setStreamSeekable(bool);
71
void setStreamSize(qint64);
73
void setPauseForBuffering(bool);
75
// for the xine input plugin:
76
int peekBuffer(void *buf);
77
qint64 readFromBuffer(void *buf, size_t count);
78
off_t seekBuffer(qint64 offset);
79
off_t currentPosition() const;
83
void needDataQueued();
84
void seekStreamQueued(qint64);
87
void callStreamInterfaceReset();
88
void syncSeekStream(qint64 offset);
89
void needData() { StreamInterface::needData(); }
93
void pullBuffer(char *buf, int len);
95
MediaObject *m_mediaObject;
99
mutable QMutex m_streamSizeMutex;
100
mutable QWaitCondition m_waitForStreamSize;
101
QWaitCondition m_waitingForData;
102
QWaitCondition m_seekWaitCondition;
103
QQueue<QByteArray> m_buffers;
105
pthread_t m_mainThread;
107
qint64 m_currentPosition;
114
bool m_buffering : 1;
115
bool m_firstReset : 1;
117
}} //namespace Phonon::Xine
119
// vim: sw=4 ts=4 sts=4 et tw=100
120
#endif // PHONON_XINE_BYTESTREAM_H