mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
gst/autoplug/: Fix autoplugging in spider element, so it works with new caps.
Original commit message from CVS: 2003-12-22 Benjamin Otte <in7y118@public.uni-hamburg.de> * gst/autoplug/gstsearchfuncs.c: (gst_autoplug_caps_intersect): * gst/autoplug/gstspideridentity.c: (gst_spider_identity_link), (gst_spider_identity_getcaps), (gst_spider_identity_change_state), (gst_spider_identity_sink_loop_type_finding): * gst/autoplug/gstspideridentity.h: Fix autoplugging in spider element, so it works with new caps. This was mainly caused by identifying empty caps incorrectly.
This commit is contained in:
parent
50b7bcab86
commit
d136495dd9
4 changed files with 53 additions and 25 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2003-12-22 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||||
|
|
||||||
|
* gst/autoplug/gstsearchfuncs.c: (gst_autoplug_caps_intersect):
|
||||||
|
* gst/autoplug/gstspideridentity.c: (gst_spider_identity_link),
|
||||||
|
(gst_spider_identity_getcaps), (gst_spider_identity_change_state),
|
||||||
|
(gst_spider_identity_sink_loop_type_finding):
|
||||||
|
* gst/autoplug/gstspideridentity.h:
|
||||||
|
Fix autoplugging in spider element, so it works with new caps.
|
||||||
|
This was mainly caused by identifying empty caps incorrectly.
|
||||||
|
|
||||||
2003-12-22 David Schleef <ds@schleef.org>
|
2003-12-22 David Schleef <ds@schleef.org>
|
||||||
|
|
||||||
* gststructure.c, gstvalue.c, gstvalue.h: Add
|
* gststructure.c, gstvalue.c, gstvalue.h: Add
|
||||||
|
|
|
@ -28,10 +28,8 @@
|
||||||
#include "gstsearchfuncs.h"
|
#include "gstsearchfuncs.h"
|
||||||
|
|
||||||
/* FIXME: "evil hack" alarm, we need a better way to get a category in here */
|
/* FIXME: "evil hack" alarm, we need a better way to get a category in here */
|
||||||
#ifndef GST_DISABLE_GST_DEBUG
|
GST_DEBUG_CATEGORY_EXTERN (GST_CAT_AUTOPLUG_ATTEMPT);
|
||||||
extern GstDebugCategory *GST_CAT_AUTOPLUG_ATTEMPT;
|
|
||||||
#define GST_CAT_DEFAULT GST_CAT_AUTOPLUG_ATTEMPT
|
#define GST_CAT_DEFAULT GST_CAT_AUTOPLUG_ATTEMPT
|
||||||
#endif
|
|
||||||
|
|
||||||
/* function that really misses in GLib
|
/* function that really misses in GLib
|
||||||
* though the GLib version should take a function as argument...
|
* though the GLib version should take a function as argument...
|
||||||
|
@ -62,16 +60,14 @@ gst_autoplug_caps_intersect (const GstCaps *src, const GstCaps *sink)
|
||||||
{
|
{
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
/* if there are no caps, we can link */
|
|
||||||
if ((src == NULL) && (sink == NULL))
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
/* get an intersection */
|
/* get an intersection */
|
||||||
caps = gst_caps_intersect (src, sink);
|
caps = gst_caps_intersect (src, sink);
|
||||||
|
|
||||||
/* if the caps can't link, there is no intersection */
|
/* if the caps can't link, there is no intersection */
|
||||||
if (caps == NULL)
|
if (gst_caps_is_empty (caps)) {
|
||||||
|
gst_caps_free (caps);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* hurrah, we can link, now remove the intersection */
|
/* hurrah, we can link, now remove the intersection */
|
||||||
gst_caps_free (caps);
|
gst_caps_free (caps);
|
||||||
|
|
|
@ -232,30 +232,40 @@ gst_spider_identity_link (GstPad *pad, const GstCaps *caps)
|
||||||
else
|
else
|
||||||
otherpad = spider_identity->src;
|
otherpad = spider_identity->src;
|
||||||
|
|
||||||
if (otherpad != NULL)
|
g_return_val_if_fail (otherpad != NULL, GST_PAD_LINK_REFUSED);
|
||||||
return gst_pad_proxy_link (otherpad, caps);
|
if (GST_PAD_PEER (otherpad) == NULL)
|
||||||
|
return GST_PAD_LINK_DELAYED;
|
||||||
return GST_PAD_LINK_OK;
|
|
||||||
|
return gst_pad_try_set_caps (otherpad, gst_caps_copy (caps));
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstCaps*
|
static GstCaps*
|
||||||
gst_spider_identity_getcaps (GstPad *pad)
|
gst_spider_identity_getcaps (GstPad *pad)
|
||||||
{
|
{
|
||||||
GstSpiderIdentity *spider_identity = GST_SPIDER_IDENTITY (gst_pad_get_parent (pad));
|
GstSpiderIdentity *ident = GST_SPIDER_IDENTITY (gst_pad_get_parent (pad));
|
||||||
GstPad *otherpad;
|
GstPad *otherpad;
|
||||||
GstPad *peer;
|
|
||||||
|
|
||||||
if (pad == spider_identity->src)
|
if (pad == ident->src)
|
||||||
otherpad = spider_identity->sink;
|
otherpad = ident->sink;
|
||||||
else
|
else
|
||||||
otherpad = spider_identity->src;
|
otherpad = ident->src;
|
||||||
|
|
||||||
if (otherpad != NULL) {
|
if (otherpad != NULL) {
|
||||||
peer = GST_PAD_PEER (otherpad);
|
GstPad *peer = GST_PAD_PEER (otherpad);
|
||||||
|
|
||||||
if (peer)
|
if (peer) {
|
||||||
return gst_pad_get_caps (peer);
|
GstCaps *ret = gst_pad_get_caps (peer);
|
||||||
|
if (ident->caps) {
|
||||||
|
GstCaps *ret2 = gst_caps_intersect (ident->caps, ret);
|
||||||
|
gst_caps_free (ret);
|
||||||
|
ret = ret2;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (ident->caps)
|
||||||
|
return gst_caps_copy (ident->caps);
|
||||||
|
|
||||||
return gst_caps_new_any ();
|
return gst_caps_new_any ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,6 +328,9 @@ gst_spider_identity_change_state (GstElement *element)
|
||||||
g_return_val_if_fail (GST_IS_SPIDER_IDENTITY (ident), GST_STATE_FAILURE);
|
g_return_val_if_fail (GST_IS_SPIDER_IDENTITY (ident), GST_STATE_FAILURE);
|
||||||
|
|
||||||
switch (GST_STATE_TRANSITION (element)) {
|
switch (GST_STATE_TRANSITION (element)) {
|
||||||
|
case GST_STATE_PAUSED_TO_READY:
|
||||||
|
gst_caps_replace (&ident->caps, NULL);
|
||||||
|
break;
|
||||||
case GST_STATE_PAUSED_TO_PLAYING:
|
case GST_STATE_PAUSED_TO_PLAYING:
|
||||||
/* autoplugger check */
|
/* autoplugger check */
|
||||||
spider = GST_SPIDER (GST_ELEMENT_PARENT (ident));
|
spider = GST_SPIDER (GST_ELEMENT_PARENT (ident));
|
||||||
|
@ -327,13 +340,16 @@ gst_spider_identity_change_state (GstElement *element)
|
||||||
/* start typefinding or plugging */
|
/* start typefinding or plugging */
|
||||||
if ((GST_RPAD_PEER (ident->sink) != NULL) && (GST_RPAD_PEER (ident->src) == NULL))
|
if ((GST_RPAD_PEER (ident->sink) != NULL) && (GST_RPAD_PEER (ident->src) == NULL))
|
||||||
{
|
{
|
||||||
if (gst_pad_get_caps ((GstPad *) GST_PAD_PEER (ident->sink)) == NULL)
|
GstCaps *caps = gst_pad_get_caps ((GstPad *) GST_PAD_PEER (ident->sink));
|
||||||
|
if (gst_caps_is_any (caps) || gst_caps_is_empty (caps))
|
||||||
{
|
{
|
||||||
gst_spider_identity_start_type_finding (ident);
|
gst_spider_identity_start_type_finding (ident);
|
||||||
|
gst_caps_free (caps);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
gst_spider_identity_plug (ident);
|
gst_spider_identity_plug (ident);
|
||||||
}
|
}
|
||||||
|
gst_caps_free (caps);
|
||||||
}
|
}
|
||||||
/* autoplug on src */
|
/* autoplug on src */
|
||||||
if ((GST_RPAD_PEER (ident->src) != NULL) && (GST_RPAD_PEER (ident->sink) == NULL))
|
if ((GST_RPAD_PEER (ident->src) != NULL) && (GST_RPAD_PEER (ident->sink) == NULL))
|
||||||
|
@ -461,8 +477,11 @@ gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity *ident)
|
||||||
find.buffer = GST_BUFFER (data);
|
find.buffer = GST_BUFFER (data);
|
||||||
/* maybe there are already valid caps now? */
|
/* maybe there are already valid caps now? */
|
||||||
find.caps = gst_pad_get_caps (ident->sink);
|
find.caps = gst_pad_get_caps (ident->sink);
|
||||||
if (find.caps != NULL) {
|
if (! gst_caps_is_empty (find.caps) && !gst_caps_is_any (find.caps)) {
|
||||||
goto plug;
|
goto plug;
|
||||||
|
} else {
|
||||||
|
gst_caps_free (find.caps);
|
||||||
|
find.caps = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now do the actual typefinding with the supplied buffer */
|
/* now do the actual typefinding with the supplied buffer */
|
||||||
|
@ -499,9 +518,13 @@ end:
|
||||||
|
|
||||||
plug:
|
plug:
|
||||||
GST_INFO ("typefind function found caps");
|
GST_INFO ("typefind function found caps");
|
||||||
|
ident->caps = find.caps;
|
||||||
g_assert (gst_pad_try_set_caps (ident->src, find.caps) > 0);
|
g_assert (gst_pad_try_set_caps (ident->src, find.caps) > 0);
|
||||||
gst_caps_debug (find.caps, "spider starting caps");
|
{
|
||||||
gst_caps_free (find.caps);
|
gchar *str = gst_caps_to_string (find.caps);
|
||||||
|
GST_LOG_OBJECT (ident, "spider starting caps: %s", str);
|
||||||
|
g_free (str);
|
||||||
|
}
|
||||||
if (type_list)
|
if (type_list)
|
||||||
g_list_free (type_list);
|
g_list_free (type_list);
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,6 @@ struct _GstSpiderIdentity {
|
||||||
|
|
||||||
/* Caps from typefinding */
|
/* Caps from typefinding */
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstSpiderIdentityClass {
|
struct _GstSpiderIdentityClass {
|
||||||
|
|
Loading…
Reference in a new issue