diff --git a/src/lib_ccx/params_dump.c b/src/lib_ccx/params_dump.c index 8063721a8..a7552bc02 100644 --- a/src/lib_ccx/params_dump.c +++ b/src/lib_ccx/params_dump.c @@ -424,6 +424,27 @@ void print_file_report_json(struct lib_ccx_ctx *ctx) pid, demux->PIDs_programs[pid]->program_number); json_escape(desc[demux->PIDs_programs[pid]->printable_stream_type]); + + /* Tag DVB subtitle and Teletext PIDs */ + int is_dvb = 0, is_tlt = 0; + for (int k = 0; k < SUB_STREAMS_CNT; k++) + { + if (demux->freport.dvb_sub_pid[k] == (unsigned)pid) + { + is_dvb = 1; + break; + } + if (demux->freport.tlt_sub_pid[k] == (unsigned)pid) + { + is_tlt = 1; + break; + } + } + if (is_dvb) + printf(", \"type\": \"dvb_subtitle\""); + else if (is_tlt) + printf(", \"type\": \"teletext_subtitle\""); + printf(" }"); } printf("\n ]\n"); @@ -501,6 +522,19 @@ void print_file_report_json(struct lib_ccx_ctx *ctx) (program_ci && get_sib_stream_by_type(program_ci, CCX_CODEC_ATSC_CC)) ? "true" : "false"); printf(" },\n"); + /* Teletext seen pages */ + if (program_ci && get_sib_stream_by_type(program_ci, CCX_CODEC_TELETEXT)) + { + struct cap_info *tlt_info = get_sib_stream_by_type(program_ci, CCX_CODEC_TELETEXT); + struct lib_cc_decode *tlt_dec = update_decoder_list_cinfo(ctx, tlt_info); + if (tlt_dec && tlt_dec->codec == CCX_CODEC_TELETEXT) + { + printf(" \"teletext_pages\": "); + tlt_print_seen_pages_json(tlt_dec); + printf(",\n"); + } + } + printf(" \"captions\": {\n"); printf(" \"present\": %s,\n", has_any_captions ? "true" : "false"); diff --git a/src/lib_ccx/teletext.h b/src/lib_ccx/teletext.h index 79dcbed5b..21d7c40ac 100644 --- a/src/lib_ccx/teletext.h +++ b/src/lib_ccx/teletext.h @@ -133,6 +133,7 @@ struct TeletextCtx }; int tlt_print_seen_pages(struct lib_cc_decode *dec_ctx); +int tlt_print_seen_pages_json(struct lib_cc_decode *dec_ctx); void telxcc_dump_prev_page(struct TeletextCtx *ctx, struct cc_subtitle *sub); void set_tlt_delta(struct lib_cc_decode *dec_ctx, uint64_t pts); #endif diff --git a/src/lib_ccx/telxcc.c b/src/lib_ccx/telxcc.c index bcb0a051f..fa7def610 100644 --- a/src/lib_ccx/telxcc.c +++ b/src/lib_ccx/telxcc.c @@ -1357,6 +1357,33 @@ int tlt_print_seen_pages(struct lib_cc_decode *dec_ctx) } return CCX_OK; } + +int tlt_print_seen_pages_json(struct lib_cc_decode *dec_ctx) +{ + struct TeletextCtx *ctx = NULL; + + if (dec_ctx->codec != CCX_CODEC_TELETEXT) + { + errno = EINVAL; + return -1; + } + + ctx = dec_ctx->private_data; + + printf("["); + int first = 1; + for (int i = 0; i < MAX_TLT_PAGES; i++) + { + if (ctx->seen_sub_page[i] == 0) + continue; + if (!first) + printf(", "); + first = 0; + printf("%d", i); + } + printf("]"); + return CCX_OK; +} void set_tlt_delta(struct lib_cc_decode *dec_ctx, uint64_t pts) { struct TeletextCtx *ctx = dec_ctx->private_data;