From 18bf344ae94f7e2e6179a94e4ff138a75d54c2b3 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 15 Jan 2012 21:41:48 -0200 Subject: [PATCH] dvbv5-scan: Fix report for non-PAT service ID's Noticed several scrambled channels on my DVB-C network that don't appear properly at PAT/PMT tables. Probably, some other table is needed (CAT?). Anyway, fix the output of such services. Signed-off-by: Mauro Carvalho Chehab --- utils/dvb/dvb-file.c | 51 ++++++++++++++++++++++++++++---------------------- utils/dvb/dvbv5-scan.c | 6 +++--- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/utils/dvb/dvb-file.c b/utils/dvb/dvb-file.c index 7da20a7..dabae8b 100644 --- a/utils/dvb/dvb-file.c +++ b/utils/dvb/dvb-file.c @@ -706,7 +706,7 @@ int store_dvb_channel(struct dvb_file **dvb_file, int get_detected, int get_nit) { struct dvb_entry *entry; - int i, j; + int i, j, has_detected = 1; if (!*dvb_file) { *dvb_file = calloc(sizeof(*dvb_file), 1); @@ -761,29 +761,36 @@ int store_dvb_channel(struct dvb_file **dvb_file, break; } if (j == pat_table->pid_table_len) { - fprintf(stderr, "Service ID 0x%04x not found!\n", + fprintf(stderr, "Service ID %d not found on PMT!\n", service_table->service_id); - return -1; + has_detected = 0; + } else has_detected = 1; + + /* + * Video/audio/other pid's can only be filled if the service + * was found. + */ + if (has_detected) { + entry->video_pid = calloc(sizeof(*entry[i].video_pid), + pid_table->video_pid_len); + for (j = 0; j < pid_table->video_pid_len; j++) + entry->video_pid[j] = pid_table->video_pid[j]; + entry->video_pid_len = pid_table->video_pid_len; + + entry->audio_pid = calloc(sizeof(*entry[i].audio_pid), + pid_table->audio_pid_len); + for (j = 0; j < pid_table->audio_pid_len; j++) + entry->audio_pid[j] = pid_table->audio_pid[j]; + entry->audio_pid_len = pid_table->audio_pid_len; + + entry->other_el_pid = calloc(sizeof(*entry->other_el_pid), + pid_table->other_el_pid_len); + memcpy(entry->other_el_pid, pid_table->other_el_pid, + pid_table->other_el_pid_len * sizeof(*entry->other_el_pid)); + entry->other_el_pid_len = pid_table->other_el_pid_len; + qsort(entry->other_el_pid, entry->other_el_pid_len, + sizeof(*entry->other_el_pid), sort_other_el_pid); } - entry->video_pid = calloc(sizeof(*entry[i].video_pid), - pid_table->video_pid_len); - for (j = 0; j < pid_table->video_pid_len; j++) - entry->video_pid[j] = pid_table->video_pid[j]; - entry->video_pid_len = pid_table->video_pid_len; - - entry->audio_pid = calloc(sizeof(*entry[i].audio_pid), - pid_table->audio_pid_len); - for (j = 0; j < pid_table->audio_pid_len; j++) - entry->audio_pid[j] = pid_table->audio_pid[j]; - entry->audio_pid_len = pid_table->audio_pid_len; - - entry->other_el_pid = calloc(sizeof(*entry->other_el_pid), - pid_table->other_el_pid_len); - memcpy(entry->other_el_pid, pid_table->other_el_pid, - pid_table->other_el_pid_len * sizeof(*entry->other_el_pid)); - entry->other_el_pid_len = pid_table->other_el_pid_len; - qsort(entry->other_el_pid, entry->other_el_pid_len, - sizeof(*entry->other_el_pid), sort_other_el_pid); /* Copy data from parms */ if (get_detected) diff --git a/utils/dvb/dvbv5-scan.c b/utils/dvb/dvbv5-scan.c index e850a60..b63bb25 100644 --- a/utils/dvb/dvbv5-scan.c +++ b/utils/dvb/dvbv5-scan.c @@ -388,10 +388,10 @@ static int run_scan(struct arguments *args, struct service_table *service_table = &dvb_desc->sdt_table.service_table[i]; entry->vchannel = dvb_vchannel(dvb_desc, i); + printf("Service #%d (%d)", i, + service_table->service_id); if (service_table->service_name) - printf("Service #%d: %s", i, service_table->service_name); - else - printf("Service #%d", i); + printf(" %s", service_table->service_name); if (entry->vchannel) printf(" channel %s", entry->vchannel); printf("\n"); -- 2.7.4