| [2] | 1 | /****************************************************************************** |
|---|
| 2 | *_Copyright (c) 2009 Digital Stream Technology Inc. All Rights Reserved. |
|---|
| 3 | * |
|---|
| 4 | * Module: pd_dmx.h |
|---|
| 5 | * |
|---|
| 6 | * Description |
|---|
| 7 | * Pseudo Driver for Demux |
|---|
| 8 | * |
|---|
| 9 | * @author Junku Park (hwatk@dstreamtech.com) |
|---|
| 10 | * @version $Revision: 1.1 $ |
|---|
| 11 | * |
|---|
| 12 | ******************************************************************************/ |
|---|
| 13 | |
|---|
| 14 | #ifndef __PD_DMX_H__ |
|---|
| 15 | #define __PD_DMX_H__ |
|---|
| 16 | |
|---|
| 17 | #define STREAM_BITRATE_MIN 13000000 |
|---|
| 18 | #define STREAM_BITRATE_MAX 40000000 |
|---|
| 19 | #define STREAM_BITRATE_DEF 19392000 |
|---|
| 20 | // |
|---|
| 21 | // Stream file bitrate min/max. |
|---|
| 22 | // If incoming stream file has wrong PCR stamp, in that case we will |
|---|
| 23 | // |
|---|
| 24 | #if 0 |
|---|
| 25 | typedef struct tag_PESInfo_t { |
|---|
| 26 | DS_U32 i_flags; |
|---|
| 27 | DS_S64 i_pts; |
|---|
| 28 | DS_S64 i_dts; |
|---|
| 29 | } PESInfo_t; |
|---|
| 30 | #endif |
|---|
| 31 | |
|---|
| 32 | typedef enum |
|---|
| 33 | { |
|---|
| 34 | MPEG2_VIDEO_STREAM, |
|---|
| 35 | |
|---|
| 36 | SUBTITLE_STREAM, |
|---|
| 37 | |
|---|
| 38 | AC3_AUDIO_STREAM, |
|---|
| 39 | MPEG2_AUDIO_STREAM, |
|---|
| 40 | MPEG1_AUDIO_STREAM, |
|---|
| 41 | PCM_AUDIO_STREAM, |
|---|
| 42 | } PES_TYPE; |
|---|
| 43 | |
|---|
| 44 | #define MAX_FILTER_SIZE 16 |
|---|
| 45 | |
|---|
| 46 | enum stream_query_e |
|---|
| 47 | { |
|---|
| 48 | /* capabilities */ |
|---|
| 49 | STREAM_CAN_SEEK, /**< arg1= bool * res=cannot fail*/ |
|---|
| 50 | STREAM_CAN_FASTSEEK, /**< arg1= bool * res=cannot fail*/ |
|---|
| 51 | |
|---|
| 52 | /* */ |
|---|
| 53 | STREAM_SET_POSITION, /**< arg1= int64_t res=can fail */ |
|---|
| 54 | STREAM_GET_POSITION, /**< arg1= int64_t * res=cannot fail*/ |
|---|
| 55 | |
|---|
| 56 | STREAM_GET_SIZE, /**< arg1= int64_t * res=cannot fail (0 if no sense)*/ |
|---|
| 57 | |
|---|
| 58 | STREAM_GET_MTU, /**< arg1= int * res=cannot fail (0 if no sense)*/ |
|---|
| 59 | |
|---|
| 60 | /* Special for direct access control from demuxer. |
|---|
| 61 | * XXX: avoid using it by all means */ |
|---|
| 62 | STREAM_CONTROL_ACCESS, /* arg1= int i_access_query, args res: can fail |
|---|
| 63 | if access unreachable or access control answer */ |
|---|
| 64 | |
|---|
| 65 | STREAM_GET_CONTENT_TYPE, /**< arg1= char ** res=can file */ |
|---|
| 66 | }; |
|---|
| 67 | |
|---|
| 68 | enum demux_query_e |
|---|
| 69 | { |
|---|
| 70 | /* I. Common queries to access_demux and demux */ |
|---|
| 71 | /* POSITION double between 0.0 and 1.0 */ |
|---|
| 72 | DEMUX_GET_POSITION, /* arg1= double * res= */ |
|---|
| 73 | DEMUX_SET_POSITION, /* arg1= double res=can fail */ |
|---|
| 74 | |
|---|
| 75 | /* LENGTH/TIME in microsecond, 0 if unknown */ |
|---|
| 76 | DEMUX_GET_LENGTH, /* arg1= int64_t * res= */ |
|---|
| 77 | DEMUX_GET_TIME, /* arg1= int64_t * res= */ |
|---|
| 78 | DEMUX_SET_TIME, /* arg1= int64_t res=can fail */ |
|---|
| 79 | |
|---|
| 80 | /* TITLE_INFO only if more than 1 title or 1 chapter */ |
|---|
| 81 | DEMUX_GET_TITLE_INFO, /* arg1=input_title_t*** arg2=int* |
|---|
| 82 | arg3=int*pi_title_offset(0), arg4=int*pi_seekpoint_offset(0) can fail */ |
|---|
| 83 | /* TITLE/SEEKPOINT, only when TITLE_INFO succeed */ |
|---|
| 84 | DEMUX_SET_TITLE, /* arg1= int can fail */ |
|---|
| 85 | DEMUX_SET_SEEKPOINT, /* arg1= int can fail */ |
|---|
| 86 | |
|---|
| 87 | /* DEMUX_SET_GROUP only a hit for demuxer (mainly DVB) to allow not |
|---|
| 88 | * reading everything (you should not use this to call es_out_Control) |
|---|
| 89 | * if you don't know what to do with it, just IGNORE it, it is safe(r) |
|---|
| 90 | * -1 means all group, 0 default group (first es added) */ |
|---|
| 91 | DEMUX_SET_GROUP, /* arg1= int can fail */ |
|---|
| 92 | |
|---|
| 93 | /* Ask the demux to demux until the given date at the next pf_demux call |
|---|
| 94 | * but not more (and not less, at the precision available of course). |
|---|
| 95 | * XXX: not mandatory (except for subtitle demux) but I will help a lot */ |
|---|
| 96 | DEMUX_SET_NEXT_DEMUX_TIME, /* arg1= int64_t * can fail */ |
|---|
| 97 | /* FPS for correct subtitles handling */ |
|---|
| 98 | DEMUX_GET_FPS, /* arg1= double * res=can fail */ |
|---|
| 99 | |
|---|
| 100 | /* Meta data */ |
|---|
| 101 | DEMUX_GET_META, /* arg1= vlc_meta_t ** res=can fail */ |
|---|
| 102 | DEMUX_HAS_UNSUPPORTED_META, /* arg1= bool * res can fail */ |
|---|
| 103 | |
|---|
| 104 | /* Attachments */ |
|---|
| 105 | DEMUX_GET_ATTACHMENTS, /* arg1=input_attachment_t***, int* res=can fail */ |
|---|
| 106 | |
|---|
| 107 | /* II. Specific access_demux queries */ |
|---|
| 108 | DEMUX_CAN_PAUSE, /* arg1= bool* can fail (assume false)*/ |
|---|
| 109 | DEMUX_SET_PAUSE_STATE, /* arg1= bool can fail */ |
|---|
| 110 | |
|---|
| 111 | DEMUX_GET_PTS_DELAY, /* arg1= int64_t* cannot fail */ |
|---|
| 112 | |
|---|
| 113 | /* DEMUX_CAN_CONTROL_PACE returns true (*pb_pace) if we can read the |
|---|
| 114 | * data at our pace */ |
|---|
| 115 | DEMUX_CAN_CONTROL_PACE, /* arg1= bool*pb_pace can fail (assume false) */ |
|---|
| 116 | /* DEMUX_CAN_CONTROL_RATE is called only if DEMUX_CAN_CONTROL_PACE has returned false. |
|---|
| 117 | * *pb_rate should be true when the rate can be changed (using DEMUX_SET_RATE) |
|---|
| 118 | * *pb_ts_rescale should be true when the timestamps (pts/dts/pcr) have to be rescaled */ |
|---|
| 119 | DEMUX_CAN_CONTROL_RATE, /* arg1= bool*pb_rate arg2= bool*pb_ts_rescale can fail(assume false) */ |
|---|
| 120 | /* DEMUX_SET_RATE is called only if DEMUX_CAN_CONTROL_RATE has returned true. |
|---|
| 121 | * It should return the value really used in *pi_rate */ |
|---|
| 122 | DEMUX_SET_RATE, /* arg1= int*pi_rate can fail */ |
|---|
| 123 | |
|---|
| 124 | DEMUX_CAN_SEEK, /* arg1= bool* can fail (assume false)*/ |
|---|
| 125 | }; |
|---|
| 126 | |
|---|
| 127 | enum pd_demux_error_t |
|---|
| 128 | { |
|---|
| 129 | PD_DMX_SUCCESS, |
|---|
| 130 | PD_DMX_EGENERIC, |
|---|
| 131 | PD_DMX_ECORE, |
|---|
| 132 | PD_DMX_EOUTOFMEMORY, |
|---|
| 133 | PD_DMX_ETIMEOUT, |
|---|
| 134 | }; |
|---|
| 135 | |
|---|
| 136 | typedef struct tag_PD_SECFILTER |
|---|
| 137 | { |
|---|
| 138 | struct tag_PD_SECFILTER* pNext; |
|---|
| 139 | |
|---|
| 140 | int i_pid; |
|---|
| 141 | int i_section_size; |
|---|
| 142 | |
|---|
| 143 | DS_U8 FilterBytes[MAX_FILTER_SIZE]; |
|---|
| 144 | DS_U8 FilterMask[MAX_FILTER_SIZE]; |
|---|
| 145 | int i_filter_size; |
|---|
| 146 | |
|---|
| 147 | DS_BOOL bOneShot; |
|---|
| 148 | DS_BOOL bEnable; |
|---|
| 149 | } PD_SECFILTER; |
|---|
| 150 | |
|---|
| 151 | |
|---|
| 152 | #define PD_DMX_OK(r) ((r)==PD_DMX_SUCCESS) |
|---|
| 153 | |
|---|
| 154 | #define TS_PACKET_SIZE_188 188 |
|---|
| 155 | #define TS_PACKET_SIZE_192 192 |
|---|
| 156 | #define TS_PACKET_SIZE_196 196 |
|---|
| 157 | #define TS_PACKET_SIZE_204 204 |
|---|
| 158 | #define TS_PACKET_SIZE_MAX 204 |
|---|
| 159 | #define TS_TOPFIELD_HEADER 1320 |
|---|
| 160 | |
|---|
| 161 | typedef void (*PD_DMX_PID_CALLBACK)(int Pid, DS_U8 *pPidData, int Size, void *p_info); |
|---|
| 162 | typedef void (*PD_DMX_SEC_CALLBACK)(PD_SECFILTER *p_sec, DS_U8 *pSecData, int Size); |
|---|
| 163 | |
|---|
| 164 | #ifdef __cplusplus |
|---|
| 165 | extern "C" { |
|---|
| 166 | #endif |
|---|
| 167 | |
|---|
| 168 | int PD_DMX_OpenDemux(void); |
|---|
| 169 | int PD_DMX_SetDemuxFile(const char *Pathname, DS_BOOL bContiPlay); |
|---|
| 170 | int PD_DMX_StartDemux(void); |
|---|
| 171 | int PD_DMX_StopDemux(void); |
|---|
| 172 | int PD_DMX_CloseDemux(void); |
|---|
| 173 | int PD_DMX_EnableDelay(int En); |
|---|
| 174 | |
|---|
| 175 | int PD_DMX_SetPidFilterCallback(PD_DMX_PID_CALLBACK CbFunc); |
|---|
| 176 | int PD_DMX_SetSectionFilterCallback(PD_DMX_SEC_CALLBACK CbFunc, DS_U32 Argument); |
|---|
| 177 | int PD_DMX_CreatePIDFilter(int Pid, DS_U8 streamType, DS_BOOL bOneShot); |
|---|
| 178 | int PD_DMX_DeletePIDFilter(int Pid); |
|---|
| 179 | PD_SECFILTER *PD_DMX_CreateSectionFilter(int Pid, DS_U8* FilterBytes, DS_U8* FilterMasks, |
|---|
| 180 | int FilterSiz, int SectionSize, int bOneShot); |
|---|
| 181 | int PD_DMX_EnableSectionFilter( PD_SECFILTER* p_sec, DS_BOOL bEnable); |
|---|
| 182 | int PD_DMX_DeleteSectionFilter( PD_SECFILTER* p_sec ); |
|---|
| 183 | |
|---|
| 184 | #ifdef __cplusplus |
|---|
| 185 | } |
|---|
| 186 | #endif |
|---|
| 187 | |
|---|
| 188 | |
|---|
| 189 | #endif /* __PD_DMX_H__ */ |
|---|