proxy: remove unneeded object private structs

Plugin headers are not installed.

Also mark internal funcs as internal.
This commit is contained in:
Tim-Philipp Müller 2018-02-12 19:30:01 +00:00
parent e9bfb4edc2
commit 843f118523
5 changed files with 74 additions and 87 deletions

View file

@ -26,10 +26,13 @@
G_BEGIN_DECLS G_BEGIN_DECLS
G_GNUC_INTERNAL
void gst_proxy_sink_set_proxysrc (GstProxySink *sink, GstProxySrc *src); void gst_proxy_sink_set_proxysrc (GstProxySink *sink, GstProxySrc *src);
G_GNUC_INTERNAL
GstPad* gst_proxy_sink_get_internal_sinkpad (GstProxySink *sink); GstPad* gst_proxy_sink_get_internal_sinkpad (GstProxySink *sink);
G_GNUC_INTERNAL
GstPad* gst_proxy_src_get_internal_srcpad (GstProxySrc *src); GstPad* gst_proxy_src_get_internal_srcpad (GstProxySrc *src);
G_END_DECLS G_END_DECLS

View file

@ -48,15 +48,6 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY); GST_STATIC_CAPS_ANY);
struct _GstProxySinkPrivate
{
GstPad *sinkpad;
/* The proxysrc that we push events, buffers, queries to */
GWeakRef proxysrc;
/* Whether there are sticky events pending */
gboolean pending_sticky_events;
};
/* We're not subclassing from basesink because we don't want any of the special /* We're not subclassing from basesink because we don't want any of the special
* handling it has for events/queries/etc. We just pass-through everything. */ * handling it has for events/queries/etc. We just pass-through everything. */
@ -83,8 +74,6 @@ gst_proxy_sink_class_init (GstProxySinkClass * klass)
GST_DEBUG_CATEGORY_INIT (gst_proxy_sink_debug, "proxysink", 0, "proxy sink"); GST_DEBUG_CATEGORY_INIT (gst_proxy_sink_debug, "proxysink", 0, "proxy sink");
g_type_class_add_private (klass, sizeof (GstProxySinkPrivate));
gstelement_class->change_state = gst_proxy_sink_change_state; gstelement_class->change_state = gst_proxy_sink_change_state;
gst_element_class_add_pad_template (gstelement_class, gst_element_class_add_pad_template (gstelement_class,
@ -98,19 +87,16 @@ gst_proxy_sink_class_init (GstProxySinkClass * klass)
static void static void
gst_proxy_sink_init (GstProxySink * self) gst_proxy_sink_init (GstProxySink * self)
{ {
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GST_TYPE_PROXY_SINK, self->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
GstProxySinkPrivate); gst_pad_set_chain_function (self->sinkpad,
self->priv->sinkpad =
gst_pad_new_from_static_template (&sink_template, "sink");
gst_pad_set_chain_function (self->priv->sinkpad,
GST_DEBUG_FUNCPTR (gst_proxy_sink_sink_chain)); GST_DEBUG_FUNCPTR (gst_proxy_sink_sink_chain));
gst_pad_set_chain_list_function (self->priv->sinkpad, gst_pad_set_chain_list_function (self->sinkpad,
GST_DEBUG_FUNCPTR (gst_proxy_sink_sink_chain_list)); GST_DEBUG_FUNCPTR (gst_proxy_sink_sink_chain_list));
gst_pad_set_event_function (self->priv->sinkpad, gst_pad_set_event_function (self->sinkpad,
GST_DEBUG_FUNCPTR (gst_proxy_sink_sink_event)); GST_DEBUG_FUNCPTR (gst_proxy_sink_sink_event));
gst_pad_set_query_function (self->priv->sinkpad, gst_pad_set_query_function (self->sinkpad,
GST_DEBUG_FUNCPTR (gst_proxy_sink_sink_query)); GST_DEBUG_FUNCPTR (gst_proxy_sink_sink_query));
gst_element_add_pad (GST_ELEMENT (self), self->priv->sinkpad); gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
} }
static GstStateChangeReturn static GstStateChangeReturn
@ -123,7 +109,7 @@ gst_proxy_sink_change_state (GstElement * element, GstStateChange transition)
switch (transition) { switch (transition) {
case GST_STATE_CHANGE_READY_TO_PAUSED: case GST_STATE_CHANGE_READY_TO_PAUSED:
self->priv->pending_sticky_events = FALSE; self->pending_sticky_events = FALSE;
break; break;
default: default:
break; break;
@ -144,7 +130,7 @@ gst_proxy_sink_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
GST_LOG_OBJECT (pad, "Handling query of type '%s'", GST_LOG_OBJECT (pad, "Handling query of type '%s'",
gst_query_type_get_name (GST_QUERY_TYPE (query))); gst_query_type_get_name (GST_QUERY_TYPE (query)));
src = g_weak_ref_get (&self->priv->proxysrc); src = g_weak_ref_get (&self->proxysrc);
if (src) { if (src) {
GstPad *srcpad; GstPad *srcpad;
srcpad = gst_proxy_src_get_internal_srcpad (src); srcpad = gst_proxy_src_get_internal_srcpad (src);
@ -185,18 +171,18 @@ gst_proxy_sink_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
GST_LOG_OBJECT (pad, "Got %s event", GST_EVENT_TYPE_NAME (event)); GST_LOG_OBJECT (pad, "Got %s event", GST_EVENT_TYPE_NAME (event));
if (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_STOP) if (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_STOP)
self->priv->pending_sticky_events = FALSE; self->pending_sticky_events = FALSE;
src = g_weak_ref_get (&self->priv->proxysrc); src = g_weak_ref_get (&self->proxysrc);
if (src) { if (src) {
GstPad *srcpad; GstPad *srcpad;
srcpad = gst_proxy_src_get_internal_srcpad (src); srcpad = gst_proxy_src_get_internal_srcpad (src);
if (sticky && self->priv->pending_sticky_events) { if (sticky && self->pending_sticky_events) {
CopyStickyEventsData data = { srcpad, GST_FLOW_OK }; CopyStickyEventsData data = { srcpad, GST_FLOW_OK };
gst_pad_sticky_events_foreach (pad, copy_sticky_events, &data); gst_pad_sticky_events_foreach (pad, copy_sticky_events, &data);
self->priv->pending_sticky_events = data.ret != GST_FLOW_OK; self->pending_sticky_events = data.ret != GST_FLOW_OK;
} }
ret = gst_pad_push_event (srcpad, event); ret = gst_pad_push_event (srcpad, event);
@ -204,7 +190,7 @@ gst_proxy_sink_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
gst_object_unref (src); gst_object_unref (src);
if (!ret && sticky) { if (!ret && sticky) {
self->priv->pending_sticky_events = TRUE; self->pending_sticky_events = TRUE;
ret = TRUE; ret = TRUE;
} }
} else } else
@ -222,16 +208,16 @@ gst_proxy_sink_sink_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
GST_LOG_OBJECT (pad, "Chaining buffer %p", buffer); GST_LOG_OBJECT (pad, "Chaining buffer %p", buffer);
src = g_weak_ref_get (&self->priv->proxysrc); src = g_weak_ref_get (&self->proxysrc);
if (src) { if (src) {
GstPad *srcpad; GstPad *srcpad;
srcpad = gst_proxy_src_get_internal_srcpad (src); srcpad = gst_proxy_src_get_internal_srcpad (src);
if (self->priv->pending_sticky_events) { if (self->pending_sticky_events) {
CopyStickyEventsData data = { srcpad, GST_FLOW_OK }; CopyStickyEventsData data = { srcpad, GST_FLOW_OK };
gst_pad_sticky_events_foreach (pad, copy_sticky_events, &data); gst_pad_sticky_events_foreach (pad, copy_sticky_events, &data);
self->priv->pending_sticky_events = data.ret != GST_FLOW_OK; self->pending_sticky_events = data.ret != GST_FLOW_OK;
} }
ret = gst_pad_push (srcpad, buffer); ret = gst_pad_push (srcpad, buffer);
@ -258,16 +244,16 @@ gst_proxy_sink_sink_chain_list (GstPad * pad, GstObject * parent,
GST_LOG_OBJECT (pad, "Chaining buffer list %p", list); GST_LOG_OBJECT (pad, "Chaining buffer list %p", list);
src = g_weak_ref_get (&self->priv->proxysrc); src = g_weak_ref_get (&self->proxysrc);
if (src) { if (src) {
GstPad *srcpad; GstPad *srcpad;
srcpad = gst_proxy_src_get_internal_srcpad (src); srcpad = gst_proxy_src_get_internal_srcpad (src);
if (self->priv->pending_sticky_events) { if (self->pending_sticky_events) {
CopyStickyEventsData data = { srcpad, GST_FLOW_OK }; CopyStickyEventsData data = { srcpad, GST_FLOW_OK };
gst_pad_sticky_events_foreach (pad, copy_sticky_events, &data); gst_pad_sticky_events_foreach (pad, copy_sticky_events, &data);
self->priv->pending_sticky_events = data.ret != GST_FLOW_OK; self->pending_sticky_events = data.ret != GST_FLOW_OK;
} }
ret = gst_pad_push_list (srcpad, list); ret = gst_pad_push_list (srcpad, list);
@ -290,12 +276,12 @@ GstPad *
gst_proxy_sink_get_internal_sinkpad (GstProxySink * self) gst_proxy_sink_get_internal_sinkpad (GstProxySink * self)
{ {
g_return_val_if_fail (self, NULL); g_return_val_if_fail (self, NULL);
return gst_object_ref (self->priv->sinkpad); return gst_object_ref (self->sinkpad);
} }
void void
gst_proxy_sink_set_proxysrc (GstProxySink * self, GstProxySrc * src) gst_proxy_sink_set_proxysrc (GstProxySink * self, GstProxySrc * src)
{ {
g_return_if_fail (self); g_return_if_fail (self);
g_weak_ref_set (&self->priv->proxysrc, src); g_weak_ref_set (&self->proxysrc, src);
} }

View file

@ -41,8 +41,13 @@ struct _GstProxySink {
GstElement parent; GstElement parent;
/* < private > */ /* < private > */
GstProxySinkPrivate *priv; GstPad *sinkpad;
gpointer _gst_reserved[GST_PADDING];
/* The proxysrc that we push events, buffers, queries to */
GWeakRef proxysrc;
/* Whether there are sticky events pending */
gboolean pending_sticky_events;
}; };
struct _GstProxySinkClass { struct _GstProxySinkClass {

View file

@ -93,20 +93,6 @@ enum
PROP_PROXYSINK, PROP_PROXYSINK,
}; };
struct _GstProxySrcPrivate
{
/* Queue to hold buffers from proxysink */
GstElement *queue;
/* Source pad of the above queue and the proxysrc element itself */
GstPad *srcpad;
/* Our internal srcpad that proxysink pushes buffers/events/queries into */
GstPad *internal_srcpad;
/* An unlinked dummy sinkpad; see gst_proxy_src_init() */
GstPad *dummy_sinkpad;
/* The matching proxysink; queries and events are sent to its sinkpad */
GWeakRef proxysink;
};
/* We're not subclassing from basesrc because we don't want any of the special /* We're not subclassing from basesrc because we don't want any of the special
* handling it has for events/queries/etc. We just pass-through everything. */ * handling it has for events/queries/etc. We just pass-through everything. */
@ -132,7 +118,7 @@ gst_proxy_src_get_property (GObject * object, guint prop_id, GValue * value,
switch (prop_id) { switch (prop_id) {
case PROP_PROXYSINK: case PROP_PROXYSINK:
g_value_take_object (value, g_weak_ref_get (&self->priv->proxysink)); g_value_take_object (value, g_weak_ref_get (&self->proxysink));
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);
@ -153,16 +139,16 @@ gst_proxy_src_set_property (GObject * object, guint prop_id,
if (sink == NULL) { if (sink == NULL) {
/* Unset proxysrc property on the existing proxysink to break the /* Unset proxysrc property on the existing proxysink to break the
* connection in that direction */ * connection in that direction */
GstProxySink *old_sink = g_weak_ref_get (&self->priv->proxysink); GstProxySink *old_sink = g_weak_ref_get (&self->proxysink);
if (old_sink) { if (old_sink) {
gst_proxy_sink_set_proxysrc (old_sink, NULL); gst_proxy_sink_set_proxysrc (old_sink, NULL);
g_object_unref (old_sink); g_object_unref (old_sink);
} }
g_weak_ref_set (&self->priv->proxysink, NULL); g_weak_ref_set (&self->proxysink, NULL);
} else { } else {
/* Set proxysrc property on the new proxysink to point to us */ /* Set proxysrc property on the new proxysink to point to us */
gst_proxy_sink_set_proxysrc (sink, self); gst_proxy_sink_set_proxysrc (sink, self);
g_weak_ref_set (&self->priv->proxysink, sink); g_weak_ref_set (&self->proxysink, sink);
g_object_unref (sink); g_object_unref (sink);
} }
break; break;
@ -179,8 +165,6 @@ gst_proxy_src_class_init (GstProxySrcClass * klass)
GST_DEBUG_CATEGORY_INIT (gst_proxy_src_debug, "proxysrc", 0, "proxy sink"); GST_DEBUG_CATEGORY_INIT (gst_proxy_src_debug, "proxysrc", 0, "proxy sink");
g_type_class_add_private (klass, sizeof (GstProxySrcPrivate));
gobject_class->dispose = gst_proxy_src_dispose; gobject_class->dispose = gst_proxy_src_dispose;
gobject_class->get_property = gst_proxy_src_get_property; gobject_class->get_property = gst_proxy_src_get_property;
@ -207,34 +191,30 @@ gst_proxy_src_init (GstProxySrc * self)
GST_OBJECT_FLAG_SET (self, GST_ELEMENT_FLAG_SOURCE); GST_OBJECT_FLAG_SET (self, GST_ELEMENT_FLAG_SOURCE);
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GST_TYPE_PROXY_SRC,
GstProxySrcPrivate);
/* We feed incoming buffers into a queue to decouple the downstream pipeline /* We feed incoming buffers into a queue to decouple the downstream pipeline
* from the upstream pipeline */ * from the upstream pipeline */
self->priv->queue = gst_element_factory_make ("queue", NULL); self->queue = gst_element_factory_make ("queue", NULL);
gst_bin_add (GST_BIN (self), self->priv->queue); gst_bin_add (GST_BIN (self), self->queue);
srcpad = gst_element_get_static_pad (self->priv->queue, "src"); srcpad = gst_element_get_static_pad (self->queue, "src");
templ = gst_static_pad_template_get (&src_template); templ = gst_static_pad_template_get (&src_template);
self->priv->srcpad = gst_ghost_pad_new_from_template ("src", srcpad, templ); self->srcpad = gst_ghost_pad_new_from_template ("src", srcpad, templ);
gst_object_unref (templ); gst_object_unref (templ);
gst_object_unref (srcpad); gst_object_unref (srcpad);
gst_element_add_pad (GST_ELEMENT (self), self->priv->srcpad); gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
/* A dummy sinkpad that's not actually used anywhere /* A dummy sinkpad that's not actually used anywhere
* Explanation for why this is needed is below */ * Explanation for why this is needed is below */
self->priv->dummy_sinkpad = gst_pad_new ("dummy_sinkpad", GST_PAD_SINK); self->dummy_sinkpad = gst_pad_new ("dummy_sinkpad", GST_PAD_SINK);
gst_object_set_parent (GST_OBJECT (self->priv->dummy_sinkpad), gst_object_set_parent (GST_OBJECT (self->dummy_sinkpad), GST_OBJECT (self));
GST_OBJECT (self));
self->priv->internal_srcpad = gst_pad_new ("internal_src", GST_PAD_SRC); self->internal_srcpad = gst_pad_new ("internal_src", GST_PAD_SRC);
gst_object_set_parent (GST_OBJECT (self->priv->internal_srcpad), gst_object_set_parent (GST_OBJECT (self->internal_srcpad),
GST_OBJECT (self->priv->dummy_sinkpad)); GST_OBJECT (self->dummy_sinkpad));
gst_pad_set_event_function (self->priv->internal_srcpad, gst_pad_set_event_function (self->internal_srcpad,
gst_proxy_src_internal_src_event); gst_proxy_src_internal_src_event);
gst_pad_set_query_function (self->priv->internal_srcpad, gst_pad_set_query_function (self->internal_srcpad,
gst_proxy_src_internal_src_query); gst_proxy_src_internal_src_query);
/* We need to link internal_srcpad from proxysink to the sinkpad of our /* We need to link internal_srcpad from proxysink to the sinkpad of our
@ -243,8 +223,8 @@ gst_proxy_src_init (GstProxySrc * self)
* the parent of internal_srcpad as dummy_sinkpad. This causes both these pads * the parent of internal_srcpad as dummy_sinkpad. This causes both these pads
* to share a parent allowing us to link them. * to share a parent allowing us to link them.
* Yes, this is a hack/workaround. */ * Yes, this is a hack/workaround. */
sinkpad = gst_element_get_static_pad (self->priv->queue, "sink"); sinkpad = gst_element_get_static_pad (self->queue, "sink");
gst_pad_link (self->priv->internal_srcpad, sinkpad); gst_pad_link (self->internal_srcpad, sinkpad);
gst_object_unref (sinkpad); gst_object_unref (sinkpad);
} }
@ -253,13 +233,13 @@ gst_proxy_src_dispose (GObject * object)
{ {
GstProxySrc *self = GST_PROXY_SRC (object); GstProxySrc *self = GST_PROXY_SRC (object);
gst_object_unparent (GST_OBJECT (self->priv->dummy_sinkpad)); gst_object_unparent (GST_OBJECT (self->dummy_sinkpad));
self->priv->dummy_sinkpad = NULL; self->dummy_sinkpad = NULL;
gst_object_unparent (GST_OBJECT (self->priv->internal_srcpad)); gst_object_unparent (GST_OBJECT (self->internal_srcpad));
self->priv->internal_srcpad = NULL; self->internal_srcpad = NULL;
g_weak_ref_set (&self->priv->proxysink, NULL); g_weak_ref_set (&self->proxysink, NULL);
G_OBJECT_CLASS (gst_proxy_src_parent_class)->dispose (object); G_OBJECT_CLASS (gst_proxy_src_parent_class)->dispose (object);
} }
@ -279,10 +259,10 @@ gst_proxy_src_change_state (GstElement * element, GstStateChange transition)
switch (transition) { switch (transition) {
case GST_STATE_CHANGE_READY_TO_PAUSED: case GST_STATE_CHANGE_READY_TO_PAUSED:
ret = GST_STATE_CHANGE_NO_PREROLL; ret = GST_STATE_CHANGE_NO_PREROLL;
gst_pad_set_active (self->priv->internal_srcpad, TRUE); gst_pad_set_active (self->internal_srcpad, TRUE);
break; break;
case GST_STATE_CHANGE_PAUSED_TO_READY: case GST_STATE_CHANGE_PAUSED_TO_READY:
gst_pad_set_active (self->priv->internal_srcpad, FALSE); gst_pad_set_active (self->internal_srcpad, FALSE);
break; break;
default: default:
break; break;
@ -305,7 +285,7 @@ gst_proxy_src_internal_src_query (GstPad * pad, GstObject * parent,
GST_LOG_OBJECT (pad, "Handling query of type '%s'", GST_LOG_OBJECT (pad, "Handling query of type '%s'",
gst_query_type_get_name (GST_QUERY_TYPE (query))); gst_query_type_get_name (GST_QUERY_TYPE (query)));
sink = g_weak_ref_get (&self->priv->proxysink); sink = g_weak_ref_get (&self->proxysink);
if (sink) { if (sink) {
GstPad *sinkpad; GstPad *sinkpad;
sinkpad = gst_proxy_sink_get_internal_sinkpad (sink); sinkpad = gst_proxy_sink_get_internal_sinkpad (sink);
@ -333,7 +313,7 @@ gst_proxy_src_internal_src_event (GstPad * pad, GstObject * parent,
GST_LOG_OBJECT (pad, "Got %s event", GST_EVENT_TYPE_NAME (event)); GST_LOG_OBJECT (pad, "Got %s event", GST_EVENT_TYPE_NAME (event));
sink = g_weak_ref_get (&self->priv->proxysink); sink = g_weak_ref_get (&self->proxysink);
if (sink) { if (sink) {
GstPad *sinkpad; GstPad *sinkpad;
sinkpad = gst_proxy_sink_get_internal_sinkpad (sink); sinkpad = gst_proxy_sink_get_internal_sinkpad (sink);
@ -354,5 +334,5 @@ gst_proxy_src_internal_src_event (GstPad * pad, GstObject * parent,
GstPad * GstPad *
gst_proxy_src_get_internal_srcpad (GstProxySrc * self) gst_proxy_src_get_internal_srcpad (GstProxySrc * self)
{ {
return gst_object_ref (self->priv->internal_srcpad); return gst_object_ref (self->internal_srcpad);
} }

View file

@ -41,8 +41,21 @@ struct _GstProxySrc {
GstBin parent; GstBin parent;
/* < private > */ /* < private > */
GstProxySrcPrivate *priv;
gpointer _gst_reserved[GST_PADDING]; /* Queue to hold buffers from proxysink */
GstElement *queue;
/* Source pad of the above queue and the proxysrc element itself */
GstPad *srcpad;
/* Our internal srcpad that proxysink pushes buffers/events/queries into */
GstPad *internal_srcpad;
/* An unlinked dummy sinkpad; see gst_proxy_src_init() */
GstPad *dummy_sinkpad;
/* The matching proxysink; queries and events are sent to its sinkpad */
GWeakRef proxysink;
}; };
struct _GstProxySrcClass { struct _GstProxySrcClass {