/**************************************************************************************
 *                                                                                    *
 * This application contains code from OpenDivX and is released as a "Larger Work"    *
 * under that license. Consistant with that license, this application is released     *
 * under the GNU General Public License.                                              *
 *                                                                                    *
 * The OpenDivX license can be found at: http://www.projectmayo.com/opendivx/docs.php *
 * The GPL can be found at: http://www.gnu.org/copyleft/gpl.html                      *
 *                                                                                    *
 * Copyright (c) 2001 - Project Mayo                                                  *
 *                                                                                    *
 * Authors: Damien Chavarria <adrc at projectmayo.com>                                *
 *                                                                                    *
 **************************************************************************************/


#ifndef INPUT_MEDIA_H
#define INPUT_MEDIA_H

/*
 * Includes
 */

#include <windows.h>
#include <stdio.h>

/*
 * Media source enum
 */

enum {

	INPUT_TYPE_FILE,
	INPUT_TYPE_HTTP,
};

/*
 * File mode enum
 */

enum {

	INPUT_OPEN_ASCII,
	INPUT_OPEN_BINARY
};

/*
 * Seek Enum
 */

enum {

	INPUT_SEEK_SET,
	INPUT_SEEK_CUR,
	INPUT_SEEK_END
};

/*
 * Input Class
 */

class InputMedia {

public:

	DWORD mode;

	HANDLE file;
	int filesize;
	/*
 	 * HTTP/FTP stuff 
	 */


	HANDLE    ioMutex;
	DWORD     lastReadPos;

	DWORD     currentBuffer;

	InputMedia(LPTSTR lpFilename, int mode, int type);
	~InputMedia();


	int Read(char *data, unsigned int size);
	int Seek(int   size, unsigned int method);

	int Close();
};

#endif
