use G_DEFINE_TYPE some more

This commit is contained in:
Wim Taymans 2011-04-19 17:35:47 +02:00
parent a80f3a5d74
commit 77acc618e1
6 changed files with 85 additions and 234 deletions

View file

@ -1,5 +1,5 @@
/* GStreamer
* Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
* Copyright (C) <2005,2006> Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@ -193,29 +193,9 @@ free_session (GstRTPDecSession * session)
static guint gst_rtp_dec_signals[LAST_SIGNAL] = { 0 };
GST_BOILERPLATE (GstRTPDec, gst_rtp_dec, GstElement, GST_TYPE_ELEMENT);
#define gst_rtp_dec_parent_class parent_class
G_DEFINE_TYPE (GstRTPDec, gst_rtp_dec, GST_TYPE_ELEMENT);
static void
gst_rtp_dec_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
/* sink pads */
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_dec_recv_rtp_sink_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_dec_recv_rtcp_sink_template));
/* src pads */
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_dec_recv_rtp_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_dec_rtcp_src_template));
gst_element_class_set_details_simple (element_class, "RTP Decoder",
"Codec/Parser/Network",
"Accepts raw RTP and RTCP packets and sends them forward",
"Wim Taymans <wim@fluendo.com>");
}
/* BOXED:UINT,UINT */
#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
@ -297,6 +277,8 @@ gst_rtp_dec_class_init (GstRTPDecClass * g_class)
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
GST_DEBUG_CATEGORY_INIT (rtpdec_debug, "rtpdec", 0, "RTP decoder");
gobject_class->finalize = gst_rtp_dec_finalize;
gobject_class->set_property = gst_rtp_dec_set_property;
gobject_class->get_property = gst_rtp_dec_get_property;
@ -413,11 +395,25 @@ gst_rtp_dec_class_init (GstRTPDecClass * g_class)
GST_DEBUG_FUNCPTR (gst_rtp_dec_request_new_pad);
gstelement_class->release_pad = GST_DEBUG_FUNCPTR (gst_rtp_dec_release_pad);
GST_DEBUG_CATEGORY_INIT (rtpdec_debug, "rtpdec", 0, "RTP decoder");
/* sink pads */
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_dec_recv_rtp_sink_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_dec_recv_rtcp_sink_template));
/* src pads */
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_dec_recv_rtp_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_dec_rtcp_src_template));
gst_element_class_set_details_simple (gstelement_class, "RTP Decoder",
"Codec/Parser/Network",
"Accepts raw RTP and RTCP packets and sends them forward",
"Wim Taymans <wim.taymans@gmail.com>");
}
static void
gst_rtp_dec_init (GstRTPDec * rtpdec, GstRTPDecClass * klass)
gst_rtp_dec_init (GstRTPDec * rtpdec)
{
rtpdec->provided_clock = gst_system_clock_obtain ();
rtpdec->latency = DEFAULT_LATENCY_MS;

View file

@ -267,39 +267,9 @@ static gboolean gst_rtspsrc_push_event (GstRTSPSrc * src, GstEvent * event,
#define CMD_STOP 2
/*static guint gst_rtspsrc_signals[LAST_SIGNAL] = { 0 }; */
static void
_do_init (GType rtspsrc_type)
{
static const GInterfaceInfo urihandler_info = {
gst_rtspsrc_uri_handler_init,
NULL,
NULL
};
GST_DEBUG_CATEGORY_INIT (rtspsrc_debug, "rtspsrc", 0, "RTSP src");
g_type_add_interface_static (rtspsrc_type, GST_TYPE_URI_HANDLER,
&urihandler_info);
}
GST_BOILERPLATE_FULL (GstRTSPSrc, gst_rtspsrc, GstBin, GST_TYPE_BIN, _do_init);
static void
gst_rtspsrc_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&rtptemplate));
gst_element_class_set_details_simple (element_class, "RTSP packet receiver",
"Source/Network",
"Receive data over the network via RTSP (RFC 2326)",
"Wim Taymans <wim@fluendo.com>, "
"Thijs Vermeir <thijs.vermeir@barco.com>, "
"Lutz Mueller <lutz@topfrose.de>");
}
#define gst_rtspsrc_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstRTSPSrc, gst_rtspsrc, GST_TYPE_BIN,
G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, gst_rtspsrc_uri_handler_init));
static void
gst_rtspsrc_class_init (GstRTSPSrcClass * klass)
@ -312,6 +282,8 @@ gst_rtspsrc_class_init (GstRTSPSrcClass * klass)
gstelement_class = (GstElementClass *) klass;
gstbin_class = (GstBinClass *) klass;
GST_DEBUG_CATEGORY_INIT (rtspsrc_debug, "rtspsrc", 0, "RTSP src");
gobject_class->set_property = gst_rtspsrc_set_property;
gobject_class->get_property = gst_rtspsrc_get_property;
@ -459,6 +431,16 @@ gst_rtspsrc_class_init (GstRTSPSrcClass * klass)
gstelement_class->send_event = gst_rtspsrc_send_event;
gstelement_class->change_state = gst_rtspsrc_change_state;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&rtptemplate));
gst_element_class_set_details_simple (gstelement_class,
"RTSP packet receiver", "Source/Network",
"Receive data over the network via RTSP (RFC 2326)",
"Wim Taymans <wim@fluendo.com>, "
"Thijs Vermeir <thijs.vermeir@barco.com>, "
"Lutz Mueller <lutz@topfrose.de>");
gstbin_class->handle_message = gst_rtspsrc_handle_message;
gst_rtsp_ext_list_init ();
@ -466,7 +448,7 @@ gst_rtspsrc_class_init (GstRTSPSrcClass * klass)
static void
gst_rtspsrc_init (GstRTSPSrc * src, GstRTSPSrcClass * g_class)
gst_rtspsrc_init (GstRTSPSrc * src)
{
#ifdef G_OS_WIN32
WSADATA wsa_data;

View file

@ -78,9 +78,6 @@ G_STMT_START { \
udpctx->sock = -1; \
} G_STMT_END
static void gst_dynudpsink_base_init (gpointer g_class);
static void gst_dynudpsink_class_init (GstDynUDPSink * klass);
static void gst_dynudpsink_init (GstDynUDPSink * udpsink);
static void gst_dynudpsink_finalize (GObject * object);
static GstFlowReturn gst_dynudpsink_render (GstBaseSink * sink,
@ -94,52 +91,13 @@ static void gst_dynudpsink_set_property (GObject * object, guint prop_id,
static void gst_dynudpsink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static GstElementClass *parent_class = NULL;
static guint gst_dynudpsink_signals[LAST_SIGNAL] = { 0 };
GType
gst_dynudpsink_get_type (void)
{
static GType dynudpsink_type = 0;
if (!dynudpsink_type) {
static const GTypeInfo dynudpsink_info = {
sizeof (GstDynUDPSinkClass),
gst_dynudpsink_base_init,
NULL,
(GClassInitFunc) gst_dynudpsink_class_init,
NULL,
NULL,
sizeof (GstDynUDPSink),
0,
(GInstanceInitFunc) gst_dynudpsink_init,
NULL
};
dynudpsink_type =
g_type_register_static (GST_TYPE_BASE_SINK, "GstDynUDPSink",
&dynudpsink_info, 0);
}
return dynudpsink_type;
}
#define gst_dynudpsink_parent_class parent_class
G_DEFINE_TYPE (GstDynUDPSink, gst_dynudpsink, GST_TYPE_BASE_SINK);
static void
gst_dynudpsink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_template));
gst_element_class_set_details_simple (element_class, "UDP packet sender",
"Sink/Network",
"Send data over the network via UDP",
"Philippe Khalaf <burger@speedy.org>");
}
static void
gst_dynudpsink_class_init (GstDynUDPSink * klass)
gst_dynudpsink_class_init (GstDynUDPSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
@ -173,6 +131,14 @@ gst_dynudpsink_class_init (GstDynUDPSink * klass)
gstelement_class->change_state = gst_dynudpsink_change_state;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&sink_template));
gst_element_class_set_details_simple (gstelement_class, "UDP packet sender",
"Sink/Network",
"Send data over the network via UDP",
"Philippe Khalaf <burger@speedy.org>");
gstbasesink_class->render = gst_dynudpsink_render;
GST_DEBUG_CATEGORY_INIT (dynudpsink_debug, "dynudpsink", 0, "UDP sink");

View file

@ -113,9 +113,6 @@ G_STMT_START { \
udpctx->sock = DEFAULT_SOCK; \
} G_STMT_END
static void gst_multiudpsink_base_init (gpointer g_class);
static void gst_multiudpsink_class_init (GstMultiUDPSinkClass * klass);
static void gst_multiudpsink_init (GstMultiUDPSink * udpsink);
static void gst_multiudpsink_finalize (GObject * object);
static GstFlowReturn gst_multiudpsink_render (GstBaseSink * sink,
@ -139,49 +136,10 @@ static void gst_multiudpsink_add_internal (GstMultiUDPSink * sink,
static void gst_multiudpsink_clear_internal (GstMultiUDPSink * sink,
gboolean lock);
static GstElementClass *parent_class = NULL;
static guint gst_multiudpsink_signals[LAST_SIGNAL] = { 0 };
GType
gst_multiudpsink_get_type (void)
{
static GType multiudpsink_type = 0;
if (!multiudpsink_type) {
static const GTypeInfo multiudpsink_info = {
sizeof (GstMultiUDPSinkClass),
gst_multiudpsink_base_init,
NULL,
(GClassInitFunc) gst_multiudpsink_class_init,
NULL,
NULL,
sizeof (GstMultiUDPSink),
0,
(GInstanceInitFunc) gst_multiudpsink_init,
NULL
};
multiudpsink_type =
g_type_register_static (GST_TYPE_BASE_SINK, "GstMultiUDPSink",
&multiudpsink_info, 0);
}
return multiudpsink_type;
}
static void
gst_multiudpsink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_template));
gst_element_class_set_details_simple (element_class, "UDP packet sender",
"Sink/Network",
"Send data over the network via UDP",
"Wim Taymans <wim.taymans@gmail.com>");
}
#define gst_multiudpsink_parent_class parent_class
G_DEFINE_TYPE (GstMultiUDPSink, gst_multiudpsink, GST_TYPE_BASE_SINK);
static void
gst_multiudpsink_class_init (GstMultiUDPSinkClass * klass)
@ -360,6 +318,14 @@ gst_multiudpsink_class_init (GstMultiUDPSinkClass * klass)
gstelement_class->change_state = gst_multiudpsink_change_state;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&sink_template));
gst_element_class_set_details_simple (gstelement_class, "UDP packet sender",
"Sink/Network",
"Send data over the network via UDP",
"Wim Taymans <wim.taymans@gmail.com>");
gstbasesink_class->render = gst_multiudpsink_render;
#if 0
#ifndef G_OS_WIN32

