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
This commit is contained in:
Sebastian Dröge 2015-07-01 16:25:13 +02:00
parent 5070d6367e
commit a0f1b964f1

View file

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