⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atsc_vct.c

📁 Dvbstreamer 用在解析MPTS的部分内容
💻 C
📖 第 1 页 / 共 2 页
字号:
/*Copyright (C) 2006  Adam CharrettThis program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USAvct.cDecode PSIP Virtual Channel Table.*/#include "config.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <stdint.h>#include "dvbpsi.h"#include "dvbpsi_private.h"#include "psi.h"#include "descriptor.h"#include "demux.h"#include "atsc/vct.h"#include "objects.h"typedef struct dvbpsi_atsc_vct_decoder_s{  dvbpsi_atsc_vct_callback      pf_callback;  void *                        p_cb_data;  dvbpsi_atsc_vct_t             current_vct;  dvbpsi_atsc_vct_t *           p_building_vct;  int                           b_current_valid;  uint8_t                       i_last_section_number;  dvbpsi_psi_section_t *        ap_sections [256];} dvbpsi_atsc_vct_decoder_t;dvbpsi_descriptor_t *dvbpsi_atsc_VCTAddDescriptor(                                               dvbpsi_atsc_vct_t *p_vct,                                               uint8_t i_tag, uint8_t i_length,                                               uint8_t *p_data);dvbpsi_atsc_vct_channel_t *dvbpsi_atsc_VCTAddChannel(dvbpsi_atsc_vct_t* p_vct,                                            uint8_t *p_short_name,                                            uint16_t i_major_number,                                            uint16_t i_minor_number,                                            uint8_t  i_modulation,                                            uint32_t i_carrier_freq,                                            uint16_t i_channel_tsid,                                            uint16_t i_program_number,                                            uint8_t  i_etm_location,                                            int      b_access_controlled,                                            int      b_hidden,                                            int      b_path_select,                                            int      b_out_of_band,                                            int      b_hide_guide,                                            uint8_t  i_service_type,                                            uint16_t i_source_id);dvbpsi_descriptor_t *dvbpsi_atsc_VCTChannelAddDescriptor(                                               dvbpsi_atsc_vct_channel_t *p_table,                                               uint8_t i_tag, uint8_t i_length,                                               uint8_t *p_data);void dvbpsi_atsc_GatherVCTSections(dvbpsi_decoder_t * p_psi_decoder,                              void * p_private_decoder,                              dvbpsi_psi_section_t * p_section);void dvbpsi_atsc_DecodeVCTSections(dvbpsi_atsc_vct_t* p_vct,                              dvbpsi_psi_section_t* p_section);/***************************************************************************** * dvbpsi_atsc_AttachVCT ***************************************************************************** * Initialize a VCT subtable decoder. *****************************************************************************/int dvbpsi_atsc_AttachVCT(dvbpsi_decoder_t * p_psi_decoder, uint8_t i_table_id, uint16_t i_extension,                          dvbpsi_atsc_vct_callback pf_callback, void* p_cb_data){  dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_psi_decoder->p_private_decoder;  dvbpsi_demux_subdec_t* p_subdec;  dvbpsi_atsc_vct_decoder_t*  p_vct_decoder;  unsigned int i;  if(dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))  {    DVBPSI_ERROR_ARG("VCT decoder",                     "Already a decoder for (table_id == 0x%02x extension == 0x%04x)",                     i_table_id, i_extension);    return 1;  }  p_subdec = (dvbpsi_demux_subdec_t*)malloc(sizeof(dvbpsi_demux_subdec_t));  if(p_subdec == NULL)  {    return 1;  }  p_vct_decoder = (dvbpsi_atsc_vct_decoder_t*)malloc(sizeof(dvbpsi_atsc_vct_decoder_t));  if(p_vct_decoder == NULL)  {    free(p_subdec);    return 1;  }  /* subtable decoder configuration */  p_subdec->pf_callback = &dvbpsi_atsc_GatherVCTSections;  p_subdec->p_cb_data = p_vct_decoder;  p_subdec->i_id = ((uint32_t)i_table_id << 16) | i_extension;  p_subdec->pf_detach = dvbpsi_atsc_DetachVCT;  /* Attach the subtable decoder to the demux */  p_subdec->p_next = p_demux->p_first_subdec;  p_demux->p_first_subdec = p_subdec;  /* VCT decoder information */  p_vct_decoder->pf_callback = pf_callback;  p_vct_decoder->p_cb_data = p_cb_data;  /* VCT decoder initial state */  p_vct_decoder->b_current_valid = 0;  p_vct_decoder->p_building_vct = NULL;  for(i = 0; i <= 255; i++)    p_vct_decoder->ap_sections[i] = NULL;  return 0;}/***************************************************************************** * dvbpsi_atsc_DetachVCT ***************************************************************************** * Close a VCT decoder. *****************************************************************************/void dvbpsi_atsc_DetachVCT(dvbpsi_demux_t * p_demux, uint8_t i_table_id, uint16_t i_extension){  dvbpsi_demux_subdec_t* p_subdec;  dvbpsi_demux_subdec_t** pp_prev_subdec;  dvbpsi_atsc_vct_decoder_t* p_vct_decoder;  unsigned int i;  p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);  if(p_demux == NULL)  {    DVBPSI_ERROR_ARG("VCT Decoder",                     "No such VCT decoder (table_id == 0x%02x,"                     "extension == 0x%04x)",                     i_table_id, i_extension);    return;  }  p_vct_decoder = (dvbpsi_atsc_vct_decoder_t*)p_subdec->p_cb_data;  if (p_vct_decoder->p_building_vct)  {    ObjectRefDec(p_vct_decoder->p_building_vct);  }  for(i = 0; i <= 255; i++)  {    if(p_vct_decoder->ap_sections[i])      dvbpsi_DeletePSISections(p_vct_decoder->ap_sections[i]);  }  free(p_subdec->p_cb_data);  pp_prev_subdec = &p_demux->p_first_subdec;  while(*pp_prev_subdec != p_subdec)    pp_prev_subdec = &(*pp_prev_subdec)->p_next;  *pp_prev_subdec = p_subdec->p_next;  free(p_subdec);}/***************************************************************************** * dvbpsi_atsc_InitVCT ***************************************************************************** * Initialize a pre-allocated dvbpsi_atsc_vct_t structure. *****************************************************************************/void dvbpsi_atsc_InitVCT(dvbpsi_atsc_vct_t* p_vct,uint8_t i_version, int b_current_next,                       uint8_t i_protocol, uint16_t i_ts_id, int b_cable_vct){  p_vct->i_version = i_version;  p_vct->b_current_next = b_current_next;  p_vct->i_protocol = i_protocol;  p_vct->i_ts_id = i_ts_id;  p_vct->b_cable_vct = b_cable_vct;  p_vct->p_first_channel = NULL;  p_vct->p_first_descriptor = NULL;}/***************************************************************************** * dvbpsi_atsc_EmptyVCT ***************************************************************************** * Clean a dvbpsi_atsc_vct_t structure. *****************************************************************************/void dvbpsi_atsc_EmptyVCT(dvbpsi_atsc_vct_t* p_vct){  dvbpsi_atsc_vct_channel_t* p_channel = p_vct->p_first_channel;  while(p_channel != NULL)  {    dvbpsi_atsc_vct_channel_t* p_tmp = p_channel->p_next;    dvbpsi_DeleteDescriptors(p_channel->p_first_descriptor);    free(p_channel);    p_channel = p_tmp;  }  dvbpsi_DeleteDescriptors(p_vct->p_first_descriptor);      p_vct->p_first_channel = NULL;  p_vct->p_first_descriptor = NULL;}/***************************************************************************** * dvbpsi_atsc_VCTAddDescriptor ***************************************************************************** * Add a descriptor to the VCT table. *****************************************************************************/dvbpsi_descriptor_t *dvbpsi_atsc_VCTAddDescriptor(                                               dvbpsi_atsc_vct_t *p_vct,                                               uint8_t i_tag, uint8_t i_length,                                               uint8_t *p_data){  dvbpsi_descriptor_t * p_descriptor                        = dvbpsi_NewDescriptor(i_tag, i_length, p_data);  if(p_descriptor)  {    if(p_vct->p_first_descriptor == NULL)    {      p_vct->p_first_descriptor = p_descriptor;    }    else    {      dvbpsi_descriptor_t * p_last_descriptor = p_vct->p_first_descriptor;      while(p_last_descriptor->p_next != NULL)        p_last_descriptor = p_last_descriptor->p_next;      p_last_descriptor->p_next = p_descriptor;    }  }  return p_descriptor;}/***************************************************************************** * dvbpsi_atsc_VCTAddChannel ***************************************************************************** * Add a Channel description at the end of the VCT. *****************************************************************************/dvbpsi_atsc_vct_channel_t *dvbpsi_atsc_VCTAddChannel(dvbpsi_atsc_vct_t* p_vct,                                            uint8_t *p_short_name,                                            uint16_t i_major_number,                                            uint16_t i_minor_number,                                            uint8_t  i_modulation,                                            uint32_t i_carrier_freq,                                            uint16_t i_channel_tsid,                                            uint16_t i_program_number,                                            uint8_t  i_etm_location,                                            int      b_access_controlled,                                            int      b_hidden,                                            int      b_path_select,                                            int      b_out_of_band,                                            int      b_hide_guide,                                            uint8_t  i_service_type,                                            uint16_t i_source_id){  dvbpsi_atsc_vct_channel_t * p_channel                = (dvbpsi_atsc_vct_channel_t*)malloc(sizeof(dvbpsi_atsc_vct_channel_t));  if(p_channel)  {    memcpy(p_channel->i_short_name, p_short_name, sizeof(uint16_t) * 7);    p_channel->i_major_number = i_major_number;    p_channel->i_minor_number = i_minor_number;    p_channel->i_modulation = i_modulation;    p_channel->i_carrier_freq = i_carrier_freq;    p_channel->i_channel_tsid = i_channel_tsid;    p_channel->i_program_number = i_program_number;    p_channel->i_etm_location = i_etm_location;    p_channel->b_access_controlled = b_access_controlled;    p_channel->b_path_select = b_path_select;    p_channel->b_out_of_band = b_out_of_band;    p_channel->b_hidden = b_hidden;    p_channel->b_hide_guide = b_hide_guide;    p_channel->i_service_type = i_service_type;    p_channel->i_source_id = i_source_id;        p_channel->p_first_descriptor = NULL;    p_channel->p_next = NULL;    if(p_vct->p_first_channel== NULL)    {      p_vct->p_first_channel = p_channel;    }    else

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -