| 1 |
/* |
| 2 |
* Copyright (c) 2011-2012 - Mauro Carvalho Chehab |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU Lesser General Public License as published by |
| 6 |
* the Free Software Foundation version 2.1 of the License. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public License |
| 14 |
* along with this program; if not, write to the Free Software |
| 15 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 16 |
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
| 17 |
*/ |
| 18 |
|
| 19 |
#include <stdio.h> |
| 20 |
#include <stdlib.h> |
| 21 |
#include <string.h> |
| 22 |
|
| 23 |
#include <libdvbv5/dvb-file.h> |
| 24 |
#include <libdvbv5/dvb-v5-std.h> |
| 25 |
|
| 26 |
#define PTABLE(a) .table = a, .size=ARRAY_SIZE(a) |
| 27 |
|
| 28 |
/* |
| 29 |
* Standard channel.conf format for DVB-T, DVB-C, DVB-S, DVB-S2 and ATSC |
| 30 |
*/ |
| 31 |
static const char *channel_parse_modulation[] = { |
| 32 |
[APSK_16] = "16APSK", |
| 33 |
[APSK_32] = "32APSK", |
| 34 |
[DQPSK] = "DQPSK", |
| 35 |
[PSK_8] = "8PSK", |
| 36 |
[QAM_16] = "QAM16", |
| 37 |
[QAM_32] = "QAM32", |
| 38 |
[QAM_64] = "QAM64", |
| 39 |
[QAM_128] = "QAM128", |
| 40 |
[QAM_256] = "QAM256", |
| 41 |
[QAM_AUTO] = "AUTO", |
| 42 |
[QPSK] = "QPSK", |
| 43 |
[VSB_8] = "8VSB", |
| 44 |
[VSB_16] = "16VSB", |
| 45 |
}; |
| 46 |
|
| 47 |
static const char *channel_parse_bandwidth[] = { |
| 48 |
[BANDWIDTH_1_712_MHZ] = "1.712MHz", |
| 49 |
[BANDWIDTH_5_MHZ] = "5MHz", |
| 50 |
[BANDWIDTH_6_MHZ] = "6MHz", |
| 51 |
[BANDWIDTH_7_MHZ] = "7MHz", |
| 52 |
[BANDWIDTH_8_MHZ] = "8MHz", |
| 53 |
[BANDWIDTH_10_MHZ] = "10MHz", |
| 54 |
[BANDWIDTH_AUTO] = "AUTO", |
| 55 |
}; |
| 56 |
|
| 57 |
static const char *channel_parse_trans_mode[] = { |
| 58 |
[TRANSMISSION_MODE_1K] = "1k", |
| 59 |
[TRANSMISSION_MODE_2K] = "2k", |
| 60 |
[TRANSMISSION_MODE_4K] = "4k", |
| 61 |
[TRANSMISSION_MODE_8K] = "8k", |
| 62 |
[TRANSMISSION_MODE_16K] = "16k", |
| 63 |
[TRANSMISSION_MODE_32K] = "32k", |
| 64 |
[TRANSMISSION_MODE_AUTO] = "AUTO", |
| 65 |
}; |
| 66 |
|
| 67 |
static const char *channel_parse_code_rate[12] = { |
| 68 |
[FEC_1_2] = "1/2", |
| 69 |
[FEC_2_3] = "2/3", |
| 70 |
[FEC_3_4] = "3/4", |
| 71 |
[FEC_3_5] = "3/5", |
| 72 |
[FEC_4_5] = "4/5", |
| 73 |
[FEC_5_6] = "5/6", |
| 74 |
[FEC_6_7] = "6/7", |
| 75 |
[FEC_7_8] = "7/8", |
| 76 |
[FEC_8_9] = "8/9", |
| 77 |
[FEC_9_10] = "9/10", |
| 78 |
[FEC_AUTO] = "AUTO", |
| 79 |
[FEC_NONE] = "NONE", |
| 80 |
}; |
| 81 |
|
| 82 |
static const char *channel_parse_guard_interval[] = { |
| 83 |
[GUARD_INTERVAL_1_4] = "1/4", |
| 84 |
[GUARD_INTERVAL_1_8] = "1/8", |
| 85 |
[GUARD_INTERVAL_1_16] = "1/16", |
| 86 |
[GUARD_INTERVAL_1_32] = "1/32", |
| 87 |
[GUARD_INTERVAL_1_128] = "1/128", |
| 88 |
[GUARD_INTERVAL_19_128] = "19/128", |
| 89 |
[GUARD_INTERVAL_19_256] = "19/256", |
| 90 |
[GUARD_INTERVAL_AUTO] = "AUTO", |
| 91 |
}; |
| 92 |
|
| 93 |
static const char *channel_parse_hierarchy[] = { |
| 94 |
[HIERARCHY_1] = "1", |
| 95 |
[HIERARCHY_2] = "2", |
| 96 |
[HIERARCHY_4] = "4", |
| 97 |
[HIERARCHY_AUTO] = "AUTO", |
| 98 |
[HIERARCHY_NONE] = "NONE", |
| 99 |
}; |
| 100 |
|
| 101 |
static const char *channel_parse_polarization[] = { |
| 102 |
[POLARIZATION_OFF] = "-", |
| 103 |
[POLARIZATION_H] = "H", |
| 104 |
[POLARIZATION_V] = "V", |
| 105 |
[POLARIZATION_L] = "L", |
| 106 |
[POLARIZATION_R] = "R", |
| 107 |
}; |
| 108 |
|
| 109 |
static const char *channel_parse_rolloff[] = { |
| 110 |
[ROLLOFF_20] = "20", |
| 111 |
[ROLLOFF_25] = "25", |
| 112 |
[ROLLOFF_35] = "35", |
| 113 |
[ROLLOFF_AUTO] = "AUTO", |
| 114 |
}; |
| 115 |
|
| 116 |
static const struct dvb_parse_table sys_atsc_table[] = { |
| 117 |
{ DTV_FREQUENCY, NULL, 0 }, |
| 118 |
{ DTV_MODULATION, PTABLE(channel_parse_modulation) }, |
| 119 |
}; |
| 120 |
|
| 121 |
static const struct dvb_parse_table sys_dvbc_table[] = { |
| 122 |
{ DTV_FREQUENCY, NULL, 0 }, |
| 123 |
{ DTV_SYMBOL_RATE, NULL, 0 }, |
| 124 |
{ DTV_INNER_FEC, PTABLE(channel_parse_code_rate) }, |
| 125 |
{ DTV_MODULATION, PTABLE(channel_parse_modulation) }, |
| 126 |
}; |
| 127 |
|
| 128 |
/* Note: On DVB-S, frequency is divided by 1000 */ |
| 129 |
static const struct dvb_parse_table sys_dvbs_table[] = { |
| 130 |
{ DTV_FREQUENCY, NULL, 0 }, |
| 131 |
{ DTV_POLARIZATION, PTABLE(channel_parse_polarization) }, |
| 132 |
{ DTV_SYMBOL_RATE, NULL, 0 }, |
| 133 |
{ DTV_INNER_FEC, PTABLE(channel_parse_code_rate) }, |
| 134 |
}; |
| 135 |
|
| 136 |
static const struct dvb_parse_table sys_dvbs2_table[] = { |
| 137 |
{ DTV_FREQUENCY, NULL, 0 }, |
| 138 |
{ DTV_POLARIZATION, PTABLE(channel_parse_polarization) }, |
| 139 |
{ DTV_SYMBOL_RATE, NULL, 0 }, |
| 140 |
{ DTV_INNER_FEC, PTABLE(channel_parse_code_rate) }, |
| 141 |
{ DTV_ROLLOFF, PTABLE(channel_parse_rolloff) }, |
| 142 |
{ DTV_MODULATION, PTABLE(channel_parse_modulation) }, |
| 143 |
{ DTV_STREAM_ID, NULL, 0, 0, 1, 0 }, |
| 144 |
{ DTV_PLS_CODE, NULL, 0, 0, 1, -1 }, |
| 145 |
{ DTV_PLS_MODE, NULL, 0, 0, 1, -1 }, |
| 146 |
}; |
| 147 |
|
| 148 |
static const struct dvb_parse_table sys_dvbt_table[] = { |
| 149 |
{ DTV_FREQUENCY, NULL, 0 }, |
| 150 |
{ DTV_BANDWIDTH_HZ, PTABLE(channel_parse_bandwidth) }, |
| 151 |
{ DTV_CODE_RATE_HP, PTABLE(channel_parse_code_rate) }, |
| 152 |
{ DTV_CODE_RATE_LP, PTABLE(channel_parse_code_rate) }, |
| 153 |
{ DTV_MODULATION, PTABLE(channel_parse_modulation) }, |
| 154 |
{ DTV_TRANSMISSION_MODE, PTABLE(channel_parse_trans_mode) }, |
| 155 |
{ DTV_GUARD_INTERVAL, PTABLE(channel_parse_guard_interval) }, |
| 156 |
{ DTV_HIERARCHY, PTABLE(channel_parse_hierarchy) }, |
| 157 |
}; |
| 158 |
|
| 159 |
static const struct dvb_parse_table sys_dvbt2_table[] = { |
| 160 |
{ DTV_FREQUENCY, NULL, 0 }, |
| 161 |
{ DTV_BANDWIDTH_HZ, PTABLE(channel_parse_bandwidth) }, |
| 162 |
{ DTV_CODE_RATE_HP, PTABLE(channel_parse_code_rate) }, |
| 163 |
{ DTV_CODE_RATE_LP, PTABLE(channel_parse_code_rate) }, |
| 164 |
{ DTV_MODULATION, PTABLE(channel_parse_modulation) }, |
| 165 |
{ DTV_TRANSMISSION_MODE, PTABLE(channel_parse_trans_mode) }, |
| 166 |
{ DTV_GUARD_INTERVAL, PTABLE(channel_parse_guard_interval) }, |
| 167 |
{ DTV_HIERARCHY, PTABLE(channel_parse_hierarchy) }, |
| 168 |
{ DTV_STREAM_ID, NULL, 0, 0, 1, -1 }, |
| 169 |
}; |
| 170 |
|
| 171 |
const struct dvb_parse_file channel_file_format = { |
| 172 |
.has_delsys_id = 1, |
| 173 |
.delimiter = " \n\t", |
| 174 |
.formats = { |
| 175 |
{ |
| 176 |
.id = "A", |
| 177 |
.delsys = SYS_ATSC, |
| 178 |
PTABLE(sys_atsc_table), |
| 179 |
}, { |
| 180 |
.id = "C", |
| 181 |
.delsys = SYS_DVBC_ANNEX_A, |
| 182 |
PTABLE(sys_dvbc_table), |
| 183 |
}, { |
| 184 |
.id = "S", |
| 185 |
.delsys = SYS_DVBS, |
| 186 |
PTABLE(sys_dvbs_table), |
| 187 |
}, { |
| 188 |
.id = "S2", |
| 189 |
.delsys = SYS_DVBS2, |
| 190 |
PTABLE(sys_dvbs2_table), |
| 191 |
}, { |
| 192 |
.id = "T", |
| 193 |
.delsys = SYS_DVBT, |
| 194 |
PTABLE(sys_dvbt_table), |
| 195 |
}, { |
| 196 |
.id = "T2", |
| 197 |
.delsys = SYS_DVBT2, |
| 198 |
PTABLE(sys_dvbt2_table), |
| 199 |
}, { |
| 200 |
NULL, 0, NULL, 0, |
| 201 |
} |
| 202 |
} |
| 203 |
}; |