#ifndef AVIFILE_AUDIODECODER_H
#define AVIFILE_AUDIODECODER_H

/********************************************************
 *
 * Audio decoder abstract class.
 *
 * Performs decompression of data from
 * various audio formats into raw PCM
 *
 ********************************************************/

#include <formats.h>
#include <infotypes.h>
#include <utils.h>

class IAudioDecoder
{
protected:
    WAVEFORMATEX in_fmt;
    const CodecInfo& record;
public:
    IAudioDecoder(const CodecInfo& info, const WAVEFORMATEX* in);
    virtual ~IAudioDecoder() {}
    /**
     * Minimal required output buffer size. Calls to Convert() will
     * fail if you pass smaller output buffer to it.
     */
    virtual size_t GetMinSize() { return 2; }
    /**
     * Returns output format for this audio decoder.
     */
    virtual int GetOutputFormat(WAVEFORMATEX* destfmt);
    /**
     * Estimates the amount ( in bytes ) of input data that's
     * required to produce specified amount of decompressed PCM data.
     */
    virtual int GetSrcSize(int dest_size) { return dest_size; }
    /**
     * Decodes data. It is guaranteed that either size_read or size_written
     * will receive nonzero value if out_size>=GetMinSize().
     */
    virtual int Convert(const void* in_data, size_t in_size,
			void* out_data, size_t out_size,
			size_t* size_read, size_t* size_written)	= 0;

    virtual const CodecInfo& GetCodecInfo() const { return record; }
};

#endif // AVIFILE_AUDIODECODER_H
