#ifndef TN_RA_H
#define TN_RA_H

#include <exec/exec.h>
#include <dos/dos.h>

#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/utility.h>
#include <proto/asyncio.h>

#include <libraries/tnplug.h>
#include <proto/tnplug.h>

struct TNPluginBase;

#include "common.h"
#include "debug.h"

struct TNPlugBase {
	struct Library tnpb_LibNode;
	BPTR tnpb_SegList;
};

struct TNDecHandle {
	APTR inHandle;
	LONG (*ReadFunc)(APTR,APTR,LONG);
	unsigned char *in, *deint;
	unsigned int codec;
	unsigned int freq, chans, packets;
	unsigned int blockSize, chunkSize;
	unsigned short streamid, rmf;
	void *Real;
};

/* announceplayer.c */
struct audio_player *TNPlug_AnnouncePlayer (struct TNPlugIFace *Self, uint32 version);

/* initplayer.c */
BOOL TNPlug_InitPlayer (struct TNPlugIFace *Self, struct TuneNet *inTuneNet, uint32 playmode);
void TNPlug_ExitPlayer (struct TNPlugIFace *Self, struct audio_player *aplayer);

/* openplayer.c */
int32 TNPlug_TestPlayer (struct TNPlugIFace *Self, uint8 *testme, uint8 *testbuffer,
	uint32 totalsize, uint32 testsize);
BOOL TNPlug_OpenPlayer (struct TNPlugIFace *Self, uint8 *openme, struct TuneNet *inTuneNet);
void TNPlug_ClosePlayer (struct TNPlugIFace *Self, struct TuneNet *inTuneNet);

/* decodeframeplayer.c */
int32 TNPlug_DecodeFramePlayer (struct TNPlugIFace *Self, struct TuneNet *inTuneNet,
	int16 *outbuffer);
int32 TNPlug_SeekPlayer (struct TNPlugIFace *Self, struct TuneNet *inTuneNet, uint32 seconds);

/* donotify.c */
uint32 TNPlug_DoNotify (struct TNPlugIFace *Self, struct TuneNet *inTuneNet, uint32 item,
	uint32 value);

/* raplay.c */
int ReadHeader(APTR inHandle, LONG (*ReadFunc)(APTR,APTR,LONG), unsigned char *buf,
	unsigned int *freq, unsigned int *chans, unsigned int *blocksize, unsigned int *packets,
	unsigned short *streamid, unsigned short *rmf);
LONG ReadPackets(APTR inHandle, LONG (*ReadFunc)(APTR,APTR,LONG), unsigned char *buf,
	unsigned int chunksize, unsigned int *packets, unsigned short *streamid,
	unsigned short *rmf);

#endif
