/******************************************************************** * * PSI_MpegSi.h - MPEG System Information (SI) parsing definitions * * Copyright 2004~ DigitalSTREAMTechnology, Inc. * All Rights Reserved * * _Id: PSI_MpegSi.h ,v 1.0 2004/015/28 jina Exp ********************************************************************/ #ifndef DST_PSI_MPEG_SI_ #define DST_PSI_MPEG_SI_ #ifdef __cplusplus extern "C" { #endif #ifndef DST_PSI_PROCESS_H #include "dsthalPsiProcess.h" #endif #ifndef _DSTHALERROR_H_ #include "dsthalerror.h" #endif /* macros */ #if 0 ___Definitions___() #endif #define MAX_PSI_MPEG_DATA 4096 #define MAX_PSI_SECTIONS 256 #define get_table_id(p) (p[0]) #define get_section_syntax_indicator(p) (p[1] >> 7) #define get_private_indicator(p) ((p[1] >> 6) & 0x1) #define get_section_length(p) (((p[1] & 0x0F) << 8) | p[2]) #define get_section_number(p) (p[6]) #define get_last_section_number(p) (p[7]) /* * Assigned PID's */ #define PAT_PID 0x0000 #define EIT_PID 0x0012 #define DIT_PID 0x001E #define SIT_PID 0x001F /* * Table ID's */ #define PROGRAM_ASSOCIATION_SECTION 0 #define CA_SECTION 1 #define TS_PROGRAM_MAP_SECTION 2 #define DIT_SECTION 0x7E #define SIT_SECTION 0x7F #define MAX_ECM_SECTION_SIZE 4096 #define TS_ECM_SECTION_ID 0x82 #define TS_EMM_SECTION_ID 0x84 #define COMMON_EMM_TABLE_EXTENSION_ID 0x0000 /***************************** PAT ********************************/ /* * MPEG descriptor types (Table 2-39) */ #define video_stream_tag 0x02 #define audio_stream_tag 0x03 #define hierarchy_tag 0x04 #define registration_tag 0x05 #define data_stream_alignment_tag 0x06 #define target_background_grid_tag 0x07 #define video_window_tag 0x08 #define CA_tag 0x09 #define ISO_639_language_tag 0x0A #define system_clock_tag 0x0B #define multiplex_buffer_utilization_tag 0x0C #define copyright_tag 0x0D #define maximum_bitrate_tag 0x0E #define private_data_indicator_tag 0x0F #define smoothing_buffer_tag 0x10 #define STD_tag 0x11 #define IBP_tag 0x12 /* * DVB/ARIB descriptor types */ #define network_name_tag 0x40 #define service_list_tag 0x41 #define DVB_ARIB_stuffing_tag 0x42 #define satellite_delivery_system_tag 0x43 #define cable_delivery_system_tag 0x44 #define buquet_name_tag 0x47 #define service_tag 0x48 #define country_availability_tag 0x49 #define linkage_tag 0x4A #define nvod_reference_tag 0x4B #define DVB_time_shifted_service_tag 0x4C #define short_event_tag 0x4D #define extended_event_tag 0x4E #define time_shifted_event_tag 0x4F #define component__tag 0x50 #define mosaic_tag 0x51 #define stream_identifier_tag 0x52 #define ca_identifier_tag 0x53 #define content_tag 0x54 #define parental_rating_tag 0x55 #define local_time_offset_tag 0x58 #define partial_transport_stream_tag 0x63 /* * ATSC descriptor types */ #define ATSC_stuffing_tag 0x80 #define AC3_audio_stream_tag 0x81 #define program_identifier_tag 0x85 #define caption_service_tag 0x86 #define content_advisory_tag 0x87 #define extended_channel_name_tag 0xA0 #define service_location_tag 0xA1 #define ATSC_time_shifted_service_tag 0xA2 #define component_name_tag 0xA3 #define dcc_departing_request_tag 0xA8 #define dcc_arriving_request_tag 0xA9 #define redistribution_control_tag 0xAA /* * ARIB descriptor types */ #define heirarchical_transmission_tag 0xC0 #define digital_copy_control_tag 0xC1 #define netowkr_identification_tag 0xC2 #define partial_ts_time_tag 0xC3 #define audio_component_tag 0xC4 #define hyperlink_tag 0xC5 #define target_area_tag 0xC6 #define data_control_tag 0xC7 #define video_decode_control_tag 0xC8 #define download_control_tag 0xC9 #define ca_emm_ts_tag 0xCA #define ca_contrat_information_tag 0xCB #define ca_service_tag 0xCC #define basic_local_even_tag 0xD0 #define reference_tag 0xD1 #define node_relation_tag 0xD2 #define shore_node_tag 0xD3 #define stc_reference_tag 0xD4 #define emergency_information_tag 0xFC #define data_component_tag 0xFD #define system_management_tag 0xFE /* * MPEG stream types in the PMT (Table 2-29) * NOT to be confused with stream ID's found in PES headers */ #define StreamType_MPEG1Video 1 #define StreamType_MPEG2Video 2 #define StreamType_MPEG1Audio 3 #define StreamType_MPEG2Audio 4 #define StreamType_MPEG2PrivateSection 5 #define StreamType_MPEG2PESPrivateData 6 #define StreamType_MHEG 7 #define StreamType_AnnexADSMCC 8 #define StreamType_H222_1 9 #define StreamType_DSMCCTypeA 10 #define StreamType_DSMCCTypeB 11 #define StreamType_DSMCCTypeC 12 #define StreamType_DSMCCTypeD 13 #define StreamType_MPEG2Auxiliary 14 #define StreamType_MPEG4Audio 0x11 #define StreamType_MPEG4Video 0x1B #define StreamType_AACAudio 15 #define StreamType_DC2Video 0x80 #define StreamType_AC3Audio 0x81 #if 0 ___PAT___() #endif /* * This represents one program within the Program Association Table */ typedef struct MPEG_PAT_program { DS_U16 program_number; DS_U16 program_map_PID; } MPEG_PAT_program; /* * This contains all interesting fieldsin a Program Association Table. * All sections in a multi-section PAT are included in this * one structure. */ typedef struct pat_t { DS_U16 transport_stream_id; DS_U8 version_number; DS_BOOL current_next_indicator; DS_U8 section_number; DS_U8 last_section_number; DS_BOOL isWholePAT; /* FALSE if only a singe section of a PAT */ DS_U16 numPrograms; DS_BOOL networkPIDPresent; /* TRUE if network_pid is valid */ DS_U16 network_PID; MPEG_PAT_program *programs; } pat_t, *patPtr_t; typedef struct pat_t MPEG_PAT; /* * MonitorPAT will set up a PSI monitor waiting for PAT's * current_next_indicator should be set to TRUE to get the current PAT * or FALSE to get the next PAT. * The eventProc will be called after the first PAT received, or after * each section in the PAT is received if eager is TRUE., and * then again depending on updateMode until CancelPSIPidMonitor * is called. The eventProc should call ParsePAT */ DHL_RESULT DHL_PSI_MonitorPAT( DHL_PSI_HANDLE sysInfo, DS_BOOL current_next_indicator, DS_BOOL eager, PSIUpdateMode updateMode, PSIEventProc_f eventProc, DS_U32 userParam, DHL_TBL_HANDLE *returnPSICtl); /* * ParsePAT will parse a PAT, given a PSI descriptor. It should * be called in response to a psiDataReceived event. */ DHL_RESULT DHL_PSI_ParsePAT(DS_U8 **sectionArr , MPEG_PAT **returnPat); /* * PrintPAT prints out a PAT to standard output */ void DHL_PSI_PrintPAT(const MPEG_PAT *pat); /* * This is an alternative, synchronous function for receiving PAT's when on-going * event monitoring is not desired. The timeout parameter specifies the number * of ticks to wait for a PAT, or 0 to wait indefinitely. */ DHL_RESULT DHL_PSI_GetPAT(DHL_PSI_HANDLE sysInfo, MPEG_PAT **returnPat, int timeOut); void DHL_PSI_FreeMpegSection (void *sectionPtr); /* * FreePAT will delete a PAT returned by ParsePAT or GetPAT */ #define DHL_PSI_FreePAT(x) DHL_PSI_FreeMpegSection(x) /* * FreePMT will delete a PMT returned by ParsePMT or GetPMT */ #define DHL_PSI_FreePMT(x) DHL_PSI_FreeMpegSection(x) #if 0 ___PMT___() #endif /***************************** PMT ********************************/ /* video_stream_descriptor */ typedef struct VideoStreamDescriptor { DS_BOOL multiple_frame_rate_flag; MPEG_FRAME_RATE frame_rate_code; DS_BOOL MPEG_1_only_flag; DS_BOOL constrained_parameter_flag; DS_BOOL still_picture_flag; DS_U8 profile_and_level_indication; MPEG_CHROMA_FORMAT chroma_format; DS_BOOL frame_rate_extension_flag; } VideoStreamDescriptor; /* Video Decode Control Descriptor (ARIB only) */ typedef struct VideoDecodeControlDescriptor { DS_BOOL valid; /* TRUE if this descriptor exists in PMT */ DS_BOOL still_picture_flag; DS_BOOL sequence_end_code_flag; DS_U8 video_decode_format; } VideoDecodeControlDescriptor; typedef struct tag_CA_descriptor { DS_U16 CA_system_ID; DS_U16 CA_PID; DS_U8 private_data_length; DS_U8 *p_private_data; } CA_descriptor; typedef struct MPEG_PMT_stream { DS_U8 stream_type; DS_U16 elementary_PID; DS_U16 descriptor_length; DS_U8 *descriptors; VideoStreamDescriptor *videoStreamDescriptor; /* NULL if not present */ VideoDecodeControlDescriptor videoDecodeControlDescriptor; /* Not a pointer. Check valid flag */ DS_U8 component_tag; DS_BOOL b_component_tag_valid; } MPEG_PMT_stream; /* * This contains all interesting fields in a Program Mapping Table */ #define DYNARRAY_PMTStream 32 /* Debugger thinks there's this many streams - Does not specify actual length of structure */ typedef struct pmt_t { // DS_U16 PID; DS_U16 program_number; DS_U8 version_number; DS_BOOL current_next_indicator; DS_U16 PCR_PID; DS_U16 descriptor_length; DS_U8 *descriptors; /* program descriptors */ int numStreams; MPEG_PMT_stream streams[DYNARRAY_PMTStream]; } pmt_t , *pmtPtr_t; typedef struct pmt_t MPEG_PMT; #define MPEG_PMTSize(nelem) (sizeof(MPEG_PMT) + \ ((nelem)-DYNARRAY_PMTStream)*sizeof(MPEG_PMT_stream)) /* * MonitorPMT will set up a PSI monitor waiting for PMT's at the given PID * and program_number. (The same PID can be used to carry program numbers * for different programs acording to ISO/IEC 13818-1 Section C.8.2) * current_next_indicator should be set to TRUE to get the current PMT * or FALSE to get the next PMT. * The eventProc will be called after the first PMT received, and * then again depending on updateMode until CancelPSIPidMonitor * is called. The eventProc should call ParsePMT */ DHL_RESULT DHL_PSI_MonitorPMT(DHL_PSI_HANDLE sysInfo, DS_U16 pid, DS_U16 program_number, DS_BOOL current_next_indicator, PSIUpdateMode updateMode, PSIEventProc_f eventProc, DS_U32 userParam, DHL_TBL_HANDLE *returnPSICtl); /* * ParsePMT will parse a PMT, given a PSI descriptor. It should * be called in response to a psiDataReceived event. */ DHL_RESULT DHL_PSI_ParsePMT( DS_U8 *section , MPEG_PMT **returnPmt); /* * PrintPMT prints out a PMT to standard output */ void DHL_PSI_PrintPMT(const MPEG_PMT *pmt); /* * This is an alternative, synchronous function for receiving the current PMT * at the given PID and program_number when on-going event monitoring is not desired. * The timeout parameter specifies the number of ticks to wait for a PMT, or 0 to wait * indefinitely. */ DHL_RESULT DHL_PSI_GetPMT(DHL_PSI_HANDLE sysInfo, DS_U16 pid, DS_U16 program_number, MPEG_PMT **returnPmt, int timeOut ); /* * Given a PMT, GetElementaryPIDs will return the first available audio and * video elementary streams, the PCR PID, an optional second (low bit rate) * video stream, and the type of audio. * Any return parameter may be NULL if the caller is not interested in * it. ScrambledWarning is returned if anything in the PMT is protected by * a CA system. */ DHL_RESULT DHL_PSI_GetElementaryPIDs( MPEG_PMT *pmt, DS_U16 *returnVideoPID, DS_U16 *returnAudioPID, DS_U16 *returnPcrPID, DS_U16 *returnLowBitrateVideoPID, AudioType *returnAudioType, VideoStreamDescriptor **returnVideoStreamDescriptor, DS_U8 *returnVidType); DHL_RESULT DHL_PSI_CancelMonitor( DHL_TBL_HANDLE pSectCtl ); DHL_RESULT DHL_PSI_CancelMonitor_TVGOS( DHL_TBL_HANDLE pSectCtl ); /*============================================================================== ^DHL_RESULT GetMpegDescriptor (DS_U8 *descriptors, DS_U16 len, DS_U8 tag, DS_U16 instance, DS_U8 **descriptor) *descriptors: Pointer to the un-parsed descriptors. len: Length in bytes of the un-parsed descriptors. tag: descriptor_tag to be searched for. instance: The instance of the descriptor to be returned. **descriptor Returned Pointer to the start of the descriptor. Attempts to retrieve a descriptor of the specified type from a list of un- parsed descriptors. The instance parameter allows searching for more than one descriptor instance of the same type. ==============================================================================*/ DHL_RESULT GetMpegDescriptor (DS_U8 *descriptors, DS_U16 len, DS_U8 tag, DS_U16 instance, DS_U8 **descriptor); DHL_RESULT GetMpegDescriptorEx(DS_U8 *descriptors, DS_U16 len, DS_U8 tag, DS_U8 offset, DS_U8 *pfilterBytes, DS_U8 filter_len, DS_U16 instance, DS_U8 **p_descriptor); /*============================================================================== ^void FreeMpegDescriptor (void *descriptorPtr) descriptorPtr Pointer to a parsed descriptor. Frees the memory associated with a parsed descriptor. ==============================================================================*/ void FreeMpegDescriptor (void *descriptorPtr); /* * MonitorDIT will set up a PSI monitor waiting for a Discontinuity ^ * Indicator Table (DIT). * The eventProc will be called after the first DIT received, and * then again depending on updateMode until CancelPSIPidMonitor * is called. */ #if 0 ___CAT___() #endif /* * This contains all interesting fields in a Program Mapping Table */ typedef struct cat_t { // DS_U16 PID; DS_U8 version_number; DS_BOOL current_next_indicator; DS_U16 descriptor_length; DS_U8 *descriptors; /* program descriptors */ } cat_t , *catPtr_t; typedef struct cat_t MPEG_CAT; DHL_RESULT DHL_PSI_MonitorCAT(DHL_PSI_HANDLE sysInfo, DS_BOOL current_next_indicator, DS_BOOL eager, PSIUpdateMode updateMode, PSIEventProc_f eventProc, DS_U32 userParam, DHL_TBL_HANDLE *returnPSICtl); /* * ParseCAT will parse a CAT, given a PSI descriptor. It should * be called in response to a psiDataReceived event. */ DHL_RESULT DHL_PSI_ParseCAT( DS_U8 *section , MPEG_CAT **returnCat); DHL_RESULT DHL_PSI_GetCAT( DHL_PSI_HANDLE sysInfo, MPEG_CAT **returnCat, int timeOut ); /* * PrintCAT prints out a CAT to standard output */ void DHL_PSI_PrintCAT(const MPEG_CAT *cat); /* * This is an alternative, synchronous function for receiving the current PMT * at the given PID and program_number when on-going event monitoring is not desired. * The timeout parameter specifies the number of ticks to wait for a PMT, or 0 to wait * indefinitely. */ DHL_RESULT DHL_PSI_GetCAT(DHL_PSI_HANDLE sysInfo, MPEG_CAT **returnCat, int timeOut ); DHL_RESULT DHL_PSI_ParseECMEMM( DS_U8 *section, DS_U8 **returnData); #ifdef __cplusplus } #endif #endif /* #ifndef DST_PSI_MPEG_SI_ */