// -*- c++ -*-

/*
 *
 * Copyright (C) 2002 George Staikos <staikos@kde.org>
 *
 * This library 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) any later version.
 *
 * 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., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */



#ifndef __QVSRC_PLUGIN_H
#define __QVSRC_PLUGIN_H

#include <qobject.h>
#include <qstring.h>
#include <qstringlist.h>
#include <qmap.h>
#include <qcolor.h>
#include "qvpluginbase.h"

class QVSourcePluginPrivate;

/**
 * Video source plugin base class
 */
class QVSourcePlugin : public QVPluginBase
{
    Q_OBJECT

public:
    QVSourcePlugin(QtVision *qtv, const QString& cfgkey, QObject *parent = 0, const char* name = 0);
    virtual ~QVSourcePlugin();

    /**
     * To get various values.
     */
    virtual int brightness() = 0;
    virtual int colour() = 0;
    virtual int hue() = 0;
    virtual int contrast() = 0;
    virtual int whiteness() = 0;
    virtual int frequency() = 0;
    virtual int signal() = 0;
    virtual bool muted() = 0;
    virtual int tunerMode() = 0;
    /**
     * True if the CURRENT RUNNING device is a tuner device.
     */
    virtual bool isTuner() = 0;
    virtual QColor colourKey() = 0;

    virtual bool needsNorm() const;
    virtual int norm() const;

    /**
     * True if this device is a tuner device.
     * Do not override this.  Provide this information in _tuners.
     */
    bool isTuner(const QString &dev);

    virtual const QStringList& deviceList() const;
    virtual const QStringList& sourceList(const QString& dev) const;
    virtual QString device() const;
    virtual QString source() const;

    // return 0 on success.  This is called to indicate that you should probe
    // for devices and populate _devices, _sources, and _tuners.
    // It may be called more than once.
    virtual int probeDevices() = 0;

    // Set the widget that we display on
    void setWidget(QWidget *w);

    virtual bool videoPlaying() const = 0;

    virtual bool canVideoDesktop() const;
    virtual bool canGrabStill() const;
    virtual bool grabStill( QPixmap *pix );

public slots:
    /**
     * Sets the device to use.
     */
    virtual int setDevice( const QString &dev ) = 0;

    /**
     * Sets the source to use.
     */
    virtual int setSource( const QString &src ) = 0;

    /**
     * Sets the current current channel.
     */
    virtual void setFrequency( int freq ) = 0;

    /**
     * Set the norm for the plugin. (NTSC, PAL, SECAM, etc)
     */
    virtual void setNorm(int norm);

    /**
     * Mutes the sound.
     */
    virtual void setMuted( bool muted ) = 0;

    virtual void setBrightness(int val) = 0;
    virtual void setColour(int val) = 0;
    virtual void setHue(int val) = 0;
    virtual void setContrast(int val) = 0;
    virtual void setWhiteness(int val) = 0;


    virtual int startVideo() = 0;
    virtual int stopVideo() = 0;

    virtual void viewResized(int w, int h) = 0;
    virtual void viewMoved(int x, int y);

    virtual int setVideoDesktop(bool on) = 0;

protected:
    QStringList _devices;
    QMap<QString, QStringList> _sources;
    QMap<QString, bool> _tuners;
    QString _device, _source;
    QWidget *_widget;
    bool _isVideoDesktop, _isTuner;

private:
    QVSourcePluginPrivate *d;
};

#endif

