rtprtx: don't access type-system per buffer

When doing only a single stream of audio/video this hardly matters,
but when doing many at the same time, the fact that you have to get
a hold of the glib global type-system lock every time you process a buffer,
means that there is a limit to how many streams you can process in
parallel.

Luckily the fix is very simple, by doing a cast rather than a full
type-check.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1873>
This commit is contained in:
Havard Graff 2021-02-08 21:40:19 +01:00 committed by Nirbheek Chauhan
parent 2a26daee46
commit a475c93346
4 changed files with 24 additions and 19 deletions

View file

@ -258,7 +258,7 @@ gst_rtp_rtx_receive_reset (GstRtpRtxReceive * rtx)
static void
gst_rtp_rtx_receive_finalize (GObject * object)
{
GstRtpRtxReceive *rtx = GST_RTP_RTX_RECEIVE (object);
GstRtpRtxReceive *rtx = GST_RTP_RTX_RECEIVE_CAST (object);
g_hash_table_unref (rtx->ssrc2_ssrc1_map);
g_hash_table_unref (rtx->seqnum_ssrc1_map);
@ -326,7 +326,7 @@ static gboolean
gst_rtp_rtx_receive_src_event (GstPad * pad, GstObject * parent,
GstEvent * event)
{
GstRtpRtxReceive *rtx = GST_RTP_RTX_RECEIVE (parent);
GstRtpRtxReceive *rtx = GST_RTP_RTX_RECEIVE_CAST (parent);
gboolean res;
switch (GST_EVENT_TYPE (event)) {
@ -515,7 +515,7 @@ _gst_rtp_buffer_new_from_rtx (GstRTPBuffer * rtp, guint32 ssrc1,
static GstFlowReturn
gst_rtp_rtx_receive_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstRtpRtxReceive *rtx = GST_RTP_RTX_RECEIVE (parent);
GstRtpRtxReceive *rtx = GST_RTP_RTX_RECEIVE_CAST (parent);
GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
GstFlowReturn ret = GST_FLOW_OK;
GstBuffer *new_buffer = NULL;
@ -692,7 +692,7 @@ static void
gst_rtp_rtx_receive_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
{
GstRtpRtxReceive *rtx = GST_RTP_RTX_RECEIVE (object);
GstRtpRtxReceive *rtx = GST_RTP_RTX_RECEIVE_CAST (object);
switch (prop_id) {
case PROP_PAYLOAD_TYPE_MAP:
@ -742,7 +742,7 @@ static void
gst_rtp_rtx_receive_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstRtpRtxReceive *rtx = GST_RTP_RTX_RECEIVE (object);
GstRtpRtxReceive *rtx = GST_RTP_RTX_RECEIVE_CAST (object);
switch (prop_id) {
case PROP_PAYLOAD_TYPE_MAP:
@ -768,7 +768,7 @@ gst_rtp_rtx_receive_change_state (GstElement * element,
GstStateChangeReturn ret;
GstRtpRtxReceive *rtx;
rtx = GST_RTP_RTX_RECEIVE (element);
rtx = GST_RTP_RTX_RECEIVE_CAST (element);
switch (transition) {
default:

View file

@ -28,14 +28,16 @@
#include <gst/rtp/gstrtpbuffer.h>
G_BEGIN_DECLS
typedef struct _GstRtpRtxReceive GstRtpRtxReceive;
typedef struct _GstRtpRtxReceiveClass GstRtpRtxReceiveClass;
#define GST_TYPE_RTP_RTX_RECEIVE (gst_rtp_rtx_receive_get_type())
#define GST_RTP_RTX_RECEIVE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_RTX_RECEIVE, GstRtpRtxReceive))
#define GST_RTP_RTX_RECEIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_RTX_RECEIVE, GstRtpRtxReceiveClass))
#define GST_RTP_RTX_RECEIVE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTP_RTX_RECEIVE, GstRtpRtxReceiveClass))
#define GST_IS_RTP_RTX_RECEIVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_RTX_RECEIVE))
#define GST_IS_RTP_RTX_RECEIVE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_RTX_RECEIVE))
typedef struct _GstRtpRtxReceive GstRtpRtxReceive;
typedef struct _GstRtpRtxReceiveClass GstRtpRtxReceiveClass;
#define GST_RTP_RTX_RECEIVE_CAST(obj) ((GstRtpRtxReceive *)(obj))
struct _GstRtpRtxReceive
{

View file

@ -229,7 +229,7 @@ gst_rtp_rtx_send_reset (GstRtpRtxSend * rtx)
static void
gst_rtp_rtx_send_finalize (GObject * object)
{
GstRtpRtxSend *rtx = GST_RTP_RTX_SEND (object);
GstRtpRtxSend *rtx = GST_RTP_RTX_SEND_CAST (object);
g_hash_table_unref (rtx->ssrc_data);
g_hash_table_unref (rtx->rtx_ssrcs);
@ -464,7 +464,7 @@ buffer_queue_items_cmp (BufferQueueItem * a, BufferQueueItem * b,
static gboolean
gst_rtp_rtx_send_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstRtpRtxSend *rtx = GST_RTP_RTX_SEND (parent);
GstRtpRtxSend *rtx = GST_RTP_RTX_SEND_CAST (parent);
gboolean res;
switch (GST_EVENT_TYPE (event)) {
@ -604,7 +604,7 @@ gst_rtp_rtx_send_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
static gboolean
gst_rtp_rtx_send_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstRtpRtxSend *rtx = GST_RTP_RTX_SEND (parent);
GstRtpRtxSend *rtx = GST_RTP_RTX_SEND_CAST (parent);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_START:
@ -768,7 +768,7 @@ process_buffer (GstRtpRtxSend * rtx, GstBuffer * buffer)
static GstFlowReturn
gst_rtp_rtx_send_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstRtpRtxSend *rtx = GST_RTP_RTX_SEND (parent);
GstRtpRtxSend *rtx = GST_RTP_RTX_SEND_CAST (parent);
GstFlowReturn ret;
GST_OBJECT_LOCK (rtx);
@ -790,7 +790,7 @@ static GstFlowReturn
gst_rtp_rtx_send_chain_list (GstPad * pad, GstObject * parent,
GstBufferList * list)
{
GstRtpRtxSend *rtx = GST_RTP_RTX_SEND (parent);
GstRtpRtxSend *rtx = GST_RTP_RTX_SEND_CAST (parent);
GstFlowReturn ret;
GST_OBJECT_LOCK (rtx);
@ -841,7 +841,7 @@ static gboolean
gst_rtp_rtx_send_activate_mode (GstPad * pad, GstObject * parent,
GstPadMode mode, gboolean active)
{
GstRtpRtxSend *rtx = GST_RTP_RTX_SEND (parent);
GstRtpRtxSend *rtx = GST_RTP_RTX_SEND_CAST (parent);
gboolean ret = FALSE;
switch (mode) {
@ -866,7 +866,7 @@ static void
gst_rtp_rtx_send_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
{
GstRtpRtxSend *rtx = GST_RTP_RTX_SEND (object);
GstRtpRtxSend *rtx = GST_RTP_RTX_SEND_CAST (object);
switch (prop_id) {
case PROP_PAYLOAD_TYPE_MAP:
@ -925,7 +925,7 @@ static void
gst_rtp_rtx_send_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstRtpRtxSend *rtx = GST_RTP_RTX_SEND (object);
GstRtpRtxSend *rtx = GST_RTP_RTX_SEND_CAST (object);
switch (prop_id) {
case PROP_SSRC_MAP:
@ -977,7 +977,7 @@ gst_rtp_rtx_send_change_state (GstElement * element, GstStateChange transition)
GstStateChangeReturn ret;
GstRtpRtxSend *rtx;
rtx = GST_RTP_RTX_SEND (element);
rtx = GST_RTP_RTX_SEND_CAST (element);
switch (transition) {
default:

View file

@ -29,14 +29,17 @@
#include <gst/base/gstdataqueue.h>
G_BEGIN_DECLS
typedef struct _GstRtpRtxSend GstRtpRtxSend;
typedef struct _GstRtpRtxSendClass GstRtpRtxSendClass;
#define GST_TYPE_RTP_RTX_SEND (gst_rtp_rtx_send_get_type())
#define GST_RTP_RTX_SEND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_RTX_SEND, GstRtpRtxSend))
#define GST_RTP_RTX_SEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_RTX_SEND, GstRtpRtxSendClass))
#define GST_RTP_RTX_SEND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTP_RTX_SEND, GstRtpRtxSendClass))
#define GST_IS_RTP_RTX_SEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_RTX_SEND))
#define GST_IS_RTP_RTX_SEND_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_RTX_SEND))
typedef struct _GstRtpRtxSend GstRtpRtxSend;
typedef struct _GstRtpRtxSendClass GstRtpRtxSendClass;
#define GST_RTP_RTX_SEND_CAST(obj) ((GstRtpRtxSend *)(obj))
struct _GstRtpRtxSend
{