1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
|
/*
* Simple MPEG/DVB parser to achieve network/service information without initial tuning data
*
* Copyright (C) 2006, 2007, 2008, 2009, 2011 Winfried Koehler
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of 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 of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* The author can be reached at: handygewinnspiel AT gmx DOT de
*
* The project's page is http://wirbel.htpc-forum.de/w_scan/index2.html
*/
/* 20110702 --wk */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "scan.h"
#include "extended_frontend.h"
#include "dump-vdr.h"
#include "satellites.h"
struct cTr {
const char * sat_name;
const char * vdr_sat_name;
};
static struct cTr translations[] = {
{ "S4E8", "S5E"},
{ "S7E0", "S7E"},
{ "S9E0", "S9E"},
{ "S10E0", "S10E"},
{ "S13E0", "S13E"},
{ "S16E0", "S16E"},
{ "S19E2", "S19.2E"},
{ "S21E6", "S21.6E"},
{ "S23E5", "S23.5E"},
{ "S25E5", "S25.5E"},
{ "S26EX", "S26E"},
{ "S28E2", "S28.2E"},
{ "S28E5", "S28.5E"},
{ "S31E5", "S31.5E"},
{ "S32E9", "S33E"},
{ "S33E0", "S33E"},
{ "S35E9", "S36E"},
{ "S36E0", "S36E"},
{ "S38E0", "S38E"},
{ "S39E0", "S39E"},
{ "S40EX", "S40E"},
{ "S42E0", "S42E"},
{ "S45E0", "S45E"},
{ "S49E0", "S49E"},
{ "S53E0", "S53E"},
{ "S57E0", "S56E"},
{ "S57EX", "S57E"},
{ "S60EX", "S60E"},
{ "S62EX", "S62E"},
{ "S64E2", "S64E"},
{ "S68EX", "S68.5E"},
{ "S70E5", "S70.5E"},
{ "S72EX", "S72E"},
{ "S75EX", "S75E"},
{ "S76EX", "S76.5E"},
{ "S78E5", "S78.5E"},
{ "S80EX", "S80E"},
{ "S83EX", "S83E"},
{ "S87E5", "S87.5E"},
{ "S88EX", "S88E"},
{ "S90EX", "S90E"},
{ "S91E5", "S91.5E"},
{ "S93E5", "S93.5E"},
{ "S95E0", "S95E"},
{ "S96EX", "S96.5E"},
{"S100EX","S100.5E"},
{"S105EX","S105.5E"},
{"S108EX", "S108E"},
{"S140EX", "S140E"},
{"S160E0", "S160E"},
{ "S0W8", "S1W"},
{ "S4W0", "S4W"},
{ "S5WX", "S5W"},
{ "S7W0", "S7W"},
{ "S8W0", "S8W"},
{ "S11WX", "S11W"},
{ "S12W5", "S12.5W"},
{ "S14W0", "S14W"},
{ "S15W0", "S15W"},
{ "S18WX", "S18W"},
{ "S22WX", "S22W"},
{ "S24WX", "S24.5W"},
{ "S27WX", "S27.5W"},
{ "S30W0", "S30W"}};
#define TR_COUNT(x) (sizeof(x)/sizeof(struct cTr))
/******************************************************************************
* translate short names used by w_scan into VDR satellite identifiers.
*
*****************************************************************************/
static const char * short_name_to_vdr_name(const char * satname) {
unsigned int i;
for (i = 0; i < TR_COUNT(translations); i++)
if (! strcmp(satname, translations[i].sat_name))
return translations[i].vdr_sat_name;
return satname; //fallback.
}
/******************************************************************************
* translate VDR satellite identifiers into short names used by w_scan.
*
*****************************************************************************/
const char * vdr_name_to_short_name(const char * satname) {
unsigned int i;
for (i = 0; i < TR_COUNT(translations); i++)
if (! strcmp(satname, translations[i].vdr_sat_name))
return translations[i].sat_name;
return "unknown satellite"; //fallback.
}
/******************************************************************************
* translate linuxtv inversions to VDR inversion identifiers.
*
*****************************************************************************/
const char * vdr_inversion_name(int inversion) {
switch(inversion) {
case INVERSION_OFF: return "0";
case INVERSION_ON: return "1";
default: return "999";
}
}
/******************************************************************************
* translate linuxtv forw err corr to VDR fec identifiers.
*
*****************************************************************************/
const char * vdr_fec_name(int fec) {
switch(fec) {
case FEC_NONE: return "0";
case FEC_1_2: return "12";
case FEC_2_3: return "23";
case FEC_3_4: return "34";
case FEC_4_5: return "45";
case FEC_5_6: return "56";
case FEC_6_7: return "67";
case FEC_7_8: return "78";
case FEC_8_9: return "89";
case FEC_3_5: return "35";
case FEC_9_10: return "910";
default: return "999";
}
}
/******************************************************************************
* translate linuxtv modulation types to VDR > 1.7.0 identifiers.
*
*****************************************************************************/
const char * vdr_modulation_name(int modulation) {
switch(modulation) {
case QAM_16 : return "16";
case QAM_32 : return "32";
case QAM_64 : return "64";
case QAM_128 : return "128";
case QAM_256 : return "256";
case QAM_512 : return "512";
case QAM_1024 : return "1024";
case QAM_4096 : return "4096";
case QAM_AUTO : return "998";
case QPSK : return "2";
case PSK_8 : return "5";
case APSK_16 : return "6";
case APSK_32 : return "7";
case VSB_8 : return "10";
case VSB_16 : return "11";
case DQPSK : return "12";
default : return "999";
}
}
/******************************************************************************
* translate linuxtv bandwidth values to VDR identifiers.
*
*****************************************************************************/
const char * vdr_bandwidth_name (int bandwidth) {
switch(bandwidth) {
case 8000000 : return "8";
case 7000000 : return "7";
case 6000000 : return "6";
case 5000000 : return "5";
case 10000000 : return "10";
case 1712000 : return "1712";
default : return "999";
}
}
/******************************************************************************
* translate linuxtv tm values to VDR identifiers.
*
*****************************************************************************/
const char * vdr_transmission_mode_name (int transmission_mode) {
switch(transmission_mode) {
case TRANSMISSION_MODE_2K : return "2";
case TRANSMISSION_MODE_8K : return "8";
case TRANSMISSION_MODE_4K : return "4";
case TRANSMISSION_MODE_1K : return "1";
case TRANSMISSION_MODE_16K : return "16";
case TRANSMISSION_MODE_32K : return "32";
default : return "999";
}
}
/******************************************************************************
* translate linuxtv guard values to VDR identifiers.
*
*****************************************************************************/
const char * vdr_guard_name (int guard_interval) {
switch(guard_interval) {
case GUARD_INTERVAL_1_32 : return "32";
case GUARD_INTERVAL_1_16 : return "16";
case GUARD_INTERVAL_1_8 : return "8";
case GUARD_INTERVAL_1_4 : return "4";
case GUARD_INTERVAL_1_128 : return "128";
case GUARD_INTERVAL_19_128 : return "19128";
case GUARD_INTERVAL_19_256 : return "19256";
default : return "999";
}
}
/******************************************************************************
* translate linuxtv hierarchy values to VDR identifiers.
* what about alpha? hm..
*****************************************************************************/
const char * vdr_hierarchy_name (int hierarchy) {
switch(hierarchy) {
case HIERARCHY_NONE : return "0";
case HIERARCHY_1 : return "1";
case HIERARCHY_2 : return "2";
case HIERARCHY_4 : return "4";
default : return "999";
}
}
/******************************************************************************
* translate linuxtv rolloffs values to VDR identifiers.
*
*****************************************************************************/
const char * vdr_rolloff_name(int rolloff) {
switch(rolloff) {
case ROLLOFF_20 : return "20";
case ROLLOFF_25 : return "25";
default: return "35";
}
}
/******************************************************************************
* translate linuxtv delivery_system values to VDR identifiers.
*
*****************************************************************************/
const char * vdr_delsys_name(int delsys) {
switch(delsys) {
case SYS_DVBT :
case SYS_DVBS : return "0";
case SYS_DVBS2 :
case SYS_DVBT2 : return "1";
default: return "0";
}
}
/******************************************************************************
* print "frequency:<params>:symbolrate:" to 'f' in vdr >= 1.7.4 format
* NOTE: 1.7.0 .. 1.7.3 not supported here.
*****************************************************************************/
#define vdrprint(fd, Param, Default, ID, Value) if (Param != Default) fprintf(fd,"%s%s", ID, Value)
void dump_param_vdr(FILE * f, struct transponder * t, struct w_scan_flags * flags) {
struct tuning_parameters * p = &t->param;
switch (flags->scantype) {
case SCAN_TERRCABLE_ATSC:
fprintf (f, ":%i:", p->frequency / 1000);
fprintf (f, "M%s:A:", vdr_modulation_name(p->u.atsc.modulation));
fprintf (f, "%i:", p->u.cable.symbol_rate / 1000);
break;
case SCAN_CABLE:
fprintf (f, ":%i:", p->frequency / 1000);
fprintf (f, "M%s:C:", vdr_modulation_name(p->u.cable.modulation));
fprintf (f, "%i:", p->u.cable.symbol_rate / 1000);
break;
case SCAN_TERRESTRIAL:
fprintf (f, ":%i:", p->frequency / 1000);
vdrprint(f, p->u.terr.bandwidth , 0 , "B", vdr_bandwidth_name(p->u.terr.bandwidth));
vdrprint(f, p->u.terr.code_rate_HP , FEC_AUTO , "C", vdr_fec_name(p->u.terr.code_rate_HP));
vdrprint(f, p->u.terr.code_rate_LP , FEC_AUTO , "D", vdr_fec_name(p->u.terr.code_rate_LP));
vdrprint(f, p->u.terr.guard_interval , GUARD_INTERVAL_AUTO , "G", vdr_guard_name(p->u.terr.guard_interval));
vdrprint(f, p->inversion , INVERSION_AUTO , "I", vdr_inversion_name(p->inversion));
vdrprint(f, p->u.terr.constellation , QAM_AUTO , "M", vdr_modulation_name(p->u.terr.constellation));
vdrprint(f, p->u.terr.delivery_system , SYS_DVBT , "S", vdr_delsys_name(p->u.terr.delivery_system));
vdrprint(f, p->u.terr.transmission_mode , TRANSMISSION_MODE_AUTO , "T", vdr_transmission_mode_name(p->u.terr.transmission_mode));
vdrprint(f, p->u.terr.hierarchy_information, HIERARCHY_AUTO , "Y", vdr_hierarchy_name(p->u.terr.hierarchy_information));
if (p->u.terr.delivery_system == SYS_DVBT2)
fprintf (f, "P%u", t->pids.plp_id);
fprintf (f, ":T:27500:");
break;
case SCAN_SATELLITE:
fprintf (f, ":%i:", p->frequency / 1000);
switch (p->u.sat.polarization) {
case POLARIZATION_HORIZONTAL:
fprintf (f, "h");
break;
case POLARIZATION_VERTICAL:
fprintf (f, "v");
break;
case POLARIZATION_CIRCULAR_LEFT:
fprintf (f, "l");
break;
case POLARIZATION_CIRCULAR_RIGHT:
fprintf (f, "r");
break;
default:
fatal("Unknown Polarization %d\n", p->u.sat.polarization);
}
fprintf (f, "C%s", vdr_fec_name(p->u.sat.fec_inner));
switch (p->u.sat.modulation_system) {
case SYS_DVBS2:
fprintf (f, "M%sO%sS1:",
vdr_modulation_name(p->u.sat.modulation_type),
vdr_rolloff_name(p->u.sat.rolloff));
break;
default:
/* DVB-S always r = 0.35 according to specs
* but vdr specifies 'O0' here (should be O35),
* modulation is fix QPSK = 'M2'.
*/
fprintf (f, "M2O0S0:");
}
fprintf(f, "%s:",
short_name_to_vdr_name(satellite_to_short_name(flags->list_id)));
fprintf (f, "%i:", p->u.sat.symbol_rate / 1000);
break;
default:;
};
}
/******************************************************************************
* print complete vdr channels.conf line from service params.
*
*****************************************************************************/
void vdr_dump_service_parameter_set (FILE * f,
struct service * s,
struct transponder * t,
struct w_scan_flags * flags) {
int i;
if (! flags->ca_select && s->scrambled)
return;
fprintf (f, "%s", s->service_name);
if (flags->dump_provider)
fprintf (f, ";%s", s->provider_name);
dump_param_vdr(f, t, flags);
fprintf (f, "%i", s->video_pid);
if (s->video_pid && (s->pcr_pid != s->video_pid))
fprintf (f, "+%i", s->pcr_pid);
if (s->video_stream_type)
fprintf (f, "=%u", s->video_stream_type);
fprintf (f, ":");
fprintf (f, "%i", s->audio_pid[0]);
if (s->audio_lang && s->audio_lang[0][0])
fprintf (f, "=%.4s", s->audio_lang[0]);
if (s->audio_stream_type[0])
fprintf (f, "@%u", s->audio_stream_type[0]);
for (i = 1; i < s->audio_num; i++) {
fprintf (f, ",%i", s->audio_pid[i]);
if (s->audio_lang && s->audio_lang[i][0])
fprintf (f, "=%.4s", s->audio_lang[i]);
if (flags->vdr_version > 7)
if (s->audio_stream_type[i])
fprintf (f, "@%u", s->audio_stream_type[i]);
}
if (s->ac3_num) {
fprintf (f, "%s", ";");
for (i = 0; i < s->ac3_num; i++) {
if (i > 0)
fprintf (f, "%s", ",");
fprintf (f, "%i", s->ac3_pid[i]);
if (flags->vdr_version > 7)
if (s->ac3_lang && s->ac3_lang[i][0])
fprintf (f, "=%.4s", s->ac3_lang[i]);
}
}
fprintf (f, ":%d", s->teletext_pid);
// add subtitling here
if (s->subtitling_num) {
fprintf (f, "%s", ";");
for (i = 0; i < s->subtitling_num; i++) {
if (i > 0)
fprintf (f, "%s", ",");
fprintf (f, "%i", s->subtitling_pid[i]);
if (s->subtitling_lang && s->subtitling_lang[i][0])
fprintf (f, "=%.4s", s->subtitling_lang[i]);
}
}
fprintf (f, ":%X", s->ca_id[0]);
for (i = 1; i < s->ca_num; i++) {
if (s->ca_id[i] == 0) continue;
fprintf (f, ",%X", s->ca_id[i]);
}
fprintf (f, ":%d:%d:%d:0",
s->service_id,
(t->pids.transport_stream_id > 0)?t->pids.original_network_id:0,
t->pids.transport_stream_id);
if (flags->print_pmt) {
fprintf (f, ":%d", s->pmt_pid);
}
fprintf (f, "%s", "\n");
}
|