Commit d9611864 authored by Marton Balint's avatar Marton Balint

ffprobe: add support for printing packet strings metadata as packet tags

ffprobe.xsd already contains the tag element.
Reviewed-by: 's avatarStefano Sabatini <stefasab@gmail.com>
Signed-off-by: 's avatarMarton Balint <cus@passwd.hu>
parent 47af5db7
...@@ -77,6 +77,7 @@ static int do_show_format_tags = 0; ...@@ -77,6 +77,7 @@ static int do_show_format_tags = 0;
static int do_show_frame_tags = 0; static int do_show_frame_tags = 0;
static int do_show_program_tags = 0; static int do_show_program_tags = 0;
static int do_show_stream_tags = 0; static int do_show_stream_tags = 0;
static int do_show_packet_tags = 0;
static int show_value_unit = 0; static int show_value_unit = 0;
static int use_value_prefix = 0; static int use_value_prefix = 0;
...@@ -135,6 +136,7 @@ typedef enum { ...@@ -135,6 +136,7 @@ typedef enum {
SECTION_ID_LIBRARY_VERSION, SECTION_ID_LIBRARY_VERSION,
SECTION_ID_LIBRARY_VERSIONS, SECTION_ID_LIBRARY_VERSIONS,
SECTION_ID_PACKET, SECTION_ID_PACKET,
SECTION_ID_PACKET_TAGS,
SECTION_ID_PACKETS, SECTION_ID_PACKETS,
SECTION_ID_PACKETS_AND_FRAMES, SECTION_ID_PACKETS_AND_FRAMES,
SECTION_ID_PACKET_SIDE_DATA_LIST, SECTION_ID_PACKET_SIDE_DATA_LIST,
...@@ -178,7 +180,8 @@ static struct section sections[] = { ...@@ -178,7 +180,8 @@ static struct section sections[] = {
[SECTION_ID_LIBRARY_VERSION] = { SECTION_ID_LIBRARY_VERSION, "library_version", 0, { -1 } }, [SECTION_ID_LIBRARY_VERSION] = { SECTION_ID_LIBRARY_VERSION, "library_version", 0, { -1 } },
[SECTION_ID_PACKETS] = { SECTION_ID_PACKETS, "packets", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PACKET, -1} }, [SECTION_ID_PACKETS] = { SECTION_ID_PACKETS, "packets", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PACKET, -1} },
[SECTION_ID_PACKETS_AND_FRAMES] = { SECTION_ID_PACKETS_AND_FRAMES, "packets_and_frames", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PACKET, -1} }, [SECTION_ID_PACKETS_AND_FRAMES] = { SECTION_ID_PACKETS_AND_FRAMES, "packets_and_frames", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PACKET, -1} },
[SECTION_ID_PACKET] = { SECTION_ID_PACKET, "packet", 0, { SECTION_ID_PACKET_SIDE_DATA_LIST, -1 } }, [SECTION_ID_PACKET] = { SECTION_ID_PACKET, "packet", 0, { SECTION_ID_PACKET_TAGS, SECTION_ID_PACKET_SIDE_DATA_LIST, -1 } },
[SECTION_ID_PACKET_TAGS] = { SECTION_ID_PACKET_TAGS, "tags", SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "packet_tags" },
[SECTION_ID_PACKET_SIDE_DATA_LIST] ={ SECTION_ID_PACKET_SIDE_DATA_LIST, "side_data_list", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PACKET_SIDE_DATA, -1 } }, [SECTION_ID_PACKET_SIDE_DATA_LIST] ={ SECTION_ID_PACKET_SIDE_DATA_LIST, "side_data_list", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PACKET_SIDE_DATA, -1 } },
[SECTION_ID_PACKET_SIDE_DATA] = { SECTION_ID_PACKET_SIDE_DATA, "side_data", 0, { -1 } }, [SECTION_ID_PACKET_SIDE_DATA] = { SECTION_ID_PACKET_SIDE_DATA, "side_data", 0, { -1 } },
[SECTION_ID_PIXEL_FORMATS] = { SECTION_ID_PIXEL_FORMATS, "pixel_formats", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PIXEL_FORMAT, -1 } }, [SECTION_ID_PIXEL_FORMATS] = { SECTION_ID_PIXEL_FORMATS, "pixel_formats", SECTION_FLAG_IS_ARRAY, { SECTION_ID_PIXEL_FORMAT, -1 } },
...@@ -1762,6 +1765,16 @@ static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pk ...@@ -1762,6 +1765,16 @@ static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pk
if (pkt->side_data_elems) { if (pkt->side_data_elems) {
int i; int i;
int size;
const uint8_t *side_metadata;
side_metadata = av_packet_get_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA, &size);
if (side_metadata && size && do_show_packet_tags) {
AVDictionary *dict = NULL;
if (av_packet_unpack_dictionary(side_metadata, size, &dict) >= 0)
show_tags(w, dict, SECTION_ID_PACKET_TAGS);
av_dict_free(&dict);
}
writer_print_section_header(w, SECTION_ID_PACKET_SIDE_DATA_LIST); writer_print_section_header(w, SECTION_ID_PACKET_SIDE_DATA_LIST);
for (i = 0; i < pkt->side_data_elems; i++) { for (i = 0; i < pkt->side_data_elems; i++) {
AVPacketSideData *sd = &pkt->side_data[i]; AVPacketSideData *sd = &pkt->side_data[i];
...@@ -3177,6 +3190,7 @@ int main(int argc, char **argv) ...@@ -3177,6 +3190,7 @@ int main(int argc, char **argv)
SET_DO_SHOW(FRAME_TAGS, frame_tags); SET_DO_SHOW(FRAME_TAGS, frame_tags);
SET_DO_SHOW(PROGRAM_TAGS, program_tags); SET_DO_SHOW(PROGRAM_TAGS, program_tags);
SET_DO_SHOW(STREAM_TAGS, stream_tags); SET_DO_SHOW(STREAM_TAGS, stream_tags);
SET_DO_SHOW(PACKET_TAGS, packet_tags);
if (do_bitexact && (do_show_program_version || do_show_library_versions)) { if (do_bitexact && (do_show_program_version || do_show_library_versions)) {
av_log(NULL, AV_LOG_ERROR, av_log(NULL, AV_LOG_ERROR,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment