mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-21 07:46:38 +00:00
ghostpad: API: Expose gst_proxy_pad_get_internal()
This allows to get the internal pad of ghostpads and proxypads without using gst_pad_iterate_internal_links() and is much more convenient. The internal pad of a ghostpad is the pad of the opposite direction that is used to link to the ghostpad target.
This commit is contained in:
parent
e8688b62b2
commit
a216426bb6
5 changed files with 39 additions and 7 deletions
|
@ -902,14 +902,20 @@ gst_format_get_type
|
|||
<SECTION>
|
||||
<FILE>gstghostpad</FILE>
|
||||
<TITLE>GstGhostPad</TITLE>
|
||||
GstProxyPad
|
||||
GstGhostPad
|
||||
|
||||
gst_ghost_pad_new
|
||||
gst_ghost_pad_new_no_target
|
||||
gst_ghost_pad_new_from_template
|
||||
gst_ghost_pad_new_no_target_from_template
|
||||
|
||||
gst_ghost_pad_set_target
|
||||
gst_ghost_pad_get_target
|
||||
|
||||
gst_ghost_pad_construct
|
||||
|
||||
gst_proxy_pad_get_internal
|
||||
<SUBSECTION Standard>
|
||||
GstGhostPadClass
|
||||
GST_GHOST_PAD
|
||||
|
|
|
@ -73,7 +73,6 @@ struct _GstProxyPadPrivate
|
|||
G_DEFINE_TYPE (GstProxyPad, gst_proxy_pad, GST_TYPE_PAD);
|
||||
|
||||
static GstPad *gst_proxy_pad_get_target (GstPad * pad);
|
||||
static GstPad *gst_proxy_pad_get_internal (GstPad * pad);
|
||||
|
||||
static void gst_proxy_pad_dispose (GObject * object);
|
||||
static void gst_proxy_pad_finalize (GObject * object);
|
||||
|
@ -108,7 +107,8 @@ static gboolean
|
|||
gst_proxy_pad_do_event (GstPad * pad, GstEvent * event)
|
||||
{
|
||||
gboolean res = FALSE;
|
||||
GstPad *internal = gst_proxy_pad_get_internal (pad);
|
||||
GstPad *internal =
|
||||
GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD_CAST (pad)));
|
||||
|
||||
if (internal) {
|
||||
res = gst_pad_push_event (internal, event);
|
||||
|
@ -152,7 +152,8 @@ gst_proxy_pad_do_bufferalloc (GstPad * pad, guint64 offset, guint size,
|
|||
GstCaps * caps, GstBuffer ** buf)
|
||||
{
|
||||
GstFlowReturn result = GST_FLOW_WRONG_STATE;
|
||||
GstPad *internal = gst_proxy_pad_get_internal (pad);
|
||||
GstPad *internal =
|
||||
GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD_CAST (pad)));
|
||||
|
||||
if (internal) {
|
||||
result = gst_pad_alloc_buffer (internal, offset, size, caps, buf);
|
||||
|
@ -364,18 +365,32 @@ gst_proxy_pad_get_target (GstPad * pad)
|
|||
return target;
|
||||
}
|
||||
|
||||
static GstPad *
|
||||
gst_proxy_pad_get_internal (GstPad * pad)
|
||||
/**
|
||||
* gst_proxy_pad_get_internal:
|
||||
* @pad: the #GstProxyPad
|
||||
*
|
||||
* Get the internal pad of @pad. Unref target pad after usage.
|
||||
*
|
||||
* The internal pad of a #GstGhostPad is the internally used
|
||||
* pad of opposite direction, which is used to link to the target.
|
||||
*
|
||||
* Returns: (transfer full): the target #GstProxyPad, can be NULL.
|
||||
* Unref target pad after usage.
|
||||
*/
|
||||
GstProxyPad *
|
||||
gst_proxy_pad_get_internal (GstProxyPad * pad)
|
||||
{
|
||||
GstPad *internal;
|
||||
|
||||
g_return_val_if_fail (GST_IS_PROXY_PAD (pad), NULL);
|
||||
|
||||
GST_PROXY_LOCK (pad);
|
||||
internal = GST_PROXY_PAD_INTERNAL (pad);
|
||||
if (internal)
|
||||
gst_object_ref (internal);
|
||||
GST_PROXY_UNLOCK (pad);
|
||||
|
||||
return internal;
|
||||
return GST_PROXY_PAD_CAST (internal);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -59,6 +59,8 @@ struct _GstProxyPadClass
|
|||
|
||||
GType gst_proxy_pad_get_type (void);
|
||||
|
||||
GstProxyPad* gst_proxy_pad_get_internal (GstProxyPad *pad);
|
||||
|
||||
|
||||
#define GST_TYPE_GHOST_PAD (gst_ghost_pad_get_type ())
|
||||
#define GST_IS_GHOST_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GHOST_PAD))
|
||||
|
|
|
@ -255,7 +255,7 @@ GST_END_TEST;
|
|||
GST_START_TEST (test_link)
|
||||
{
|
||||
GstElement *b1, *b2, *src, *sink;
|
||||
GstPad *srcpad, *sinkpad, *gpad;
|
||||
GstPad *srcpad, *sinkpad, *gpad, *ppad, *tmp;
|
||||
GstPadLinkReturn ret;
|
||||
|
||||
b1 = gst_element_factory_make ("pipeline", NULL);
|
||||
|
@ -278,6 +278,14 @@ GST_START_TEST (test_link)
|
|||
|
||||
/* now setup a ghostpad */
|
||||
gpad = gst_ghost_pad_new ("sink", sinkpad);
|
||||
|
||||
/* Check if the internal pads are set correctly */
|
||||
ppad = GST_PAD (gst_proxy_pad_get_internal (GST_PROXY_PAD (gpad)));
|
||||
fail_unless (ppad == GST_PAD_PEER (sinkpad));
|
||||
tmp = GST_PAD (gst_proxy_pad_get_internal (GST_PROXY_PAD (ppad)));
|
||||
fail_unless (tmp == gpad);
|
||||
gst_object_unref (tmp);
|
||||
gst_object_unref (ppad);
|
||||
gst_object_unref (sinkpad);
|
||||
/* need to ref as _add_pad takes ownership */
|
||||
gst_object_ref (gpad);
|
||||
|
|
|
@ -832,6 +832,7 @@ EXPORTS
|
|||
gst_print_element_args
|
||||
gst_print_pad_caps
|
||||
gst_progress_type_get_type
|
||||
gst_proxy_pad_get_internal
|
||||
gst_proxy_pad_get_type
|
||||
gst_qos_type_get_type
|
||||
gst_query_add_buffering_range
|
||||
|
|
Loading…
Reference in a new issue