From 0c6802533c22d0b60bf169e7ed132f1edaa0b4b3 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Sun, 3 Mar 2002 00:44:41 +0000 Subject: [PATCH] document gst_caps_debug change gst_caps_debug to accept a label argument, assists greatly in debugging capsnego bette... Original commit message from CVS: * document gst_caps_debug * change gst_caps_debug to accept a label argument, assists greatly in debugging capsnego * better names from gst_object_name_default * some more debugging in gstpad.c * require caps to match padtemplates on both side of a connection * gstspider uses default naming so that names are globally unique * moved filesrc offset arg to the top -- show up first in a prop list. in the future we should have flags on props indicating which ones it might be interesting for the end-user to change. * initialize cothreads in the more standard way, and provide some more debugging --- common | 2 +- gst/autoplug/gstspider.c | 3 +-- gst/elements/gstfilesrc.c | 2 +- gst/gstcaps.c | 11 +++++++++-- gst/gstcaps.h | 2 +- gst/gstelement.c | 2 +- gst/gstobject.c | 16 ++++++++-------- gst/gstpad.c | 35 ++++++++++++++++++++++++++--------- gst/gstprops.c | 6 +++++- gst/schedulers/gststandardscheduler.c | 25 ++++++++++++++++++++++--- plugins/elements/gstfilesrc.c | 2 +- 11 files changed, 76 insertions(+), 30 deletions(-) diff --git a/common b/common index 7b9a180..2adced5 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 7b9a18016ec2fe74c23382856a0f480da259f971 +Subproject commit 2adced54d821c7870fd4d9e5e19482418a64c931 diff --git a/gst/autoplug/gstspider.c b/gst/autoplug/gstspider.c index 9f51adc..9ffd567 100644 --- a/gst/autoplug/gstspider.c +++ b/gst/autoplug/gstspider.c @@ -529,8 +529,7 @@ gst_spider_create_and_plug (GstSpiderConnection *conn, GList *plugpath) { element = (GstElement *) (endelements == NULL ? conn->src : endelements->data); } else { - element = gst_elementfactory_create ((GstElementFactory *) plugpath->data, - gst_spider_unused_elementname (GST_BIN (spider), GST_OBJECT_NAME (plugpath->data))); + element = gst_elementfactory_create ((GstElementFactory *) plugpath->data, NULL); gst_bin_add (GST_BIN (spider), element); } /* insert and connect new element */ diff --git a/gst/elements/gstfilesrc.c b/gst/elements/gstfilesrc.c index 6ab7c88..409b38d 100644 --- a/gst/elements/gstfilesrc.c +++ b/gst/elements/gstfilesrc.c @@ -89,11 +89,11 @@ enum { enum { ARG_0, + ARG_OFFSET, ARG_LOCATION, ARG_FILESIZE, ARG_FD, ARG_BLOCKSIZE, - ARG_OFFSET, ARG_MAPSIZE, ARG_TOUCH, }; diff --git a/gst/gstcaps.c b/gst/gstcaps.c index 75ecec2..7f61e35 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -143,10 +143,17 @@ gst_caps_destroy (GstCaps *caps) gst_caps_unref (next); } +/** + * gst_caps_debug: + * @caps: the caps to print out + * @label: a label to put on the printout, or NULL + * + * Print out the contents of the caps structure. Useful for debugging. + */ void -gst_caps_debug (GstCaps *caps) +gst_caps_debug (GstCaps *caps, const gchar *label) { - GST_DEBUG_ENTER ("caps debug"); + GST_DEBUG_ENTER ("caps debug: %s", label); while (caps) { GST_DEBUG (GST_CAT_CAPS, "caps: %p %s %s\n", caps, caps->name, gst_caps_get_mime (caps)); diff --git a/gst/gstcaps.h b/gst/gstcaps.h index 8fb8be0..39ee56d 100644 --- a/gst/gstcaps.h +++ b/gst/gstcaps.h @@ -85,7 +85,7 @@ GstCaps* gst_caps_unref (GstCaps *caps); GstCaps* gst_caps_ref (GstCaps *caps); void gst_caps_destroy (GstCaps *caps); -void gst_caps_debug (GstCaps *caps); +void gst_caps_debug (GstCaps *caps, const gchar *label); GstCaps* gst_caps_copy (GstCaps *caps); GstCaps* gst_caps_copy_1 (GstCaps *caps); diff --git a/gst/gstelement.c b/gst/gstelement.c index 5885155..2490076 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -831,7 +831,7 @@ gst_element_get_compatible_pad (GstElement *element, GstPad *pad) } /** - * gst_element_connect_elements: + * gst_element_connect_elements_filtered: * @src: the element containing source pad * @dest: the element containing destination pad * @filtercaps: the caps to use as filter diff --git a/gst/gstobject.c b/gst/gstobject.c index 93f4e4c..e7f9eda 100644 --- a/gst/gstobject.c +++ b/gst/gstobject.c @@ -271,8 +271,8 @@ static void gst_object_set_name_default (GstObject *object) { gint count; - gchar *name; - const gchar *type_name, *subname; + gchar *name, *tmp; + const gchar *type_name; type_name = G_OBJECT_TYPE_NAME (object); @@ -286,12 +286,12 @@ gst_object_set_name_default (GstObject *object) G_UNLOCK (object_name_mutex); - /* GstFooSink -> sinkN */ - subname = type_name + strlen (type_name) - 1; - while (g_ascii_islower (*subname) && subname > type_name) - subname--; - name = g_strdup_printf ("%s%d", subname, count); - *name = g_ascii_tolower (*name); + /* GstFooSink -> foosinkN */ + if (strncmp (type_name, "Gst", 3) == 0) + type_name += 3; + tmp = g_strdup_printf ("%s%d", type_name, count); + name = g_ascii_strdown (tmp, strlen (tmp)); + g_free (tmp); gst_object_set_name (object, name); g_free (name); diff --git a/gst/gstpad.c b/gst/gstpad.c index 9460123..e1842a1 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -727,7 +727,7 @@ gst_pad_connect_filtered (GstPad *srcpad, GstPad *sinkpad, GstCaps *filtercaps) return FALSE; } - + /* fire off a signal to each of the pads telling them that they've been connected */ g_signal_emit (G_OBJECT (realsrc), gst_real_pad_signals[REAL_CONNECTED], 0, realsink); g_signal_emit (G_OBJECT (realsink), gst_real_pad_signals[REAL_CONNECTED], 0, realsrc); @@ -740,6 +740,7 @@ gst_pad_connect_filtered (GstPad *srcpad, GstPad *sinkpad, GstCaps *filtercaps) GST_INFO (GST_CAT_PADS, "connected %s:%s and %s:%s", GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); + gst_caps_debug (gst_pad_get_caps (GST_PAD_CAST (realsrc)), "caps of newly connected src pad"); return TRUE; } @@ -956,6 +957,7 @@ static GstPadConnectReturn gst_pad_try_set_caps_func (GstRealPad *pad, GstCaps *caps, gboolean notify) { GstCaps *oldcaps; + GstPadTemplate *template; GstElement *parent = GST_PAD_PARENT (pad); /* thomas: FIXME: is this the right result to return ? */ @@ -973,6 +975,18 @@ gst_pad_try_set_caps_func (GstRealPad *pad, GstCaps *caps, gboolean notify) GST_INFO (GST_CAT_CAPS, "trying to set caps %p on pad %s:%s", caps, GST_DEBUG_PAD_NAME (pad)); + + if ((template = gst_pad_get_padtemplate (GST_PAD_CAST (pad)))) { + if (!gst_caps_intersect (caps, gst_padtemplate_get_caps (template))) { + GST_INFO (GST_CAT_CAPS, "caps did not intersect with %s:%s's padtemplate", + GST_DEBUG_PAD_NAME (pad)); + gst_caps_debug (gst_padtemplate_get_caps (template), + "pad template caps that did not agree with caps"); + return GST_PAD_CONNECT_REFUSED; + } + /* given that the caps are fixed, we know that their intersection with the + * padtemplate caps is the same as caps itself */ + } /* we need to notify the connect function */ if (notify && GST_RPAD_CONNECTFUNC (pad)) { @@ -1058,15 +1072,18 @@ gst_pad_try_set_caps (GstPad *pad, GstCaps *caps) GST_INFO (GST_CAT_CAPS, "trying to set caps %p on pad %s:%s", caps, GST_DEBUG_PAD_NAME (realpad)); + gst_caps_debug (caps, "caps that we are trying to set"); + /* setting non fixed caps on a pad is not allowed */ if (!GST_CAPS_IS_FIXED (caps)) { GST_INFO (GST_CAT_CAPS, "trying to set unfixed caps on pad %s:%s, not allowed", GST_DEBUG_PAD_NAME (realpad)); g_warning ("trying to set non fixed caps on pad %s:%s, not allowed", GST_DEBUG_PAD_NAME (realpad)); - gst_caps_debug (caps); + gst_caps_debug (caps, "unfixed caps"); return FALSE; } + /* if we have a peer try to set the caps, notifying the peerpad * if it has a connect function */ if (peer && (gst_pad_try_set_caps_func (peer, caps, TRUE) != GST_PAD_CONNECT_OK)) @@ -1075,6 +1092,7 @@ gst_pad_try_set_caps (GstPad *pad, GstCaps *caps) GST_DEBUG_PAD_NAME (peer)); return FALSE; } + /* then try to set our own caps, we don't need to be notified */ if (gst_pad_try_set_caps_func (realpad, caps, FALSE) != GST_PAD_CONNECT_OK) { @@ -1084,7 +1102,6 @@ gst_pad_try_set_caps (GstPad *pad, GstCaps *caps) } GST_INFO (GST_CAT_CAPS, "succeeded setting caps %p on pad %s:%s", caps, GST_DEBUG_PAD_NAME (realpad)); - gst_caps_debug (caps); g_assert (GST_PAD_CAPS (pad)); return TRUE; @@ -1127,10 +1144,10 @@ gst_pad_try_reconnect_filtered_func (GstRealPad *srcpad, GstRealPad *sinkpad, Gs srccaps = gst_pad_get_caps (GST_PAD (realsrc)); GST_INFO (GST_CAT_PADS, "dumping caps of pad %s:%s", GST_DEBUG_PAD_NAME (realsrc)); - gst_caps_debug (srccaps); + gst_caps_debug (srccaps, "caps of src pad (pre-reconnect)"); sinkcaps = gst_pad_get_caps (GST_PAD (realsink)); GST_INFO (GST_CAT_PADS, "dumping caps of pad %s:%s", GST_DEBUG_PAD_NAME (realsink)); - gst_caps_debug (sinkcaps); + gst_caps_debug (sinkcaps, "caps of sink pad (pre-reconnect)"); /* first take the intersection of the pad caps */ intersection = gst_caps_intersect (srccaps, sinkcaps); @@ -1168,7 +1185,7 @@ gst_pad_try_reconnect_filtered_func (GstRealPad *srcpad, GstRealPad *sinkpad, Gs } } GST_DEBUG (GST_CAT_CAPS, "setting filter for connection to:\n"); - gst_caps_debug (intersection); + gst_caps_debug (intersection, "filter for connection"); GST_RPAD_FILTER (realsrc) = intersection; GST_RPAD_FILTER (realsink) = intersection; @@ -1204,13 +1221,13 @@ gst_pad_perform_negotiate (GstPad *srcpad, GstPad *sinkpad) /* calculate the new caps here */ srccaps = gst_pad_get_caps (GST_PAD (realsrc)); GST_INFO (GST_CAT_PADS, "dumping caps of pad %s:%s", GST_DEBUG_PAD_NAME (realsrc)); - gst_caps_debug (srccaps); + gst_caps_debug (srccaps, "src caps, awaiting negotiation"); sinkcaps = gst_pad_get_caps (GST_PAD (realsink)); GST_INFO (GST_CAT_PADS, "dumping caps of pad %s:%s", GST_DEBUG_PAD_NAME (realsink)); - gst_caps_debug (sinkcaps); + gst_caps_debug (sinkcaps, "sink caps, awaiting negotiation"); intersection = gst_caps_intersect (srccaps, sinkcaps); - /* no negotiation is performed it the pads have filtercaps */ + /* no negotiation is performed if the pads have filtercaps */ if (intersection) { GstPadConnectReturn res; diff --git a/gst/gstprops.c b/gst/gstprops.c index bf75fb9..2a849d7 100644 --- a/gst/gstprops.c +++ b/gst/gstprops.c @@ -494,9 +494,13 @@ gst_props_newv (const gchar *firstname, va_list var_args) * gst_props_set: * @props: the props to modify * @name: the name of the entry to modify - * @...: More property entries. + * @...: The prop entry. * * Modifies the value of the given entry in the props struct. + * For the optional args, use GST_PROPS_FOO, where FOO is INT, + * STRING, etc. This macro expands to a variable number of arguments, + * hence the lack of precision in the function prototype. No + * terminating NULL is necessary. * * Returns: the new modified property structure. */ diff --git a/gst/schedulers/gststandardscheduler.c b/gst/schedulers/gststandardscheduler.c index 4676b8d..345d980 100644 --- a/gst/schedulers/gststandardscheduler.c +++ b/gst/schedulers/gststandardscheduler.c @@ -185,7 +185,6 @@ gst_standard_scheduler_init (GstStandardScheduler *scheduler) scheduler->num_elements = 0; scheduler->chains = NULL; scheduler->num_chains = 0; - scheduler->main = cothread_create (NULL, 0, NULL, NULL); } static void @@ -221,6 +220,19 @@ GstPluginDesc plugin_desc = { plugin_init }; +static inline cothread* sched_create (GstStandardScheduler *scheduler, GstElement *element, cothread_func func) +{ + cothread *ret = NULL; + + GST_DEBUG (GST_CAT_COTHREADS, "calling cothread_create (%p, %d, %p, %p)\n", func, 1, element, scheduler->main); + + ret = cothread_create (func, 1, (void**) element, scheduler->main); + + GST_INFO (GST_CAT_COTHREADS, "created new cothread %p", ret); + + return ret; +} + static inline void sched_switch (cothread *to) { cothread *from = cothread_self (); @@ -575,7 +587,7 @@ gst_standard_scheduler_cothreaded_chain (GstBin * bin, GstSchedulerChain * chain /* need to set up the cothread now */ if (wrapper_function != NULL) { if (!GST_ELEMENT_THREADSTATE (element)) { - GST_ELEMENT_THREADSTATE (element) = cothread_create (wrapper_function, 1, (void **) element, chain->sched->main); + GST_ELEMENT_THREADSTATE (element) = sched_create (chain->sched, element, wrapper_function); if (GST_ELEMENT_THREADSTATE (element) == NULL) { gst_element_error (element, "could not create cothread for \"%s\"", GST_ELEMENT_NAME (element), NULL); @@ -900,7 +912,14 @@ gst_standard_scheduler_chain_recursive_add (GstSchedulerChain * chain, GstElemen static void gst_standard_scheduler_setup (GstScheduler *sched) { - /* bling blau */ + GstStandardScheduler *scheduler = GST_STANDARD_SCHEDULER (sched); + + /* initialize the main cothread here. this way we know that we're within the + gthread that the sched will be running */ + if (!scheduler->main) + scheduler->main = cothread_create (NULL, 0, NULL, NULL); + + g_return_if_fail (scheduler->main != NULL); } static void diff --git a/plugins/elements/gstfilesrc.c b/plugins/elements/gstfilesrc.c index 6ab7c88..409b38d 100644 --- a/plugins/elements/gstfilesrc.c +++ b/plugins/elements/gstfilesrc.c @@ -89,11 +89,11 @@ enum { enum { ARG_0, + ARG_OFFSET, ARG_LOCATION, ARG_FILESIZE, ARG_FD, ARG_BLOCKSIZE, - ARG_OFFSET, ARG_MAPSIZE, ARG_TOUCH, }; -- 2.7.4