View file

@ -62,9 +62,6 @@ enum
/* FILL ME */
};
static void gst_udpsink_base_init (gpointer g_class);
static void gst_udpsink_class_init (GstUDPSink * klass);
static void gst_udpsink_init (GstUDPSink * udpsink);
static void gst_udpsink_finalize (GstUDPSink * udpsink);
static void gst_udpsink_uri_handler_init (gpointer g_iface,
@ -75,63 +72,19 @@ static void gst_udpsink_set_property (GObject * object, guint prop_id,
static void gst_udpsink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static GstElementClass *parent_class = NULL;
/*static guint gst_udpsink_signals[LAST_SIGNAL] = { 0 }; */
GType
gst_udpsink_get_type (void)
{
static GType udpsink_type = 0;
if (!udpsink_type) {
static const GTypeInfo udpsink_info = {
sizeof (GstUDPSinkClass),
gst_udpsink_base_init,
NULL,
(GClassInitFunc) gst_udpsink_class_init,
NULL,
NULL,
sizeof (GstUDPSink),
0,
(GInstanceInitFunc) gst_udpsink_init,
NULL
};
static const GInterfaceInfo urihandler_info = {
gst_udpsink_uri_handler_init,
NULL,
NULL
};
udpsink_type =
g_type_register_static (GST_TYPE_MULTIUDPSINK, "GstUDPSink",
&udpsink_info, 0);
g_type_add_interface_static (udpsink_type, GST_TYPE_URI_HANDLER,
&urihandler_info);
}
return udpsink_type;
}
#define gst_udpsink_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstUDPSink, gst_udpsink, GST_TYPE_MULTIUDPSINK,
G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, gst_udpsink_uri_handler_init));
static void
gst_udpsink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details_simple (element_class, "UDP packet sender",
"Sink/Network",
"Send data over the network via UDP", "Wim Taymans <wim@fluendo.com>");
}
static void
gst_udpsink_class_init (GstUDPSink * klass)
gst_udpsink_class_init (GstUDPSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);
gstelement_class = (GstElementClass *) klass;
gobject_class->set_property = gst_udpsink_set_property;
gobject_class->get_property = gst_udpsink_get_property;
@ -146,8 +99,11 @@ gst_udpsink_class_init (GstUDPSink * klass)
g_param_spec_int ("port", "port", "The port to send the packets to",
0, 65535, UDP_DEFAULT_PORT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
gst_element_class_set_details_simple (gstelement_class, "UDP packet sender",
"Sink/Network",
"Send data over the network via UDP", "Wim Taymans <wim@fluendo.com>");
}
static void
gst_udpsink_init (GstUDPSink * udpsink)

