/****************************************************************************** *_Copyright (c) 2009 Digital Stream Technology Inc. All Rights Reserved. * * Module: pd_dmx.h * * Description * Pseudo Driver for Demux * * @author Junku Park (hwatk@dstreamtech.com) * @version $Revision: 1.1 $ * ******************************************************************************/ #ifndef __PD_DMX_H__ #define __PD_DMX_H__ #define STREAM_BITRATE_MIN 13000000 #define STREAM_BITRATE_MAX 40000000 #define STREAM_BITRATE_DEF 19392000 // // Stream file bitrate min/max. // If incoming stream file has wrong PCR stamp, in that case we will // #if 0 typedef struct tag_PESInfo_t { DS_U32 i_flags; DS_S64 i_pts; DS_S64 i_dts; } PESInfo_t; #endif typedef enum { MPEG2_VIDEO_STREAM, SUBTITLE_STREAM, AC3_AUDIO_STREAM, MPEG2_AUDIO_STREAM, MPEG1_AUDIO_STREAM, PCM_AUDIO_STREAM, } PES_TYPE; #define MAX_FILTER_SIZE 16 enum stream_query_e { /* capabilities */ STREAM_CAN_SEEK, /**< arg1= bool * res=cannot fail*/ STREAM_CAN_FASTSEEK, /**< arg1= bool * res=cannot fail*/ /* */ STREAM_SET_POSITION, /**< arg1= int64_t res=can fail */ STREAM_GET_POSITION, /**< arg1= int64_t * res=cannot fail*/ STREAM_GET_SIZE, /**< arg1= int64_t * res=cannot fail (0 if no sense)*/ STREAM_GET_MTU, /**< arg1= int * res=cannot fail (0 if no sense)*/ /* Special for direct access control from demuxer. * XXX: avoid using it by all means */ STREAM_CONTROL_ACCESS, /* arg1= int i_access_query, args res: can fail if access unreachable or access control answer */ STREAM_GET_CONTENT_TYPE, /**< arg1= char ** res=can file */ }; enum demux_query_e { /* I. Common queries to access_demux and demux */ /* POSITION double between 0.0 and 1.0 */ DEMUX_GET_POSITION, /* arg1= double * res= */ DEMUX_SET_POSITION, /* arg1= double res=can fail */ /* LENGTH/TIME in microsecond, 0 if unknown */ DEMUX_GET_LENGTH, /* arg1= int64_t * res= */ DEMUX_GET_TIME, /* arg1= int64_t * res= */ DEMUX_SET_TIME, /* arg1= int64_t res=can fail */ /* TITLE_INFO only if more than 1 title or 1 chapter */ DEMUX_GET_TITLE_INFO, /* arg1=input_title_t*** arg2=int* arg3=int*pi_title_offset(0), arg4=int*pi_seekpoint_offset(0) can fail */ /* TITLE/SEEKPOINT, only when TITLE_INFO succeed */ DEMUX_SET_TITLE, /* arg1= int can fail */ DEMUX_SET_SEEKPOINT, /* arg1= int can fail */ /* DEMUX_SET_GROUP only a hit for demuxer (mainly DVB) to allow not * reading everything (you should not use this to call es_out_Control) * if you don't know what to do with it, just IGNORE it, it is safe(r) * -1 means all group, 0 default group (first es added) */ DEMUX_SET_GROUP, /* arg1= int can fail */ /* Ask the demux to demux until the given date at the next pf_demux call * but not more (and not less, at the precision available of course). * XXX: not mandatory (except for subtitle demux) but I will help a lot */ DEMUX_SET_NEXT_DEMUX_TIME, /* arg1= int64_t * can fail */ /* FPS for correct subtitles handling */ DEMUX_GET_FPS, /* arg1= double * res=can fail */ /* Meta data */ DEMUX_GET_META, /* arg1= vlc_meta_t ** res=can fail */ DEMUX_HAS_UNSUPPORTED_META, /* arg1= bool * res can fail */ /* Attachments */ DEMUX_GET_ATTACHMENTS, /* arg1=input_attachment_t***, int* res=can fail */ /* II. Specific access_demux queries */ DEMUX_CAN_PAUSE, /* arg1= bool* can fail (assume false)*/ DEMUX_SET_PAUSE_STATE, /* arg1= bool can fail */ DEMUX_GET_PTS_DELAY, /* arg1= int64_t* cannot fail */ /* DEMUX_CAN_CONTROL_PACE returns true (*pb_pace) if we can read the * data at our pace */ DEMUX_CAN_CONTROL_PACE, /* arg1= bool*pb_pace can fail (assume false) */ /* DEMUX_CAN_CONTROL_RATE is called only if DEMUX_CAN_CONTROL_PACE has returned false. * *pb_rate should be true when the rate can be changed (using DEMUX_SET_RATE) * *pb_ts_rescale should be true when the timestamps (pts/dts/pcr) have to be rescaled */ DEMUX_CAN_CONTROL_RATE, /* arg1= bool*pb_rate arg2= bool*pb_ts_rescale can fail(assume false) */ /* DEMUX_SET_RATE is called only if DEMUX_CAN_CONTROL_RATE has returned true. * It should return the value really used in *pi_rate */ DEMUX_SET_RATE, /* arg1= int*pi_rate can fail */ DEMUX_CAN_SEEK, /* arg1= bool* can fail (assume false)*/ }; enum pd_demux_error_t { PD_DMX_SUCCESS, PD_DMX_EGENERIC, PD_DMX_ECORE, PD_DMX_EOUTOFMEMORY, PD_DMX_ETIMEOUT, }; typedef struct tag_PD_SECFILTER { struct tag_PD_SECFILTER* pNext; int i_pid; int i_section_size; DS_U8 FilterBytes[MAX_FILTER_SIZE]; DS_U8 FilterMask[MAX_FILTER_SIZE]; int i_filter_size; DS_BOOL bOneShot; DS_BOOL bEnable; } PD_SECFILTER; #define PD_DMX_OK(r) ((r)==PD_DMX_SUCCESS) #define TS_PACKET_SIZE_188 188 #define TS_PACKET_SIZE_192 192 #define TS_PACKET_SIZE_196 196 #define TS_PACKET_SIZE_204 204 #define TS_PACKET_SIZE_MAX 204 #define TS_TOPFIELD_HEADER 1320 typedef void (*PD_DMX_PID_CALLBACK)(int Pid, DS_U8 *pPidData, int Size, void *p_info); typedef void (*PD_DMX_SEC_CALLBACK)(PD_SECFILTER *p_sec, DS_U8 *pSecData, int Size); #ifdef __cplusplus extern "C" { #endif int PD_DMX_OpenDemux(void); int PD_DMX_SetDemuxFile(const char *Pathname, DS_BOOL bContiPlay); int PD_DMX_StartDemux(void); int PD_DMX_StopDemux(void); int PD_DMX_CloseDemux(void); int PD_DMX_EnableDelay(int En); int PD_DMX_SetPidFilterCallback(PD_DMX_PID_CALLBACK CbFunc); int PD_DMX_SetSectionFilterCallback(PD_DMX_SEC_CALLBACK CbFunc, DS_U32 Argument); int PD_DMX_CreatePIDFilter(int Pid, DS_U8 streamType, DS_BOOL bOneShot); int PD_DMX_DeletePIDFilter(int Pid); PD_SECFILTER *PD_DMX_CreateSectionFilter(int Pid, DS_U8* FilterBytes, DS_U8* FilterMasks, int FilterSiz, int SectionSize, int bOneShot); int PD_DMX_EnableSectionFilter( PD_SECFILTER* p_sec, DS_BOOL bEnable); int PD_DMX_DeleteSectionFilter( PD_SECFILTER* p_sec ); #ifdef __cplusplus } #endif #endif /* __PD_DMX_H__ */