/*  This file is part of the KDE project
    Copyright (C) 2007 Matthias Kretz <kretz@kde.org>

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) version 3.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.

*/

#ifndef PROXYBACKEND_MEDIAOBJECT_H
#define PROXYBACKEND_MEDIAOBJECT_H

#include <QtCore/QObject>

#include <Phonon/MediaObjectInterface>
#include <Phonon/AddonInterface>

#include "proxyobject.h"

namespace Phonon
{
namespace Proxy
{

class MediaObject : public QObject, public MediaObjectInterface, public AddonInterface, public ProxyObject
{
    Q_OBJECT
    Q_INTERFACES(Phonon::MediaObjectInterface Phonon::AddonInterface)
    public:
        MediaObject(QObject *parent);
        ~MediaObject();
        void handleSignal(SignalId, QDataStream &) const;
        QObject *qObject() { return this; }

        State state() const;
        bool hasVideo() const;
        bool isSeekable() const;
        qint64 currentTime() const;
        qint64 totalTime() const;
        qint64 remainingTime() const;
        qint32 tickInterval() const;

        void setTickInterval(qint32 newTickInterval);
        void play();
        void pause();
        void stop();
        void seek(qint64 time);

        QString errorString() const;
        Phonon::ErrorType errorType() const;

        bool hasInterface(AddonInterface::Interface i) const;
        QVariant interfaceCall(AddonInterface::Interface, int, const QList<QVariant> &);

        qint32 prefinishMark() const;
        void setPrefinishMark(qint32 newPrefinishMark);

        qint32 transitionTime() const;
        void setTransitionTime(qint32 newTransitionTime);

        MediaSource source() const;
        void setSource(const MediaSource &source);
        void setNextSource(const MediaSource &source);

    signals:
        void aboutToFinish() const;
        void finished() const;
        void prefinishMarkReached(qint32 msec) const;
        void totalTimeChanged(qint64 length) const;

        void stateChanged(Phonon::State newstate, Phonon::State oldstate) const;
        void tick(qint64 time) const;
        void metaDataChanged(const QMultiMap<QString, QString> &) const;
        void seekableChanged(bool) const;
        void hasVideoChanged(bool) const;
        void bufferStatus(int) const;

        // AddonInterface
        void availableTitlesChanged(int) const;
        void titleChanged(int) const;
        void availableChaptersChanged(int) const;
        void chapterChanged(int) const;
        void availableAnglesChanged(int) const;
        void angleChanged(int) const;
};
}} //namespace Phonon::Proxy
#endif // PROXYBACKEND_MEDIAOBJECT_H
