Add a -prog <n> option to tsreport -b

This lets us get reports on programs other than the 1st in the PAT.  In
the fullness of time we should report on all programs by default but for
now this will do.
master
John Cox 2012-07-09 15:13:33 +01:00
rodzic cf0483fdce
commit 12b7b5c3a0
4 zmienionych plików z 40 dodań i 12 usunięć

34
ts.c
Wyświetl plik

@ -3513,6 +3513,7 @@ extern int find_next_pmt(TS_reader_p tsreader,
* programs, 1 if something else went wrong.
*/
extern int find_pmt(TS_reader_p tsreader,
const int req_prog_no,
int max,
int verbose,
int quiet,
@ -3523,6 +3524,7 @@ extern int find_pmt(TS_reader_p tsreader,
pidint_list_p prog_list = NULL;
int sofar;
int prog_index = 0;
int prog_no = 0;
*pmt = NULL;
@ -3552,16 +3554,30 @@ extern int find_pmt(TS_reader_p tsreader,
return -2;
}
else if (prog_list->length > 1 && !quiet)
print_msg("Multiple programs in PAT - using the first non-zero\n\n");
while (prog_list->number[prog_index] == 0)
{
if (++prog_index >= prog_list->length)
{
if (!quiet)
fprint_msg("No non-zero program_numbers in PAT (packet %d)\n",sofar);
return -2;
}
if (req_prog_no == 1)
print_msg("Multiple programs in PAT - using the first non-zero\n\n");
else
fprint_msg("Multiple programs in PAT - program %d\n\n", req_prog_no);
}
for (prog_index = 0; prog_index < prog_list->length; ++prog_index)
{
if (prog_list->number[prog_index] == 0)
continue;
if (++prog_no == req_prog_no)
break;
}
if (prog_no == 0)
{
fprint_msg("No non-zero program_numbers in PAT (packet %d)\n",sofar);
return -2;
}
if (prog_no != req_prog_no)
{
fprint_msg("Unable to find program %d in PAT, only found %d (packet %d)\n", req_prog_no, prog_no, sofar);
return -2;
}
// Amend max to take account of the packets we've already read

2
ts2es.c 100644 → 100755
Wyświetl plik

@ -322,7 +322,7 @@ static int extract_av(int input,
if (max > 0 && max_to_read <= 0)
break;
err = find_pmt(tsreader,max_to_read,verbose,quiet,&num_read,&pmt);
err = find_pmt(tsreader, 1, max_to_read,verbose,quiet,&num_read,&pmt);
if (err == EOF)
{
if (!quiet)

1
ts_fns.h 100644 → 100755
Wyświetl plik

@ -780,6 +780,7 @@ extern int find_next_pmt(TS_reader_p tsreader,
* programs, 1 if something else went wrong.
*/
extern int find_pmt(TS_reader_p tsreader,
const int req_prog_no,
int max,
int verbose,
int quiet,

Wyświetl plik

@ -206,6 +206,7 @@ avg_rate_add(avg_rate_t * ar, uint64_t time, uint64_t bytes)
* Returns 0 if all went well, 1 if something went wrong.
*/
static int report_buffering_stats(TS_reader_p tsreader,
const int req_prog_no,
int max,
int verbose,
int quiet,
@ -286,7 +287,7 @@ static int report_buffering_stats(TS_reader_p tsreader,
}
// First we need to determine what we're taking our data from.
err = find_pmt(tsreader,max,FALSE,quiet,&pmt_at,&pmt);
err = find_pmt(tsreader, req_prog_no, max,FALSE,quiet,&pmt_at,&pmt);
if (err) return 1;
pcr_pid = pmt->PCR_pid;
@ -1257,6 +1258,8 @@ static void print_usage()
" Writes all the values of the counter to a file called\n"
" 'continuity_counter.txt'. Turns buffering on (-b).\n"
" -max <n>, -m <n> Maximum number of TS packets to read\n"
" -prog <n> Report on program <n> [default = 1]\n"
" (hopefully default will be 'all' in the future)\n"
"\n"
"Single PID:\n"
" -justpid <pid> Just show data (file offset, index, adaptation field\n"
@ -1298,6 +1301,7 @@ int main(int argc, char **argv)
int show_data = FALSE;
char *output_name = NULL;
uint32_t continuity_cnt_pid = INVALID_PID;
int req_prog_no = 1;
uint64_t report_mask = ~0; // report as many bits as we get
@ -1425,6 +1429,13 @@ int main(int argc, char **argv)
use_stdin = TRUE;
had_input_name = TRUE; // so to speak
}
else if (!strcmp("-prog",argv[ii]))
{
CHECKARG("tsreport",ii);
err = int_value("tsreport",argv[ii],argv[ii+1],TRUE,10,&req_prog_no);
if (err) return 1;
ii++;
}
else
{
fprint_err("### tsreport: "
@ -1469,7 +1480,7 @@ int main(int argc, char **argv)
if (select_pid)
err = report_single_pid(tsreader,max,quiet,just_pid);
else if (report_buffering)
err = report_buffering_stats(tsreader,max,verbose,quiet,
err = report_buffering_stats(tsreader,req_prog_no,max,verbose,quiet,
output_name,continuity_cnt_pid,report_mask);
else
err = report_ts(tsreader,max,verbose,show_data,report_timing);