summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2015-06-30 13:51:33 +0200
committerTim-Philipp Müller <tim@centricular.com>2016-02-17 14:58:01 +0000
commit0472d9f8b238ff5ad99b88eafd556469e116796b (patch)
treebd9079bb1b2a8e256f2aef8d5dd9b585eae1d13b
parentff51629c9aba8dac99c393512776e57719081879 (diff)
downloadgstreamer-plugins-good-0472d9f8b238ff5ad99b88eafd556469e116796b.tar.gz
opus: 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/rtp/gstrtpopusdepay.c24
-rw-r--r--gst/rtp/gstrtpopuspay.c35
2 files changed, 59 insertions, 0 deletions
diff --git a/gst/rtp/gstrtpopusdepay.c b/gst/rtp/gstrtpopusdepay.c
index af3237beb..abb7218e0 100644
--- a/gst/rtp/gstrtpopusdepay.c
+++ b/gst/rtp/gstrtpopusdepay.c
@@ -26,6 +26,7 @@
#include <string.h>
#include <stdlib.h>
#include <gst/rtp/gstrtpbuffer.h>
+#include <gst/audio/audio.h>
#include "gstrtpopusdepay.h"
GST_DEBUG_CATEGORY_STATIC (rtpopusdepay_debug);
@@ -137,6 +138,25 @@ gst_rtp_opus_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
return ret;
}
+static gboolean
+foreach_metadata (GstBuffer * inbuf, GstMeta ** meta, gpointer user_data)
+{
+ GstRTPOpusDepay *depay = user_data;
+ 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)))) {
+ GST_DEBUG_OBJECT (depay, "keeping metadata %s", g_type_name (info->api));
+ } else {
+ GST_DEBUG_OBJECT (depay, "dropping metadata %s", g_type_name (info->api));
+ *meta = NULL;
+ }
+
+ return TRUE;
+}
+
static GstBuffer *
gst_rtp_opus_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
@@ -147,5 +167,9 @@ gst_rtp_opus_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
outbuf = gst_rtp_buffer_get_payload_buffer (&rtpbuf);
gst_rtp_buffer_unmap (&rtpbuf);
+ outbuf = gst_buffer_make_writable (outbuf);
+ /* Filter away all metas that are not sensible to copy */
+ gst_buffer_foreach_meta (outbuf, foreach_metadata, depayload);
+
return outbuf;
}
diff --git a/gst/rtp/gstrtpopuspay.c b/gst/rtp/gstrtpopuspay.c
index 057c8d0cc..ead49a58a 100644
--- a/gst/rtp/gstrtpopuspay.c
+++ b/gst/rtp/gstrtpopuspay.c
@@ -26,6 +26,7 @@
#include <string.h>
#include <gst/rtp/gstrtpbuffer.h>
+#include <gst/audio/audio.h>
#include "gstrtpopuspay.h"
@@ -160,18 +161,52 @@ gst_rtp_opus_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
return res;
}
+typedef struct
+{
+ GstRtpOPUSPay *pay;
+ GstBuffer *outbuf;
+} CopyMetaData;
+
+static gboolean
+foreach_metadata (GstBuffer * inbuf, GstMeta ** meta, gpointer user_data)
+{
+ CopyMetaData *data = user_data;
+ GstRtpOPUSPay *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_opus_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstBuffer * buffer)
{
GstBuffer *outbuf;
GstClockTime pts, dts, duration;
+ CopyMetaData data;
pts = GST_BUFFER_PTS (buffer);
dts = GST_BUFFER_DTS (buffer);
duration = GST_BUFFER_DURATION (buffer);
outbuf = gst_rtp_buffer_new_allocate (0, 0, 0);
+ data.pay = GST_RTP_OPUS_PAY (basepayload);
+ data.outbuf = outbuf;
+ gst_buffer_foreach_meta (buffer, foreach_metadata, &data);
outbuf = gst_buffer_append (outbuf, buffer);
GST_BUFFER_PTS (outbuf) = pts;