Started work on better ghostpad management, and started to build the low- level EOS mechanism.

Original commit message from CVS:
Started work on better ghostpad management, and started to build the low-
level EOS mechanism.

Also removed a couple of printouts that aren't needed any more.
This commit is contained in:
Erik Walthinsen 2000-12-31 22:18:05 +00:00
parent 424d4f5e4e
commit 9a0438ba93
11 changed files with 115 additions and 7 deletions

View file

@ -197,10 +197,22 @@ gst_element_add_ghost_pad (GstElement *element, GstPad *pad)
element->pads = g_list_append (element->pads, pad);
element->numpads++;
/* emit the NEW_PAD signal */
/* emit the NEW_GHOST_PAD signal */
gtk_signal_emit (GTK_OBJECT (element), gst_element_signals[NEW_GHOST_PAD], pad);
}
void
gst_element_remove_ghost_pad (GstElement *element, GstPad *pad)
{
g_return_if_fail (element != NULL);
g_return_if_fail (GST_IS_ELEMENT (element));
g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_PAD (pad));
// FIXME
}
/**
* gst_element_get_pad:
* @element: element to find pad of

View file

@ -193,6 +193,7 @@ GstPad* gst_element_get_pad (GstElement *element, gchar *name);
GList* gst_element_get_pad_list (GstElement *element);
GList* gst_element_get_padtemplate_list (GstElement *element);
void gst_element_add_ghost_pad (GstElement *element, GstPad *pad);
void gst_element_remove_ghost_pad (GstElement *element, GstPad *pad);
void gst_element_connect (GstElement *src, gchar *srcpadname,
GstElement *dest, gchar *destpadname);

View file

@ -182,7 +182,7 @@ gst_default_error_handler (gchar *file, gchar *function,
// if there's an element, print out the pertinent information
if (element) {
if (GST_IS_ELEMENT(element)) {
if (GST_IS_OBJECT(element)) {
path = gst_object_get_path_string(element);
fprintf(stderr,"Element: %s",path);
chars = 9 + strlen(path);

View file

@ -193,7 +193,6 @@ extern guint32 _gst_info_categories;
}G_STMT_END
//#define GST_INFO_PLUGIN_LOAD 0
enum {
GST_INFO_GST_INIT = 0, // Library initialization
GST_INFO_COTHREADS, // Cothread creation, etc.

View file

@ -52,6 +52,7 @@ static void gst_pad_get_arg (GtkObject *object,GtkArg *arg,guint id);
static void gst_pad_real_destroy (GtkObject *object);
static void gst_pad_push_func (GstPad *pad, GstBuffer *buf);
static gboolean gst_pad_eos_func (GstPad *pad);
static GstObject *pad_parent_class = NULL;
static guint gst_pad_signals[LAST_SIGNAL] = { 0 };
@ -114,6 +115,7 @@ gst_pad_init (GstPad *pad)
pad->getfunc = NULL;
pad->getregionfunc = NULL;
pad->qosfunc = NULL;
pad->eosfunc = gst_pad_eos_func;
pad->pushfunc = GST_DEBUG_FUNCPTR(gst_pad_push_func);
pad->pullfunc = NULL;
@ -342,6 +344,25 @@ gst_pad_set_qos_function (GstPad *pad,
pad->qosfunc = qos;
}
/**
* gst_pad_set_eos_function:
* @pad: the pad to set the eos function for
* @qos: the eos function
*
* Set the given EOS function for the pad
*/
void
gst_pad_set_eos_function (GstPad *pad,
GstPadEOSFunction eos)
{
g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_PAD (pad));
pad->eosfunc = eos;
}
static void
gst_pad_push_func(GstPad *pad, GstBuffer *buf)
{
@ -1017,3 +1038,56 @@ gst_padtemplate_load_thyself (xmlNodePtr parent)
return factory;
}
static gboolean
gst_pad_eos_func(GstPad *pad)
{
GstElement *element;
GList *pads;
GstPad *srcpad;
gboolean result, success = TRUE;
g_return_val_if_fail (pad != NULL, FALSE);
g_return_val_if_fail (GST_IS_PAD(pad), FALSE);
INFO(GST_INFO_PADS,"attempting to set EOS on sink pad %s:%s",GST_DEBUG_PAD_NAME(pad));
element = GST_ELEMENT(gst_pad_get_parent (pad));
// g_return_val_if_fail (element != NULL, FALSE);
// g_return_val_if_fail (GST_IS_ELEMENT(element), FALSE);
pads = gst_element_get_pad_list(element);
while (pads) {
srcpad = GST_PAD(pads->data);
pads = g_list_next(pads);
if (gst_pad_get_direction(srcpad) == GST_PAD_SRC) {
result = gst_pad_eos(srcpad);
if (result == FALSE) success = FALSE;
}
}
if (result == FALSE) return FALSE;
INFO(GST_INFO_PADS,"set EOS on sink pad %s:%s",GST_DEBUG_PAD_NAME(pad));
GST_FLAG_SET (pad, GST_PAD_EOS);
return TRUE;
}
gboolean
gst_pad_set_eos(GstPad *pad)
{
g_return_val_if_fail (pad != NULL, FALSE);
g_return_val_if_fail (GST_IS_PAD(pad), FALSE);
g_return_val_if_fail (GST_PAD_CONNECTED(pad), FALSE);
INFO(GST_INFO_PADS,"attempting to set EOS on src pad %s:%s",GST_DEBUG_PAD_NAME(pad));
if (!gst_pad_eos(pad)) return FALSE;
INFO(GST_INFO_PADS,"set EOS on src pad %s:%s",GST_DEBUG_PAD_NAME(pad));
GST_FLAG_SET (pad, GST_PAD_EOS);
return TRUE;
}

