Commit 4a28e649 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller

rtp: cache meta tag quarks and add more utility functions for metas

Every g_quark_from_static_string() is a hash table lookup serialised
on the global quark lock in GLib. Let's just look up the two quarks
we need once and cache them locally for future use. While we're at it,
add new utility functions for the two most commonly used tags
(audio + video). Make first argument a gpointer so we don't have to
cast and make the code ugly. These are used for logging purposes
only anyway.
parent 810c0bb0
......@@ -23,6 +23,8 @@
#include <gst/tag/tag.h>
#include "gstrtputils.h"
#include "gstrtpac3depay.h"
#include "gstrtpac3pay.h"
#include "gstrtpbvdepay.h"
......@@ -115,6 +117,11 @@ plugin_init (GstPlugin * plugin)
{
gst_tag_image_type_get_type ();
rtp_quark_meta_tag_video =
g_quark_from_static_string (GST_META_TAG_VIDEO_STR);
rtp_quark_meta_tag_audio =
g_quark_from_static_string (GST_META_TAG_AUDIO_STR);
if (!gst_rtp_ac3_depay_plugin_init (plugin))
return FALSE;
......
......@@ -258,8 +258,7 @@ gst_rtp_L16_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
goto reorder_failed;
}
gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpL16depay), outbuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_drop_non_audio_meta (rtpL16depay, outbuf);
return outbuf;
......
......@@ -230,8 +230,7 @@ gst_rtp_L24_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
outbuf = gst_buffer_make_writable (outbuf);
if (outbuf) {
gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpL24depay), outbuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_drop_non_audio_meta (rtpL24depay, outbuf);
}
if (rtpL24depay->order &&
!gst_audio_buffer_reorder_channels (outbuf,
......
......@@ -156,8 +156,7 @@ gst_rtp_ac3_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
outbuf = gst_rtp_buffer_get_payload_subbuffer (rtp, 2, -1);
if (outbuf) {
gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpac3depay), outbuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_drop_non_audio_meta (rtpac3depay, outbuf);
GST_DEBUG_OBJECT (rtpac3depay, "pushing buffer of size %" G_GSIZE_FORMAT,
gst_buffer_get_size (outbuf));
}
......
......@@ -323,8 +323,8 @@ gst_rtp_ac3_pay_flush (GstRtpAC3Pay * rtpac3pay)
payload_buffer =
gst_adapter_take_buffer_fast (rtpac3pay->adapter, payload_len);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpac3pay), outbuf, payload_buffer,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_copy_audio_meta (rtpac3pay, outbuf, payload_buffer);
outbuf = gst_buffer_append (outbuf, payload_buffer);
......
......@@ -427,8 +427,7 @@ gst_rtp_amr_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
GST_DEBUG_OBJECT (depayload, "pushing buffer of size %" G_GSIZE_FORMAT,
gst_buffer_get_size (outbuf));
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpamrdepay), outbuf, rtp->buffer,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_copy_audio_meta (rtpamrdepay, outbuf, rtp->buffer);
}
return outbuf;
......
......@@ -392,8 +392,7 @@ gst_rtp_amr_pay_handle_buffer (GstRTPBasePayload * basepayload,
gst_buffer_unmap (buffer, &map);
gst_rtp_buffer_unmap (&rtp);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpamrpay), outbuf, buffer,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_copy_audio_meta (rtpamrpay, outbuf, buffer);
gst_buffer_unref (buffer);
......
......@@ -176,8 +176,7 @@ gst_rtp_bv_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
}
if (outbuf) {
gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_drop_non_audio_meta (depayload, outbuf);
}
return outbuf;
......
......@@ -260,8 +260,7 @@ gst_rtp_celt_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
GST_TIME_ARGS (GST_BUFFER_PTS (outbuf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)));
gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_drop_non_audio_meta (depayload, outbuf);
gst_rtp_base_depayload_push (depayload, outbuf);
}
......
......@@ -362,8 +362,7 @@ gst_rtp_celt_pay_flush_queued (GstRtpCELTPay * rtpceltpay)
gst_buffer_extract (buf, 0, payload, size);
payload += size;
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpceltpay), outbuf, buf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_copy_audio_meta (rtpceltpay, outbuf, buf);
gst_buffer_unref (buf);
}
......
......@@ -240,8 +240,7 @@ gst_rtp_g722_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
}
if (outbuf) {
gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpg722depay), outbuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_drop_non_audio_meta (rtpg722depay, outbuf);
}
return outbuf;
......
......@@ -164,8 +164,7 @@ gst_rtp_g723_pay_flush (GstRTPG723Pay * pay)
pay->discont = FALSE;
}
gst_rtp_buffer_unmap (&rtp);
gst_rtp_copy_meta (GST_ELEMENT_CAST (pay), outbuf, payload_buf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_copy_audio_meta (pay, outbuf, payload_buf);
outbuf = gst_buffer_append (outbuf, payload_buf);
......
......@@ -228,8 +228,7 @@ gst_rtp_g726_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
outbuf = gst_rtp_buffer_get_payload_buffer (rtp);
if (!outbuf)
goto bad_len;
gst_rtp_drop_meta (GST_ELEMENT_CAST (depay), outbuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_drop_non_audio_meta (depay, outbuf);
} else {
guint8 *in, *out, tmp;
guint len;
......@@ -243,8 +242,7 @@ gst_rtp_g726_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
goto bad_len;
outbuf = gst_buffer_make_writable (outbuf);
gst_rtp_drop_meta (GST_ELEMENT_CAST (depay), outbuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_drop_non_audio_meta (depay, outbuf);
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
out = map.data;
......
......@@ -202,8 +202,7 @@ gst_rtp_g729_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_RESYNC);
}
gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_drop_non_audio_meta (depayload, outbuf);
GST_LOG_OBJECT (depayload, "pushing buffer of size %" G_GSIZE_FORMAT,
gst_buffer_get_size (outbuf));
......
......@@ -190,8 +190,7 @@ gst_rtp_g729_pay_push (GstRTPG729Pay * rtpg729pay, GstBuffer * buf)
gst_rtp_buffer_unmap (&rtp);
/* append payload */
gst_rtp_copy_meta (GST_ELEMENT_CAST (basepayload), outbuf, buf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_copy_audio_meta (basepayload, outbuf, buf);
outbuf = gst_buffer_append (outbuf, buf);
ret = gst_rtp_base_payload_push (basepayload, outbuf);
......
......@@ -138,8 +138,7 @@ gst_rtp_gsm_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
}
if (outbuf) {
gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_drop_non_audio_meta (depayload, outbuf);
}
return outbuf;
......
......@@ -151,8 +151,7 @@ gst_rtp_gsm_pay_handle_buffer (GstRTPBasePayload * basepayload,
GST_BUFFER_PTS (outbuf) = timestamp;
GST_BUFFER_DURATION (outbuf) = duration;
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpgsmpay), outbuf, buffer,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_copy_audio_meta (rtpgsmpay, outbuf, buffer);
/* append payload */
outbuf = gst_buffer_append (outbuf, buffer);
......
......@@ -170,8 +170,7 @@ skip:
avail = gst_adapter_available (depay->adapter);
outbuf = gst_adapter_take_buffer (depay->adapter, avail);
gst_rtp_drop_meta (GST_ELEMENT_CAST (depay), outbuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_drop_non_video_meta (depay, outbuf);
/* Note that the I flag does not mean intra frame, but that the entire
* stream is intra coded. */
......
......@@ -850,8 +850,7 @@ gst_rtp_h261_pay_fragment_push (GstRtpH261Pay * pay, GstBuffer * buffer,
gst_rtp_buffer_unmap (&rtp);
gst_rtp_copy_meta (GST_ELEMENT_CAST (pay), outbuf, buffer,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (pay, outbuf, buffer);
return gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD_CAST (pay), outbuf);
}
......
......@@ -387,8 +387,7 @@ skip:
GST_DEBUG ("Pushing out a buffer of %d bytes", avail);
gst_rtp_drop_meta (GST_ELEMENT_CAST (rtph263depay), outbuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_drop_non_video_meta (rtph263depay, outbuf);
gst_rtp_base_depayload_push (depayload, outbuf);
rtph263depay->offset = 0;
......
......@@ -1320,9 +1320,8 @@ gst_rtp_h263_pay_push (GstRtpH263Pay * rtph263pay,
gst_buffer_copy_into (package->outbuf, rtph263pay->current_buffer,
GST_BUFFER_COPY_MEMORY, package->payload_start - rtph263pay->map.data,
package->payload_len);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph263pay), package->outbuf,
rtph263pay->current_buffer,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (rtph263pay, package->outbuf,
rtph263pay->current_buffer);
ret =
gst_rtp_base_payload_push (GST_RTP_BASE_PAYLOAD (rtph263pay),
......
......@@ -331,8 +331,7 @@ gst_rtp_h263p_depay_process (GstRTPBaseDepayload * depayload,
outbuf = gst_buffer_append (outbuf, padbuf);
}
gst_rtp_drop_meta (GST_ELEMENT_CAST (rtph263pdepay), outbuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_drop_non_video_meta (rtph263pdepay, outbuf);
return outbuf;
} else {
......
......@@ -753,8 +753,7 @@ gst_rtp_h263p_pay_flush (GstRtpH263PPay * rtph263ppay)
gst_rtp_buffer_unmap (&rtp);
payload_buf = gst_adapter_take_buffer_fast (rtph263ppay->adapter, towrite);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph263ppay), outbuf, payload_buf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (rtph263ppay, outbuf, payload_buf);
outbuf = gst_buffer_append (outbuf, payload_buf);
avail -= towrite;
......
......@@ -863,17 +863,14 @@ gst_rtp_h264_depay_handle_nal (GstRtpH264Depay * rtph264depay, GstBuffer * nal,
/* prepend codec_data */
if (rtph264depay->codec_data) {
GST_DEBUG_OBJECT (depayload, "prepending codec_data");
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph264depay),
rtph264depay->codec_data, outbuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (rtph264depay, rtph264depay->codec_data, outbuf);
outbuf = gst_buffer_append (rtph264depay->codec_data, outbuf);
rtph264depay->codec_data = NULL;
out_keyframe = TRUE;
}
outbuf = gst_buffer_make_writable (outbuf);
gst_rtp_drop_meta (GST_ELEMENT_CAST (rtph264depay), outbuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_drop_non_video_meta (rtph264depay, outbuf);
GST_BUFFER_PTS (outbuf) = out_timestamp;
......@@ -1046,8 +1043,7 @@ gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
memcpy (map.data + sizeof (sync_bytes), payload, nalu_size);
gst_buffer_unmap (outbuf, &map);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph264depay), outbuf,
rtp->buffer, g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (rtph264depay, outbuf, rtp->buffer);
outbuf =
gst_rtp_h264_depay_handle_nal (rtph264depay, outbuf, timestamp,
......@@ -1128,8 +1124,7 @@ gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
map.data[sizeof (sync_bytes)] = nal_header;
gst_buffer_unmap (outbuf, &map);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph264depay), outbuf,
rtp->buffer, g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (rtph264depay, outbuf, rtp->buffer);
GST_DEBUG_OBJECT (rtph264depay, "queueing %d bytes", outsize);
......@@ -1144,8 +1139,7 @@ gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
outbuf = gst_buffer_new_and_alloc (outsize);
gst_buffer_fill (outbuf, 0, payload, outsize);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph264depay), outbuf,
rtp->buffer, g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (rtph264depay, outbuf, rtp->buffer);
GST_DEBUG_OBJECT (rtph264depay, "queueing %d bytes", outsize);
......@@ -1182,8 +1176,7 @@ gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
memcpy (map.data + sizeof (sync_bytes), payload, nalu_size);
gst_buffer_unmap (outbuf, &map);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph264depay), outbuf,
rtp->buffer, g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (rtph264depay, outbuf, rtp->buffer);
outbuf = gst_rtp_h264_depay_handle_nal (rtph264depay, outbuf, timestamp,
marker);
......
......@@ -891,8 +891,7 @@ gst_rtp_h264_pay_payload_nal (GstRTPBasePayload * basepayload,
gst_rtp_buffer_unmap (&rtp);
/* insert payload memory block */
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph264pay), outbuf, paybuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (rtph264pay, outbuf, paybuf);
outbuf = gst_buffer_append (outbuf, paybuf);
/* push the buffer to the next element */
......@@ -952,8 +951,7 @@ gst_rtp_h264_pay_payload_nal (GstRTPBasePayload * basepayload,
gst_rtp_buffer_unmap (&rtp);
/* insert payload memory block */
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph264pay), outbuf, paybuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (rtph264pay, outbuf, paybuf);
gst_buffer_copy_into (outbuf, paybuf, GST_BUFFER_COPY_MEMORY, pos,
limitedSize);
......
......@@ -1026,17 +1026,14 @@ gst_rtp_h265_depay_handle_nal (GstRtpH265Depay * rtph265depay, GstBuffer * nal,
/* prepend codec_data */
if (rtph265depay->codec_data) {
GST_DEBUG_OBJECT (depayload, "prepending codec_data");
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph265depay),
rtph265depay->codec_data, outbuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (rtph265depay, rtph265depay->codec_data, outbuf);
outbuf = gst_buffer_append (rtph265depay->codec_data, outbuf);
rtph265depay->codec_data = NULL;
out_keyframe = TRUE;
}
outbuf = gst_buffer_make_writable (outbuf);
gst_rtp_drop_meta (GST_ELEMENT_CAST (rtph265depay), outbuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_drop_non_video_meta (rtph265depay, outbuf);
GST_BUFFER_PTS (outbuf) = out_timestamp;
......@@ -1241,8 +1238,7 @@ gst_rtp_h265_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
memcpy (map.data + sizeof (sync_bytes), payload, nalu_size);
gst_buffer_unmap (outbuf, &map);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph265depay), outbuf,
rtp->buffer, g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (rtph265depay, outbuf, rtp->buffer);
outbuf =
gst_rtp_h265_depay_handle_nal (rtph265depay, outbuf, timestamp,
......@@ -1338,8 +1334,7 @@ gst_rtp_h265_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
map.data[sizeof (sync_bytes) + 1] = nal_header & 0xff;
gst_buffer_unmap (outbuf, &map);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph265depay), outbuf,
rtp->buffer, g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (rtph265depay, outbuf, rtp->buffer);
GST_DEBUG_OBJECT (rtph265depay, "queueing %d bytes", outsize);
......@@ -1358,8 +1353,7 @@ gst_rtp_h265_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
outbuf = gst_buffer_new_and_alloc (outsize);
gst_buffer_fill (outbuf, 0, payload, outsize);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph265depay), outbuf,
rtp->buffer, g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (rtph265depay, outbuf, rtp->buffer);
GST_DEBUG_OBJECT (rtph265depay, "queueing %d bytes", outsize);
......@@ -1404,8 +1398,7 @@ gst_rtp_h265_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
memcpy (map.data + sizeof (sync_bytes), payload, nalu_size);
gst_buffer_unmap (outbuf, &map);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph265depay), outbuf,
rtp->buffer, g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (rtph265depay, outbuf, rtp->buffer);
outbuf = gst_rtp_h265_depay_handle_nal (rtph265depay, outbuf, timestamp,
marker);
......
......@@ -1001,8 +1001,7 @@ gst_rtp_h265_pay_payload_nal (GstRTPBasePayload * basepayload,
GST_BUFFER_DTS (outbuf) = dts;
/* insert payload memory block */
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph265pay), outbuf, paybuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (rtph265pay, outbuf, paybuf);
outbuf = gst_buffer_append (outbuf, paybuf);
outlist = gst_buffer_list_new ();
......@@ -1072,8 +1071,7 @@ gst_rtp_h265_pay_payload_nal (GstRTPBasePayload * basepayload,
gst_rtp_buffer_unmap (&rtp);
/* insert payload memory block */
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtph265pay), outbuf, paybuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (rtph265pay, outbuf, paybuf);
gst_buffer_copy_into (outbuf, paybuf, GST_BUFFER_COPY_MEMORY, pos,
limitedSize);
/* add the buffer to the buffer list */
......
......@@ -191,8 +191,7 @@ gst_rtp_ilbc_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
}
if (outbuf) {
gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_drop_non_audio_meta (depayload, outbuf);
}
return outbuf;
......
......@@ -431,8 +431,7 @@ gst_rtp_j2k_depay_flush_frame (GstRTPBaseDepayload * depayload)
GST_DEBUG_OBJECT (rtpj2kdepay, "pushing buffer of %u bytes", avail);
outbuf = gst_adapter_take_buffer (rtpj2kdepay->f_adapter, avail);
gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload),
outbuf, g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_drop_non_video_meta (depayload, outbuf);
ret = gst_rtp_base_depayload_push (depayload, outbuf);
} else {
GST_WARNING_OBJECT (rtpj2kdepay, "empty packet");
......
......@@ -506,8 +506,7 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
/* make subbuffer of j2k data */
paybuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL,
offset, data_size);
gst_rtp_copy_meta (GST_ELEMENT_CAST (basepayload), outbuf, paybuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (basepayload, outbuf, paybuf);
outbuf = gst_buffer_append (outbuf, paybuf);
gst_buffer_list_add (list, outbuf);
......
......@@ -721,8 +721,7 @@ gst_rtp_jpeg_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
rtpjpegdepay->discont = FALSE;
}
gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpjpegdepay), outbuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_drop_non_video_meta (rtpjpegdepay, outbuf);
GST_DEBUG_OBJECT (rtpjpegdepay, "returning %u bytes", avail);
}
......
......@@ -895,8 +895,7 @@ gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * basepayload,
jpeg_header_size + offset, payload_size);
/* join memory parts */
gst_rtp_copy_meta (GST_ELEMENT_CAST (pay), outbuf, paybuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (pay, outbuf, paybuf);
outbuf = gst_buffer_append (outbuf, paybuf);
GST_BUFFER_PTS (outbuf) = timestamp;
......
......@@ -394,8 +394,7 @@ gst_rtp_mp4a_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
avail -= skip;
GST_BUFFER_PTS (tmp) = timestamp;
gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), tmp,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_drop_non_audio_meta (depayload, tmp);
gst_rtp_base_depayload_push (depayload, tmp);
/* shift ts for next buffers */
......
......@@ -435,8 +435,7 @@ gst_rtp_mp4a_pay_handle_buffer (GstRTPBasePayload * basepayload,
offset, payload_len);
/* join memory parts */
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpmp4apay), outbuf, paybuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_copy_audio_meta (rtpmp4apay, outbuf, paybuf);
outbuf = gst_buffer_append (outbuf, paybuf);
gst_buffer_list_add (list, outbuf);
offset += payload_len;
......
......@@ -187,8 +187,7 @@ gst_rtp_mp4v_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
GST_DEBUG ("gst_rtp_mp4v_depay_chain: pushing buffer of size %"
G_GSIZE_FORMAT, gst_buffer_get_size (outbuf));
gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpmp4vdepay), outbuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_drop_non_video_meta (rtpmp4vdepay, outbuf);
}
return outbuf;
......
......@@ -287,8 +287,7 @@ gst_rtp_mp4v_pay_flush (GstRtpMP4VPay * rtpmp4vpay)
gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
gst_rtp_buffer_set_marker (&rtp, avail == 0);
gst_rtp_buffer_unmap (&rtp);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpmp4vpay), outbuf, outbuf_data,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (rtpmp4vpay, outbuf, outbuf_data);
outbuf = gst_buffer_append (outbuf, outbuf_data);
GST_BUFFER_PTS (outbuf) = rtpmp4vpay->first_timestamp;
......
......@@ -157,8 +157,7 @@ gst_rtp_mpa_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
gst_buffer_get_size (outbuf));
if (outbuf) {
gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpmpadepay), outbuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_drop_non_audio_meta (rtpmpadepay, outbuf);
}
/* FIXME, we can push half mpeg frames when they are split over multiple
......
......@@ -243,8 +243,7 @@ gst_rtp_mpa_pay_flush (GstRtpMPAPay * rtpmpapay)
gst_rtp_buffer_unmap (&rtp);
paybuf = gst_adapter_take_buffer_fast (rtpmpapay->adapter, payload_len);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpmpapay), outbuf, paybuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_copy_audio_meta (rtpmpapay, outbuf, paybuf);
outbuf = gst_buffer_append (outbuf, paybuf);
GST_BUFFER_PTS (outbuf) = rtpmpapay->first_ts;
......
......@@ -174,8 +174,7 @@ gst_rtp_mpv_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
GST_DEBUG_OBJECT (rtpmpvdepay,
"gst_rtp_mpv_depay_chain: pushing buffer of size %" G_GSIZE_FORMAT,
gst_buffer_get_size (outbuf));
gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpmpvdepay), outbuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_drop_non_video_meta (rtpmpvdepay, outbuf);
}
}
......
......@@ -228,8 +228,7 @@ gst_rtp_mpv_pay_flush (GstRTPMPVPay * rtpmpvpay)
gst_rtp_buffer_unmap (&rtp);
paybuf = gst_adapter_take_buffer_fast (rtpmpvpay->adapter, payload_len);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtpmpvpay), outbuf, paybuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (rtpmpvpay, outbuf, paybuf);
outbuf = gst_buffer_append (outbuf, paybuf);
GST_BUFFER_PTS (outbuf) = rtpmpvpay->first_ts;
......
......@@ -150,8 +150,7 @@ gst_rtp_pcma_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_RESYNC);
}
gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_drop_non_audio_meta (depayload, outbuf);
}
return outbuf;
......
......@@ -151,8 +151,7 @@ gst_rtp_pcmu_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_RESYNC);
}
gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_drop_non_audio_meta (depayload, outbuf);
}
return outbuf;
......
......@@ -357,8 +357,7 @@ gst_rtp_qcelp_depay_process (GstRTPBaseDepayload * depayload,
GST_BUFFER_PTS (outbuf) = timestamp;
GST_BUFFER_DURATION (outbuf) = FRAME_DURATION;
gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_drop_non_audio_meta (depayload, outbuf);
if (!depay->interleaved || index == 0) {
/* not interleaved or first frame in packet, just push */
......
......@@ -245,8 +245,7 @@ gst_rtp_sbc_depay_process (GstRTPBaseDepayload * base, GstRTPBuffer * rtp)
if (last) {
data = gst_adapter_take_buffer (depay->adapter,
gst_adapter_available (depay->adapter));
gst_rtp_drop_meta (GST_ELEMENT_CAST (depay), data,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_drop_non_audio_meta (depay, data);
} else
data = NULL;
......
......@@ -212,8 +212,7 @@ gst_rtp_sbc_pay_flush_buffers (GstRtpSBCPay * sbcpay)
gst_rtp_buffer_unmap (&rtp);
paybuf = gst_adapter_take_buffer_fast (sbcpay->adapter, payload_length);
gst_rtp_copy_meta (GST_ELEMENT_CAST (sbcpay), outbuf, paybuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_copy_audio_meta (sbcpay, outbuf, paybuf);
outbuf = gst_buffer_append (outbuf, paybuf);
GST_BUFFER_PTS (outbuf) = sbcpay->last_timestamp;
......
......@@ -111,8 +111,7 @@ gst_rtp_siren_depay_process (GstRTPBaseDepayload * depayload,
outbuf = gst_rtp_buffer_get_payload_buffer (rtp);
if (outbuf) {
gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_drop_non_audio_meta (depayload, outbuf);
}
return outbuf;
......
......@@ -212,8 +212,7 @@ gst_rtp_speex_depay_process (GstRTPBaseDepayload * depayload,
if (outbuf) {
GST_BUFFER_DURATION (outbuf) = 20 * GST_MSECOND;
gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_drop_non_audio_meta (depayload, outbuf);
}
return outbuf;
......
......@@ -289,8 +289,7 @@ gst_rtp_speex_pay_handle_buffer (GstRTPBasePayload * basepayload,
GST_BUFFER_PTS (outbuf) = timestamp;
GST_BUFFER_DURATION (outbuf) = duration;
gst_rtp_copy_meta (GST_ELEMENT_CAST (basepayload), outbuf, buffer,
g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
gst_rtp_copy_audio_meta (basepayload, outbuf, buffer);
outbuf = gst_buffer_append (outbuf, buffer);
buffer = NULL;
......
......@@ -265,8 +265,7 @@ gst_rtp_sv3v_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
avail = gst_adapter_available (rtpsv3vdepay->adapter);
GST_DEBUG ("Returning completed output buffer [%d bytes]", avail);
outbuf = gst_adapter_take_buffer (rtpsv3vdepay->adapter, avail);
gst_rtp_drop_meta (GST_ELEMENT_CAST (rtpsv3vdepay), outbuf,
g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_drop_non_video_meta (rtpsv3vdepay, outbuf);
}
}
......
......@@ -335,8 +335,7 @@ gst_rtp_theora_pay_flush_packet (GstRtpTheoraPay * rtptheorapay)
for (l = g_list_last (rtptheorapay->packet_buffers); l; l = l->prev) {
GstBuffer *buf = GST_BUFFER_CAST (l->data);
gst_rtp_copy_meta (GST_ELEMENT_CAST (rtptheorapay), rtptheorapay->packet,
buf, g_quark_from_static_string (GST_META_TAG_VIDEO_STR));
gst_rtp_copy_video_meta (rtptheorapay, rtptheorapay->packet, buf);
gst_buffer_unref (buf);
}
g_list_free (rtptheorapay->packet_buffers);
......
......@@ -26,6 +26,9 @@ typedef struct
GQuark copy_tag;
} CopyMetaData;
GQuark rtp_quark_meta_tag_video;
GQuark rtp_quark_meta_tag_audio;
static gboolean
foreach_metadata_copy (GstBuffer * inbuf, GstMeta ** meta, gpointer user_data)
{
......@@ -61,6 +64,20 @@ gst_rtp_copy_meta (GstElement * element, GstBuffer * outbuf, GstBuffer * inbuf,
gst_buffer_foreach_meta (inbuf, foreach_metadata_copy, &data);
}
void
gst_rtp_copy_video_meta (gpointer element, GstBuffer * outbuf,
GstBuffer * inbuf)
{
gst_rtp_copy_meta (element, outbuf, inbuf, rtp_quark_meta_tag_video);
}
void
gst_rtp_copy_audio_meta (gpointer element, GstBuffer * outbuf,
GstBuffer * inbuf)
{
gst_rtp_copy_meta (element, outbuf, inbuf, rtp_quark_meta_tag_audio);
}
typedef struct
{
GstElement *element;
......@@ -96,6 +113,18 @@ gst_rtp_drop_meta (GstElement * element, GstBuffer * buf, GQuark keep_tag)
gst_buffer_foreach_meta (buf, foreach_metadata_drop, &data);
}
void
gst_rtp_drop_non_audio_meta (gpointer element, GstBuffer * buf)
{