diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2015-07-01 16:25:13 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2015-08-11 12:46:36 +0200 |
commit | a0f1b964f110708ccfeb234ed64b12661a62cf1f (patch) | |
tree | 6837a905ffca9bcb6e2237107330fba53b25ba99 | |
parent | 5070d6367e6581aa62396b4f64ff2e0537696522 (diff) |
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
-rw-r--r-- | gst-libs/gst/rtp/gstrtpbaseaudiopayload.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gst-libs/gst/rtp/gstrtpbaseaudiopayload.c b/gst-libs/gst/rtp/gstrtpbaseaudiopayload.c index 0e5ed8a61..917aeae6f 100644 --- a/gst-libs/gst/rtp/gstrtpbaseaudiopayload.c +++ b/gst-libs/gst/rtp/gstrtpbaseaudiopayload.c @@ -62,6 +62,7 @@ #include <string.h> #include <gst/rtp/gstrtpbuffer.h> #include <gst/base/gstadapter.h> +#include <gst/audio/audio.h> #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); |