?? psfdemux_parsing.c
字號:
/* * * Copyright (c) Sigma Designs, Inc. 2006. All rights reserved. * *//* * *********************************************************** * This is UGLY, #including this file isnt the way to go, but * it's a fast way of cleaning play_psfdemux.c * The best approach will be to convert this into a library * which might be re-used by RMVDEMUX lib. * *********************************************************** *//** @file psfdemux_parsing.c @brief PMT, PAT, etc parsing functionality for play_psfdemux @author Aurelia Popa-Radu @ingroup dccsamplecode*/#include "../samples/sample_os.h"#define ALLOW_OS_CODE 1#include "../dcc/include/dcc.h"#include "../samples/common.h"#include "../rmscc/include/rmscc.h"#include "mp4descriptors.h"#include "mp4scene.h"#include "psfdemux_common.h"#include "../samples/rmttx.h"#if 0#define CALLDBG ENABLE#else#define CALLDBG DISABLE#endif/* pid and output tables for app_type = pid_filter_section */struct PidEntry_type gPidTable[] = { /* pid, input_type, flags, enable, output_mask[1], cipher, pid type, index */ /* (where to send) mask, index[1], (what to send) */#ifndef USE_HW_FIXED_PID_ENTRY /* defined in psfdemux_common.h only for EM8622 chip; undefined for EM863x */ /* enable PAT, CAT in PidTable and disable the fixed PAT pid from hardware */ { 0x0000, EMhwlibPid_Ts, TS_FLAGS, TRUE, {PAT_OUTPUT_MASK}, 0, {0}, PAT_PID_ENTRY, }, { 0x0001, EMhwlibPid_Ts, TS_FLAGS, TRUE, {CAT_OUTPUT_MASK}, 0, {0}, CAT_PID_ENTRY, },#endif { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {VIDEO_OUTPUT_MASK}, 0, {0}, VIDEO_PID_ENTRY, }, { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {AUDIO_OUTPUT_MASK}, 0, {0}, AUDIO_PID_ENTRY, }, { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {PCR_OUTPUT_MASK}, 0, {0}, PCR_PID_ENTRY, }, { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {PMT_OUTPUT_MASK}, 0, {0}, PMT_PID_ENTRY, }, { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {ECM0_OUTPUT_MASK}, 0, {0}, ECM0_PID_ENTRY, },/* hardcoded for dvb encrypted files */ { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {ECM1_OUTPUT_MASK}, 0, {0}, ECM1_PID_ENTRY, },/* hardcoded for dvb encrypted files */ // reserve two pid for mp4 bifs and od { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {BIFS_OUTPUT_MASK}, 0, {0}, BIFS_PID_ENTRY, },/* mp4 bifs stream */ { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {OD_OUTPUT_MASK}, 0, {0}, OD_PID_ENTRY, },/* mp4 od stream */ { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, TRUE, {TTX_OUTPUT_MASK}, 0, {0}, TTX_PID_ENTRY, },/* teletext stream */ #ifdef MULTI2_EIGHT_KEYS { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {1<<(DATA_OUT+0)}, 0, {0}, DATA_ENTRY+0, }, // data out13 { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {1<<(DATA_OUT+1)}, 0, {0}, DATA_ENTRY+1, }, { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {1<<(DATA_OUT+2)}, 0, {0}, DATA_ENTRY+2, }, { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {1<<(DATA_OUT+3)}, 0, {0}, DATA_ENTRY+3, }, { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {1<<(DATA_OUT+4)}, 0, {0}, DATA_ENTRY+4, }, { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {1<<(DATA_OUT+5)}, 0, {0}, DATA_ENTRY+5, }, { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {1<<(DATA_OUT+6 )}, 0, {0}, DATA_ENTRY+6, }, // ecm out19 { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {1<<(DATA_OUT+7 )}, 0, {0}, DATA_ENTRY+7, }, { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {1<<(DATA_OUT+8 )}, 0, {0}, DATA_ENTRY+8, }, { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {1<<(DATA_OUT+9 )}, 0, {0}, DATA_ENTRY+9, }, { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {1<<(DATA_OUT+10)}, 0, {0}, DATA_ENTRY+10,}, { 0x1fff, EMhwlibPid_Ts, TS_FLAGS, FALSE, {1<<(DATA_OUT+11)}, 0, {0}, DATA_ENTRY+11,},#endif //#ifdef MULTI2_EIGHT_KEYS};struct Output_type gOutputTable[] = { /* data_type, section_mask, buffer partial thrshld, pts,ibc, consumer, callback, file, output receive_data */ /* count, size, read, name,handle,size, module_id, mode */ { EMhwlibData_PSI, PAT_SECTION_MASK, 4, LOG2_4k, TRUE, 0, 0, 0, 0, PATCallback, "0.out", NULL, 0, 0, receive_data_dma_no_delay, }, { EMhwlibData_PSI, PMT_SECTION_MASK, 4, LOG2_4k, TRUE, 0, 0, 0, 0, PMTCallback, "1.out", NULL, 0, 0, receive_data_dma_no_delay, }, { EMhwlibData_Vpayload_pts, 0, 16, LOG2_32k, FALSE, 0x8000, 128, 64, VideoDecoder, NULL, "2.out", NULL, 0, 0, receive_data_dma_backward_compatible, }, { EMhwlibData_ASpayload_pts, 0, 16, LOG2_32k, FALSE, 0x8000, 128, 64, AudioDecoder, NULL, "3.out", NULL, 0, 0, receive_data_dma_backward_compatible, }, { EMhwlibData_PCR, 0, 0, 0, FALSE, 0, 0, 0, 0, NULL, "", NULL, 0, 0, receive_data_dma_backward_compatible, }, { EMhwlibData_PSI, CAT_SECTION_MASK, 4, LOG2_4k, TRUE, 0, 0, 0, 0, CATCallback, "5.out", NULL, 0, 0, receive_data_dma_no_delay, }, { EMhwlibData_PSI, ECM0_SECTION_MASK, 4, LOG2_4k, TRUE, 0, 0, 0, 0, ECMCallback, "6.out", NULL, 0, 0, receive_data_dma_no_delay, }, { EMhwlibData_PSI, ECM1_SECTION_MASK, 4, LOG2_4k, TRUE, 0, 0, 0, 0, ECMCallback, "7.out", NULL, 0, 0, receive_data_dma_no_delay, }, // output used for recording TS - used when RECORD_AV_TS or WITH_TIME_SHIFT is defined in psfdemux_common.h#ifdef RECORD_AV_TS { EMhwlibData_TS, 0, REC_CNT, LOG2_32k, FALSE, 0x8000, 0, 64, 0, NULL, "8.out", NULL, 0, 0, receive_data_dma_full_buffer, },#else { EMhwlibData_TS, 0, 0, 0, FALSE, 0x8000, 0, 0, 0, NULL, "8.out", NULL, 0, 0, receive_data_dma_backward_compatible, },#endif { EMhwlibData_ASpayload_pts, 0, 16, LOG2_32k, FALSE, 0x8000, 128, 64, AudioDecoder, NULL, "9.out", NULL, 0, 0, receive_data_dma_backward_compatible, }, { EMhwlibData_PSI, BIFS_SECTION_MASK, 4, LOG2_4k, TRUE, 0, 0, 0, 0, NULL,"10.out", NULL, 0, 0, receive_data_dma_no_delay, }, { EMhwlibData_DMB_OD, OD_SECTION_MASK, 4, LOG2_4k, TRUE, 0, 0, 0, 0, NULL,"11.out", NULL, 0, 0, receive_data_dma_no_delay, }, { EMhwlibData_APES, 0, 4, LOG2_32k, TRUE, 0, 0, 0, 0, TTXCallback,"12.out", NULL, 0, 0, receive_data_dma_no_delay, }, { EMhwlibData_TS, 0, 16, LOG2_32k, FALSE, 0x8000, 0, 0, 0, NULL,"13.out", NULL, 0, 0, receive_data_dma_full_buffer, }, #ifdef MULTI2_EIGHT_KEYS { EMhwlibData_ASpayload_pts, 0, 4, LOG2_4k, FALSE, 0, 0, 0, 0, NULL,"13.out", NULL, 0, 0, receive_data_dma_backward_compatible, }, // data// { EMhwlibData_DSM_CC,(1<<(DATA_SEC+1)),4, LOG2_4k, FALSE, 0, 0, 0, 0, NULL,"13.out", NULL, 0, 0, receive_data_dma_backward_compatible, }, { EMhwlibData_DSM_CC,(1<<(DATA_SEC+2)),4, LOG2_4k, FALSE, 0, 0, 0, 0, NULL,"14.out", NULL, 0, 0, receive_data_dma_backward_compatible, }, { EMhwlibData_DSM_CC,(1<<(DATA_SEC+3)),4, LOG2_4k, FALSE, 0, 0, 0, 0, NULL,"15.out", NULL, 0, 0, receive_data_dma_backward_compatible, }, { EMhwlibData_DSM_CC,(1<<(DATA_SEC+4)),4, LOG2_4k, FALSE, 0, 0, 0, 0, NULL,"16.out", NULL, 0, 0, receive_data_dma_backward_compatible, }, { EMhwlibData_DSM_CC,(1<<(DATA_SEC+5)),4, LOG2_4k, FALSE, 0, 0, 0, 0, NULL,"17.out", NULL, 0, 0, receive_data_dma_backward_compatible, }, { EMhwlibData_DSM_CC,(1<<(DATA_SEC+6)),4, LOG2_4k, FALSE, 0, 0, 0, 0, NULL,"18.out", NULL, 0, 0, receive_data_dma_backward_compatible, }, { EMhwlibData_PSI, (1<<(DATA_SEC+7 )), 4, LOG2_4k, TRUE, 0, 0, 0, 0, ECMCallback,"19.out", NULL, 0, 0, receive_data_dma_backward_compatible, }, // data { EMhwlibData_PSI, (1<<(DATA_SEC+8 )), 4, LOG2_4k, TRUE, 0, 0, 0, 0, ECMCallback,"20.out", NULL, 0, 0, receive_data_dma_backward_compatible, }, { EMhwlibData_PSI, (1<<(DATA_SEC+9 )), 4, LOG2_4k, TRUE, 0, 0, 0, 0, ECMCallback,"21.out", NULL, 0, 0, receive_data_dma_backward_compatible, }, { EMhwlibData_PSI, (1<<(DATA_SEC+10)), 4, LOG2_4k, TRUE, 0, 0, 0, 0, ECMCallback,"22.out", NULL, 0, 0, receive_data_dma_backward_compatible, }, { EMhwlibData_PSI, (1<<(DATA_SEC+11)), 4, LOG2_4k, TRUE, 0, 0, 0, 0, ECMCallback,"23.out", NULL, 0, 0, receive_data_dma_backward_compatible, }, { EMhwlibData_PSI, (1<<(DATA_SEC+12)), 4, LOG2_4k, TRUE, 0, 0, 0, 0, ECMCallback,"24.out", NULL, 0, 0, receive_data_dma_backward_compatible, },#endif //#ifdef MULTI2_EIGHT_KEYS};/* pid and output table for app_type = program_stream_parsing */struct PesEntry_type gPesTable[] = { /* sid, ssid, input_type, enable, output_mask[1], cipher_mask, cipher_index[1] */ { 0xE0, 0, EMhwlibPes_packet, TRUE, {1<<0}, 0, {0}, }, // video { 0xBD, 0x80, EMhwlibPes_packet, TRUE, {(1<<1) | (1<<3)}, 0, {0}, }, // two audio outputs { 0xBD, 0x20, EMhwlibPes_packet, TRUE, {1<<2}, 0, {0}, }, // subpicture};struct Output_type gPesOutputTable[] = { /* data_type, section_mask, buffer partial thrshld, pts,ibc, consumer, callback, file, output receive_data */ /* count, size, read, name,handle,size, module_id, mode */ { EMhwlibData_Vpayload_pts, 0, 64, LOG2_32k, FALSE, 0x8000, 128, 64, VideoDecoder, NULL, "0.out", NULL, 0, 0, receive_data_dma_backward_compatible, }, { EMhwlibData_ASpayload_pts, 0, 16, LOG2_32k, FALSE, 0x8000, 128, 64, AudioDecoder, NULL, "1.out", NULL, 0, 0, receive_data_dma_backward_compatible, }, { EMhwlibData_ASpayload_pts, 0, 16, LOG2_4k, FALSE, 0x1000, 128, 64, SpuDecoder, NULL, "2.out", NULL, 0, 0, receive_data_dma_backward_compatible, }, { EMhwlibData_ASpayload_pts, 0, 16, LOG2_32k, FALSE, 0x8000, 128, 64, AudioDecoder, NULL, "3.out", NULL, 0, 0, receive_data_dma_backward_compatible, },};/* generic section filter - including PAT, PMT, DSM_CC */struct MatchSectionEntry_type gmatchSectionTable[] = { {{ 0xff, 0xff, {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 0 mask {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // mode=positive match {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // PAT {{ 0xff, 0xff, {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 1 mask {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // mode=positive match {0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // PMT {{ 0xff, 0xff, {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 2 mask {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // mode=positive match {0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // DSM_CC {{ 0xff, 0xff, {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 3 mask {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // mode=positive match {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // CAT {{ 0xff, 0xff, {0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 4 mask {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // mode=positive match {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // ECM 0x80,0x81,0x82 {{ 0xff, 0xff, {0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 5 mask {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // mode=positive match {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // ECM 0x80,0x81,0x82 {{ 0xff, 0xff, {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 6 mask {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // mode=positive match {0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // bifs streams {{ 0xff, 0xff, {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 7 mask {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // mode=positive match {0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // od streams {{ 0xff, 0xff, {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 8 not used {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // {0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, //#ifdef MULTI2_EIGHT_KEYS // section for data outputs {{ 0xff, 0xff, {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 9 reserved for out 13 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // {{ 0xff, 0xff, {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 10 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // {{ 0xff, 0xff, {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 11 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // {{ 0xff, 0xff, {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 12 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // {{ 0xff, 0xff, {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 13 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // {{ 0xff, 0xff, {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 14 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // // section for ecm outputs {{ 0xff, 0xff, {0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 15 mask {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // mode=positive match {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // ECM 0x80,0x81,0x82 {{ 0xff, 0xff, {0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 16 mask {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // mode=positive match {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // ECM 0x80,0x81,0x82 {{ 0xff, 0xff, {0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 17 mask {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // mode=positive match {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // ECM 0x80,0x81,0x82 {{ 0xff, 0xff, {0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 18 mask {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // mode=positive match {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // ECM 0x80,0x81,0x82 {{ 0xff, 0xff, {0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 19 mask {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // mode=positive match {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // ECM 0x80,0x81,0x82 {{ 0xff, 0xff, {0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 20 mask {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // mode=positive match {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}}, // ECM 0x80,0x81,0x82#endif //#ifdef MULTI2_EIGHT_KEYS};RMstatus ParsePAT(RMuint8 *pBuffer1, RMuint32 size1, RMuint8 *pBuffer2, RMuint32 size2, struct PATInfo_type *out){ /* function assumes to be called on correct PAT boundaries */#define PAT_TABLE_ID 1#define PAT_LENGTH_HI 2#define PAT_LENGTH_LO 3#define PAT_TRANSPORT_STREAM_ID_HI 4#define PAT_TRANSPORT_STREAM_ID_LO 5#define PAT_VERSION_NUMBER 6#define PAT_SECTION_NUMBER 7#define PAT_LAST_SECTION_NUMBER 8#define PAT_PROGRAM_NUMBER_HI 9#define PAT_PROGRAM_NUMBER_LO 10#define PAT_PROGRAM_MAP_PID_HI 11#define PAT_PROGRAM_MAP_PID_LO 12#define PAT_CRC_3 13#define PAT_CRC_2 14#define PAT_CRC_1 15#define PAT_CRC_0 16 RMuint32 PatState = PAT_TABLE_ID; RMuint16 length = 0, transport_stream_id = 0, program_number = 0, program_map_pid = 0; RMuint8 section_number, last_section_number; RMuint32 size = size1 + size2; RMuint16 len = 0; RMuint8 *p = NULL; RMDBGLOG((CALLDBG, "parsePAT\n")); if (out == NULL) return RM_ERROR; out->count = 0; if (pBuffer1 && size1) { p = pBuffer1; } while (size) { switch (PatState) { case PAT_TABLE_ID: if (*p != 0x00) { fprintf(stderr, "ParsePAT table_id=%02x instead of 0x00 !\n", *p); return RM_ERROR; } PatState++; break; case PAT_LENGTH_HI: /* section_syntax_indicator and length_hi*/ if ((*p & 0xc0) != 0x80) { fprintf(stderr, "ParsePAT section_syntax_indicator 0 !\n");// return RM_ERROR; } length = *p & 0x0f; length <<= 8; PatState++; break; case PAT_LENGTH_LO: length |= *p; len = length; PatState++; break; case PAT_TRANSPORT_STREAM_ID_HI: transport_stream_id = *p; transport_stream_id <<= 8; PatState++; len--; break; case PAT_TRANSPORT_STREAM_ID_LO: transport_stream_id |= *p; PatState++; len--; break; case PAT_VERSION_NUMBER: /* version_number on bit 5..1, current_next_indicator on bit 0 */ out->version_number_current_next_indicator = *p & 0x3f; RMDBGLOG((DISABLE, "ParsePAT version number = %x current_next_indicator = %x\n", out->version_number_current_next_indicator>>1, out->version_number_current_next_indicator & 1)); PatState++; len--; break; case PAT_SECTION_NUMBER: if (*p != 0x00) { fprintf(stderr, "ParsePAT no multiple sections in PAT supported yet !\n"); return RM_ERROR; } section_number = *p; PatState++; len--; break; case PAT_LAST_SECTION_NUMBER: last_section_number = *p; PatState++; len--; break; case PAT_PROGRAM_NUMBER_HI: if (len < 8) { fprintf(stderr, "ParsePAT not enough data for program and crc !\n"); return RM_ERROR; } program_number = *p; program_number <<= 8; PatState++; len--; break; case PAT_PROGRAM_NUMBER_LO: program_number |= *p; PatState++; len--; out->program_number[out->count] = program_number; break;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -