#ifndef AVIFILE_INFOTYPES_H
#define AVIFILE_INFOTYPES_H

#include <default.h>
#include <formats.h>
#include <com.h>

#include <vector>
#include <string>

/**
 * Describes the attibute of encoder or decoder.
 */
struct AttributeInfo
{

    std::string name;  // short attribute name ( unique within CodecInfo struct )
    std::string about; // human-readable description
    /**
     * 'Integer' - attribute is an integer, either limited by i_min and i_max,
     * in which case i_min<i_max, or unlimited.
     * 'String' - attribute can have any string value, such as registration code.
     * 'Select' - value can have one of several string values from 'options'.
     */
    enum Kind { Integer, String, Select };
    Kind kind;
    std::vector<std::string> options;
    int i_min, i_max;

    AttributeInfo();
    ~AttributeInfo();
    /* Constructors for unlimited integer attributes */
    AttributeInfo(const char* n);
    AttributeInfo(const std::string n);
    /* Constructor for select-type attribute */
    AttributeInfo(const char* n, const char* a, const char** o);
    /* Generic constructor */
    AttributeInfo(const char* n, const char* a, Kind k, int minval=0, int maxval=-1);
};

/**
 * Structure describes video codec, registered in the system.
 */
struct CodecInfo
{
//
// Fields that loader expects to be filled by plugin
//
    fourcc_t fourcc;		// default fourcc for this codec.
    std::string text;		// short unique codec name.
    std::string about;		// codec description.
//
// All fourcc's that should be handled with this codec.
//
    std::vector<fourcc_t> fourcc_array;

    enum Kind
    {
	Source = 0, Plugin, Win32, DShow_Dec, DShow_Enc, Custom=0xFFFFFFFF
    };
    enum Media { Audio, Video };
    enum Direction { Encode = 1, Decode, Both };
//
// Source - structure describes codec that is implemented as a part of library.
// All other values in this field are ignored by the library and can be used within
// plugins.
//
    Kind kind;
    Media media;
    Direction direction;

    std::vector<AttributeInfo> decoder_info; // acceptable attrs for decoder.
    std::vector<AttributeInfo> encoder_info; // acceptable attrs for encoder.

//
// These two fields will be filled by plugin loader.
//
    std::string modulename;
    void* handle;
//
// These fields contain custom data that may be needed by plugin.
// They will be ignored by loader.
//
    GUID guid;		// CLSID ( only needed by DirectShow codecs ).
    std::string dll;	// Win32 DLL name ( only needed by Win32 DLL codecs ).

    CodecInfo();
    ~CodecInfo();
    CodecInfo(const int* array, const char* info, const char* path,
	      const char* a, Kind _kind, Media _media = Video,
	      Direction _direction = Both, const GUID* id = 0,
	      const std::vector<AttributeInfo>& ei = std::vector<AttributeInfo>(),
	      const std::vector<AttributeInfo>& di = std::vector<AttributeInfo>());
//
// Searches for codec matching given fourcc, returns NULL if there's no match.
//
    static const CodecInfo* match(unsigned long codec, Media media=Video, const CodecInfo* start=0);
};

struct VideoEncoderInfo
{
    int quality;
    int keyfreq;
    fourcc_t compressor;
    std::string cname;
    BITMAPINFOHEADER header;
};

extern std::vector<CodecInfo> video_codecs;
extern std::vector<CodecInfo> audio_codecs;

#endif // AVIFILE_INFOTYPES_H
