rtp: Update for g_type_class_add_private() deprecation in recent GLib

https://gitlab.gnome.org/GNOME/glib/merge_requests/7
This commit is contained in:
Tim-Philipp Müller 2018-06-23 21:33:16 +02:00
parent 511a8d7ddd
commit 7f9730ecf4
3 changed files with 41 additions and 25 deletions

View file

@ -114,11 +114,6 @@ struct _GstRTPBaseAudioPayloadPrivate
gboolean buffer_list; 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_finalize (GObject * object);
static void gst_rtp_base_audio_payload_set_property (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); * payload, GstEvent * event);
#define gst_rtp_base_audio_payload_parent_class parent_class #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); GST_TYPE_RTP_BASE_PAYLOAD);
static void static void
@ -168,8 +163,6 @@ gst_rtp_base_audio_payload_class_init (GstRTPBaseAudioPayloadClass * klass)
GstElementClass *gstelement_class; GstElementClass *gstelement_class;
GstRTPBasePayloadClass *gstrtpbasepayload_class; GstRTPBasePayloadClass *gstrtpbasepayload_class;
g_type_class_add_private (klass, sizeof (GstRTPBaseAudioPayloadPrivate));
gobject_class = (GObjectClass *) klass; gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass; gstelement_class = (GstElementClass *) klass;
gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass; gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
@ -198,7 +191,7 @@ gst_rtp_base_audio_payload_class_init (GstRTPBaseAudioPayloadClass * klass)
static void static void
gst_rtp_base_audio_payload_init (GstRTPBaseAudioPayload * payload) 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 */ /* these need to be set by child object if frame based */
payload->frame_size = 0; payload->frame_size = 0;

View file

@ -31,9 +31,6 @@
GST_DEBUG_CATEGORY_STATIC (rtpbasedepayload_debug); GST_DEBUG_CATEGORY_STATIC (rtpbasedepayload_debug);
#define GST_CAT_DEFAULT (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 struct _GstRTPBaseDepayloadPrivate
{ {
GstClockTime npt_start; GstClockTime npt_start;
@ -95,6 +92,8 @@ static gboolean gst_rtp_base_depayload_handle_event (GstRTPBaseDepayload *
filter, GstEvent * event); filter, GstEvent * event);
static GstElementClass *parent_class = NULL; static GstElementClass *parent_class = NULL;
static gint private_offset = 0;
static void gst_rtp_base_depayload_class_init (GstRTPBaseDepayloadClass * static void gst_rtp_base_depayload_class_init (GstRTPBaseDepayloadClass *
klass); klass);
static void gst_rtp_base_depayload_init (GstRTPBaseDepayload * rtpbasepayload, static void gst_rtp_base_depayload_init (GstRTPBaseDepayload * rtpbasepayload,
@ -119,14 +118,26 @@ gst_rtp_base_depayload_get_type (void)
0, 0,
(GInstanceInitFunc) gst_rtp_base_depayload_init, (GInstanceInitFunc) gst_rtp_base_depayload_init,
}; };
GType _type;
g_once_init_leave ((gsize *) & rtp_base_depayload_type, _type = g_type_register_static (GST_TYPE_ELEMENT, "GstRTPBaseDepayload",
g_type_register_static (GST_TYPE_ELEMENT, "GstRTPBaseDepayload", &rtp_base_depayload_info, G_TYPE_FLAG_ABSTRACT);
&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; 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 static void
gst_rtp_base_depayload_class_init (GstRTPBaseDepayloadClass * klass) gst_rtp_base_depayload_class_init (GstRTPBaseDepayloadClass * klass)
{ {
@ -137,7 +148,8 @@ gst_rtp_base_depayload_class_init (GstRTPBaseDepayloadClass * klass)
gstelement_class = (GstElementClass *) klass; gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_peek_parent (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->finalize = gst_rtp_base_depayload_finalize;
gobject_class->set_property = gst_rtp_base_depayload_set_property; gobject_class->set_property = gst_rtp_base_depayload_set_property;
@ -184,7 +196,8 @@ gst_rtp_base_depayload_init (GstRTPBaseDepayload * filter,
GstPadTemplate *pad_template; GstPadTemplate *pad_template;
GstRTPBaseDepayloadPrivate *priv; GstRTPBaseDepayloadPrivate *priv;
priv = GST_RTP_BASE_DEPAYLOAD_GET_PRIVATE (filter); priv = gst_rtp_base_depayload_get_instance_private (filter);
filter->priv = priv; filter->priv = priv;
GST_DEBUG_OBJECT (filter, "init"); GST_DEBUG_OBJECT (filter, "init");

View file

@ -33,9 +33,6 @@
GST_DEBUG_CATEGORY_STATIC (rtpbasepayload_debug); GST_DEBUG_CATEGORY_STATIC (rtpbasepayload_debug);
#define GST_CAT_DEFAULT (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 struct _GstRTPBasePayloadPrivate
{ {
gboolean ts_offset_random; gboolean ts_offset_random;
@ -141,6 +138,7 @@ static gboolean gst_rtp_base_payload_negotiate (GstRTPBasePayload * payload);
static GstElementClass *parent_class = NULL; static GstElementClass *parent_class = NULL;
static gint private_offset = 0;
GType GType
gst_rtp_base_payload_get_type (void) gst_rtp_base_payload_get_type (void)
@ -159,14 +157,25 @@ gst_rtp_base_payload_get_type (void)
0, 0,
(GInstanceInitFunc) gst_rtp_base_payload_init, (GInstanceInitFunc) gst_rtp_base_payload_init,
}; };
GType _type;
g_once_init_leave ((gsize *) & rtpbasepayload_type, _type = g_type_register_static (GST_TYPE_ELEMENT, "GstRTPBasePayload",
g_type_register_static (GST_TYPE_ELEMENT, "GstRTPBasePayload", &rtpbasepayload_info, G_TYPE_FLAG_ABSTRACT);
&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; 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 static void
gst_rtp_base_payload_class_init (GstRTPBasePayloadClass * klass) gst_rtp_base_payload_class_init (GstRTPBasePayloadClass * klass)
{ {
@ -176,7 +185,8 @@ gst_rtp_base_payload_class_init (GstRTPBasePayloadClass * klass)
gobject_class = (GObjectClass *) klass; gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) 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); parent_class = g_type_class_peek_parent (klass);
@ -307,7 +317,7 @@ gst_rtp_base_payload_init (GstRTPBasePayload * rtpbasepayload, gpointer g_class)
GstRTPBasePayloadPrivate *priv; GstRTPBasePayloadPrivate *priv;
rtpbasepayload->priv = priv = rtpbasepayload->priv = priv =
GST_RTP_BASE_PAYLOAD_GET_PRIVATE (rtpbasepayload); gst_rtp_base_payload_get_instance_private (rtpbasepayload);
templ = templ =
gst_element_class_get_pad_template (GST_ELEMENT_CLASS (g_class), "src"); gst_element_class_get_pad_template (GST_ELEMENT_CLASS (g_class), "src");