/*
   (c) Copyright 2004  convergence GmbH

   All rights reserved.

   Written by Michael Hunold <hunold@convergence.de> and
              Denis Oliver Kropp <dok@directfb.org>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the
   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
*/

#ifndef __SOFTMPEG_H__
#define __SOFTMPEG_H__

#include <unistd.h>
#include <directfb.h>

#ifdef __cplusplus
extern "C"
{
#endif

struct softmpeg_decoder;

enum softmpeg_video_output {
	SOFTMPEG_DIRECTFB
	/* SOFTMPEG_XV */	
};

struct softmpeg_directfb_initdata {
	DFBWindowID		window_id;
	DFBDisplayLayerID	layer_id;	/* only used if window_id == -1 */
	unsigned int 		width;		/* only used if window_id == -1 */
	unsigned int 		height;		/* only used if window_id == -1 */
};

enum softmpeg_audio_output {
	SOFTMPEG_FUSIONSOUND
	/* SOFTMPEG_ALSA */	
};

struct softmpeg_callbacks
{
	void (*resize)	(void *priv, int width, int height, float aspect_ratio);
	void (*data)	(void *priv, unsigned char *buf, ssize_t count);
};

struct softmpeg_decoder *softmpeg_decoder_create(void *priv, struct softmpeg_callbacks *cbs,
	enum softmpeg_video_output vo, void *v_init_data,
	enum softmpeg_audio_output ao, void *a_init_data);

struct softmpeg_decoder *softmpeg_get_current_softmpeg_context(void);

int softmpeg_decoder_destroy(struct softmpeg_decoder *d);

int softmpeg_decoder_set_av_sync(struct softmpeg_decoder *d, int enable);

int softmpeg_decoder_process_pes_data(struct softmpeg_decoder *d, unsigned char *buf, ssize_t count);
int softmpeg_decoder_process_ts_data(struct softmpeg_decoder *d, unsigned char *buf, ssize_t count);

int softmpeg_decoder_stop(struct softmpeg_decoder *d);
int softmpeg_decoder_set_pids(struct softmpeg_decoder *, unsigned int vpid, unsigned int apid, unsigned int pcrpid, int fd);
int softmpeg_decoder_audio_pid_change(struct softmpeg_decoder *d, unsigned int apid);
int softmpeg_decoder_polling_thread_create(struct softmpeg_decoder *d, int fd);

enum softmpeg_mode {
	SOFTMPEG_BACKWARD,	/* backward play with speed arg */
	SOFTMPEG_REVERSE,	/* backward play with original speed (arg ignored) */
	SOFTMPEG_PAUSE,		/* playback paused (arg ignored) */
	SOFTMPEG_SKIP,		/* skip arg seconds in any direction if possible */
	SOFTMPEG_PLAY,		/* playback with original speed (arg ignored) */
	SOFTMPEG_FORWARD	/* playback with speed arg */
};

enum softmpeg_mode softmpeg_decoder_set_mode(struct softmpeg_decoder *d, enum softmpeg_mode, float arg);

#ifdef __cplusplus
}
#endif

#endif
