static void _show_pip_metadata(MPLS_PL *pl, int level) { int ii; for (ii = 0; ii < pl->ext_pip_data_count; ii++) { MPLS_PIP_METADATA *data; data = &pl->ext_pip_data[ii]; indent_printf(level, "PiP metadata block %d:", ii); _show_pip_metadata_block(data, level+1); } }
static void _show_sub_paths(MPLS_PL *pl, int level) { int ss; for (ss = 0; ss < pl->sub_count; ss++) { MPLS_SUB *sub; sub = &pl->sub_path[ss]; indent_printf(level, "Sub Path %d:", ss); _show_sub_path(sub, level+1); } }
static void _show_prog_info(CLPI_PROG_INFO *pi, int level) { CLPI_PROG *prog; int ii, jj; indent_printf(level, "Program Info"); indent_printf(level+1, "Number Programs: %d", pi->num_prog); for (ii = 0; ii < pi->num_prog; ii++) { prog = &pi->progs[ii]; indent_printf(level+1, "Program %d", ii); indent_printf(level+2, "SPN Program Sequence Start: %d", prog->spn_program_sequence_start); indent_printf(level+2, "Program Map PID: %d", prog->program_map_pid); indent_printf(level+2, "Number Streams: %d", prog->num_streams); indent_printf(level+2, "Number Groups: %d", prog->num_groups); for (jj = 0; jj < prog->num_streams; jj++) { indent_printf(level+2, "Stream %d", jj); _show_stream(&prog->streams[jj], level+3); } } }
int main(int argc, char *argv[]) { CLPI_CL *cl; int opt; int opt_clip_info = 0, opt_seq_info = 0, opt_prog_info = 0; int opt_cpi_info = 0, opt_extent_start = 0; int ii; do { opt = getopt(argc, argv, OPTS); switch (opt) { case -1: break; case 'v': verbose = 1; break; case 's': opt_seq_info = 1; break; case 'i': opt_cpi_info = 1; break; case 'c': opt_clip_info = 1; break; case 'p': opt_prog_info = 1; break; case 'e': opt_extent_start = 1; break; default: _usage(argv[0]); break; } } while (opt != -1); if (optind >= argc) { _usage(argv[0]); } for (ii = optind; ii < argc; ii++) { cl = clpi_parse(argv[ii]); if (cl == NULL) { fprintf(stderr, "Parse failed\n"); continue; } if (opt_clip_info) { // Show clip info _show_clip_info(&cl->clip, 1); } if (opt_seq_info) { // Show sequence info _show_seq_info(&cl->sequence, 1); } if (opt_prog_info) { // Show program info _show_prog_info(&cl->program, 1); } if (opt_cpi_info) { // Show cpi _show_cpi_info(&cl->cpi, 1); } if (opt_prog_info) { if (cl->program_ss.num_prog) { printf("\n"); indent_printf(1, "Extension: Program Info SS"); _show_prog_info(&cl->program_ss, 1); } } if (opt_cpi_info) { if (cl->program_ss.num_prog) { printf("\n"); indent_printf(1, "Extension: CPI SS"); _show_cpi_info(&cl->cpi_ss, 1); } } if (opt_extent_start) { // Show extent start point if (cl->extent_start.num_point > 0) { _show_extent_start(&cl->extent_start, 1); } } clpi_free(cl); } return 0; }
static void _show_cpi_info(CLPI_CPI *cpi, int level) { CLPI_EP_MAP_ENTRY *entry; CLPI_EP_COARSE *coarse; CLPI_EP_FINE *fine; int ii, jj, kk; indent_printf(level, "CPI"); indent_printf(level+1, "Number Stream PID: %d", cpi->num_stream_pid); for (ii = 0; ii < cpi->num_stream_pid; ii++) { entry = &cpi->entry[ii]; indent_printf(level+1, "Stream: %d", ii); indent_printf(level+2, "PID: %04x", entry->pid); indent_printf(level+2, "EP Stream Type: %d", entry->ep_stream_type); indent_printf(level+2, "Number EP Coarse: %d", entry->num_ep_coarse); indent_printf(level+2, "Number EP Fine: %d", entry->num_ep_fine); indent_printf(level+2, "EP Map Start: %d", entry->ep_map_stream_start_addr); for (jj = 0; jj < entry->num_ep_coarse; jj++) { coarse = &entry->coarse[jj]; indent_printf(level+2, "Coarse: %d", jj); indent_printf(level+3, "Ref EP Fine: %d", coarse->ref_ep_fine_id); indent_printf(level+3, "PTS EP: %d", coarse->pts_ep); indent_printf(level+3, "SPN EP: %d", coarse->spn_ep); } for (jj = 0; jj < entry->num_ep_fine; jj++) { fine = &entry->fine[jj]; indent_printf(level+2, "Fine: %d", jj); indent_printf(level+3, "Angle Change Point: %s", fine->is_angle_change_point ? "True":"False"); indent_printf(level+3, "I End Offset: %d", fine->i_end_position_offset); indent_printf(level+3, "PTS EP: %d", fine->pts_ep); indent_printf(level+3, "SPN EP: %d", fine->spn_ep); } if (verbose) { uint64_t pts; uint32_t spn; indent_printf(level+2, "PTS - SPN Map"); for (jj = 0; jj < entry->num_ep_coarse; jj++) { int start, end; indent_printf(level+3, "Coarse: %d", jj); coarse = &entry->coarse[jj]; start = coarse->ref_ep_fine_id; if (jj < entry->num_ep_coarse - 1) { end = entry->coarse[jj+1].ref_ep_fine_id; } else { end = entry->num_ep_fine; } for (kk = start; kk < end; kk++) { fine = &entry->fine[kk]; pts = ((uint64_t) (coarse->pts_ep & ~0x01) << 19) + ((uint64_t)fine->pts_ep << 9); spn = (coarse->spn_ep & ~0x1FFFF) + fine->spn_ep; indent_printf(level+4, "PTS %8"PRIu64"/%8"PRIu64" -- SPN %u", pts, pts >> 1, spn); } } } } }
static void _show_seq_info(CLPI_SEQ_INFO *si, int level) { CLPI_ATC_SEQ *atc; CLPI_STC_SEQ *stc; int ii, jj; indent_printf(level, "Sequence Info"); indent_printf(level+1, "Number ATC Sequences: %d", si->num_atc_seq); for (ii = 0; ii < si->num_atc_seq; ii++) { atc = &si->atc_seq[ii]; indent_printf(level+1, "ATC Sequence %d", ii); indent_printf(level+2, "SPN ATC Start: %u", atc->spn_atc_start); indent_printf(level+2, "Offset STC Id: %d", atc->offset_stc_id); indent_printf(level+2, "Number STC Sequences: %d", atc->num_stc_seq); for (jj = 0; jj < atc->num_stc_seq; jj++) { stc = &atc->stc_seq[jj]; indent_printf(level+2, "ATC Sequence %d", jj); indent_printf(level+3, "SPN STC Start: %u", stc->spn_stc_start); indent_printf(level+3, "PCR PID: %04x", stc->pcr_pid); indent_printf(level+3, "Presentation Start: %u", stc->presentation_start_time); indent_printf(level+3, "Presentation End: %u", stc->presentation_end_time); } } }
static void _show_clip_info(CLPI_CLIP_INFO *ci, int level) { int ii; indent_printf(level, "Clip Info"); indent_printf(level+1, "Clip Stream Type: %02x", ci->clip_stream_type); indent_printf(level+1, "Clip Application Type: %02x", ci->application_type); indent_printf(level+1, "is_ATC_delta: %s", ci->is_atc_delta ? "True" : "False"); indent_printf(level+1, "ATC delta count: %d", ci->atc_delta_count); indent_printf(level+1, "TS Recording Rate: %u", ci->ts_recording_rate); indent_printf(level+1, "Number Source Packets: %u", ci->num_source_packets); // Show ts type info indent_printf(level+1, "TS Type Info"); indent_printf(level+2, "Validity Flags %02x", ci->ts_type_info.validity); indent_printf(level+2, "Format Id %s", ci->ts_type_info.format_id); // Show cc5 thing for (ii = 0; ii < ci->atc_delta_count; ii++) { indent_printf(level+1, "ATC delta[ %d ]", ii); indent_printf(level+2, "Delta %08x", ci->atc_delta[ii].delta); indent_printf(level+2, "File Id %s", ci->atc_delta[ii].file_id); indent_printf(level+2, "File Code %s", ci->atc_delta[ii].file_code); } printf("\n"); }
static void _show_stream(CLPI_PROG_STREAM *ss, int level) { indent_printf(level, "Codec (%04x): %s", ss->coding_type, _lookup_str(codec_map, ss->coding_type)); indent_printf(level, "PID: %04x", ss->pid); switch (ss->coding_type) { case 0x01: case 0x02: case 0xea: case 0x1b: case 0x20: indent_printf(level, "Format %02x: %s", ss->format, _lookup_str(video_format_map, ss->format)); indent_printf(level, "Rate %02x: %s", ss->rate, _lookup_str(video_rate_map, ss->rate)); indent_printf(level, "Aspect %02x: %s", ss->aspect, _lookup_str(video_aspect_map, ss->aspect)); indent_printf(level, "oc_flag %02x", ss->oc_flag); break; case 0x03: case 0x04: case 0x80: case 0x81: case 0x82: case 0x83: case 0x84: case 0x85: case 0x86: case 0xa1: case 0xa2: indent_printf(level, "Format %02x: %s", ss->format, _lookup_str(audio_format_map, ss->format)); indent_printf(level, "Rate %02x: %s", ss->rate, _lookup_str(audio_rate_map, ss->rate)); indent_printf(level, "Language: %s", ss->lang); break; case 0x90: case 0x91: case 0xa0: indent_printf(level, "Language: %s", ss->lang); break; case 0x92: indent_printf(level, "Char Code: %02x", ss->char_code); indent_printf(level, "Language: %s", ss->lang); break; default: fprintf(stderr, "unrecognized coding type %02x\n", ss->coding_type); break; }; }
static void _show_pip_metadata_block(MPLS_PIP_METADATA *block, int level) { int ii; indent_printf(level, "Clip ref: %d", block->clip_ref); indent_printf(level, "Secondary video ref: %d", block->secondary_video_ref); indent_printf(level, "Timeline type: %d", block->timeline_type); indent_printf(level, "Luma key flag: %d", block->luma_key_flag); if (block->luma_key_flag) { indent_printf(level, "Upper limit luma key: %d", block->upper_limit_luma_key); } indent_printf(level, "Trick play flag: %d", block->trick_play_flag); for (ii = 0; ii < block->data_count; ii++) { indent_printf(level, "data block %d:", ii); indent_printf(level+1, "Timestamp: %d", block->data[ii].time); indent_printf(level+1, "Horizontal position %d", block->data[ii].xpos); indent_printf(level+1, "Vertical position: %d", block->data[ii].ypos); indent_printf(level+1, "Scaling factor: %d", block->data[ii].scale_factor); } }
static void _show_sub_path(MPLS_SUB *sub, int level) { int ii; indent_printf(level+1, "Type: %d (%s)", sub->type, _lookup_str(subpath_type_map, sub->type)); indent_printf(level+1, "Repeat: %d", sub->is_repeat); indent_printf(level+1, "Sub playitem count: %d", sub->sub_playitem_count); for (ii = 0; ii < sub->sub_playitem_count; ii++) { MPLS_SUB_PI *pi; pi = &sub->sub_play_item[ii]; if (verbose) { indent_printf(level+1, "Sub playitem %d", ii); indent_printf(level+2, "Clip Id %s", pi->clip[0].clip_id); indent_printf(level+2, "Multi clip: %d", pi->is_multi_clip); indent_printf(level+2, "Clip count: %d", pi->clip_count); indent_printf(level+2, "Connection Condition: %s (%02x)", _lookup_str(connection_type_map, pi->connection_condition), pi->connection_condition); indent_printf(level+2, "In-Time: %d", pi->in_time); indent_printf(level+2, "Out-Time: %d", pi->out_time); indent_printf(level+2, "Sync playitem Id: %d", pi->sync_play_item_id); indent_printf(level+2, "Sync PTS: %d", pi->sync_pts); } else { indent_printf(level+1, "%s.m2ts", pi->clip[0].clip_id); } } }
static void _show_details(MPLS_PL *pl, int level) { int ii, jj, kk; for (ii = 0; ii < pl->list_count; ii++) { MPLS_PI *pi; pi = &pl->play_item[ii]; indent_printf(level, "Clip Id %s", pi->clip[0].clip_id); indent_printf(level+1, "Stc Id: %02x", pi->clip[0].stc_id); indent_printf(level+1, "Connection Condition: %s (%02x)", _lookup_str(connection_type_map, pi->connection_condition), pi->connection_condition); indent_printf(level+1, "In-Time: %d", pi->in_time); indent_printf(level+1, "Out-Time: %d", pi->out_time); if (pi->still_mode == 1) { indent_printf(level+1, "Still time: %ds\n", pi->still_time); } if (pi->still_mode == 2) { indent_printf(level+1, "Still time: infinite\n"); } if (pi->angle_count > 1) { for (jj = 1; jj < pi->angle_count; jj++) { indent_printf(level+1, "Angle %d:", jj); indent_printf(level+2, "Clip Id %s", pi->clip[jj].clip_id); indent_printf(level+2, "Stc Id: %02x", pi->clip[jj].stc_id); } } for (jj = 0; jj < pi->stn.num_video; jj++) { indent_printf(level+1, "Video Stream %d:", jj); _show_stream(&pi->stn.video[jj], level + 2); } for (jj = 0; jj < pi->stn.num_audio; jj++) { indent_printf(level+1, "Audio Stream %d:", jj); _show_stream(&pi->stn.audio[jj], level + 2); } for (jj = 0; jj < pi->stn.num_ig; jj++) { indent_printf(level+1, "Interactive Graphics Stream %d:", jj); _show_stream(&pi->stn.ig[jj], level + 2); } for (jj = 0; jj < (pi->stn.num_pg + pi->stn.num_pip_pg); jj++) { if (jj < pi->stn.num_pg) { indent_printf(level+1, "Presentation Graphics Stream %d:", jj); } else { indent_printf(level+1, "PIP Presentation Graphics Stream %d:", jj); } _show_stream(&pi->stn.pg[jj], level + 2); } for (jj = 0; jj < pi->stn.num_secondary_video; jj++) { indent_printf(level+1, "Secondary Video Stream %d:", jj); _show_stream(&pi->stn.secondary_video[jj], level + 2); for (kk = 0; kk < pi->stn.secondary_video[jj].sv_num_secondary_audio_ref; kk++) { indent_printf(level+2, "Secondary Audio Ref %d: %d", kk,pi->stn.secondary_video[jj].sv_secondary_audio_ref[kk]); } for (kk = 0; kk < pi->stn.secondary_video[jj].sv_num_pip_pg_ref; kk++) { indent_printf(level+2, "PIP Presentation Graphic Ref %d: %d", kk,pi->stn.secondary_video[jj].sv_pip_pg_ref[kk]); } } for (jj = 0; jj < pi->stn.num_secondary_audio; jj++) { indent_printf(level+1, "Secondary Audio Stream %d:", jj); _show_stream(&pi->stn.secondary_audio[jj], level + 2); for (kk = 0; kk < pi->stn.secondary_audio[jj].sa_num_primary_audio_ref; kk++) { indent_printf(level+2, "Primary Audio Ref %d: %d", kk,pi->stn.secondary_audio[jj].sa_primary_audio_ref[kk]); } } printf("\n"); } }
static void _show_stream(MPLS_STREAM *ss, int level) { indent_printf(level, "Codec (%04x): %s", ss->coding_type, _lookup_str(codec_map, ss->coding_type)); switch (ss->stream_type) { case 1: indent_printf(level, "PID: %04x", ss->pid); break; case 2: case 4: indent_printf(level, "SubPath Id: %02x", ss->subpath_id); indent_printf(level, "SubClip Id: %02x", ss->subclip_id); indent_printf(level, "PID: %04x", ss->pid); break; case 3: indent_printf(level, "SubPath Id: %02x", ss->subpath_id); indent_printf(level, "PID: %04x", ss->pid); break; default: fprintf(stderr, "unrecognized stream type %02x\n", ss->stream_type); break; }; switch (ss->coding_type) { case 0x01: case 0x02: case 0xea: case 0x1b: indent_printf(level, "Format %02x: %s", ss->format, _lookup_str(video_format_map, ss->format)); indent_printf(level, "Rate %02x: %s", ss->rate, _lookup_str(video_rate_map, ss->rate)); break; case 0x03: case 0x04: case 0x80: case 0x81: case 0x82: case 0x83: case 0x84: case 0x85: case 0x86: case 0xa1: case 0xa2: indent_printf(level, "Format %02x: %s", ss->format, _lookup_str(audio_format_map, ss->format)); indent_printf(level, "Rate %02x: %s", ss->rate, _lookup_str(audio_rate_map, ss->rate)); indent_printf(level, "Language: %s", ss->lang); break; case 0x90: case 0x91: indent_printf(level, "Language: %s", ss->lang); break; case 0x92: indent_printf(level, "Char Code: %02x", ss->char_code); indent_printf(level, "Language: %s", ss->lang); break; default: fprintf(stderr, "unrecognized coding type %02x\n", ss->coding_type); break; }; }
static int process(const char *uri, const UI_METHOD *uimeth, PW_CB_DATA *uidata, int text, int noout, int recursive, int indent, BIO *out) { OSSL_STORE_CTX *store_ctx = NULL; int ret = 1, items = 0; if ((store_ctx = OSSL_STORE_open(uri, uimeth, uidata, NULL, NULL)) == NULL) { BIO_printf(bio_err, "Couldn't open file or uri %s\n", uri); ERR_print_errors(bio_err); return ret; } /* From here on, we count errors, and we'll return the count at the end */ ret = 0; for (;;) { OSSL_STORE_INFO *info = OSSL_STORE_load(store_ctx); int type = info == NULL ? 0 : OSSL_STORE_INFO_get_type(info); const char *infostr = info == NULL ? NULL : OSSL_STORE_INFO_type_string(type); if (info == NULL) { if (OSSL_STORE_eof(store_ctx)) break; if (OSSL_STORE_error(store_ctx)) { if (recursive) ERR_clear_error(); else ERR_print_errors(bio_err); ret++; continue; } BIO_printf(bio_err, "ERROR: OSSL_STORE_load() returned NULL without " "eof or error indications\n"); BIO_printf(bio_err, " This is an error in the loader\n"); ERR_print_errors(bio_err); ret++; break; } if (type == OSSL_STORE_INFO_NAME) { const char *name = OSSL_STORE_INFO_get0_NAME(info); const char *desc = OSSL_STORE_INFO_get0_NAME_description(info); indent_printf(indent, bio_out, "%d: %s: %s\n", items, infostr, name); if (desc != NULL) indent_printf(indent, bio_out, "%s\n", desc); } else { indent_printf(indent, bio_out, "%d: %s\n", items, infostr); } /* * Unfortunately, PEM_X509_INFO_write_bio() is sorely lacking in * functionality, so we must figure out how exactly to write things * ourselves... */ switch (type) { case OSSL_STORE_INFO_NAME: if (recursive) { const char *suburi = OSSL_STORE_INFO_get0_NAME(info); ret += process(suburi, uimeth, uidata, text, noout, recursive, indent + 2, out); } break; case OSSL_STORE_INFO_PARAMS: if (text) EVP_PKEY_print_params(out, OSSL_STORE_INFO_get0_PARAMS(info), 0, NULL); if (!noout) PEM_write_bio_Parameters(out, OSSL_STORE_INFO_get0_PARAMS(info)); break; case OSSL_STORE_INFO_PKEY: if (text) EVP_PKEY_print_private(out, OSSL_STORE_INFO_get0_PKEY(info), 0, NULL); if (!noout) PEM_write_bio_PrivateKey(out, OSSL_STORE_INFO_get0_PKEY(info), NULL, NULL, 0, NULL, NULL); break; case OSSL_STORE_INFO_CERT: if (text) X509_print(out, OSSL_STORE_INFO_get0_CERT(info)); if (!noout) PEM_write_bio_X509(out, OSSL_STORE_INFO_get0_CERT(info)); break; case OSSL_STORE_INFO_CRL: if (text) X509_CRL_print(out, OSSL_STORE_INFO_get0_CRL(info)); if (!noout) PEM_write_bio_X509_CRL(out, OSSL_STORE_INFO_get0_CRL(info)); break; default: BIO_printf(bio_err, "!!! Unknown code\n"); ret++; break; } items++; OSSL_STORE_INFO_free(info); } indent_printf(indent, out, "Total found: %d\n", items); if (!OSSL_STORE_close(store_ctx)) { ERR_print_errors(bio_err); ret++; } return ret; }