//////////////////////////////////////////////////////////////////////////////
//
// Asura_PS2_Mpeg.h
//
// Created by Morgan Parry.
//
// Mostly copyright (c) 2002 Sony Computer Entertainment Europe.
// Portions copyright (c) 2002 Rebellion. All rights reserved.
//
//////////////////////////////////////////////////////////////////////////////

// B E G I N   F I L E   W R A P P E R ///////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif

#ifndef ___ASURA_PS2_MPEG_H___
#define ___ASURA_PS2_MPEG_H___ 1

// M A C R O S ///////////////////////////////////////////////////////////////

// (MP - 20.09.2002) Quick hack so I can check stuff in while I'm away...
#define ASURA_PS2_USE_NEW_FMV_STUFF (0)

#if ASURA_PS2_USE_NEW_FMV_STUFF

// F O R W A R D   D E C L A R A T I O N S ///////////////////////////////////

union Asura_PS2_QW;

// T Y P E S /////////////////////////////////////////////////////////////////

enum ASURA_PS2_MPEG_MULTIPLEXTYPE
{
    ASURA_PS2_MPEG_MULTIPLEXTYPE_NONE,
    ASURA_PS2_MPEG_MULTIPLEXTYPE_PSS,
};

enum ASURA_PS2_MPEG_VIDEOTYPE
{
    ASURA_PS2_MPEG_VIDEOTYPE_IPU_STANDARD,
    ASURA_PS2_MPEG_VIDEOTYPE_IPU_COLUMNS,
    ASURA_PS2_MPEG_VIDEOTYPE_M2V_CSCIPU,
};

enum ASURA_PS2_MPEG_AUDIOTYPE
{
    ASURA_PS2_MPEG_AUDIOTYPE_NONE,
    ASURA_PS2_MPEG_AUDIOTYPE_PCM,
    ASURA_PS2_MPEG_AUDIOTYPE_ADPCM,
    ASURA_PS2_MPEG_AUDIOTYPE_SPDIF,
};

// C O N S T A N T S /////////////////////////////////////////////////////////

static const u_int ASURA_PS2_MPEG_MAX_CONCURRENT_STREAMS = 1;

// This is the maximum that the file loading callback will be asked to read
// per call.
static const u_int ASURA_PS2_MPEG_READCHUNKSIZE = 16384;

// P R O T O T Y P E S   A N D   I N L I N E   F U N C T I O N S /////////////

class Asura_PS2_MpegSystem
{
public:
	// C L A S S   M E T H O D S /////////////////////////////////////////

	static void	 Initialise( void );
	static void  Shutdown( void );

	static bool  Bind( int iHandle );
	static int	 Create( ASURA_PS2_MPEG_MULTIPLEXTYPE eMultiplexType,
						 ASURA_PS2_MPEG_VIDEOTYPE eVideoType,
						 ASURA_PS2_MPEG_AUDIOTYPE eAudioType,
						 int audioChannel,
						 void (*pfnFileInitCallback)( int ),
						 int (*pfnFileLoadCallback)( u_char*, int, int ),
						 int iFileCallbackParam,
						 void (*pfnIdleCallback)( void ),
						 bool bDoubleBuffer );
	static void  Destroy( int iHandle );
	static u_int GetVideo( u_int uDestBfrBase );
	static void	 GetAudio( u_int (*pfnReceiver)( u_char *, u_int, u_int, u_int, int ), int iParam );
	static void	 GetTex0( u_long *pulTex0, u_int uTBP );
	static bool  IsFinished( void );
	static void  PrepareNextFrame( void );
	static void  Recharge( void );
	static void  Rewind( void );
};
// End class Asura_PS2_MpegSystem.

class Asura_PS2_StreamingMpegSystem
{

    public:

        // C L A S S   M E T H O D S /////////////////////////////////////////

        static int Create( int iTextureIdx );
        static void Destroy( int iHandle );
        static int GetTextureIdxForHandle( int iHandle );

    private:

        // F R I E N D S /////////////////////////////////////////////////////

        friend class Asura_PS2_MpegSystem;

        // C L A S S   M E T H O D S /////////////////////////////////////////

        // These are taken care of by Asura_PS2_MpegSystem.
        static void Initialise( void );
        static void Shutdown( void );

};
// End class Asura_PS2_StreamingMpegSystem.

#endif // ASURA_PS2_USE_NEW_FMV_STUFF

// E N D   F I L E   W R A P P E R ///////////////////////////////////////////

#endif // #ifndef ___ASURA_PS2_MPEG_H___

