Commit 51cbf226 authored by Wim Taymans's avatar Wim Taymans

This is a megapatch with the following changes:

Original commit message from CVS:
This is a megapatch with the following changes:

- moved the gchar *name to GstObject, removed the ones in GstElement and
GstPad.
- moved the parent handling completely into GstObject. This cause *all* of
the plugins to fail (except those that used gst_pad_get_parent)
- rearanged the XML save handling.
- GstObject now has a class function save/restore_thyself.
- GstObject has a generic method gst_object_save_thyself, this makes it
possible to fire a signal wehever a new object is loaded. This is needed
so we can add XML save hooks.
- GstXML API has changed slightly. You now have to create a GstXML object
first before you can actually load something. This makes it possible to
attach a signal to GstXML whenever an object is loaded. I'm not sure we
will keep this interface.
- GstObject can now print the path_string without knowing about the GstPad and
GstElement types.
- Added gst_bin_get_by_name_recurse_up to lookup an element in the current
element hierarchy.
- added XML namespaces to the saved pipelines the namespace is:
http://gstreamer.net/gst-core/1.0/
namespaces are needed to distinguish user generated XML from the core XML.

Note that the plugins still contain a macro GST_OBJECT_PARENT that will be
replaced with gst_pad_get_parent shortly.
parent d0abadd9
......@@ -405,24 +405,16 @@ circumstances.
@element:
<!-- ##### FUNCTION gst_element_save_thyself ##### -->
<para>
</para>
@element:
@parent:
@Returns:
<!-- ##### FUNCTION gst_element_load_thyself ##### -->
<para>
</para>
@self:
@parent:
@elements:
@Returns:
<!-- # Unused Parameters # -->
@elements:
<!-- ##### FUNCTION gst_elementfactory_new ##### -->
......
......@@ -503,22 +503,14 @@ Call the EOS function of the pad
@pad: the pad to call the eos function of.
<!-- ##### FUNCTION gst_pad_save_thyself ##### -->
<para>
</para>
@pad:
@parent:
@Returns:
<!-- ##### FUNCTION gst_pad_load_and_connect ##### -->
<para>
</para>
@self:
@parent:
<!-- # Unused Parameters # -->
@element:
@elements:
......
......@@ -217,19 +217,19 @@ the stream.
</para>
<!-- ##### FUNCTION gst_object_get_type ##### -->
<!-- ##### MACRO GST_SINESRC ##### -->
<para>
</para>
@Returns:
@obj:
<!-- ##### MACRO GST_SINESRC ##### -->
<!-- ##### FUNCTION gst_object_get_type ##### -->
<para>
</para>
@obj:
@Returns:
<!-- ##### SECTION ./tmpl/plugin.sgml:Long_Description ##### -->
<para>
......@@ -1613,6 +1613,16 @@ Query the element for the current mime type
</para>
<!-- ##### FUNCTION gst_xml_new_from_memory ##### -->
<para>
</para>
@buffer:
@size:
@root:
@Returns:
<!-- ##### SECTION ./tmpl/gstgetbits.sgml:Long_Description ##### -->
<para>
......@@ -1916,6 +1926,15 @@ Indicates this pad is active
</para>
<!-- ##### FUNCTION gst_element_save_thyself ##### -->
<para>
</para>
@element:
@parent:
@Returns:
<!-- ##### FUNCTION gst_sinesrc_push ##### -->
<para>
......@@ -1993,6 +2012,15 @@ Indicates this pad is active
@obj:
<!-- ##### FUNCTION gst_pad_save_thyself ##### -->
<para>
</para>
@pad:
@parent:
@Returns:
<!-- ##### STRUCT GstElementClass ##### -->
<para>
......
......@@ -21,28 +21,18 @@ All GstElements can be serialized to an XML presentation and subsequently loaded
</para>
@object:
@elements:
@topelements:
@ns:
<!-- ##### FUNCTION gst_xml_new ##### -->
<para>
</para>
@fname:
@root:
@Returns:
<!-- ##### FUNCTION gst_xml_new_from_memory ##### -->
<para>
</para>
@buffer:
@size:
<!-- # Unused Parameters # -->
@fname:
@root:
@Returns:
<!-- ##### FUNCTION gst_xml_write ##### -->
......
......@@ -139,7 +139,7 @@ gst_editor_pad_new(GstEditorElement *parent,GstPad *pad,
GstEditorPad *peereditorpad;
// FIXME does this need to check for ghost/real?
peerpad = GST_PAD_PEER(pad);
peerpad = gst_pad_get_peer (pad);
peereditorpad = GST_EDITOR_GET_OBJECT (peerpad);
......@@ -152,7 +152,7 @@ gst_editor_pad_new(GstEditorElement *parent,GstPad *pad,
}
gtk_signal_connect_object (GTK_OBJECT (parent), "position_changed",
gst_editor_pad_position_changed, editorpad);
gst_editor_pad_position_changed, GTK_OBJECT (editorpad));
return editorpad;
}
......@@ -454,10 +454,7 @@ static void
gst_editor_pad_position_changed(GstEditorPad *pad,
GstEditorElement *element)
{
GList *pads;
if (pad->connection) {
// g_print("updating pad's connection\n");
pad->connection->resize = TRUE;
gst_editor_connection_resize(pad->connection);
}
......
......@@ -128,7 +128,8 @@ gst_editor_project_new_from_file (const guchar *fname)
editorproject = gst_editor_project_new();
xml = gst_xml_new (fname, NULL);
xml = gst_xml_new ();
gst_xml_parse_file (xml, fname, NULL);
elements = gst_xml_get_topelements(xml);
......
......@@ -76,7 +76,7 @@ static void gst_example_get_arg (GtkObject *object,GtkArg *arg,guint id);
GstPadTemplate *src_template, *sink_template;
static GstElementClass *parent_class = NULL;
static guint gst_example_signals[LAST_SIGNAL] = { 0 };
//static guint gst_example_signals[LAST_SIGNAL] = { 0 };
GtkType
gst_example_get_type(void)
......@@ -134,15 +134,13 @@ static void
gst_example_chain (GstPad *pad, GstBuffer *buf)
{
GstExample *example;
guchar *data;
gint i;
g_return_if_fail(pad != NULL);
g_return_if_fail(GST_IS_PAD(pad));
g_return_if_fail(buf != NULL);
//g_return_if_fail(GST_IS_BUFFER(buf));
example = GST_EXAMPLE(pad->parent);
example = GST_EXAMPLE(gst_pad_get_parent (pad));
g_return_if_fail(example != NULL);
g_return_if_fail(GST_IS_EXAMPLE(example));
......@@ -199,10 +197,10 @@ plugin_init (GModule *module)
GstElementFactory *factory;
plugin = gst_plugin_new("example");
g_return_if_fail(plugin != NULL);
g_return_val_if_fail(plugin != NULL, NULL);
factory = gst_elementfactory_new("example", GST_TYPE_EXAMPLE, &example_details);
g_return_if_fail(factory != NULL);
g_return_val_if_fail(factory != NULL, NULL);
sink_template = gst_padtemplate_new (&sink_factory);
gst_elementfactory_add_padtemplate (factory, sink_template);
......
......@@ -52,7 +52,7 @@ int main(int argc,char *argv[])
gst_bin_add(GST_BIN(thread), queue2);
gst_bin_add(GST_BIN(thread2), audiosink);
gst_pad_connect(gst_element_get_pad(disksrc,"src"),
gst_element_get_pad(queue,"sink"));
......
......@@ -3,33 +3,40 @@
gboolean playing;
/* eos will be called when the src element has an end of stream */
void eos(GstElement *element, gpointer data)
static void
xml_loaded (GstXML *xml, GstObject *object, gpointer data)
{
g_print("have eos, quitting\n");
playing = FALSE;
if (GST_IS_PAD (object)) {
g_print ("pad loaded '%s'\n", gst_pad_get_name (GST_PAD (object)));
}
else if (GST_IS_ELEMENT (object)) {
g_print ("element loaded '%s'\n", gst_element_get_name (GST_ELEMENT (object)));
}
}
int main(int argc,char *argv[])
int main(int argc,char *argv[])
{
GstXML *xml;
GstElement *bin;
GstElement *disk;
gboolean ret;
gst_init(&argc,&argv);
xml = gst_xml_new("xmlTest.gst", NULL);
xml = gst_xml_new ();
gtk_signal_connect (GTK_OBJECT (xml), "object_loaded", xml_loaded, NULL);
ret = gst_xml_parse_file(xml, "xmlTest.gst", NULL);
g_assert (ret == TRUE);
bin = gst_xml_get_element(xml, "bin");
g_assert (bin != NULL);
gst_element_set_state(bin, GST_STATE_PLAYING);
playing = TRUE;
while (playing) {
gst_bin_iterate(GST_BIN(bin));
}
while (gst_bin_iterate(GST_BIN(bin)));
gst_element_set_state(bin, GST_STATE_NULL);
......
......@@ -218,7 +218,7 @@ gst_asyncdisksrc_get (GstPad *pad)
GstBuffer *buf;
g_return_val_if_fail (pad != NULL, NULL);
src = GST_ASYNCDISKSRC (gst_pad_get_parent(pad));
src = GST_ASYNCDISKSRC (gst_pad_get_parent (pad));
g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_ASYNCDISKSRC_OPEN), NULL);
/* deal with EOF state */
......@@ -276,7 +276,7 @@ gst_asyncdisksrc_get_region (GstPad *pad, gulong offset, gulong size)
g_return_val_if_fail (pad != NULL, NULL);
src = GST_ASYNCDISKSRC (gst_pad_get_parent(pad));
src = GST_ASYNCDISKSRC (gst_pad_get_parent (pad));
g_return_val_if_fail (GST_IS_ASYNCDISKSRC (src), NULL);
g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_ASYNCDISKSRC_OPEN), NULL);
......
......@@ -244,7 +244,7 @@ gst_audiosink_chain (GstPad *pad, GstBuffer *buf)
/* this has to be an audio buffer */
// g_return_if_fail(((GstMeta *)buf->meta)->type !=
//gst_audiosink_type_audio);
audiosink = GST_AUDIOSINK (pad->parent);
audiosink = GST_AUDIOSINK (gst_pad_get_parent (pad));
// g_return_if_fail(GST_FLAG_IS_SET(audiosink,GST_STATE_RUNNING));
if ((in_flush = GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLUSH))) {
......
......@@ -149,7 +149,7 @@ gst_audiosrc_get (GstPad *pad)
glong readbytes;
g_return_val_if_fail (pad != NULL, NULL);
src = GST_AUDIOSRC(gst_pad_get_parent(pad));
src = GST_AUDIOSRC(gst_pad_get_parent (pad));
// g_print("attempting to read something from soundcard\n");
......
......@@ -208,7 +208,7 @@ gst_disksrc_get (GstPad *pad)
glong readbytes;
g_return_val_if_fail (pad != NULL, NULL);
src = GST_DISKSRC(gst_pad_get_parent(pad));
src = GST_DISKSRC(gst_pad_get_parent (pad));
g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_DISKSRC_OPEN), NULL);
g_return_val_if_fail (GST_STATE (src) >= GST_STATE_READY, NULL);
......
......@@ -180,7 +180,7 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (buf != NULL);
fakesink = GST_FAKESINK (pad->parent);
fakesink = GST_FAKESINK (gst_pad_get_parent (pad));
g_print("fakesink: ******* (%s:%s)< \n",GST_DEBUG_PAD_NAME(pad));
gst_buffer_unref (buf);
......
......@@ -269,9 +269,11 @@ gst_fakesrc_get(GstPad *pad)
GstFakeSrc *src;
GstBuffer *buf;
g_return_val_if_fail(pad != NULL, NULL);
src = GST_FAKESRC(gst_pad_get_parent(pad));
g_return_val_if_fail(GST_IS_FAKESRC(src), NULL);
g_return_val_if_fail (pad != NULL, NULL);
src = GST_FAKESRC (gst_pad_get_parent (pad));
g_return_val_if_fail (GST_IS_FAKESRC (src), NULL);
if (src->num_buffers == 0) {
gst_pad_set_eos (pad);
......
......@@ -113,7 +113,7 @@ gst_fdsink_chain (GstPad *pad, GstBuffer *buf)
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (buf != NULL);
fdsink = GST_FDSINK (pad->parent);
fdsink = GST_FDSINK (gst_pad_get_parent (pad));
g_return_if_fail (fdsink->fd >= 0);
......
......@@ -184,7 +184,7 @@ gst_fdsrc_get(GstPad *pad)
glong readbytes;
g_return_val_if_fail (pad != NULL, NULL);
src = GST_FDSRC(gst_pad_get_parent(pad));
src = GST_FDSRC(gst_pad_get_parent (pad));
/* create the buffer */
// FIXME: should eventually use a bufferpool for this
......
......@@ -131,7 +131,7 @@ gst_httpsrc_get(GstPad *pad)
glong readbytes;
g_return_val_if_fail (pad != NULL, NULL);
src = GST_HTTPSRC(gst_pad_get_parent(pad));
src = GST_HTTPSRC(gst_pad_get_parent (pad));
buf = gst_buffer_new();
GST_BUFFER_DATA(buf) = (gpointer)malloc(src->bytes_per_read);
......
......@@ -120,7 +120,7 @@ gst_identity_chain (GstPad *pad, GstBuffer *buf)
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (buf != NULL);
identity = GST_IDENTITY (pad->parent);
identity = GST_IDENTITY (gst_pad_get_parent (pad));
g_print("identity: ******* (%s:%s)i \n",GST_DEBUG_PAD_NAME(pad));
gst_pad_push (identity->srcpad, buf);
......
......@@ -118,13 +118,6 @@ static void gst_pipefilter_init(GstPipefilter *pipefilter) {
pipefilter->seq = 0;
}
GstElement *gst_pipefilter_new(gchar *name) {
GstElement *pipefilter = GST_ELEMENT(gtk_type_new(GST_TYPE_PIPEFILTER));
gst_element_set_name(GST_ELEMENT(pipefilter),name);
return pipefilter;
}
static gboolean gst_pipefilter_read_and_push(GstPipefilter *pipefilter) {
GstBuffer *newbuf;
glong readbytes;
......@@ -179,7 +172,7 @@ void gst_pipefilter_chain(GstPad *pad,GstBuffer *buf) {
g_return_if_fail(GST_IS_PAD(pad));
g_return_if_fail(buf != NULL);
pipefilter = GST_PIPEFILTER(pad->parent);
pipefilter = GST_PIPEFILTER (gst_pad_get_parent (pad));
while (gst_pipefilter_read_and_push(pipefilter));
......
......@@ -132,18 +132,6 @@ static void gst_sinesrc_init(GstSineSrc *sinesrc) {
sinesrc->sentmeta = FALSE;
}
GstElement *gst_sinesrc_new(gchar *name) {
GstElement *sinesrc = GST_ELEMENT(gtk_type_new(GST_TYPE_SINESRC));
gst_element_set_name(GST_ELEMENT(sinesrc),name);
return sinesrc;
}
GstElement *gst_sinesrc_new_with_fd(gchar *name,gchar *filename) {
GstElement *sinesrc = gst_sinesrc_new(name);
gtk_object_set(GTK_OBJECT(sinesrc),"location",filename,NULL);
return sinesrc;
}
static GstBuffer *
gst_sinesrc_get(GstPad *pad)
{
......@@ -155,7 +143,7 @@ gst_sinesrc_get(GstPad *pad)
gdouble val;
g_return_val_if_fail (pad != NULL, NULL);
src = GST_SINESRC(gst_pad_get_parent(pad));
src = GST_SINESRC(gst_pad_get_parent (pad));
buf = gst_buffer_new();
g_return_val_if_fail (buf, NULL);
......
......@@ -181,7 +181,7 @@ gst_tee_chain (GstPad *pad, GstBuffer *buf)
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (buf != NULL);
tee = GST_TEE (pad->parent);
tee = GST_TEE (gst_pad_get_parent (pad));
gst_trace_add_entry (NULL, 0, buf, "tee buffer");
for (i=0; i<tee->numsrcpads-1; i++)
......
......@@ -28,8 +28,6 @@
#include "gstscheduler.h"
GstElementDetails gst_bin_details = {
"Generic bin",
"Bin",
......@@ -51,9 +49,8 @@ static gboolean gst_bin_change_state_type (GstBin *bin,
static void gst_bin_create_plan_func (GstBin *bin);
static gboolean gst_bin_iterate_func (GstBin *bin);
static xmlNodePtr gst_bin_save_thyself (GstElement *element, xmlNodePtr parent);
static void gst_bin_restore_thyself (GstElement *element, xmlNodePtr parent,
GHashTable *elements);
static xmlNodePtr gst_bin_save_thyself (GstObject *object, xmlNodePtr parent);
static void gst_bin_restore_thyself (GstObject *object, xmlNodePtr self);
/* Bin signals and args */
enum {
......@@ -99,9 +96,11 @@ static void
gst_bin_class_init (GstBinClass *klass)
{
GtkObjectClass *gtkobject_class;
GstObjectClass *gstobject_class;
GstElementClass *gstelement_class;
gtkobject_class = (GtkObjectClass*)klass;
gstobject_class = (GstObjectClass*)klass;
gstelement_class = (GstElementClass*)klass;
parent_class = gtk_type_class (GST_TYPE_ELEMENT);
......@@ -118,9 +117,10 @@ gst_bin_class_init (GstBinClass *klass)
klass->schedule = gst_bin_schedule_func;
klass->iterate = gst_bin_iterate_func;
gstobject_class->save_thyself = gst_bin_save_thyself;
gstobject_class->restore_thyself = gst_bin_restore_thyself;
gstelement_class->change_state = gst_bin_change_state;
gstelement_class->save_thyself = gst_bin_save_thyself;
gstelement_class->restore_thyself = gst_bin_restore_thyself;
gtkobject_class->destroy = gst_bin_real_destroy;
}
......@@ -180,7 +180,7 @@ gst_bin_add (GstBin *bin,
bin->numchildren++;
gst_object_set_parent (GST_OBJECT (element), GST_OBJECT (bin));
GST_INFO_ELEMENT (GST_CAT_PARENTAGE, bin, "added child %s", gst_element_get_name(element));
GST_INFO_ELEMENT (GST_CAT_PARENTAGE, bin, "added child %s", GST_ELEMENT_NAME (element));
/* we know we have at least one child, we just added one... */
// if (GST_STATE(element) < GST_STATE_READY)
......@@ -220,7 +220,7 @@ gst_bin_remove (GstBin *bin,
bin->children = g_list_remove (bin->children, element);
bin->numchildren--;
GST_INFO_ELEMENT (GST_CAT_PARENTAGE, bin, "removed child %s", gst_element_get_name(element));
GST_INFO_ELEMENT (GST_CAT_PARENTAGE, bin, "removed child %s", GST_ELEMENT_NAME (element));
/* if we're down to zero children, force state to NULL */
if (bin->numchildren == 0)
......@@ -235,7 +235,7 @@ gst_bin_change_state (GstElement *element)
GList *children;
GstElement *child;
GST_DEBUG_ENTER("(\"%s\")",gst_element_get_name (element));
GST_DEBUG_ENTER("(\"%s\")",GST_ELEMENT_NAME (element));
g_return_val_if_fail (GST_IS_BIN (element), GST_STATE_FAILURE);
......@@ -271,16 +271,16 @@ gst_bin_change_state (GstElement *element)
children = bin->children;
while (children) {
child = GST_ELEMENT (children->data);
GST_DEBUG (0,"setting state on '%s'\n",gst_element_get_name (child));
GST_DEBUG (0,"setting state on '%s'\n",GST_ELEMENT_NAME (child));
switch (gst_element_set_state (child, GST_STATE_PENDING (element))) {
case GST_STATE_FAILURE:
GST_STATE_PENDING (element) = GST_STATE_NONE_PENDING;
GST_DEBUG (0,"child '%s' failed to go to state %d(%s)\n", gst_element_get_name (child),
GST_DEBUG (0,"child '%s' failed to go to state %d(%s)\n", GST_ELEMENT_NAME (child),
GST_STATE_PENDING (element), _gst_print_statename (GST_STATE_PENDING (element)));
return GST_STATE_FAILURE;
break;
case GST_STATE_ASYNC:
GST_DEBUG (0,"child '%s' is changing state asynchronously\n", gst_element_get_name (child));
GST_DEBUG (0,"child '%s' is changing state asynchronously\n", GST_ELEMENT_NAME (child));
break;
}
// g_print("\n");
......@@ -355,7 +355,7 @@ gst_bin_set_state_type (GstBin *bin,
GstBinClass *oclass;
GST_DEBUG (0,"gst_bin_set_state_type(\"%s\",%d,%d)\n",
gst_element_get_name (GST_ELEMENT (bin)), state,type);
GST_ELEMENT_NAME (bin), state,type);
g_return_val_if_fail (bin != NULL, FALSE);
g_return_val_if_fail (GST_IS_BIN (bin), FALSE);
......@@ -411,7 +411,7 @@ gst_bin_get_by_name (GstBin *bin,
children = bin->children;
while (children) {
child = GST_ELEMENT (children->data);
if (!strcmp (child->name,name))
if (!strcmp (gst_object_get_name (GST_OBJECT (child)),name))
return child;
if (GST_IS_BIN (child)) {
GstElement *res = gst_bin_get_by_name (GST_BIN (child), name);
......@@ -424,6 +424,41 @@ gst_bin_get_by_name (GstBin *bin,
return NULL;
}
/**
* gst_bin_get_by_name_recurse_up:
* @bin: #Gstbin to search
* @name: the element name to search for
*
* Get the element with the given name from this bin. If the
* element is not found, a recursion is performed on the parent bin.
*
* Returns: the element with the given name
*/
GstElement*
gst_bin_get_by_name_recurse_up (GstBin *bin,
const gchar *name)
{
GstElement *result = NULL;
GstObject *parent;
g_return_val_if_fail (bin != NULL, NULL);
g_return_val_if_fail (GST_IS_BIN (bin), NULL);
g_return_val_if_fail (name != NULL, NULL);
result = gst_bin_get_by_name (bin, name);
if (result)
return result;
parent = gst_object_get_parent (GST_OBJECT (bin));
if (parent && GST_IS_BIN (parent)) {
result = gst_bin_get_by_name_recurse_up (GST_BIN (parent), name);
}
return result;
}
/**
* gst_bin_get_list:
* @bin: #Gstbin to get the list from
......@@ -442,48 +477,46 @@ gst_bin_get_list (GstBin *bin)
}
static xmlNodePtr
gst_bin_save_thyself (GstElement *element,
gst_bin_save_thyself (GstObject *object,
xmlNodePtr parent)