Commit a0f1b964 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵
Browse files

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
parent 5070d636
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
#include <string.h> #include <string.h>
#include <gst/rtp/gstrtpbuffer.h> #include <gst/rtp/gstrtpbuffer.h>
#include <gst/base/gstadapter.h> #include <gst/base/gstadapter.h>
#include <gst/audio/audio.h>
#include "gstrtpbaseaudiopayload.h" #include "gstrtpbaseaudiopayload.h"
...@@ -477,6 +478,36 @@ gst_rtp_base_audio_payload_push (GstRTPBaseAudioPayload * baseaudiopayload, ...@@ -477,6 +478,36 @@ gst_rtp_base_audio_payload_push (GstRTPBaseAudioPayload * baseaudiopayload,
return ret; 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 static GstFlowReturn
gst_rtp_base_audio_payload_push_buffer (GstRTPBaseAudioPayload * gst_rtp_base_audio_payload_push_buffer (GstRTPBaseAudioPayload *
baseaudiopayload, GstBuffer * buffer, GstClockTime timestamp) baseaudiopayload, GstBuffer * buffer, GstClockTime timestamp)
...@@ -519,7 +550,12 @@ gst_rtp_base_audio_payload_push_buffer (GstRTPBaseAudioPayload * ...@@ -519,7 +550,12 @@ gst_rtp_base_audio_payload_push_buffer (GstRTPBaseAudioPayload *
GST_DEBUG_OBJECT (baseaudiopayload, "Pushing list %p", list); GST_DEBUG_OBJECT (baseaudiopayload, "Pushing list %p", list);
ret = gst_rtp_base_payload_push_list (basepayload, list); ret = gst_rtp_base_payload_push_list (basepayload, list);
} else { } else {
CopyMetaData data;
/* copy payload */ /* copy payload */
data.pay = baseaudiopayload;
data.outbuf = outbuf;
gst_buffer_foreach_meta (buffer, foreach_metadata, &data);
outbuf = gst_buffer_append (outbuf, buffer); outbuf = gst_buffer_append (outbuf, buffer);
GST_DEBUG_OBJECT (baseaudiopayload, "Pushing buffer %p", outbuf); GST_DEBUG_OBJECT (baseaudiopayload, "Pushing buffer %p", outbuf);
...@@ -596,11 +632,17 @@ gst_rtp_base_audio_payload_flush (GstRTPBaseAudioPayload * baseaudiopayload, ...@@ -596,11 +632,17 @@ gst_rtp_base_audio_payload_flush (GstRTPBaseAudioPayload * baseaudiopayload,
timestamp); timestamp);
} else { } else {
GstBuffer *paybuf; GstBuffer *paybuf;
CopyMetaData data;
/* create buffer to hold the payload */ /* create buffer to hold the payload */
outbuf = gst_rtp_buffer_new_allocate (0, 0, 0); outbuf = gst_rtp_buffer_new_allocate (0, 0, 0);
paybuf = gst_adapter_take_buffer_fast (adapter, payload_len); 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); outbuf = gst_buffer_append (outbuf, paybuf);
/* set metadata */ /* set metadata */
...@@ -872,6 +914,7 @@ gst_rtp_base_audio_payload_handle_buffer (GstRTPBasePayload * ...@@ -872,6 +914,7 @@ gst_rtp_base_audio_payload_handle_buffer (GstRTPBasePayload *
GST_DEBUG_OBJECT (payload, "available now %u", available); GST_DEBUG_OBJECT (payload, "available now %u", available);
/* as long as we have full frames */ /* as long as we have full frames */
/* TODO: Use buffer lists here */
while (available >= min_payload_len) { while (available >= min_payload_len) {
/* get multiple of alignment */ /* get multiple of alignment */
payload_len = MIN (max_payload_len, available); payload_len = MIN (max_payload_len, available);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment