1 /* 2 * Simple MPEG/DVB parser to achieve network/service information without initial tuning data 3 * 4 * Copyright (C) 2006 - 2014 Winfried Koehler 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 20 */ 21 22 #ifndef __SI_TYPES_H 23 #define __SI_TYPES_H 24 25 #include <stdint.h> 26 #include "descriptors.h" 27 #include "tools.h" 28 29 /******************************************************************************* 30 * section buffer 31 ******************************************************************************/ 32 33 #define SECTION_FLAG_DEFAULT (1U) << 0 34 #define SECTION_FLAG_INITIAL (1U) << 1 35 #define SECTION_FLAG_FREE (1U) << 2 36 #define SECTION_BUF_SIZE 4096 37 38 struct section_buf { 39 /*----------------------------*/ 40 void *prev; 41 void *next; 42 uint32_t index; 43 /*----------------------------*/ 44 const char *dmx_devname; 45 unsigned int run_once:1; 46 unsigned int segmented:1; // segmented by table_id_ext 47 int fd; 48 int pid; 49 int table_id; 50 int table_id_ext; 51 int section_version_number; 52 uint8_t section_done[32]; 53 int sectionfilter_done; 54 unsigned char buf[SECTION_BUF_SIZE]; 55 uint32_t flags; 56 time_t timeout; 57 time_t start_time; 58 time_t running_time; 59 struct section_buf *next_seg; // this is used to handle segmented tables (like NIT-other) 60 pList garbage; 61 }; 62 63 /******************************************************************************* 64 * service type. 65 ******************************************************************************/ 66 67 #define AUDIO_CHAN_MAX (32) 68 #define AC3_CHAN_MAX (32) 69 #define CA_SYSTEM_ID_MAX (32) 70 #define SUBTITLES_MAX (32) 71 72 struct transponder; 73 struct service { 74 /*----------------------------*/ 75 void *prev; 76 void *next; 77 uint32_t index; 78 /*----------------------------*/ 79 struct transponder *transponder; 80 uint16_t transport_stream_id; 81 uint16_t service_id; 82 char *provider_name; 83 char *provider_short_name; 84 char *service_name; 85 char *service_short_name; 86 uint16_t pmt_pid; 87 uint16_t pcr_pid; 88 uint16_t video_pid; 89 uint8_t video_stream_type; 90 uint16_t audio_pid[AUDIO_CHAN_MAX]; 91 uint8_t audio_stream_type[AUDIO_CHAN_MAX]; 92 char audio_lang[AUDIO_CHAN_MAX][4]; 93 int audio_num; 94 uint16_t ca_id[CA_SYSTEM_ID_MAX]; 95 int ca_num; 96 uint16_t teletext_pid; 97 uint16_t subtitling_pid[SUBTITLES_MAX]; 98 char subtitling_lang[SUBTITLES_MAX][4]; 99 uint8_t subtitling_type[SUBTITLES_MAX]; 100 uint16_t composition_page_id[SUBTITLES_MAX]; 101 uint16_t ancillary_page_id[SUBTITLES_MAX]; 102 int subtitling_num; 103 uint16_t ac3_pid[AC3_CHAN_MAX]; 104 uint8_t ac3_stream_type[AC3_CHAN_MAX]; 105 char ac3_lang[AC3_CHAN_MAX][4]; 106 int ac3_num; 107 unsigned int type:8; 108 bool scrambled; 109 bool visible_service; 110 uint32_t logical_channel_number; 111 uint8_t running; 112 void *priv; 113 }; 114 115 /******************************************************************************* 116 * transponder type. 117 ******************************************************************************/ 118 119 struct transposer { 120 uint8_t cell_id_extension; 121 uint32_t transposer_frequency; 122 }; 123 124 struct cell { 125 /*----------------------------*/ 126 void *prev; 127 void *next; 128 uint32_t index; 129 /*----------------------------*/ 130 uint16_t cell_id; 131 132 // if TFS: up to 6 RF freqs. 133 int num_center_frequencies; 134 uint32_t center_frequencies[6]; 135 136 int num_transposers; 137 struct transposer transposers[16]; 138 }; 139 140 struct transponder { 141 /*----------------------------*/ 142 void *prev; 143 void *next; 144 uint32_t index; 145 pList services; 146 cList _services; 147 pList cells; /* DVB-T/T2 */ 148 cList _cells; 149 /*----------------------------- starting from here copied by 'copy_fe_params' ------------------------------------------*/ 150 /* NOTE: 'frequency' needs to be first item - dont touch! */ 151 uint32_t frequency; /* unit Hz, except satellite: kHz 1..4 */ 152 fe_spectral_inversion_t inversion:8; /* 5 */ 153 uint32_t symbolrate; /* symbols per second 6..9 */ 154 uint32_t bandwidth; /* Hz 10..13 */ 155 uint16_t orbital_position; /* 0x0000-0x1800 14..15 */ 156 uint8_t input_stream_identifier; /* ISI 8bit. 16 */ 157 fe_delivery_system_t delsys:6; /* 0..18 -> 5 -> 6 (63) 17 */ 158 fe_polarization_t polarization:2; /* H,V,L,R 0..3 -> 2 -> 2 (3) 17 */ 159 fe_modulation_t modulation:6; /* 0..13 -> 4 -> 6 (63) 18 */ 160 fe_pilot_t pilot:2; /* pilot, on, off, auto 0..2 -> 2 -> 2 (3) 18 */ 161 fe_code_rate_t coderate:7; /* code rate 0..12 -> 4 -> 7 (127) 19 */ 162 fe_code_rate_t coderate_LP:7; /* code rate low priority stream 0..12 -> 4 -> 7 (127) 19..20 */ 163 fe_guard_interval_t guard:7; /* 0..10 -> 4 -> 7 (127) 20..21 */ 164 fe_rolloff_t rolloff:3; /* 0.35, 0.25, 0.20, auto 0..3 -> 2 -> 3 (7) 21 */ 165 fe_transmit_mode_t transmission:7; /* 0..8 -> 4 -> 7 (127) 22 */ 166 fe_west_east_flag_t west_east_flag:1; /* east, west 0..1 -> 1 -> 1 (1) 22 */ 167 fe_hierarchy_t hierarchy:4; /* 0..4 -> 3 -> 4 (15) 23 */ 168 unsigned time_slicing:2; /* only defined in w_scan2. 0..2 -> 2 -> 2 (3) 23 */ 169 unsigned scrambling_sequence_index:18; /* not yet in use. 23..25 */ 170 unsigned scrambling_sequence_selector:1; /* on/off 0..1 -> 1 26 */ 171 unsigned multiple_input_stream_flag:1; /* on/off 0..1 -> 1 26 */ 172 fe_frequency_type_t C2_tuning_frequency_type:2; /* 0..2 0..2 -> 2 -> 2 (3) 26 */ 173 fe_ofdm_symbol_duration_t active_OFDM_symbol_duration:2; /* 26 */ 174 fe_alpha_t alpha:2; /* only defined in w_scan2 26 */ 175 fe_interleave_t terr_interleaver:2; /* only defined in w_scan2 27 */ 176 unsigned priority:1; /* only defined in w_scan2 27 */ 177 unsigned mpe_fec:1; /* 27 */ 178 unsigned extended_info:1; /* 27 */ 179 unsigned SISO_MISO:1; /* 1 = multiple input single output 27 */ 180 unsigned locks_with_params:1; /* do we get lock with current tp params? 27 */ 181 unsigned reserved_byte27:1; /* align to byte. 27 */ 182 unsigned tfs_flag:1; /* 1 if Time-Frequency-Slicing 28 */ 183 unsigned other_frequency_flag:1; /* DVB-T/T2 28 */ 184 unsigned last_tuning_failed:1; /* 28 */ 185 unsigned type:5; /* 3bit + 2bit byte_align 28 */ 186 uint32_t source; /* 29..32 */ 187 uint16_t system_id; /* DVB-C2, DVB-T2 system_id 33..34 */ 188 uint8_t plp_id; /* DVB-C2, DVB-T2 35 */ 189 uint8_t data_slice_id; /* DVB-C2 36 */ 190 /*---------------------------- below is not copied by 'copy_fe_params' -------------------------------------------------*/ 191 uint8_t private_from_here; 192 /*----------------------------*/ 193 uint16_t network_PID; // which PID contains NIT ? (0x0010..0x1FFE) 194 uint16_t network_id; 195 uint16_t original_network_id; 196 uint16_t transport_stream_id; 197 /*----------------------------*/ 198 char *network_name; 199 network_change_t network_change; 200 }; 201 202 /******************************************************************************* 203 * satellite channel routing type. 204 ******************************************************************************/ 205 206 struct scr { 207 uint16_t user_frequency; // 20140101: DVB-S/S2, satellite channel routing 208 uint8_t slot; // 50494: 0..7 , 50607: 0..31 209 uint8_t pos; // 50494: 0..1 , 50607: 0..0xCC 210 uint16_t pin; // 50494: 0..255, 50607: 0..255 211 int8_t offset; // 50494: -2..+2, 50607: 0 212 uint8_t norm; // 50494: 1 , 50607: 2 213 }; 214 215 #endif 216