From 7f9730ecf4ede6689bf8bd6ad15ced81c79f0728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 23 Jun 2018 21:33:16 +0200 Subject: [PATCH] rtp: Update for g_type_class_add_private() deprecation in recent GLib https://gitlab.gnome.org/GNOME/glib/merge_requests/7 --- gst-libs/gst/rtp/gstrtpbaseaudiopayload.c | 11 ++------- gst-libs/gst/rtp/gstrtpbasedepayload.c | 29 ++++++++++++++++------- gst-libs/gst/rtp/gstrtpbasepayload.c | 26 +++++++++++++------- 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/gst-libs/gst/rtp/gstrtpbaseaudiopayload.c b/gst-libs/gst/rtp/gstrtpbaseaudiopayload.c index ca48d6605d..52a4c095a3 100644 --- a/gst-libs/gst/rtp/gstrtpbaseaudiopayload.c +++ b/gst-libs/gst/rtp/gstrtpbaseaudiopayload.c @@ -114,11 +114,6 @@ struct _GstRTPBaseAudioPayloadPrivate gboolean buffer_list; }; - -#define GST_RTP_BASE_AUDIO_PAYLOAD_GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((o), GST_TYPE_RTP_BASE_AUDIO_PAYLOAD, \ - GstRTPBaseAudioPayloadPrivate)) - static void gst_rtp_base_audio_payload_finalize (GObject * object); static void gst_rtp_base_audio_payload_set_property (GObject * object, @@ -158,7 +153,7 @@ static gboolean gst_rtp_base_payload_audio_sink_event (GstRTPBasePayload * payload, GstEvent * event); #define gst_rtp_base_audio_payload_parent_class parent_class -G_DEFINE_TYPE (GstRTPBaseAudioPayload, gst_rtp_base_audio_payload, +G_DEFINE_TYPE_WITH_PRIVATE (GstRTPBaseAudioPayload, gst_rtp_base_audio_payload, GST_TYPE_RTP_BASE_PAYLOAD); static void @@ -168,8 +163,6 @@ gst_rtp_base_audio_payload_class_init (GstRTPBaseAudioPayloadClass * klass) GstElementClass *gstelement_class; GstRTPBasePayloadClass *gstrtpbasepayload_class; - g_type_class_add_private (klass, sizeof (GstRTPBaseAudioPayloadPrivate)); - gobject_class = (GObjectClass *) klass; gstelement_class = (GstElementClass *) klass; gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass; @@ -198,7 +191,7 @@ gst_rtp_base_audio_payload_class_init (GstRTPBaseAudioPayloadClass * klass) static void gst_rtp_base_audio_payload_init (GstRTPBaseAudioPayload * payload) { - payload->priv = GST_RTP_BASE_AUDIO_PAYLOAD_GET_PRIVATE (payload); + payload->priv = gst_rtp_base_audio_payload_get_instance_private (payload); /* these need to be set by child object if frame based */ payload->frame_size = 0; diff --git a/gst-libs/gst/rtp/gstrtpbasedepayload.c b/gst-libs/gst/rtp/gstrtpbasedepayload.c index 09a4f25945..2420174d24 100644 --- a/gst-libs/gst/rtp/gstrtpbasedepayload.c +++ b/gst-libs/gst/rtp/gstrtpbasedepayload.c @@ -31,9 +31,6 @@ GST_DEBUG_CATEGORY_STATIC (rtpbasedepayload_debug); #define GST_CAT_DEFAULT (rtpbasedepayload_debug) -#define GST_RTP_BASE_DEPAYLOAD_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_RTP_BASE_DEPAYLOAD, GstRTPBaseDepayloadPrivate)) - struct _GstRTPBaseDepayloadPrivate { GstClockTime npt_start; @@ -95,6 +92,8 @@ static gboolean gst_rtp_base_depayload_handle_event (GstRTPBaseDepayload * filter, GstEvent * event); static GstElementClass *parent_class = NULL; +static gint private_offset = 0; + static void gst_rtp_base_depayload_class_init (GstRTPBaseDepayloadClass * klass); static void gst_rtp_base_depayload_init (GstRTPBaseDepayload * rtpbasepayload, @@ -119,14 +118,26 @@ gst_rtp_base_depayload_get_type (void) 0, (GInstanceInitFunc) gst_rtp_base_depayload_init, }; + GType _type; - g_once_init_leave ((gsize *) & rtp_base_depayload_type, - g_type_register_static (GST_TYPE_ELEMENT, "GstRTPBaseDepayload", - &rtp_base_depayload_info, G_TYPE_FLAG_ABSTRACT)); + _type = g_type_register_static (GST_TYPE_ELEMENT, "GstRTPBaseDepayload", + &rtp_base_depayload_info, G_TYPE_FLAG_ABSTRACT); + + private_offset = + g_type_add_instance_private (_type, + sizeof (GstRTPBaseDepayloadPrivate)); + + g_once_init_leave ((gsize *) & rtp_base_depayload_type, _type); } return rtp_base_depayload_type; } +static inline GstRTPBaseDepayloadPrivate * +gst_rtp_base_depayload_get_instance_private (GstRTPBaseDepayload * self) +{ + return (G_STRUCT_MEMBER_P (self, private_offset)); +} + static void gst_rtp_base_depayload_class_init (GstRTPBaseDepayloadClass * klass) { @@ -137,7 +148,8 @@ gst_rtp_base_depayload_class_init (GstRTPBaseDepayloadClass * klass) gstelement_class = (GstElementClass *) klass; parent_class = g_type_class_peek_parent (klass); - g_type_class_add_private (klass, sizeof (GstRTPBaseDepayloadPrivate)); + if (private_offset != 0) + g_type_class_adjust_private_offset (klass, &private_offset); gobject_class->finalize = gst_rtp_base_depayload_finalize; gobject_class->set_property = gst_rtp_base_depayload_set_property; @@ -184,7 +196,8 @@ gst_rtp_base_depayload_init (GstRTPBaseDepayload * filter, GstPadTemplate *pad_template; GstRTPBaseDepayloadPrivate *priv; - priv = GST_RTP_BASE_DEPAYLOAD_GET_PRIVATE (filter); + priv = gst_rtp_base_depayload_get_instance_private (filter); + filter->priv = priv; GST_DEBUG_OBJECT (filter, "init"); diff --git a/gst-libs/gst/rtp/gstrtpbasepayload.c b/gst-libs/gst/rtp/gstrtpbasepayload.c index b411af0b89..b518ac735f 100644 --- a/gst-libs/gst/rtp/gstrtpbasepayload.c +++ b/gst-libs/gst/rtp/gstrtpbasepayload.c @@ -33,9 +33,6 @@ GST_DEBUG_CATEGORY_STATIC (rtpbasepayload_debug); #define GST_CAT_DEFAULT (rtpbasepayload_debug) -#define GST_RTP_BASE_PAYLOAD_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_RTP_BASE_PAYLOAD, GstRTPBasePayloadPrivate)) - struct _GstRTPBasePayloadPrivate { gboolean ts_offset_random; @@ -141,6 +138,7 @@ static gboolean gst_rtp_base_payload_negotiate (GstRTPBasePayload * payload); static GstElementClass *parent_class = NULL; +static gint private_offset = 0; GType gst_rtp_base_payload_get_type (void) @@ -159,14 +157,25 @@ gst_rtp_base_payload_get_type (void) 0, (GInstanceInitFunc) gst_rtp_base_payload_init, }; + GType _type; - g_once_init_leave ((gsize *) & rtpbasepayload_type, - g_type_register_static (GST_TYPE_ELEMENT, "GstRTPBasePayload", - &rtpbasepayload_info, G_TYPE_FLAG_ABSTRACT)); + _type = g_type_register_static (GST_TYPE_ELEMENT, "GstRTPBasePayload", + &rtpbasepayload_info, G_TYPE_FLAG_ABSTRACT); + + private_offset = + g_type_add_instance_private (_type, sizeof (GstRTPBasePayloadPrivate)); + + g_once_init_leave ((gsize *) & rtpbasepayload_type, _type); } return rtpbasepayload_type; } +static inline GstRTPBasePayloadPrivate * +gst_rtp_base_payload_get_instance_private (GstRTPBasePayload * self) +{ + return (G_STRUCT_MEMBER_P (self, private_offset)); +} + static void gst_rtp_base_payload_class_init (GstRTPBasePayloadClass * klass) { @@ -176,7 +185,8 @@ gst_rtp_base_payload_class_init (GstRTPBasePayloadClass * klass) gobject_class = (GObjectClass *) klass; gstelement_class = (GstElementClass *) klass; - g_type_class_add_private (klass, sizeof (GstRTPBasePayloadPrivate)); + if (private_offset != 0) + g_type_class_adjust_private_offset (klass, &private_offset); parent_class = g_type_class_peek_parent (klass); @@ -307,7 +317,7 @@ gst_rtp_base_payload_init (GstRTPBasePayload * rtpbasepayload, gpointer g_class) GstRTPBasePayloadPrivate *priv; rtpbasepayload->priv = priv = - GST_RTP_BASE_PAYLOAD_GET_PRIVATE (rtpbasepayload); + gst_rtp_base_payload_get_instance_private (rtpbasepayload); templ = gst_element_class_get_pad_template (GST_ELEMENT_CLASS (g_class), "src");