#ifndef _SAF_DEMUXER_H
#define _SAF_DEMUXER_H

#include <gpac/m4_network.h>

typedef struct {
	u8 objectTypeIndication;
	u8 streamType;
	u16 bufferSizeDB;
	u32 decSpecificInfo_length;
	unsigned char *decSpecificInfo_data;
} simple_decoder_config_descriptor;

typedef struct stream_info {
	LPNETCHANNEL channel;
	s32 es_id;
	s32 status;
} SAFStreamInfo;

typedef struct _saf_demuxer_t {

	/*the service we're responsible for*/
	LPNETSERVICE service;

	FILE *stream;
	BitStream *bs;

	SAFStreamInfo laser_info;
	SAFStreamInfo od_info;
	Chain *stream_infos;

	/*demuxer thread - we cannot use direct fetching because of demultiplex structure of libavformat
	(reading one channel may lock the other)*/
	M4Thread *thread;
	M4Mutex *mx;

	Double seek_time;
	u32 is_paused, is_running;

} SAFDemux;


void *NewSAFDemuxer();
void DeleteSAFDemuxer(void *ifce);


u32 SAF_Run(void *par);

#endif