From 128dd3d82c5813f3337d84da9b7edb5115316d96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 25 Oct 2024 17:41:46 +0300 Subject: [PATCH] buffer: Don't copy reference timestamp meta if the destination buffer already has the same GstRtpBaseDepayload and other places already had such de-duplication code, so it's probably better to solve this at the root. Part-of: --- subprojects/gstreamer/gst/gstbuffer.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/subprojects/gstreamer/gst/gstbuffer.c b/subprojects/gstreamer/gst/gstbuffer.c index 807b95847f..75b6220ba1 100644 --- a/subprojects/gstreamer/gst/gstbuffer.c +++ b/subprojects/gstreamer/gst/gstbuffer.c @@ -2804,12 +2804,28 @@ static gboolean _gst_reference_timestamp_meta_transform (GstBuffer * dest, GstMeta * meta, GstBuffer * buffer, GQuark type, gpointer data) { - GstReferenceTimestampMeta *dmeta, *smeta; + const GstReferenceTimestampMeta *smeta, *ometa; + GstReferenceTimestampMeta *dmeta; + gpointer iter = NULL; /* we copy over the reference timestamp meta, independent of transformation * that happens. If it applied to the original buffer, it still applies to * the new buffer as it refers to the time when the media was captured */ - smeta = (GstReferenceTimestampMeta *) meta; + smeta = (const GstReferenceTimestampMeta *) meta; + + while ((ometa = (const GstReferenceTimestampMeta *) + gst_buffer_iterate_meta_filtered (dest, &iter, + GST_REFERENCE_TIMESTAMP_META_API_TYPE))) { + if (ometa->timestamp == smeta->timestamp + && ometa->duration == smeta->duration + && gst_caps_is_equal (ometa->reference, smeta->reference)) { + GST_CAT_TRACE (gst_reference_timestamp_meta_debug, + "Not copying reference timestamp metadata from buffer %p to %p because equal meta already exists", + buffer, dest); + return TRUE; + } + } + dmeta = gst_buffer_add_reference_timestamp_meta (dest, smeta->reference, smeta->timestamp, smeta->duration);