From a0f1b964f110708ccfeb234ed64b12661a62cf1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 1 Jul 2015 16:25:13 +0200 Subject: [PATCH] rtpbaseaudiopayload: Copy metadata in the (de)payloader, but only the relevant ones The payloader didn't copy anything so far, the depayloader copied every possible meta. Let's make it consistent and just copy all metas without tags or with only the audio tag. https://bugzilla.gnome.org/show_bug.cgi?id=751774 --- gst-libs/gst/rtp/gstrtpbaseaudiopayload.c | 43 +++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/gst-libs/gst/rtp/gstrtpbaseaudiopayload.c b/gst-libs/gst/rtp/gstrtpbaseaudiopayload.c index 0e5ed8a617..917aeae6f3 100644 --- a/gst-libs/gst/rtp/gstrtpbaseaudiopayload.c +++ b/gst-libs/gst/rtp/gstrtpbaseaudiopayload.c @@ -62,6 +62,7 @@ #include #include #include +#include #include "gstrtpbaseaudiopayload.h" @@ -477,6 +478,36 @@ gst_rtp_base_audio_payload_push (GstRTPBaseAudioPayload * baseaudiopayload, return ret; } +typedef struct +{ + GstRTPBaseAudioPayload *pay; + GstBuffer *outbuf; +} CopyMetaData; + +static gboolean +foreach_metadata (GstBuffer * inbuf, GstMeta ** meta, gpointer user_data) +{ + CopyMetaData *data = user_data; + GstRTPBaseAudioPayload *pay = data->pay; + GstBuffer *outbuf = data->outbuf; + const GstMetaInfo *info = (*meta)->info; + const gchar *const *tags = gst_meta_api_type_get_tags (info->api); + + if (!tags || (g_strv_length ((gchar **) tags) == 1 + && gst_meta_api_type_has_tag (info->api, + g_quark_from_string (GST_META_TAG_AUDIO_STR)))) { + GstMetaTransformCopy copy_data = { FALSE, 0, -1 }; + GST_DEBUG_OBJECT (pay, "copy metadata %s", g_type_name (info->api)); + /* simply copy then */ + info->transform_func (outbuf, *meta, inbuf, + _gst_meta_transform_copy, ©_data); + } else { + GST_DEBUG_OBJECT (pay, "not copying metadata %s", g_type_name (info->api)); + } + + return TRUE; +} + static GstFlowReturn gst_rtp_base_audio_payload_push_buffer (GstRTPBaseAudioPayload * baseaudiopayload, GstBuffer * buffer, GstClockTime timestamp) @@ -519,7 +550,12 @@ gst_rtp_base_audio_payload_push_buffer (GstRTPBaseAudioPayload * GST_DEBUG_OBJECT (baseaudiopayload, "Pushing list %p", list); ret = gst_rtp_base_payload_push_list (basepayload, list); } else { + CopyMetaData data; + /* copy payload */ + data.pay = baseaudiopayload; + data.outbuf = outbuf; + gst_buffer_foreach_meta (buffer, foreach_metadata, &data); outbuf = gst_buffer_append (outbuf, buffer); GST_DEBUG_OBJECT (baseaudiopayload, "Pushing buffer %p", outbuf); @@ -596,11 +632,17 @@ gst_rtp_base_audio_payload_flush (GstRTPBaseAudioPayload * baseaudiopayload, timestamp); } else { GstBuffer *paybuf; + CopyMetaData data; + /* create buffer to hold the payload */ outbuf = gst_rtp_buffer_new_allocate (0, 0, 0); paybuf = gst_adapter_take_buffer_fast (adapter, payload_len); + + data.pay = baseaudiopayload; + data.outbuf = outbuf; + gst_buffer_foreach_meta (paybuf, foreach_metadata, &data); outbuf = gst_buffer_append (outbuf, paybuf); /* set metadata */ @@ -872,6 +914,7 @@ gst_rtp_base_audio_payload_handle_buffer (GstRTPBasePayload * GST_DEBUG_OBJECT (payload, "available now %u", available); /* as long as we have full frames */ + /* TODO: Use buffer lists here */ while (available >= min_payload_len) { /* get multiple of alignment */ payload_len = MIN (max_payload_len, available);