gstrtph265depay: keep consistency with rtph264depay

Use gst_rtp_drop_meta() and the same function prototype for
gst_rtp_copy_meta() to keep consistency with the RTP elements in
gst-plugins-good
This commit is contained in:
Luis de Bethencourt 2016-02-05 15:34:51 +00:00
parent 94f1748b6b
commit 682bce33a5
2 changed files with 27 additions and 10 deletions

View file

@ -945,12 +945,12 @@ foreach_metadata_copy (GstBuffer * inbuf, GstMeta ** meta, gpointer user_data)
CopyMetaData *data = user_data;
GstElement *element = data->element;
GstBuffer *outbuf = data->outbuf;
GQuark copy_tag = data->copy_tag;
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_VIDEO_STR)))) {
if (!tags || (copy_tag != 0 && g_strv_length ((gchar **) tags) == 1
&& gst_meta_api_type_has_tag (info->api, copy_tag))) {
GstMetaTransformCopy copy_data = { FALSE, 0, -1 };
GST_DEBUG_OBJECT (element, "copy metadata %s", g_type_name (info->api));
/* simply copy then */
@ -977,22 +977,32 @@ gst_rtp_copy_meta (GstElement * element, GstBuffer * outbuf, GstBuffer * inbuf,
static gboolean
foreach_metadata_drop (GstBuffer * inbuf, GstMeta ** meta, gpointer user_data)
{
GstRtpH265Depay *depay = user_data;
DropMetaData *data = user_data;
GstElement *element = data->element;
GQuark keep_tag = data->keep_tag;
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_VIDEO_STR)))) {
GST_DEBUG_OBJECT (depay, "keeping metadata %s", g_type_name (info->api));
if (!tags || (keep_tag != 0 && g_strv_length ((gchar **) tags) == 1
&& gst_meta_api_type_has_tag (info->api, keep_tag))) {
GST_DEBUG_OBJECT (element, "keeping metadata %s", g_type_name (info->api));
} else {
GST_DEBUG_OBJECT (depay, "dropping metadata %s", g_type_name (info->api));
GST_DEBUG_OBJECT (element, "dropping metadata %s", g_type_name (info->api));
*meta = NULL;
}
return TRUE;
}
/* TODO: Should probably make keep_tag an array at some point */
static void
gst_rtp_drop_meta (GstElement * element, GstBuffer * buf, GQuark keep_tag)
{
DropMetaData data = { element, keep_tag };
gst_buffer_foreach_meta (buf, foreach_metadata_drop, &data);
}
static GstBuffer *
gst_rtp_h265_depay_handle_nal (GstRtpH265Depay * rtph265depay, GstBuffer * nal,
GstClockTime in_timestamp, gboolean marker)
@ -1099,7 +1109,8 @@ gst_rtp_h265_depay_handle_nal (GstRtpH265Depay * rtph265depay, GstBuffer * nal,
}
outbuf = gst_buffer_make_writable (outbuf);
gst_buffer_foreach_meta (outbuf, foreach_metadata_drop, depayload);
gst_rtp_drop_meta (GST_ELEMENT_CAST (rtph265depay), outbuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
GST_BUFFER_PTS (outbuf) = out_timestamp;

View file

@ -94,6 +94,12 @@ typedef struct
GQuark copy_tag;
} CopyMetaData;
typedef struct
{
GstElement *element;
GQuark keep_tag;
} DropMetaData;
void gst_rtp_copy_meta (GstElement * element, GstBuffer *outbuf, GstBuffer *inbuf, GQuark copy_tag);
GType gst_rtp_h265_depay_get_type (void);