mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
rtp: opus: use existing utility funcs for copying/dropping metas
We had our own copies of those while the code was in -bad, but now we can use the existing utility functions instead of re-implementing them.
This commit is contained in:
parent
4a28e649c3
commit
f9a740b319
2 changed files with 6 additions and 55 deletions
|
@ -28,6 +28,7 @@
|
||||||
#include <gst/rtp/gstrtpbuffer.h>
|
#include <gst/rtp/gstrtpbuffer.h>
|
||||||
#include <gst/audio/audio.h>
|
#include <gst/audio/audio.h>
|
||||||
#include "gstrtpopusdepay.h"
|
#include "gstrtpopusdepay.h"
|
||||||
|
#include "gstrtputils.h"
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (rtpopusdepay_debug);
|
GST_DEBUG_CATEGORY_STATIC (rtpopusdepay_debug);
|
||||||
#define GST_CAT_DEFAULT (rtpopusdepay_debug)
|
#define GST_CAT_DEFAULT (rtpopusdepay_debug)
|
||||||
|
@ -138,25 +139,6 @@ gst_rtp_opus_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
||||||
return ret;
|
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 *
|
static GstBuffer *
|
||||||
gst_rtp_opus_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
gst_rtp_opus_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
|
@ -168,8 +150,7 @@ gst_rtp_opus_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
gst_rtp_buffer_unmap (&rtpbuf);
|
gst_rtp_buffer_unmap (&rtpbuf);
|
||||||
|
|
||||||
outbuf = gst_buffer_make_writable (outbuf);
|
outbuf = gst_buffer_make_writable (outbuf);
|
||||||
/* Filter away all metas that are not sensible to copy */
|
gst_rtp_drop_non_audio_meta (depayload, outbuf);
|
||||||
gst_buffer_foreach_meta (outbuf, foreach_metadata, depayload);
|
|
||||||
|
|
||||||
return outbuf;
|
return outbuf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <gst/audio/audio.h>
|
#include <gst/audio/audio.h>
|
||||||
|
|
||||||
#include "gstrtpopuspay.h"
|
#include "gstrtpopuspay.h"
|
||||||
|
#include "gstrtputils.h"
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (rtpopuspay_debug);
|
GST_DEBUG_CATEGORY_STATIC (rtpopuspay_debug);
|
||||||
#define GST_CAT_DEFAULT (rtpopuspay_debug)
|
#define GST_CAT_DEFAULT (rtpopuspay_debug)
|
||||||
|
@ -162,52 +163,21 @@ gst_rtp_opus_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
|
||||||
return res;
|
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, ©_data);
|
|
||||||
} else {
|
|
||||||
GST_DEBUG_OBJECT (pay, "not copying metadata %s", g_type_name (info->api));
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_rtp_opus_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
gst_rtp_opus_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
GstBuffer * buffer)
|
GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
GstClockTime pts, dts, duration;
|
GstClockTime pts, dts, duration;
|
||||||
CopyMetaData data;
|
|
||||||
|
|
||||||
pts = GST_BUFFER_PTS (buffer);
|
pts = GST_BUFFER_PTS (buffer);
|
||||||
dts = GST_BUFFER_DTS (buffer);
|
dts = GST_BUFFER_DTS (buffer);
|
||||||
duration = GST_BUFFER_DURATION (buffer);
|
duration = GST_BUFFER_DURATION (buffer);
|
||||||
|
|
||||||
outbuf = gst_rtp_buffer_new_allocate (0, 0, 0);
|
outbuf = gst_rtp_buffer_new_allocate (0, 0, 0);
|
||||||
data.pay = GST_RTP_OPUS_PAY (basepayload);
|
|
||||||
data.outbuf = outbuf;
|
gst_rtp_copy_audio_meta (basepayload, outbuf, buffer);
|
||||||
gst_buffer_foreach_meta (buffer, foreach_metadata, &data);
|
|
||||||
outbuf = gst_buffer_append (outbuf, buffer);
|
outbuf = gst_buffer_append (outbuf, buffer);
|
||||||
|
|
||||||
GST_BUFFER_PTS (outbuf) = pts;
|
GST_BUFFER_PTS (outbuf) = pts;
|
||||||
|
|
Loading…
Reference in a new issue