From d98df47e534459bec3c51c8c0e5d53a47e569f2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 5 May 2025 11:08:51 +0300 Subject: [PATCH] qtdemux: Add qtdemux_tree_get_child_by_index_full() helper function Part-of: --- .../gst/isomp4/qtdemux_tree.c | 24 +++++++++++++++++++ .../gst/isomp4/qtdemux_tree.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/subprojects/gst-plugins-good/gst/isomp4/qtdemux_tree.c b/subprojects/gst-plugins-good/gst/isomp4/qtdemux_tree.c index e27dc45a39..14ba2214ab 100644 --- a/subprojects/gst-plugins-good/gst/isomp4/qtdemux_tree.c +++ b/subprojects/gst-plugins-good/gst/isomp4/qtdemux_tree.c @@ -87,6 +87,30 @@ qtdemux_tree_get_child_by_index (GNode * node, guint index) return g_node_nth_child (node, index); } +GNode * +qtdemux_tree_get_child_by_index_full (GNode * node, guint index, + GstByteReader * parser) +{ + GNode *child; + guint8 *buffer; + guint32 child_len; + + child = g_node_nth_child (node, index); + if (child) { + buffer = (guint8 *) child->data; + + if (parser) { + child_len = QT_UINT32 (buffer); + if (G_UNLIKELY (child_len < (4 + 4))) + return NULL; + /* FIXME: must verify if atom length < parent atom length */ + gst_byte_reader_init (parser, buffer + (4 + 4), child_len - (4 + 4)); + } + return child; + } + return NULL; +} + GNode * qtdemux_tree_get_sibling_by_type_full (GNode * node, guint32 fourcc, GstByteReader * parser) diff --git a/subprojects/gst-plugins-good/gst/isomp4/qtdemux_tree.h b/subprojects/gst-plugins-good/gst/isomp4/qtdemux_tree.h index 14381815ae..c8775f14da 100644 --- a/subprojects/gst-plugins-good/gst/isomp4/qtdemux_tree.h +++ b/subprojects/gst-plugins-good/gst/isomp4/qtdemux_tree.h @@ -41,6 +41,8 @@ GNode *qtdemux_tree_get_sibling_by_type (GNode * node, guint32 fourcc); GNode *qtdemux_tree_get_sibling_by_type_full (GNode * node, guint32 fourcc, GstByteReader * parser); GNode *qtdemux_tree_get_child_by_index (GNode * node, guint index); +GNode *qtdemux_tree_get_child_by_index_full (GNode * node, guint index, + GstByteReader * parser); G_END_DECLS