| 1 | /****************************************************************************** |
|---|
| 2 | *_Copyright (c) 2009 Digital Stream Technology Inc. All Rights Reserved. |
|---|
| 3 | * |
|---|
| 4 | * Module: dsthaldtv.h |
|---|
| 5 | * |
|---|
| 6 | * Description |
|---|
| 7 | * DTV Interface Functions |
|---|
| 8 | * |
|---|
| 9 | * @author |
|---|
| 10 | * @version $Revision: 1.1 $ |
|---|
| 11 | * |
|---|
| 12 | ******************************************************************************/ |
|---|
| 13 | |
|---|
| 14 | #if !defined (_DSTHAL_DTV_H_) |
|---|
| 15 | #define _DSTHAL_DTV_H_ |
|---|
| 16 | |
|---|
| 17 | #include "dsthallocal.h" |
|---|
| 18 | #include "dstoslayer.h" |
|---|
| 19 | #include "dsthaldisp.h" |
|---|
| 20 | |
|---|
| 21 | typedef struct tag_PESInfo_t { |
|---|
| 22 | DS_U32 i_flags; |
|---|
| 23 | DS_S64 i_pts; |
|---|
| 24 | DS_S64 i_dts; |
|---|
| 25 | } PESInfo_t; |
|---|
| 26 | |
|---|
| 27 | typedef void (*DHL_DTV_PES_CALLBACK)(int Pid, DS_U8 *pPidData, int Size, PESInfo_t *p_info); |
|---|
| 28 | typedef void (DHL_VDC_CALLBACK)(DS_U32 CallerContext, void *Notification); |
|---|
| 29 | typedef DHL_VDC_CALLBACK * P_DHL_VDC_CALLBACK; |
|---|
| 30 | |
|---|
| 31 | /****************************************************************************** |
|---|
| 32 | * DHL AV Callback Type |
|---|
| 33 | ******************************************************************************/ |
|---|
| 34 | typedef enum |
|---|
| 35 | { |
|---|
| 36 | DHL_CB_VDC_SQH, //Sequence Header change to VDC set |
|---|
| 37 | DHL_CB_VDC_CCUDP, //CC user data parser to VDC set |
|---|
| 38 | DHL_CB_VDC_CCEDP, //CC extended data parser to VDC set |
|---|
| 39 | DHL_CB_VDC_DECODE_ERR, //Decoder Error Report(DoNotUse this enum type) |
|---|
| 40 | DHL_CB_NOTIFY_VSTARTING, //Notify about video starting state(FALSE-starting, TRUE-complete) |
|---|
| 41 | DHL_CB_NOTIFY_VSTOPPING, //Norify about video stopping state(FALSE-stopping, TRUE-complete) |
|---|
| 42 | DHL_CB_NOTIFY_DISPINITIALIZE, //Norify display initialization state(TRUE-complete) |
|---|
| 43 | DHL_CB_VDC_FATAL_ERROR, //Norify VDC FATAL ERROR |
|---|
| 44 | DHL_CB_END |
|---|
| 45 | } DHL_DTV_CBTYPE; |
|---|
| 46 | |
|---|
| 47 | /****************************************************************************** |
|---|
| 48 | * DHL Audio Stream Type |
|---|
| 49 | ******************************************************************************/ |
|---|
| 50 | typedef enum |
|---|
| 51 | { |
|---|
| 52 | DHL_STREAM_AUDIO_PCM = 0x00000400, |
|---|
| 53 | DHL_STREAM_AUDIO_AC3 = 0x00000100, |
|---|
| 54 | DHL_STREAM_AUDIO_MPEG2 = 0x00000200, |
|---|
| 55 | DHL_STREAM_AUDIO_AAC = 0x00000800, |
|---|
| 56 | DHL_STREAM_AUDIO_MPEG4 = 0x00001000, |
|---|
| 57 | DHL_STREAM_AUDIO_END |
|---|
| 58 | } DHL_AUD_STREAMTYPE; |
|---|
| 59 | |
|---|
| 60 | /****************************************************************************** |
|---|
| 61 | * DHL Digital Audio (SPDIF) Output Type |
|---|
| 62 | ******************************************************************************/ |
|---|
| 63 | typedef enum |
|---|
| 64 | { |
|---|
| 65 | DHL_STREAM_AUDOUT_PCM=1, |
|---|
| 66 | DHL_STREAM_AUDOUT_AC3 |
|---|
| 67 | } DHL_AUD_OUTPUT_FORMAT; |
|---|
| 68 | |
|---|
| 69 | /****************************************************************************** |
|---|
| 70 | * DHL DTV Program Information |
|---|
| 71 | ******************************************************************************/ |
|---|
| 72 | typedef struct tag_DHL_PRG_INFO |
|---|
| 73 | { |
|---|
| 74 | DS_U16 VidPID; //current video PID |
|---|
| 75 | DS_U16 AudPID; //current audio PID |
|---|
| 76 | DS_U16 PCRPID; //current PCR PID |
|---|
| 77 | DHL_AUD_STREAMTYPE AudStreamType; //current input audio stream type |
|---|
| 78 | } DHL_PRG_INFO, *P_DHL_PRG_INFO; |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | typedef struct tag_PES_FILTER |
|---|
| 82 | { |
|---|
| 83 | DS_U16 uPesPid; |
|---|
| 84 | DS_U32 Param; |
|---|
| 85 | DS_BOOL isValid; |
|---|
| 86 | } DHL_PESFILTER, *P_DST_PESFILTER; |
|---|
| 87 | |
|---|
| 88 | /****************************************************************************** |
|---|
| 89 | * MPEG Audio Information |
|---|
| 90 | ******************************************************************************/ |
|---|
| 91 | typedef struct tag_DHL_DTV_MPEG_STATUS |
|---|
| 92 | { |
|---|
| 93 | /* The following status fields are for MPEG mode. Please refer to MPEG |
|---|
| 94 | * Specification ISO/IEC 11172-3 for a detail explanation and the |
|---|
| 95 | * expected values. |
|---|
| 96 | */ |
|---|
| 97 | |
|---|
| 98 | DS_U32 MpegId; /* 1: ISO/IEC 11172-3; 0: reserved */ |
|---|
| 99 | DS_U32 MpegLayer; /* 1: Layer 3; 2: Layer 2; 3: Layer 1 */ |
|---|
| 100 | DS_U32 ProtectionBit; /* 0: CRC protected; 1: no CRC protected */ |
|---|
| 101 | DS_U32 BitRateIndex; /* Index to a bitrate table */ |
|---|
| 102 | DS_U32 SampleRate; /* 0: 44.1kHz; 1: 48kHz; 2: 32kHz; 3: reserved */ |
|---|
| 103 | DS_U32 PaddingBit; /* Indicates whether the frame contains an */ |
|---|
| 104 | /* extra slot to adjust the mean bitrate. */ |
|---|
| 105 | /* 0: no padding; 1: padding exists */ |
|---|
| 106 | DS_U32 PrivateBit; /* Reserved for non-ISO purpose */ |
|---|
| 107 | DS_U32 Mode; /* Indicates the audio configuration mode */ |
|---|
| 108 | DS_U32 ModeExtension; /* Indicates which subbands are in intensity */ |
|---|
| 109 | /* stereo */ |
|---|
| 110 | DS_U32 Copyright; /* 0:no copyright protected; */ |
|---|
| 111 | /* 1:copyright protected */ |
|---|
| 112 | DS_U32 Original; /* 0:bitstream is a copy; */ |
|---|
| 113 | /* 1:bitstream is an original */ |
|---|
| 114 | DS_U32 Emphasis; /* Indicates which type of de-emphasis is used */ |
|---|
| 115 | |
|---|
| 116 | } DHL_DTV_MPEG_STATUS, *P_DHL_DTV_MPEG_STATUS; |
|---|
| 117 | |
|---|
| 118 | /****************************************************************************** |
|---|
| 119 | * DTV AC3 Information |
|---|
| 120 | ******************************************************************************/ |
|---|
| 121 | typedef struct tag_DHL_DTV_AC3_STATUS |
|---|
| 122 | { |
|---|
| 123 | /* The following status fields are for AC3 mode. Please refer to AC-3 */ |
|---|
| 124 | /* ATSC document for a detail explanation and the expected values. */ |
|---|
| 125 | |
|---|
| 126 | DS_U32 Fscod; /* Indicates the current sample rate code: */ |
|---|
| 127 | /* 0: 48kHz; 1: 44.1kHz; 2: 32kHz; 3: reserved */ |
|---|
| 128 | DS_U32 Frmsizecod; /* Current frame size code */ |
|---|
| 129 | DS_U32 Lfeon; /* 0: Low frequency effects channel is off */ |
|---|
| 130 | /* 1: Low frequency effects channel is on */ |
|---|
| 131 | DS_U32 Acmod; /* Current audio coding mode */ |
|---|
| 132 | DS_U32 Bsid; /* Bit stream identification value 0-31 */ |
|---|
| 133 | DS_U32 Bsmod; /* Current bit stream mode */ |
|---|
| 134 | DS_U32 Cmixlev; /* Centre mixing level */ |
|---|
| 135 | DS_U32 Surmixlev; /* Surround mixing level */ |
|---|
| 136 | DS_U32 Dsurmod; /* Dolby surround mode */ |
|---|
| 137 | DS_U32 Copyright; /* Copyright bit value 0 or 1 */ |
|---|
| 138 | DS_U32 Original; /* Original bit stream 0 or 1 */ |
|---|
| 139 | DS_U32 Dialnorm1; /* Dialogue normalization word (CH1)value 0-31 */ |
|---|
| 140 | DS_U32 Dialnorm2; /* Dialogue normalization word (CH2) value 0-31 */ |
|---|
| 141 | DS_U32 Langcod1; /* Current language code (CH1) value 0-255 */ |
|---|
| 142 | DS_U32 Langcod2; /* Current language code (CH2) value 0-255 */ |
|---|
| 143 | DS_U32 Roomtype1; /* Room type (CH1) value 0-3 */ |
|---|
| 144 | DS_U32 Roomtype2; /* Room type (CH2) value 0-3 */ |
|---|
| 145 | DS_U32 Mixlevel1; /* Current mixing level (CH1) value 0-31 */ |
|---|
| 146 | DS_U32 Mixlevel2; /* Current mixing level (CH2) value 0-31 */ |
|---|
| 147 | |
|---|
| 148 | } DHL_DTV_AC3_STATUS, *P_DHL_DTV_AC3_STATUS; |
|---|
| 149 | |
|---|
| 150 | /****************************************************************************** |
|---|
| 151 | * DTV Video Source Information from Sequence Header |
|---|
| 152 | ******************************************************************************/ |
|---|
| 153 | typedef struct tag_DHL_DTV_SRCVID_INFO |
|---|
| 154 | { |
|---|
| 155 | DS_U32 uSrcW; |
|---|
| 156 | DS_U32 uSrcH; |
|---|
| 157 | DS_U32 uFrameRate; |
|---|
| 158 | DS_BOOL bInterlace; |
|---|
| 159 | DHL_DISP_ASPECTRATIO AspectRatio; |
|---|
| 160 | } DHL_DTV_SRCVID_INFO, *P_DHL_DTV_SRCVID_INFO; |
|---|
| 161 | |
|---|
| 162 | /****************************************************************************** |
|---|
| 163 | * DTV Configuration |
|---|
| 164 | ******************************************************************************/ |
|---|
| 165 | typedef struct tag_DHL_DTV_CONFIGURATION |
|---|
| 166 | { |
|---|
| 167 | OS_MUTEX_ID AVMutex; |
|---|
| 168 | DS_BOOL bScrambled; //Is this channel scrambled? |
|---|
| 169 | |
|---|
| 170 | P_DHL_VDC_CALLBACK VideoCbFunc[DHL_CB_END]; |
|---|
| 171 | DS_U32 VideoCbParam[DHL_CB_END]; |
|---|
| 172 | |
|---|
| 173 | DS_BOOL bVideoPlayReq; |
|---|
| 174 | DS_BOOL bAudioPlayReq; |
|---|
| 175 | DS_BOOL bVideoInPlay; |
|---|
| 176 | DS_BOOL bAudioInPlay; |
|---|
| 177 | |
|---|
| 178 | DS_BOOL isAVPaused; |
|---|
| 179 | |
|---|
| 180 | DHL_PRG_INFO PrgInfo; |
|---|
| 181 | } DHL_DTV_CONFIG, *P_DHL_DTV_CONFIG; |
|---|
| 182 | |
|---|
| 183 | /****************************************************************************** |
|---|
| 184 | * Audio Decoder Compression Mode (Specified in Dolby Specifiction.) |
|---|
| 185 | ******************************************************************************/ |
|---|
| 186 | typedef enum /* AC3 Compression mode */ |
|---|
| 187 | { |
|---|
| 188 | DHL_ADC_COMP_CUSTOM0 = 0, /* Custom mode 0 (Analog Dialnorm) */ |
|---|
| 189 | DHL_ADC_COMP_CUSTOM1, /* Custom mode 1 (Digital Dialnorm) */ |
|---|
| 190 | DHL_ADC_COMP_LINE, /* Line out mode */ |
|---|
| 191 | DHL_ADC_COMP_RF /* RF Remodulation mode */ |
|---|
| 192 | } DHL_ADC_COMP_MODE, *P_DHL_ADC_COMP_MODE; |
|---|
| 193 | |
|---|
| 194 | /****************************************************************************** |
|---|
| 195 | * MPEG PES Header - Flag Field |
|---|
| 196 | ******************************************************************************/ |
|---|
| 197 | typedef enum |
|---|
| 198 | { |
|---|
| 199 | DHL_PES_SCRAMBLING_CONTROL = 0, |
|---|
| 200 | DHL_PES_PRIORITY, |
|---|
| 201 | DHL_DATA_ALIGNMENT_INDICATOR, |
|---|
| 202 | DHL_COPYRIGHT, |
|---|
| 203 | DHL_ORIGINAL_OR_COPY, |
|---|
| 204 | DHL_PTS_DTS_FLAGS, |
|---|
| 205 | DHL_ESCR_FLAG, |
|---|
| 206 | DHL_ES_RATE_FLAG, |
|---|
| 207 | DHL_DSM_TRICK_MODE_FLAG, |
|---|
| 208 | DHL_ADDITIONAL_COPY_INFO_FLAG, |
|---|
| 209 | DHL_PES_CRC_FLAG, |
|---|
| 210 | DHL_PES_EXTENSION_FLAG, |
|---|
| 211 | DHL_PES_PRIVATE_DATA_FLAG, |
|---|
| 212 | DHL_PACK_HEADER_FIELD_FLAG, |
|---|
| 213 | DHL_PROG_PACK_SEQ_COUNTER_FLAG, |
|---|
| 214 | DHL_P_STD_BUFFER_FLAG, |
|---|
| 215 | DHL_PES_EXTENSION_FLAG_2, |
|---|
| 216 | DHL_STREAM_ID |
|---|
| 217 | } DHL_MPEG_PES_H_FLAG, *P_DHL_MPEG_PES_H_FLAG; |
|---|
| 218 | |
|---|
| 219 | /****************************************************************************** |
|---|
| 220 | * MPEG PES Header - Type Field |
|---|
| 221 | ******************************************************************************/ |
|---|
| 222 | typedef enum |
|---|
| 223 | { |
|---|
| 224 | DHL_PES_START = 0, |
|---|
| 225 | DHL_PES_VIDEO_0, //MPEG_0 |
|---|
| 226 | DHL_PES_VIDEO_1, //MPEG_1 |
|---|
| 227 | DHL_PES_AUDIO_P, //PRIMARY Parser |
|---|
| 228 | DHL_PES_AUDIO_S, //SECONDARY Parser |
|---|
| 229 | DHL_PES_AUDIO_J, //J1 Parser |
|---|
| 230 | DHL_PES_AUDIO_SP,//SPDIF Parser |
|---|
| 231 | DHL_PES_END, |
|---|
| 232 | } DHL_MPEG_PES_H_TYPE, *P_DHL_MPEG_PES_H_TYPE; |
|---|
| 233 | |
|---|
| 234 | typedef enum |
|---|
| 235 | { |
|---|
| 236 | DHL_CC_PRGSEQ_SHIFT = 0, |
|---|
| 237 | DHL_CC_PRGFR_SHIFT = 1, |
|---|
| 238 | DHL_CC_TOPFL_SHIFT = 2, |
|---|
| 239 | DHL_CC_RPTFL_SHIFT = 3, |
|---|
| 240 | DHL_CC_CODE_SHIFT = 4, |
|---|
| 241 | DHL_CC_PIC_SHIFT = 8, |
|---|
| 242 | } DHL_CC_DATA_SHIFT; |
|---|
| 243 | |
|---|
| 244 | typedef enum |
|---|
| 245 | { |
|---|
| 246 | DHL_CC_PRGSEQ_MASK = 1, |
|---|
| 247 | DHL_CC_PRGFR_MASK = 1, |
|---|
| 248 | DHL_CC_TOPFL_MASK = 1, |
|---|
| 249 | DHL_CC_RPTFL_MASK = 1, |
|---|
| 250 | DHL_CC_PIC_MASK = 0xFF, |
|---|
| 251 | } DHL_CC_DATA_MASK; |
|---|
| 252 | |
|---|
| 253 | #if defined __cplusplus |
|---|
| 254 | extern "C" { |
|---|
| 255 | #endif |
|---|
| 256 | |
|---|
| 257 | /****************************************************************************** |
|---|
| 258 | * DTV - Common APIs |
|---|
| 259 | ******************************************************************************/ |
|---|
| 260 | DHL_RESULT DHL_DTV_Open(void); |
|---|
| 261 | DHL_RESULT DHL_DTV_Init(void); |
|---|
| 262 | DHL_RESULT DHL_DTV_StartAV(DS_U16 uVidPID, DS_U16 uAudPID, DS_U16 uPcrPID, DHL_AUD_STREAMTYPE AudStreamType); |
|---|
| 263 | DHL_RESULT DHL_DTV_StopAV(void); |
|---|
| 264 | DHL_RESULT DHL_DTV_Close(void); |
|---|
| 265 | DHL_RESULT DHL_DTV_PresetCallback(void *pCallBack, DHL_DTV_CBTYPE CBType, DS_U32 ClientCntx); |
|---|
| 266 | DHL_RESULT DHL_DTV_DoCallback(DHL_DTV_CBTYPE CBType, void *Arg); |
|---|
| 267 | DHL_RESULT DHL_DTV_Pause(void); |
|---|
| 268 | DHL_RESULT DHL_DTV_Resume(void); |
|---|
| 269 | DS_BOOL DHL_DTV_IsAVStarted(void); |
|---|
| 270 | DHL_RESULT DHL_DTV_IsAvAlive(DS_BOOL *bVideo, DS_BOOL *bAudio); |
|---|
| 271 | DHL_RESULT DHL_DTV_IsAvAliveExt(DS_BOOL *bVideo, DS_BOOL *bAudio, DS_U32 uVidWaitingTick, DS_U32 uAudWaitingTick); |
|---|
| 272 | void DHL_DTV_SetStillPicture( DS_BOOL bStill ); |
|---|
| 273 | DS_BOOL DHL_DTV_GetStillPicture(void); |
|---|
| 274 | |
|---|
| 275 | /****************************************************************************** |
|---|
| 276 | * DTV - Video APIs |
|---|
| 277 | ******************************************************************************/ |
|---|
| 278 | DHL_RESULT DHL_DTV_StartVideo(DS_U16 uVidPID, DS_U16 uPcrPID); |
|---|
| 279 | DHL_RESULT DHL_DTV_StartVideoEx2(DS_U16 uVidPID, DS_U16 uPcrPID,DS_U8 Stream_Type); |
|---|
| 280 | DHL_RESULT DHL_DTV_StartVideo2(DS_U16 uVidPID, DS_U16 uPcrPID,DS_U16 uAudPID); |
|---|
| 281 | DHL_RESULT DHL_DTV_StopVideo(void); |
|---|
| 282 | DHL_RESULT DHL_DTV_GetSrcVideoInfo(P_DHL_DTV_SRCVID_INFO pSrcInfo); |
|---|
| 283 | DS_BOOL DHL_DTV_IsVideoStarted(void); |
|---|
| 284 | |
|---|
| 285 | /****************************************************************************** |
|---|
| 286 | * DTV - Audio APIs |
|---|
| 287 | ******************************************************************************/ |
|---|
| 288 | DHL_RESULT DHL_DTV_StartAudio(DS_U16 uAudPID, DS_U16 uPcrPID, DHL_AUD_STREAMTYPE AudStreamType, DS_BOOL bAudOnlyCh); |
|---|
| 289 | DHL_RESULT DHL_DTV_StopAudio(void); |
|---|
| 290 | DHL_RESULT DHL_DTV_SetAudioDynamicRange( DS_BOOL dynrngOn ); |
|---|
| 291 | DHL_RESULT DHL_DTV_GetAudioDynamicRange( DS_U32* pRangeHi, DS_U32* pRangeLow ); |
|---|
| 292 | DHL_RESULT DHL_DTV_GetAudioInfoAc3( P_DHL_DTV_AC3_STATUS pAc3Info ); |
|---|
| 293 | DHL_RESULT DHL_DTV_GetAudioInfoMpeg( P_DHL_DTV_MPEG_STATUS pMpegInfo ); |
|---|
| 294 | void DHL_DTV_DumpAudioInfoAc3( void ); |
|---|
| 295 | DS_BOOL DHL_DTV_IsAudioStarted(void); |
|---|
| 296 | |
|---|
| 297 | /****************************************************************************** |
|---|
| 298 | * DTV - Userdata APIs |
|---|
| 299 | ******************************************************************************/ |
|---|
| 300 | DHL_RESULT DHL_DTV_InitCC(void); |
|---|
| 301 | DHL_RESULT DHL_DTV_EnableCC(void); |
|---|
| 302 | DHL_RESULT DHL_DTV_DisableCC(void); |
|---|
| 303 | DHL_RESULT DHL_DTV_CloseCC(void); |
|---|
| 304 | |
|---|
| 305 | /****************************************************************************** |
|---|
| 306 | * PES filter APIs |
|---|
| 307 | ******************************************************************************/ |
|---|
| 308 | DHL_RESULT DHL_DTV_PresetPESCallback( DHL_DTV_PES_CALLBACK cbFunc ); |
|---|
| 309 | DHL_RESULT DHL_DTV_StartPESFilter(DS_U16 uPESPid); |
|---|
| 310 | DHL_RESULT DHL_DTV_StopPESFilter(DS_U16 uPESPid, DS_BOOL bAll); |
|---|
| 311 | |
|---|
| 312 | #if defined __cplusplus |
|---|
| 313 | } |
|---|
| 314 | #endif |
|---|
| 315 | |
|---|
| 316 | #endif /* _DSTHAL_DTV_H_ */ |
|---|