/*  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 COMM_H
#define COMM_H

#include <Phonon/EffectParameter>
#include <QtCore/QDataStream>

namespace Phonon
{
class MediaSource;
namespace Proxy
{

class ProxyObject;

enum ConstructorId {
    BackendConstructor,
    _AfterConstructorId
};

enum FunctionId {
    // functions
    NoFunction = _AfterConstructorId,

    Destructor,
    BackendShutdown,                      // no args
    BackendCreateObject,                  // void *, BackendInterface::Class, QVariantList
    BackendAvailableMimeTypes,            // no args
    BackendObjectDescriptionIndexes,      // ObjectDescriptionType
    BackendObjectDescriptionProperties,   // ObjectDescriptionType, int
    BackendStartConnectionChange,         // QSet<QObject *>
    BackendConnectNodes,                  // QObject *, QObject *
    BackendDisconnectNodes,               // QObject *, QObject *
    BackendEndConnectionChange,           // QSet<QObject *>

    AudioOutputVolume,
    AudioOutputSetVolume,                 // qreal
    AudioOutputOutputDevice,
    AudioOutputSetOutputDevice,           // int

    EffectParameters,
    EffectParameterValue,
    EffectSetParameterValue,

    MediaObjectState,
    MediaObjectHasVideo,
    MediaObjectIsSeekable,
    MediaObjectCurrentTime,
    MediaObjectTotalTime,
    MediaObjectRemainingTime,
    MediaObjectTickInterval,
    MediaObjectSetTickInterval,
    MediaObjectPlay,
    MediaObjectPause,
    MediaObjectStop,
    MediaObjectSeek,
    MediaObjectErrorString,
    MediaObjectErrorType,
    MediaObjectHasInterface,
    MediaObjectInterfaceCall,
    MediaObjectPrefinishMark,
    MediaObjectSetPrefinishMark,
    MediaObjectTransitionTime,
    MediaObjectSetTransitionTime,
    MediaObjectSource,
    MediaObjectSetSource,
    MediaObjectSetNextSource,

    _AfterFunctionId
};

enum SignalId {
    BackendObjectDescriptionChanged = _AfterFunctionId,
    AudioOutputVolumeChanged,             // qreal
    AudioOutputAudioDeviceFailed,

    MediaObjectAboutToFinish,             //
    MediaObjectFinished,                  //
    MediaObjectPrefinishMarkReached,      // qint32 msec
    MediaObjectTotalTimeChanged,          // qint64 length
    MediaObjectStateChanged,              // Phonon::State newstate, Phonon::State oldstate
    MediaObjectTick,                      // qint64 time
    MediaObjectMetaDataChanged,           // const QMultiMap<QString, QString> &
    MediaObjectSeekableChanged,           // bool
    MediaObjectHasVideoChanged,           // bool
    MediaObjectBufferStatus,              // int
    MediaObjectAvailableTitlesChanged,    // int
    MediaObjectTitleChanged,              // int
    MediaObjectAvailableChaptersChanged,  // int
    MediaObjectChapterChanged,            // int
    MediaObjectAvailableAnglesChanged,    // int
    MediaObjectAngleChanged,              // int

    _AfterSignalId
};

} // namespace Proxy
} // namespace Phonon

inline QDataStream &operator>>(QDataStream &s, void *&ptr)
{
    QVariant v;
    s >> v;
    ptr = qvariant_cast<void *>(v);
    return s;
}

inline QDataStream &operator>>(QDataStream &s, Phonon::Proxy::ProxyObject *&ptr)
{
    QVariant v;
    s >> v;
    ptr = reinterpret_cast<Phonon::Proxy::ProxyObject *>(qvariant_cast<void *>(v));
    return s;
}

inline QDataStream &operator<<(QDataStream &s, void *ptr)
{
    return s << QVariant::fromValue(ptr);
}

QDataStream &operator<<(QDataStream &s, const Phonon::EffectParameter &p);
QDataStream &operator>>(QDataStream &s, Phonon::EffectParameter &p);
QDataStream &operator<<(QDataStream &s, const Phonon::MediaSource &ms);
QDataStream &operator>>(QDataStream &s, Phonon::MediaSource &ms);

#endif // COMM_H