View file

@ -65,6 +65,8 @@ typedef void (*GstPadPushFunction) (GstPad *pad, GstBuffer *buf);
typedef GstBuffer *(*GstPadPullFunction) (GstPad *pad);
typedef GstBuffer *(*GstPadPullRegionFunction) (GstPad *pad, gulong offset, gulong size);
typedef gboolean (*GstPadEOSFunction) (GstPad *pad);
typedef enum {
GST_PAD_UNKNOWN,
GST_PAD_SRC,
@ -101,6 +103,8 @@ struct _GstPad {
GstPadPullFunction pullfunc;
GstPadPullRegionFunction pullregionfunc;
GstPadEOSFunction eosfunc;
GstObject *parent;
GList *ghostparents;
@ -169,6 +173,7 @@ void gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain);
void gst_pad_set_get_function (GstPad *pad, GstPadGetFunction get);
void gst_pad_set_getregion_function (GstPad *pad, GstPadGetRegionFunction getregion);
void gst_pad_set_qos_function (GstPad *pad, GstPadQoSFunction qos);
void gst_pad_set_eos_function (GstPad *pad, GstPadEOSFunction eos);
void gst_pad_set_caps_list (GstPad *pad, GList *caps);
GList* gst_pad_get_caps_list (GstPad *pad);
@ -206,6 +211,9 @@ GstBuffer* gst_pad_pull_region (GstPad *pad, gulong offset, gulong size);
(((pad)->peer->pullregionfunc) ? ((pad)->peer->pullregionfunc)((pad)->peer,(offset),(size)) : NULL)
#endif
#define gst_pad_eos(pad) ((pad)->peer->eosfunc((pad)->peer))
gboolean gst_pad_set_eos (GstPad *pad);
void gst_pad_handle_qos (GstPad *pad, glong qos_message);
xmlNodePtr gst_pad_save_thyself (GstPad *pad, xmlNodePtr parent);

View file

@ -39,6 +39,8 @@ gint _gst_modules_seqno;
/* global list of plugins and its sequence number */
GList *_gst_plugins;
gint _gst_plugins_seqno;
gint _gst_plugin_elementfactories = 0;
gint _gst_plugin_types = 0;
/* list of paths to check for plugins */
GList *_gst_plugin_paths;
@ -141,6 +143,8 @@ gst_plugin_load_all(void)
gst_plugin_load_recurse(path->data,NULL);
path = g_list_next(path);
}
INFO(GST_INFO_PLUGIN_LOADING,"loaded %d plugins with %d elements and %d types",
_gst_plugins_seqno,_gst_plugin_elementfactories,_gst_plugin_types);
}
/**
@ -260,13 +264,16 @@ gst_plugin_load_absolute (gchar *name)
if (module != NULL) {
if (g_module_symbol(module,"plugin_init",(gpointer *)&initfunc)) {
if ((plugin = (initfunc)(module))) {
INFO(GST_INFO_PLUGIN_LOADING,"plugin %s loaded", plugin->name);
INFO(GST_INFO_PLUGIN_LOADING,"plugin \"%s\" loaded: %d elements, %d types",
plugin->name,plugin->numelements,plugin->numtypes);
plugin->filename = g_strdup(name);
plugin->loaded = TRUE;
_gst_modules = g_list_prepend(_gst_modules,module);
_gst_modules_seqno++;
_gst_plugins = g_list_prepend(_gst_plugins,plugin);
_gst_plugins_seqno++;
_gst_plugin_elementfactories += plugin->numelements;
_gst_plugin_types += plugin->numtypes;
return TRUE;
}
}
@ -299,8 +306,10 @@ gst_plugin_new (gchar *name)
plugin->name = g_strdup(name);
plugin->longname = NULL;
plugin->types = NULL;
plugin->elements = NULL;
plugin->numelements = 0;
plugin->types = NULL;
plugin->numtypes = 0;
plugin->loaded = TRUE;
return plugin;
@ -495,6 +504,7 @@ gst_plugin_add_factory (GstPlugin *plugin, GstElementFactory *factory)
// g_print("adding factory to plugin\n");
plugin->elements = g_list_prepend (plugin->elements, factory);
plugin->numelements++;
}
/**
@ -512,6 +522,7 @@ gst_plugin_add_type (GstPlugin *plugin, GstTypeFactory *factory)
// g_print("adding factory to plugin\n");
plugin->types = g_list_prepend (plugin->types, factory);
plugin->numtypes++;
gst_type_register (factory);
}

View file

@ -40,7 +40,9 @@ struct _GstPlugin {
gchar *filename; /* filename it came from */
GList *types; /* list of types provided */
gint numtypes;
GList *elements; /* list of elements provided */
gint numelements;
gboolean loaded; /* if the plugin is in memory */
};

View file

@ -396,6 +396,7 @@ void gst_bin_schedule_func(GstBin *bin) {
pads = g_list_next (pads);
DEBUG("have pad %s:%s\n",GST_DEBUG_PAD_NAME(pad));
if (pad->peer == NULL) ERROR(pad,"peer is null!");
g_assert(pad->peer != NULL);
g_assert(pad->peer->parent != NULL);
//g_assert(GST_ELEMENT(pad->peer->parent)->manager != NULL);

View file

@ -68,7 +68,7 @@ gst_type_register (GstTypeFactory *factory)
g_return_val_if_fail (factory != NULL, 0);
DEBUG("type register %s\n", factory->mime);
// INFO(GST_INFO_TYPES,"type register %s", factory->mime);
id = gst_type_find_by_mime (factory->mime);
if (!id) {

View file

@ -44,7 +44,7 @@ plugin_init (GModule *module)
i++;
}
gst_info ("gsttypes: loaded %d standard types\n",i);
// gst_info ("gsttypes: loaded %d standard types\n",i);
return plugin;
}