~ubuntu-branches/ubuntu/oneiric/phonon/oneiric-201108111512

« back to all changes in this revision

Viewing changes to xine/bytestream.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2011-01-24 10:12:11 UTC
  • mfrom: (0.5.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110124101211-w9rew7q0dmwbwhqx
Tags: 4:4.7.0really4.4.4-0ubuntu1
* New upstream release
* Xine and GStreamer backends now split out source, remove build-deps and
  binary packages from debian/control
* Remove 02_no_rpath.patch, now upstream
* Disable kubuntu04_no_va_mangle.patch, no longer applies
* Remove kubuntu_05_gst_codec_installer_window_id.diff, kubuntu_06_forward_events.diff,
  kubuntu_07_include_fix.diff, gstreamer now separate

Show diffs side-by-side

added added

removed removed

Lines of Context:
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>
4
 
 
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.
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 GNU
13
 
    Library General Public License for more details.
14
 
 
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.
19
 
 
20
 
*/
21
 
#ifndef PHONON_XINE_BYTESTREAM_H
22
 
#define PHONON_XINE_BYTESTREAM_H
23
 
 
24
 
#include "mediaobject.h"
25
 
 
26
 
#include <xine.h>
27
 
 
28
 
#include "xineengine.h"
29
 
#include <phonon/StreamInterface>
30
 
#include <QByteArray>
31
 
#include <QSharedData>
32
 
#include <QQueue>
33
 
#include <QCoreApplication>
34
 
#include <QMutex>
35
 
#include <QWaitCondition>
36
 
#include <pthread.h>
37
 
#include <cstdlib>
38
 
#include <QObject>
39
 
 
40
 
extern const char Error__off_t_needs_to_have_64_bits[sizeof(off_t) == 8 ? 1 : -1];
41
 
 
42
 
namespace Phonon
43
 
{
44
 
namespace Xine
45
 
{
46
 
class MediaObject;
47
 
class ByteStream : public QObject, public StreamInterface, public QSharedData
48
 
{
49
 
    Q_OBJECT
50
 
    public:
51
 
        static ByteStream *fromMrl(const QByteArray &mrl);
52
 
        ByteStream(const MediaSource &, MediaObject *parent);
53
 
        ~ByteStream();
54
 
 
55
 
        QByteArray mrl() const;
56
 
 
57
 
        // does not block, but might change later
58
 
        bool streamSeekable() const { return m_seekable; }
59
 
 
60
 
        // blocks until the size is known
61
 
        qint64 streamSize() const;
62
 
 
63
 
        void stop();
64
 
 
65
 
        void reset();
66
 
 
67
 
    public slots:
68
 
        void writeData(const QByteArray &data);
69
 
        void endOfData();
70
 
        void setStreamSeekable(bool);
71
 
        void setStreamSize(qint64);
72
 
 
73
 
        void setPauseForBuffering(bool);
74
 
 
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;
80
 
 
81
 
    signals:
82
 
        void resetQueued();
83
 
        void needDataQueued();
84
 
        void seekStreamQueued(qint64);
85
 
 
86
 
    private slots:
87
 
        void callStreamInterfaceReset();
88
 
        void syncSeekStream(qint64 offset);
89
 
        void needData() { StreamInterface::needData(); }
90
 
 
91
 
    private:
92
 
//X             void setMrl();
93
 
        void pullBuffer(char *buf, int len);
94
 
 
95
 
        MediaObject *m_mediaObject;
96
 
        QByteArray m_preview;
97
 
        QMutex m_mutex;
98
 
        QMutex m_seekMutex;
99
 
        mutable QMutex m_streamSizeMutex;
100
 
        mutable QWaitCondition m_waitForStreamSize;
101
 
        QWaitCondition m_waitingForData;
102
 
        QWaitCondition m_seekWaitCondition;
103
 
        QQueue<QByteArray> m_buffers;
104
 
 
105
 
        pthread_t m_mainThread;
106
 
        qint64 m_streamSize;
107
 
        qint64 m_currentPosition;
108
 
        size_t m_buffersize;
109
 
        int m_offset;
110
 
 
111
 
        bool m_seekable : 1;
112
 
        bool m_stopped : 1;
113
 
        bool m_eod : 1;
114
 
        bool m_buffering : 1;
115
 
        bool m_firstReset : 1;
116
 
};
117
 
}} //namespace Phonon::Xine
118
 
 
119
 
// vim: sw=4 ts=4 sts=4 et tw=100
120
 
#endif // PHONON_XINE_BYTESTREAM_H