From 04f62588637f0ed095643b2d4da8c5e3194ce674 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 19 May 2022 11:06:31 +0300 Subject: [PATCH] qtdemux: Parse styp box for informational purposes And include some more details in the debug logs for the ftyp box too. Part-of: --- subprojects/gst-plugins-good/gst/isomp4/fourcc.h | 1 + subprojects/gst-plugins-good/gst/isomp4/qtdemux.c | 58 ++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-good/gst/isomp4/fourcc.h b/subprojects/gst-plugins-good/gst/isomp4/fourcc.h index 5be6921..70b219b 100644 --- a/subprojects/gst-plugins-good/gst/isomp4/fourcc.h +++ b/subprojects/gst-plugins-good/gst/isomp4/fourcc.h @@ -144,6 +144,7 @@ G_BEGIN_DECLS #define FOURCC_free GST_MAKE_FOURCC('f','r','e','e') #define FOURCC_frma GST_MAKE_FOURCC('f','r','m','a') #define FOURCC_ftyp GST_MAKE_FOURCC('f','t','y','p') +#define FOURCC_styp GST_MAKE_FOURCC('s','t','y','p') #define FOURCC_ftab GST_MAKE_FOURCC('f','t','a','b') #define FOURCC_gama GST_MAKE_FOURCC('g','a','m','a') #define FOURCC_glbl GST_MAKE_FOURCC('g','l','b','l') diff --git a/subprojects/gst-plugins-good/gst/isomp4/qtdemux.c b/subprojects/gst-plugins-good/gst/isomp4/qtdemux.c index 2535f81..f4799c5 100644 --- a/subprojects/gst-plugins-good/gst/isomp4/qtdemux.c +++ b/subprojects/gst-plugins-good/gst/isomp4/qtdemux.c @@ -2672,14 +2672,56 @@ qtdemux_parse_ftyp (GstQTDemux * qtdemux, const guint8 * buffer, gint length) /* only consider at least a sufficiently complete ftyp atom */ if (length >= 20) { GstBuffer *buf; + guint32 minor_version; + const guint8 *p; qtdemux->major_brand = QT_FOURCC (buffer + 8); - GST_DEBUG_OBJECT (qtdemux, "major brand: %" GST_FOURCC_FORMAT, + GST_DEBUG_OBJECT (qtdemux, "ftyp major brand: %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (qtdemux->major_brand)); + minor_version = QT_UINT32 (buffer + 12); + GST_DEBUG_OBJECT (qtdemux, "ftyp minor version: %u", minor_version); if (qtdemux->comp_brands) gst_buffer_unref (qtdemux->comp_brands); buf = qtdemux->comp_brands = gst_buffer_new_and_alloc (length - 16); gst_buffer_fill (buf, 0, buffer + 16, length - 16); + + p = buffer + 16; + length = length - 16; + while (length > 0) { + GST_DEBUG_OBJECT (qtdemux, "ftyp compatible brand: %" GST_FOURCC_FORMAT, + GST_FOURCC_ARGS (QT_FOURCC (p))); + length -= 4; + p += 4; + } + } +} + +static void +qtdemux_parse_styp (GstQTDemux * qtdemux, const guint8 * buffer, gint length) +{ + /* only consider at least a sufficiently complete styp atom */ + if (length >= 20) { + GstBuffer *buf; + guint32 major_brand; + guint32 minor_version; + const guint8 *p; + + major_brand = QT_FOURCC (buffer + 8); + GST_DEBUG_OBJECT (qtdemux, "styp major brand: %" GST_FOURCC_FORMAT, + GST_FOURCC_ARGS (major_brand)); + minor_version = QT_UINT32 (buffer + 12); + GST_DEBUG_OBJECT (qtdemux, "styp minor version: %u", minor_version); + buf = qtdemux->comp_brands = gst_buffer_new_and_alloc (length - 16); + gst_buffer_fill (buf, 0, buffer + 16, length - 16); + + p = buffer + 16; + length = length - 16; + while (length > 0) { + GST_DEBUG_OBJECT (qtdemux, "styp compatible brand: %" GST_FOURCC_FORMAT, + GST_FOURCC_ARGS (QT_FOURCC (p))); + length -= 4; + p += 4; + } } } @@ -4605,6 +4647,20 @@ gst_qtdemux_loop_state_header (GstQTDemux * qtdemux) gst_buffer_unref (ftyp); break; } + case FOURCC_styp: + { + GstBuffer *styp = NULL; + + ret = gst_qtdemux_pull_atom (qtdemux, cur_offset, length, &styp); + if (ret != GST_FLOW_OK) + goto beach; + qtdemux->offset += length; + gst_buffer_map (styp, &map, GST_MAP_READ); + qtdemux_parse_styp (qtdemux, map.data, map.size); + gst_buffer_unmap (styp, &map); + gst_buffer_unref (styp); + break; + } case FOURCC_uuid: { GstBuffer *uuid = NULL; -- 2.7.4