View file

@ -196,49 +196,25 @@ static void gst_udpsrc_set_property (GObject * object, guint prop_id,
static void gst_udpsrc_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void
_do_init (GType type)
{
static const GInterfaceInfo urihandler_info = {
gst_udpsrc_uri_handler_init,
NULL,
NULL
};
g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &urihandler_info);
GST_DEBUG_CATEGORY_INIT (udpsrc_debug, "udpsrc", 0, "UDP src");
}
GST_BOILERPLATE_FULL (GstUDPSrc, gst_udpsrc, GstPushSrc, GST_TYPE_PUSH_SRC,
_do_init);
static void
gst_udpsrc_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_template));
gst_element_class_set_details_simple (element_class, "UDP packet receiver",
"Source/Network",
"Receive data over the network via UDP",
"Wim Taymans <wim@fluendo.com>, "
"Thijs Vermeir <thijs.vermeir@barco.com>");
}
#define gst_udpsrc_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstUDPSrc, gst_udpsrc, GST_TYPE_PUSH_SRC,
G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, gst_udpsrc_uri_handler_init));
static void
gst_udpsrc_class_init (GstUDPSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseSrcClass *gstbasesrc_class;
GstPushSrcClass *gstpushsrc_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasesrc_class = (GstBaseSrcClass *) klass;
gstpushsrc_class = (GstPushSrcClass *) klass;
GST_DEBUG_CATEGORY_INIT (udpsrc_debug, "udpsrc", 0, "UDP src");
gobject_class->set_property = gst_udpsrc_set_property;
gobject_class->get_property = gst_udpsrc_get_property;
gobject_class->finalize = gst_udpsrc_finalize;
@ -301,6 +277,15 @@ gst_udpsrc_class_init (GstUDPSrcClass * klass)
g_param_spec_boolean ("reuse", "Reuse", "Enable reuse of the port",
UDP_DEFAULT_REUSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&src_template));
gst_element_class_set_details_simple (gstelement_class, "UDP packet receiver",
"Source/Network",
"Receive data over the network via UDP",
"Wim Taymans <wim@fluendo.com>, "
"Thijs Vermeir <thijs.vermeir@barco.com>");
gstbasesrc_class->start = gst_udpsrc_start;
gstbasesrc_class->stop = gst_udpsrc_stop;
gstbasesrc_class->unlock = gst_udpsrc_unlock;
@ -311,7 +296,7 @@ gst_udpsrc_class_init (GstUDPSrcClass * klass)
}
static void
gst_udpsrc_init (GstUDPSrc * udpsrc, GstUDPSrcClass * g_class)
gst_udpsrc_init (GstUDPSrc * udpsrc)
{
WSA_STARTUP (udpsrc);