?? psfdemux_parsing.c
字號(hào):
CatState++; break; case CAT_LENGTH_LO: length |= *p; len = length; CatState++; break; case CAT_RESERVED_0: CatState++; len--; break; case CAT_RESERVED_1: CatState++; len--; break; case CAT_VERSION_NUMBER: /* version_number on bit 5..1, current_next_indicator on bit 0 */ out->version_number_current_next_indicator = *p & 0x3F; if ((*p & 1) == 0x00) { fprintf(stderr, "ParseCAT the Conditional Access Table sent is not yet applicable!\n"); return RM_ERROR; } RMDBGLOG((DISABLE, "ParseCAT version number = %x current_next_indicator = %x\n", out->version_number_current_next_indicator>>1, out->version_number_current_next_indicator & 1)); CatState++; len--; break; case CAT_SECTION_NUMBER: if (*p != 0x00) { fprintf(stderr, "ParseCAT no multiple sections in CAT supported yet !\n"); return RM_ERROR; } section_number = *p; CatState++; len--; break; case CAT_LAST_SECTION_NUMBER: last_section_number = *p; CatState++; len--; break; case CAT_DESCRIPTOR_TAG: if (len < 10) { fprintf(stderr, "ParseCAT not enough data for descriptor and crc !\n"); return RM_ERROR; } descriptor_tag = *p; CatState++; len--; break; case CAT_DESCRIPTOR_LENGTH: descriptor_length = *p; if (descriptor_tag != 0x09) { /* not CA descriptor */ CatState = CAT_CA_PRIVATE_DATA; if (descriptor_length == 0) descriptor_length = 1; } else { CatState++; } len--; break; case CAT_CA_SYSTEM_ID_HI: ca_system_id = *p; ca_system_id <<= 8; descriptor_length--; CatState++; len--; break; case CAT_CA_SYSTEM_ID_LO: ca_system_id |= *p; out->ca_system_id[out->count] = ca_system_id; descriptor_length--; CatState++; len--; break; case CAT_CA_PID_HI: ca_pid = *p & 0x1F; ca_pid <<= 8; descriptor_length--; CatState++; len--; break; case CAT_CA_PID_LO: ca_pid |= *p; out->emm_pid[out->count] = ca_pid; out->count++; if (out->count > MAX_PROGRAM_NUMBER) { fprintf(stderr, "ParseCAT has more programs than the max=0x%x !\n", MAX_PROGRAM_NUMBER); return RM_ERROR; } len--; descriptor_length--; if (descriptor_length > 0) { /* private_data_byte */ CatState = CAT_CA_PRIVATE_DATA; } else { /* no private_data_byte */ if (len > 4) { /* another CA descriptor*/ CatState = CAT_DESCRIPTOR_TAG; } else { CatState = CAT_CRC_3; } } break; case CAT_CA_PRIVATE_DATA: len--; descriptor_length--; if (descriptor_length == 0) { if (len > 4) { /* another CA descriptor*/ CatState = CAT_DESCRIPTOR_TAG; } else { CatState = CAT_CRC_3; } } break; case CAT_CRC_3: case CAT_CRC_2: case CAT_CRC_1: CatState++; len--; break; case CAT_CRC_0: CatState++; len--; if (len) { fprintf(stderr, "ParseCAT reach CRC but there are 0x%x bytes" " left from 0x%x !\n", len, length); return RM_ERROR; } break; } size--; size1--; if (size1 == 0) p = pBuffer2; else p++; } return RM_OK;}/************************************************************************ * ************************************************************************/void CATCallback(RMuint8 *pBuffer1, RMuint32 size1, RMuint8 *pBuffer2, RMuint32 size2, RMstatus err, RMuint32 mask, void *context_in){ /* * The API is more general with two pointers * - in current implementation we use only first buffer */ struct context_per_task *context = (struct context_per_task *)context_in; struct CATInfo_type cat_info_temp; RMuint32 i; RMuint32 cat_compare_size; RMDBGLOG((CALLDBG, "CATCallback (context @0x%08lx)\n", (RMuint32)context_in)); if (RMFAILED(err)) { fprintf(stderr, "CATCallback ERROR\n"); return; } #if (0) if (size1 > 188) fprintf(stderr, "multiple CAT sections %ld\n", size1);#endif RMMemset(&cat_info_temp, 0, sizeof(struct CATInfo_type)); ParseCAT(pBuffer1, size1, pBuffer2, size2, &cat_info_temp); /* compare the CMT content except for version and update */ cat_compare_size = (RMuint32)&cat_info_temp.version_number_current_next_indicator - (RMuint32)&cat_info_temp.count; if (RMMemcmp((void*)&context->cat_info, (void*)&cat_info_temp, cat_compare_size) != 0) { context->cat_info = cat_info_temp; fprintf(stderr, " %ld_CAT: ", context->id); for (i = 0; i < cat_info_temp.count; i++) { fprintf(stderr, "[%04x %04x] ", cat_info_temp.ca_system_id[i], cat_info_temp.emm_pid[i]); /* * Allocate pid entries for every PMT and keep track of these * PMT pid entries in one list */ } fprintf(stderr, "\n"); context->cat = TRUE; } { /* filter only a new cat version in hardware section filter - in order to optimize CPU usage on standalone */ struct DemuxTask_MatchSectionEntry_type section_entry; /* version_number on bit 5..1, current_next_indicator on bit 0 */ context->match_section_table[3].section_entry.mask[5] = 0x3f; context->match_section_table[3].section_entry.mode[5] = ~0x3f; context->match_section_table[3].section_entry.comp[5] = cat_info_temp.version_number_current_next_indicator; section_entry.Index = context->match_section_table[3].index; section_entry.SectionEntry = context->match_section_table[3].section_entry; err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_MatchSectionEntry, §ion_entry, sizeof(section_entry), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Error RMDemuxTaskPropertyID_MatchSectionEntry")); } }}RMstatus InitTableVariables(struct context_per_task *context){ RMDBGLOG((CALLDBG, "initTableVariables (context @0x%08lx)\n", (RMuint32)context)); /* ############## AES_CBC_PRECIPHER CODE BEGIN ############# */ if (context->dtcpip_streaming == TRUE || context->test_aes_precipher == TRUE) context->key_size = 16; /* ############## AES_CBC_PRECIPHER CODE BEGIN ############# */ if (context->app_type == input_record) { context->match_section_table_count = 0; context->pid_table_count = 0; context->output_table = (struct Output_type *) RMMalloc(sizeof(struct Output_type)); if (context->output_table == NULL) { return RM_FATALOUTOFMEMORY; } context->output_table_count = 1; } else if (context->app_type != program_stream_parsing) { context->match_section_table = (struct MatchSectionEntry_type *) RMMalloc(sizeof(gmatchSectionTable)); if (context->match_section_table == NULL) { return RM_FATALOUTOFMEMORY; } RMMemcpy(context->match_section_table, gmatchSectionTable, sizeof(gmatchSectionTable)); context->match_section_table_count = sizeof(gmatchSectionTable)/sizeof(struct MatchSectionEntry_type); context->pid_table = (struct PidEntry_type *) RMMalloc(sizeof(gPidTable)); if (context->pid_table == NULL) { return RM_FATALOUTOFMEMORY; } RMMemcpy(context->pid_table, gPidTable, sizeof(gPidTable)); context->pid_table_count = sizeof(gPidTable)/sizeof(struct PidEntry_type); context->output_table = (struct Output_type *) RMMalloc(sizeof(gOutputTable)); if (context->output_table == NULL) { return RM_FATALOUTOFMEMORY; } RMMemcpy(context->output_table, gOutputTable, sizeof(gOutputTable)); context->output_table_count = sizeof(gOutputTable)/sizeof(struct Output_type); RMDBGLOG((ENABLE, "init output_table 0x%lx with statically defined gOutputTable, count %lu\n", context->output_table, context->output_table_count)); if (context->app_type == dvbcsa_decryption) { RMDBGLOG((ENABLE, "\ndvbcsa_decryption application\n")); context->key_size = 8; } if ((context->app_type == aes_cbc_decryption) || (context->app_type == aes_ecb_decryption) || (context->app_type == aes_nsa_decryption) || (context->app_type == aes_ofb_decryption) ) { RMDBGLOG((ENABLE, "\naes_?_decryption application\n")); context->key_size = 16; } RMDBGLOG((ENABLE, "\npid_filter_section application: pid_table_count=%ld output_table_count=%ld\n", context->pid_table_count, context->output_table_count)); } else { context->pes_table = (struct PesEntry_type *) RMMalloc(sizeof(gPesTable)); if (context->pes_table == NULL) { return RM_FATALOUTOFMEMORY; } RMMemcpy(context->pes_table, gPesTable, sizeof(gPesTable)); if( context->SourceType == SourceType_m1s ) { // if the app type is m1s context->pes_table[1].stream_id = 0xc0 | context->audio_subid; context->pes_table[1].substream_id = 0x0; context->pes_table[2].stream_id = 0x0; // zeroed spu context->pes_table[2].substream_id = 0x0; } else if (context->SourceType == SourceType_dvd) { context->pes_table[0].stream_id = 0xe0; // video context->audio_pid = (context->audio_opt->Codec == AudioDecoder_Codec_MPEG1) ? 0xC0:0xBD; switch(context->audio_opt->Codec) { case AudioDecoder_Codec_PCM: context->pes_table[1].substream_id = 0xa0 | context->audio_subid; break; case AudioDecoder_Codec_DTS: context->pes_table[1].substream_id = 0x88 | context->audio_subid; break; case AudioDecoder_Codec_MPEG1: if (context->audio_pid != (0xC0 /*+ Tasks[i].audio_subid*/)) { fprintf(stderr, "\n***************** audio_pid audio_subid conflict *****************\n"); fprintf(stderr, "*** for mpeg audio select either audio_pid, either audio_subid ***\n"); fprintf(stderr, "******************************************************************\n\n"); } context->pes_table[1].stream_id = 0xc0 | context->audio_subid; context->pes_table[1].substream_id = 0; break; default: context->pes_table[1].substream_id = 0x80 | context->audio_subid; break; } context->pes_table[2].stream_id = 0xbd; context->pes_table[2].substream_id = 0x20 | context->spu_subid; } context->pes_table_count = sizeof(gPesTable)/sizeof(struct PesEntry_type); context->output_table = (struct Output_type *) RMMalloc(sizeof(gPesOutputTable)); if (context->output_table == NULL) { return RM_FATALOUTOFMEMORY; } RMMemcpy(context->output_table, gPesOutputTable, sizeof(gPesOutputTable)); context->output_table_count = sizeof(gPesOutputTable)/sizeof(struct Output_type); RMDBGLOG((ENABLE, "\nprogram_stream_parsing application\n")); } return RM_OK;}void TTXCallback(RMuint8 *pBuffer1, RMuint32 size1, RMuint8 *pBuffer2, RMuint32 size2, RMstatus err, RMuint32 mask, void *context_in){ struct context_per_task *context = (struct context_per_task *)context_in; if( context->dcc_info->ttx_sw_decoder ) { RMstatus err = RMTTXDecode( context->dcc_info->ttx_sw_decoder, pBuffer1, size1 ); if( RMFAILED(err) ) { // flush the buffer and start filling buffer again RMTTXFlush( context->dcc_info->ttx_sw_decoder ); } } else RMDBGLOG((ENABLE, "No TTX DECODER\n")); return;}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -