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

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;
......
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