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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7747>
This commit is contained in:
Sebastian Dröge 2024-10-25 17:41:46 +03:00 committed by GStreamer Marge Bot
parent 39c770af90
commit 128dd3d82c

View file

@ -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);