23#include "abstractmediastream2.h"
24#include "abstractmediastream2_p.h"
25#include "mediaobjectinterface.h"
26#include "mediaobject_p.h"
27#include "phononnamespace_p.h"
29#include <QAbstractEventDispatcher>
35bool AbstractMediaStream2::event(
QEvent *e)
39 if (d->eventDispatcher) {
40 pWarning() <<
"Do not call moveToThread on an AbstractMediaStream2 object when it is in use.";
41 QObject::disconnect(d->eventDispatcher, SIGNAL(awake()),
this, SLOT(_k_handleStreamEvent()));
42 d->eventDispatcher = 0;
48void AbstractMediaStream2Private::dataReady()
50 Q_Q(AbstractMediaStream2);
51 if (!eventDispatcher) {
53 if (!eventDispatcher) {
54 pError() <<
"AbstractMediaStream2 needs to run in a thread with QEventLoop";
60 eventDispatcher->wakeUp();
63void AbstractMediaStream2Private::_k_handleStreamEvent()
65 Q_ASSERT(streamEventQueue);
66 Q_Q(AbstractMediaStream2);
67 StreamEventQueue::Command c;
68 while (streamEventQueue->nextCommandForFrontend(&c)) {
70 case StreamEventQueue::SetStreamSize:
71 case StreamEventQueue::SetSeekable:
72 case StreamEventQueue::Write:
73 case StreamEventQueue::EndOfData:
74 case StreamEventQueue::SeekDone:
75 case StreamEventQueue::ResetDone:
76 case StreamEventQueue::ConnectDone:
77 pFatal(
"AbstractMediaStream2 received wrong Command");
79 case StreamEventQueue::NeedData:
80 q->needData(qvariant_cast<quint32>(c.data));
82 case StreamEventQueue::EnoughData:
85 case StreamEventQueue::Seek:
86 q->seekStream(qvariant_cast<quint64>(c.data));
88 case StreamEventQueue::Reset:
91 case StreamEventQueue::Connect:
94 streamEventQueue->sendToBackend(StreamEventQueue::ConnectDone);
95 streamEventQueue->sendToBackend(StreamEventQueue::SetSeekable, streamSeekable);
96 if (streamSize != 0) {
97 streamEventQueue->sendToBackend(StreamEventQueue::SetStreamSize, streamSize);
118void AbstractMediaStream2Private::setStreamSize(qint64 newSize)
120 streamSize = newSize;
121 streamEventQueue->sendToBackend(StreamEventQueue::SetStreamSize, newSize);
124void AbstractMediaStream2Private::setStreamSeekable(
bool s)
127 streamEventQueue->sendToBackend(StreamEventQueue::SetSeekable, s);
130void AbstractMediaStream2Private::writeData(
const QByteArray &data)
132 streamEventQueue->sendToBackend(StreamEventQueue::Write, data);
135void AbstractMediaStream2Private::endOfData()
137 streamEventQueue->sendToBackend(StreamEventQueue::EndOfData);
140void AbstractMediaStream2::resetDone()
143 if (d->connectReset > 0) {
145 d->streamEventQueue->sendToBackend(StreamEventQueue::ConnectDone);
147 d->streamEventQueue->sendToBackend(StreamEventQueue::ResetDone);
149 d->streamEventQueue->sendToBackend(StreamEventQueue::SetSeekable, d->streamSeekable);
150 if (d->streamSize != 0) {
151 d->streamEventQueue->sendToBackend(StreamEventQueue::SetStreamSize, d->streamSize);
155void AbstractMediaStream2::seekStreamDone()
157 d_func()->streamEventQueue->sendToBackend(StreamEventQueue::SeekDone);
160AbstractMediaStream2Private::AbstractMediaStream2Private()
161 : streamEventQueue(new StreamEventQueue),
166 streamEventQueue->ref();
167 streamEventQueue->setFrontendCommandHandler(
this);
170AbstractMediaStream2Private::~AbstractMediaStream2Private()
175 streamEventQueue->setFrontendCommandHandler(0);
176 streamEventQueue->deref();
177 streamEventQueue = 0;
185#include "moc_abstractmediastream2.cpp"
QAbstractEventDispatcher * instance(QThread *thread)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
virtual bool event(QEvent *e)