~oem-solutions-group/unity-2d/phonon

« back to all changes in this revision

Viewing changes to phonon/tests/fakebackend/mediaobject.cpp

  • Committer: Alex Chiang
  • Date: 2011-04-12 15:51:11 UTC
  • Revision ID: achiang@canonical.com-20110412155111-n3oq9x9w9f2yt4xk
* New upstream release
* Switch to source format 3.0 (quilt)
* Bump the Breaks version too. I really should have test installed that.
* Bump version number so that the phonon packages are installable
* Sync with Debian, now packaging separately from Qt since QtWebKit is also packaged separately
* Bump version number to match ours
* Bump Qt build-depends to 4.7
* Update symbol file for armel, fixes FTBFS.
* New upstream release:
 - fixes crash when opening PDF document (Closes: #580802);
* Add debian/watch.
* Update patches:
  - refresh 01 and 02;
  - adapt 03 to upstream changes;
  - remove 04, was stolen from upstream.
* Use dh_xine, version libxine-dev build dependency to >= 1.1.16.3
  (Closes: #575115).
* Update libphonon4 symbol file.
* Add ${misc:Depends} to phonon-backend-null.
* Update libphonon-dev.install: ship new style CamelCase headers in
  /usr/include/phonon.
* Make libphonon-dev depend on libqt4-dev.
* Manually create /usr/include/qt4/phonon symlink on upgrades.
  See #404850 why dpkg does not create it by itself.
* Urgency high as the bug leaves Phonon undiscoverable by KDE
  FindPhonon.cmake after upgrade and the buggy libphonon-dev is already in
  testing.
* phonon-backend-gstreamer: depend on gstreamer0.10-alsa only on Linux
  architectures, as ALSA is available only there. (Closes: #578255)
* Upload to unstable.
* New upstream release (4.4.0).
* Add 04_skip_pa_detection_if_no_glib_loop.diff patch which fixes phonon
  hang if GLib loop is disabled in Qt.
* Refresh patches.
* Update libphonon4 symbol file.
* Update libphonon-dev.install: add pulsesupport.h.
* Override lintian "phonon-backend-null: empty-binary-package".
* Add explicit debian/source/format as lintian suggests.
* New upstream release (using really-style version number).
* Build Phonon from kdesupport again:
  - Add phonon, phonon-dbg, libphonon4 and libphonon-dev packages.
* Remove patches:
  - 02_disable_phonon_build.diff - dropped.
  - 03_r950739_fullscreen_hidecursor.diff - stolen upstream.
  - 05_924144_encoding_local_files_fix.diff - stolen upstream.
  - 06_983650_play_filenames_with_hash.diff - stolen upstream.
  - 07_feature_backport_xine_equalizer.diff - stolen upstream.
* Update debian/control:
  - Bump build dependencies (debhelper and pkg-kde-tools).
  - Add libpulse-dev build dependency.
  - Remove libphonon-dev build dependency.
  - Bump Standards-Version from 3.8.2 to 3.8.4 (no changes needed).
* Remove myself from Uploaders.
* Change my email address to modax@debian.org in Uploaders field.
* Fix Vcs-Browser URL.
* Improve descriptions.
* Downgrade Qt build dependency to 4.5.
* Bump version to 4:4.6.0really4.3.80 to be higher than the last
  release of the Phonon libraries with the qt4-x11 source package.
* Convert libphonon4.symbols to new pkg-kde-tools 0.6 style, adjust
  for 4.3.80 release.
* Do not install "experimental" headers to libphonon-dev.
* Add libphonon4 lintian overrides for
  {shlibs,symbols}-declares-dependency-on-other-package warnings.
* Add 02_no_rpath.patch patch to disable /usr/lib RPATH by default.
* Add DEP-3 patch header to 01_phonon-inc.patch.
* Tweak copyright file a bit so lintian stops thinking it's of
  old-dh-make style. Also bump years of packaging copyright.
* Add phonon-backends-dbg to phonon-dbg Conflicts and Replaces.
* Do not version dependency on the phonon metapackage.
* Use strict interdependencies among backends and libphonon4.
* Build depend on dpkg-dev 1.15.5.
* Make libphonon4 break phonon-backend-xine (<< 4:4.6.0really4.3.80).
* Fix installing of include headers so that others can also find them.
+++ Changes by Modestas Vainius:
* Rename source package to phonon-backends.
* Add phonon-backends-dbg debug package.
* Add patch (06_983650_play_filenames_with_hash.diff) to fix playback of
  files with hash (#) symbol in their name (Closes: #546271).
* Backport Xine equalizer support from Phonon trunk (patch
  07_feature_backport_xine_equalizer.diff).
+++ Changes by Modestas Vainius:
* Install backends to /usr/lib/qt4 (Closes: #539623). Otherwise pure Qt4
  applications cannot find any backends.
+++ Changes by Sune Vuorela:
* Backport a bugfix from upstream to fix encoding issues with filenames.
* Fix not-installed file and remove trailing whitespaces
+++ Changes by Fathi Boudra:
* Add gstreamer0.10-alsa dependency to phonon-backend-gstreamer.
  (Closes: #532490)
+++ Changes by Modestas Vainius:
* Add 03_r950739_fullscreen_hidecursor.diff patch which makes it possible
  to hide mouse cursor in fullscreen mode when xine backend is in use.
* Build Phonon from Qt sources:
  - Add myself to Uploaders field.
  - Add 02_disable_phonon_build.diff to avoid Phonon build.
  - Add versioned libphonon-dev build dependency.
  - Bump Standards-Version from 3.8.1 to 3.8.2 (no changes needed).
  - Remove phonon, phonon-dbg, libphonon4 and libphonon-dev packages.
  - Cleanup unnecessary files.
* New upstream release.
+++ Changes by Modestas Vainius:
* Point Debian Vcs URLs to pkg-kde/trunk (new location).
+++ Changes by Modestas Vainius
* Bump debian/compat and debhelper build dependency to v7 (to get more
  sophisticated debian/tmp handling).
* Switch from internal debian/cdbs/kde.mk to pkg-kde-tools:
  - bump pkg-kde-tools build depend to 0.4;
  - remove debian/cdbs directory;
  - replace debian/cdbs/kde.mk with
    /usr/share/pkg-kde-tools/qt-kde-team/1/debian-qt-kde.mk in debian/rules;
  - remove custom symbolshelper rules from debian/rules.
* Remove THIS_SHOULD_GO_TO_UNSTABLE from debian/rules.
* New upstream release.
+++ Changes by Modestas Vainius:
* Add xine backend. Based on kdebase-runtime packaging.
* Make xine backend a default one (via phonon metapackage).
* Bump cmake build dependency to 2.6.2.
* Bump Standards-Version to 3.8.0: add README.source.
* phonon-xine-backend replaces earlier kde-icons-oxygen.
* Add symbols file for libphonon4. This needs pkg-kde-tools (>= 0.3)
  at build time.
  - Hook up phonon dependency to play(), stop(), pause() etc. methods.
* Resync patches:
  - drop phonon-libraryPaths.patch patch. Merged upstream.
  - prepend sequence number to phonon-inc.patch (01_) and refresh it.
* Switch to new installgen format.
* Make phonon-backend-xine depend on gstreamer0.10-plugins-base. Otherwise,
  it causes crashes sometimes.
* Make phonon-backend-gstreamer recommend gstreamer0.10-plugins-good and
  suggest gstreamer0.10-plugins-ugly. Explain reasoning in the package 
  description.
+++ Changes by George Kiagiadakis:
* Build-conflict with the experimental libxine2 as the
  phonon-xine backend cannot build with it.
+++ Changes by Pino Toscano:
* Update copyright file.
+++ Changes by Ana Beatriz Guerrero Lopez:
* Update packaging years and upstream URL in copyright. 
* Make phonon find its backends. (Closes: 498573)
  Thanks to Vincent Fourmond for tracking down the cause and Matthias Kretz
  for the fix.
* Create a magic phonon header (thanks to Matthias Kretz) and as the Qt.
  documentation is unclear, symlink Phonon to the phonon header.
  Also create a symlink from /usr/include/qt4/phonon to /usr/include/phonon
  so that application using qmake can use it.
* New upstream release.
+++ Changes by Modestas Vainius:
* Bump libphonon shlibs to 4.2.0.

* New snapshot, upload to unstable. 
+++ Changes by Modestas Vainius:
* Exclude phonon metapackage from automatic shlibdeps because libphonon4
  itself ended up depending on it somehow.
+++ Changes by Ana Beatriz Guerrero Lopez:
* Update copyright file and write the BSD license instead of pointing at it.
* Replace the N/A stuff with some more meaningful (unspecified).
+++ Changes by Ana Guerrero, Modestas Vainius, Pino Toscano and Sune Vuorela:
* First release. This has been split out from kde4libs.
* Add support for Phonon backends:
  - Make the phonon-backend-gstreamer provide a virtual phonon-backend.
  - Create a phonon metapackage that installs the phonon library and ensure
    a backend is installed too.

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-2007 Matthias Kretz <kretz@kde.org>
 
3
 
 
4
    This library is free software; you can redistribute it and/or
 
5
    modify it under the terms of the GNU Lesser General Public
 
6
    License as published by the Free Software Foundation; either
 
7
    version 2.1 of the License, or (at your option) version 3, or any
 
8
    later version accepted by the membership of KDE e.V. (or its
 
9
    successor approved by the membership of KDE e.V.), Nokia Corporation 
 
10
    (or its successors, if any) and the KDE Free Qt Foundation, which shall
 
11
    act as a proxy defined in Section 6 of version 3 of the license.
 
12
 
 
13
    This library is distributed in the hope that it will be useful,
 
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
    Lesser General Public License for more details.
 
17
 
 
18
    You should have received a copy of the GNU Lesser General Public 
 
19
    License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 
20
 
 
21
*/
 
22
 
 
23
#include "mediaobject.h"
 
24
#include <QtCore/QTimer>
 
25
#include "stream.h"
 
26
#include "../../abstractmediastream_p.h"
 
27
#include <QtCore/QVector>
 
28
#include <cmath>
 
29
#include <QtCore/QFile>
 
30
#include <QtCore/QByteRef>
 
31
#include <QtCore/QStringList>
 
32
#include "audionode.h"
 
33
#include "videonode.h"
 
34
 
 
35
namespace Phonon
 
36
{
 
37
namespace Fake
 
38
{
 
39
static const int SAMPLE_RATE = 44100;
 
40
static const float SAMPLE_RATE_FLOAT = 44100.0f;
 
41
static const int FRAME_RATE = 25;
 
42
static const int SAMPLES_PER_FRAME = SAMPLE_RATE / FRAME_RATE;
 
43
 
 
44
MediaObject::MediaObject(QObject *parent)
 
45
    : QObject(parent)
 
46
    , m_state(Phonon::LoadingState)
 
47
    , m_tickTimer(new QTimer(this))
 
48
    , m_bufferSize(SAMPLES_PER_FRAME)//512)
 
49
    , m_lastSamplesMissing(0)
 
50
    , m_position(0.0f)
 
51
    , m_frequency(440.0f)
 
52
    , m_prefinishMarkReachedNotEmitted(true), m_waiting(0)
 
53
{
 
54
    //kDebug(604) ;
 
55
    connect(m_tickTimer, SIGNAL(timeout()), SLOT(emitTick()));
 
56
}
 
57
 
 
58
MediaObject::~MediaObject()
 
59
{
 
60
    //kDebug(604) ;
 
61
}
 
62
 
 
63
State MediaObject::state() const
 
64
{
 
65
    //kDebug(604) ;
 
66
    return m_state;
 
67
}
 
68
 
 
69
bool MediaObject::hasVideo() const
 
70
{
 
71
    //kDebug(604) ;
 
72
    return false;
 
73
}
 
74
 
 
75
bool MediaObject::isSeekable() const
 
76
{
 
77
    //kDebug(604) ;
 
78
    return true;
 
79
}
 
80
 
 
81
qint64 MediaObject::currentTime() const
 
82
{
 
83
    //kDebug(604) ;
 
84
    switch(state())
 
85
    {
 
86
    case Phonon::PausedState:
 
87
    case Phonon::BufferingState:
 
88
        return m_startTime.msecsTo(m_pauseTime);
 
89
    case Phonon::PlayingState:
 
90
        return m_startTime.elapsed();
 
91
    case Phonon::StoppedState:
 
92
    case Phonon::LoadingState:
 
93
        return 0;
 
94
    case Phonon::ErrorState:
 
95
        break;
 
96
    }
 
97
    return -1;
 
98
}
 
99
 
 
100
qint32 MediaObject::tickInterval() const
 
101
{
 
102
    //kDebug(604) ;
 
103
    return m_tickInterval;
 
104
}
 
105
 
 
106
void MediaObject::setTickInterval(qint32 newTickInterval)
 
107
{
 
108
    //kDebug(604) ;
 
109
    m_tickInterval = newTickInterval;
 
110
    if (m_tickInterval <= 0)
 
111
        m_tickTimer->setInterval(50);
 
112
    else
 
113
        m_tickTimer->setInterval(newTickInterval);
 
114
}
 
115
 
 
116
void MediaObject::play()
 
117
{
 
118
    //kDebug(604) ;
 
119
    if (m_state == Phonon::LoadingState) {
 
120
        setState(Phonon::BufferingState);
 
121
    } else {
 
122
        setState(Phonon::PlayingState);
 
123
    }
 
124
}
 
125
 
 
126
QString MediaObject::errorString() const
 
127
{
 
128
    return QString();
 
129
}
 
130
 
 
131
Phonon::ErrorType MediaObject::errorType() const
 
132
{
 
133
    return Phonon::NoError;
 
134
}
 
135
 
 
136
void MediaObject::setState(State newstate)
 
137
{
 
138
    if (newstate == m_state)
 
139
        return;
 
140
    State oldstate = m_state;
 
141
    m_state = newstate;
 
142
    switch(newstate)
 
143
    {
 
144
    case Phonon::PausedState:
 
145
    case Phonon::BufferingState:
 
146
        m_pauseTime.start();
 
147
        break;
 
148
    case Phonon::PlayingState:
 
149
        m_tickTimer->start();
 
150
        if (oldstate == Phonon::PausedState || oldstate == Phonon::BufferingState)
 
151
            m_startTime = m_startTime.addMSecs(m_pauseTime.elapsed());
 
152
        else
 
153
            m_startTime.start();
 
154
        break;
 
155
    case Phonon::StoppedState:
 
156
    case Phonon::ErrorState:
 
157
    case Phonon::LoadingState:
 
158
        m_startTime = QTime();
 
159
        break;
 
160
    }
 
161
    //kDebug(604) << "emit stateChanged(" << newstate << ", " << oldstate << ")";
 
162
    emit stateChanged(newstate, oldstate);
 
163
}
 
164
 
 
165
static const float TWOPI = 6.28318530718f;
 
166
static const float maxFrequency = 1760.0f;
 
167
static const float minFrequency = 440.0f;
 
168
static const float frequencyToDelta = TWOPI / SAMPLE_RATE_FLOAT;
 
169
 
 
170
void MediaObject::fillBuffer(QVector<float> *buffer)
 
171
{
 
172
    //static QFile createdump("createdump");
 
173
    //if (!createdump.isOpen())
 
174
        //createdump.open(QIODevice::WriteOnly);
 
175
 
 
176
    m_frequency *= 1.059463094359f;
 
177
    if (m_frequency > maxFrequency)
 
178
        m_frequency = minFrequency;
 
179
    float delta = frequencyToDelta * m_frequency;
 
180
 
 
181
    float *data = buffer->data();
 
182
    const float * const end = data + m_bufferSize;
 
183
 
 
184
    while (data != end)
 
185
    {
 
186
        const float sample = std::sin(m_position);
 
187
        //createdump.write(QByteArray::number(sample) + "\n");
 
188
         *(data++) = sample;
 
189
        m_position += delta;
 
190
        if (m_position > TWOPI)
 
191
            m_position -= TWOPI;
 
192
    }
 
193
}
 
194
 
 
195
void MediaObject::fillFrameData(Phonon::Experimental::VideoFrame *frame)
 
196
{
 
197
    Q_UNUSED(frame);
 
198
//X    static quint32 frameCount = 0;
 
199
//X    quint8 *dataPtr = reinterpret_cast<quint8 *>(frame->data.data());
 
200
//X    for (int y = 0; y < frame->height; ++y)
 
201
//X        for (int x = 0; x < frame->width; ++x)
 
202
//X        {
 
203
//X             *dataPtr++ = static_cast<quint8>(0xff);
 
204
//X             *dataPtr++ = static_cast<quint8>((x + frameCount) * 2 / 3); //red
 
205
//X             *dataPtr++ = static_cast<quint8>(y + frameCount); //green
 
206
//X             *dataPtr++ = static_cast<quint8>(frameCount / 2); //blue
 
207
//X        }
 
208
//X    ++frameCount;
 
209
}
 
210
 
 
211
qint64 MediaObject::totalTime() const
 
212
{
 
213
    //kDebug(604) ;
 
214
    return 1000 *60 *3; // 3 minutes
 
215
}
 
216
 
 
217
qint32 MediaObject::prefinishMark() const
 
218
{
 
219
    //kDebug(604) ;
 
220
    return m_prefinishMark;
 
221
}
 
222
 
 
223
qint32 MediaObject::transitionTime() const
 
224
{
 
225
    return m_transitionTime;
 
226
}
 
227
 
 
228
void MediaObject::setTransitionTime(qint32 time)
 
229
{
 
230
    m_transitionTime = time;
 
231
}
 
232
 
 
233
qint64 MediaObject::remainingTime() const
 
234
{
 
235
    return totalTime() - currentTime();
 
236
}
 
237
 
 
238
 
 
239
MediaSource MediaObject::source() const
 
240
{
 
241
    return m_source;
 
242
}
 
243
 
 
244
void MediaObject::setNextSource(const MediaSource &source)
 
245
{
 
246
    m_nextSource = source;
 
247
}
 
248
 
 
249
void MediaObject::setSource(const MediaSource &source)
 
250
{
 
251
    //kDebug(604) ;
 
252
    m_prefinishMarkReachedNotEmitted = true;
 
253
    m_source = source;
 
254
    setState(Phonon::LoadingState);
 
255
    switch (m_source.type()) {
 
256
    case MediaSource::Invalid:
 
257
    case MediaSource::Empty:
 
258
        return;
 
259
    case MediaSource::Disc:
 
260
        Q_ASSERT(m_source.discType() != NoDisc);
 
261
        break;
 
262
    case MediaSource::Url:
 
263
        Q_ASSERT(m_source.url().isValid());
 
264
        break;
 
265
    case MediaSource::LocalFile:
 
266
        Q_ASSERT(!m_source.fileName().isEmpty());
 
267
        break;
 
268
    case MediaSource::Stream:
 
269
        //Stream *s = new Stream(m_source, this);
 
270
        //Q_ASSERT(qobject_cast<Stream *>(m_source.stream()->d_ptr->streamInterface));
 
271
        break;
 
272
    }
 
273
    emit totalTimeChanged(totalTime());
 
274
    QMultiMap<QString, QString> metaData;
 
275
    metaData.insert("TITLE", "Fake video");
 
276
    metaData.insert("ARTIST", "Matthias Kretz");
 
277
    emit metaDataChanged(metaData);
 
278
    emit currentSourceChanged(m_source);
 
279
    QTimer::singleShot(50, this, SLOT(loadingComplete()));
 
280
}
 
281
 
 
282
void MediaObject::loadingComplete()
 
283
{
 
284
    if (state() == Phonon::LoadingState) {
 
285
        setState(Phonon::StoppedState);
 
286
    } else if (state() == Phonon::BufferingState) {
 
287
        setState(Phonon::PlayingState);
 
288
    }
 
289
}
 
290
 
 
291
void MediaObject::setPrefinishMark(qint32 newPrefinishMark)
 
292
{
 
293
    //kDebug(604) ;
 
294
    m_prefinishMark = newPrefinishMark;
 
295
    if (currentTime() < totalTime() - m_prefinishMark) // not about to finish
 
296
        m_prefinishMarkReachedNotEmitted = true;
 
297
}
 
298
 
 
299
void MediaObject::pause()
 
300
{
 
301
    //kDebug(604) ;
 
302
    switch (state()) {
 
303
    case PlayingState:
 
304
    case BufferingState:
 
305
    case StoppedState:
 
306
        m_tickTimer->stop();
 
307
        setState(Phonon::PausedState);
 
308
        break;
 
309
    case PausedState:
 
310
    case LoadingState:
 
311
    case ErrorState:
 
312
        break;
 
313
    }
 
314
}
 
315
 
 
316
void MediaObject::stop()
 
317
{
 
318
    //kDebug(604) ;
 
319
    if (state() == Phonon::PlayingState || state() == Phonon::BufferingState || state() == Phonon::PausedState) {
 
320
        m_tickTimer->stop();
 
321
        setState(Phonon::StoppedState);
 
322
        m_position = 0.0f;
 
323
        m_frequency = 440.0f;
 
324
        m_prefinishMarkReachedNotEmitted = true;
 
325
    }
 
326
}
 
327
 
 
328
void MediaObject::seek(qint64 time)
 
329
{
 
330
    //kDebug(604) ;
 
331
    if (isSeekable())
 
332
    {
 
333
        switch(state())
 
334
        {
 
335
        case Phonon::PausedState:
 
336
        case Phonon::BufferingState:
 
337
            m_startTime = m_pauseTime;
 
338
            break;
 
339
        case Phonon::PlayingState:
 
340
            m_startTime.start();
 
341
            break;
 
342
        case Phonon::StoppedState:
 
343
        case Phonon::ErrorState:
 
344
        case Phonon::LoadingState:
 
345
            return; // cannot seek
 
346
        }
 
347
        m_startTime = m_startTime.addMSecs(-time);
 
348
    }
 
349
 
 
350
    if (currentTime() < totalTime() - m_prefinishMark) // not about to finish
 
351
        m_prefinishMarkReachedNotEmitted = true;
 
352
}
 
353
 
 
354
void MediaObject::emitTick()
 
355
{
 
356
    //kDebug(604) << "emit tick(" << currentTime() << ")";
 
357
    int tickInterval = 50;
 
358
    if (m_tickInterval > 0)
 
359
    {
 
360
        emit tick(currentTime());
 
361
        tickInterval = m_tickInterval;
 
362
    }
 
363
/*    if (m_waiting == 0) {
 
364
        QVector<float> buffer(m_bufferSize);
 
365
        Experimental::VideoFrame frame;
 
366
        frame.width = 320;
 
367
        frame.height = 240;
 
368
        frame.colorspace = Experimental::VideoFrame::Format_RGBA8;
 
369
        frame.data.resize(frame.width * frame.height * 4);
 
370
 
 
371
        const int availableSamples = tickInterval * SAMPLE_RATE / 1000 + m_lastSamplesMissing;
 
372
        const int bufferCount = availableSamples / m_bufferSize;
 
373
        m_lastSamplesMissing = availableSamples - bufferCount * m_bufferSize;
 
374
        for (int i = 0; i < bufferCount; ++i)
 
375
        {
 
376
            fillBuffer(&buffer);
 
377
            foreach (AudioNode *an, m_audioNodes) {
 
378
                an->processBuffer(buffer);
 
379
            }
 
380
            fillFrameData(&frame);
 
381
            foreach (VideoNode *vn, m_videoNodes) {
 
382
                vn->processFrame(frame);
 
383
            }
 
384
        }
 
385
    }
 
386
*/
 
387
    if (currentTime() >= totalTime() - m_prefinishMark) { // about to finish
 
388
        if (m_prefinishMarkReachedNotEmitted) {
 
389
            m_prefinishMarkReachedNotEmitted = false;
 
390
            emit prefinishMarkReached(totalTime() - currentTime());
 
391
        }
 
392
    }
 
393
    if (currentTime() >= totalTime()) // finished
 
394
    {
 
395
        emit aboutToFinish();
 
396
        if (m_nextSource.type() == MediaSource::Empty || m_nextSource.type() == MediaSource::Invalid) {
 
397
            stop();
 
398
            emit finished();
 
399
        } else {
 
400
            m_prefinishMarkReachedNotEmitted = true;
 
401
            m_source = m_nextSource;
 
402
            m_nextSource = MediaSource();
 
403
            switch (m_source.type()) {
 
404
            case MediaSource::Empty:
 
405
            case MediaSource::Invalid:
 
406
                abort();
 
407
            case MediaSource::Disc:
 
408
                Q_ASSERT(m_source.discType() != NoDisc);
 
409
                break;
 
410
            case MediaSource::Url:
 
411
                Q_ASSERT(m_source.url().isValid());
 
412
                break;
 
413
            case MediaSource::LocalFile:
 
414
                Q_ASSERT(!m_source.fileName().isEmpty());
 
415
                break;
 
416
            case MediaSource::Stream:
 
417
                break;
 
418
            }
 
419
            emit totalTimeChanged(totalTime());
 
420
            QMultiMap<QString, QString> metaData;
 
421
            metaData.insert("TITLE", "Fake video");
 
422
            metaData.insert("ARTIST", "Matthias Kretz");
 
423
            emit metaDataChanged(metaData);
 
424
        }
 
425
    }
 
426
}
 
427
bool MediaObject::wait()
 
428
{
 
429
    ++m_waiting;
 
430
    return true;
 
431
}
 
432
 
 
433
bool MediaObject::done()
 
434
{
 
435
    --m_waiting;
 
436
    return true;
 
437
}
 
438
 
 
439
void MediaObject::addAudioNode(AudioNode *node)
 
440
{
 
441
    m_audioNodes << node;
 
442
    node->setHasInput(true);
 
443
}
 
444
 
 
445
void MediaObject::addVideoNode(VideoNode *node)
 
446
{
 
447
    m_videoNodes << node;
 
448
    node->setHasInput(true);
 
449
}
 
450
 
 
451
bool MediaObject::removeAudioNode(AudioNode *node)
 
452
{
 
453
    node->setHasInput(false);
 
454
    return 1 == m_audioNodes.removeAll(node);
 
455
}
 
456
 
 
457
bool MediaObject::removeVideoNode(VideoNode *node)
 
458
{
 
459
    node->setHasInput(false);
 
460
    return 1 == m_videoNodes.removeAll(node);
 
461
}
 
462
 
 
463
}}
 
464
 
 
465
#include "moc_mediaobject.cpp"
 
466
// vim: sw=4 ts=4