From 695f761c2ba7430f9abc626b8a284c940b11c03c Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sun, 8 Oct 2000 22:17:11 +0000 Subject: [PATCH] Fixed a bug in the typeloading. Original commit message from CVS: Fixed a bug in the typeloading. Fixes to various elements so that correct types are returned. Fixed flag collision with GtkObject. Elements can now suggest a thread. not sure if this is the right way to handle automatic thread creation. Autoplugging now works with multiple sinks and thread setup. No threads are created for intermediate elements yet, so MPEG may still be choppy. --- configure.in | 2 + editor/editor.glade | 4 +- editor/gsteditor.h | 7 +- editor/gsteditorbin.c | 19 +++-- editor/gsteditorcanvas.c | 21 ++++-- editor/gsteditorconnection.c | 30 ++++---- editor/gsteditorconnection.h | 5 +- editor/gsteditorcreate.c | 1 - editor/gsteditorpad.c | 20 +++--- editor/gsteditorproperty.c | 117 ++++++++++++++++++++++++------ editor/gstelementselect.c | 3 +- gst/elements/gstaudiosink.c | 1 + gst/gstbin.c | 2 +- gst/gstelement.h | 4 +- gst/gstelementfactory.c | 28 ++++++-- gst/gstfilter.c | 2 +- gst/gstpad.c | 4 +- gst/gstpipeline.c | 122 +++++++++++++++++++++++++++----- gst/gstplugin.c | 5 +- gst/gstsink.c | 2 +- gst/gstthread.c | 1 - gst/gsttype.c | 34 ++++----- gst/types/gsttypes.c | 5 +- plugins/elements/gstaudiosink.c | 1 + 24 files changed, 313 insertions(+), 127 deletions(-) diff --git a/configure.in b/configure.in index 6db44e59c8..81b6eae60e 100644 --- a/configure.in +++ b/configure.in @@ -413,6 +413,7 @@ plugins/avi/Makefile plugins/avi/wincodec/Makefile plugins/jpeg/Makefile plugins/mp3decode/Makefile +plugins/mp3decode/types/Makefile plugins/mp3decode/xa/Makefile plugins/mp3decode/xing/Makefile plugins/mp3decode/mpg123/Makefile @@ -425,6 +426,7 @@ plugins/mpeg2/video/Makefile plugins/mpeg2/mpeg2enc/Makefile plugins/mpeg2/subtitles/Makefile plugins/mpeg1/Makefile +plugins/mpeg1/mpegtypes/Makefile plugins/mpeg1/mpeg_play/Makefile plugins/mpeg1/mpegaudio/Makefile plugins/mpeg1/parse/Makefile diff --git a/editor/editor.glade b/editor/editor.glade index d0afe2a522..ae42425383 100644 --- a/editor/editor.glade +++ b/editor/editor.glade @@ -597,7 +597,7 @@ GtkVBox vbox3 False - 0 + 2 GtkScrolledWindow @@ -696,7 +696,7 @@ 5 2 False - 0 + 2 0 0 diff --git a/editor/gsteditor.h b/editor/gsteditor.h index d10cabcf98..bf295c59e7 100644 --- a/editor/gsteditor.h +++ b/editor/gsteditor.h @@ -209,7 +209,9 @@ struct _GstEditorBinClass { GtkType gst_editor_bin_get_type(); GstEditorBin *gst_editor_bin_new(GstEditorBin *parent,GstBin *bin, const gchar *first_arg_name,...); - +void gst_editor_bin_connection_drag(GstEditorBin *bin, + gdouble wx,gdouble wy); +void gst_editor_bin_start_banding(GstEditorBin *bin,GstEditorPad *pad); #define GST_TYPE_EDITOR_CANVAS \ @@ -354,6 +356,9 @@ struct _GstEditorConnectionClass { }; GtkType gst_editor_connection_get_type(); +GstEditorConnection *gst_editor_connection_new(GstEditorBin *parent, + GstEditorPad *frompad); + void gst_editor_connection_resize(GstEditorConnection *connection); void gst_editor_connection_set_endpoint(GstEditorConnection *connection, gdouble x,gdouble y); diff --git a/editor/gsteditorbin.c b/editor/gsteditorbin.c index 44ebeab877..b2226728fb 100644 --- a/editor/gsteditorbin.c +++ b/editor/gsteditorbin.c @@ -22,6 +22,7 @@ #include #include "gsteditor.h" +#include "gsteditorcreate.h" /* signals and args */ enum { @@ -34,8 +35,8 @@ enum { static void gst_editor_bin_class_init(GstEditorBinClass *klass); static void gst_editor_bin_init(GstEditorBin *bin); -static void gst_editor_bin_set_arg(GtkObject *object,GtkArg *arg,guint id); -static void gst_editor_bin_get_arg(GtkObject *object,GtkArg *arg,guint id); +//static void gst_editor_bin_set_arg(GtkObject *object,GtkArg *arg,guint id); +//static void gst_editor_bin_get_arg(GtkObject *object,GtkArg *arg,guint id); static gint gst_editor_bin_event(GnomeCanvasItem *item, GdkEvent *event, @@ -43,6 +44,8 @@ static gint gst_editor_bin_event(GnomeCanvasItem *item, static gint gst_editor_bin_button_event(GnomeCanvasItem *item, GdkEvent *event, GstEditorElement *element); +void gst_editor_bin_connection_drag(GstEditorBin *bin, + gdouble wx,gdouble wy); static GstEditorElementClass *parent_class = NULL; @@ -88,10 +91,10 @@ GstEditorBin *gst_editor_bin_new(GstEditorBin *parent,GstBin *bin, GstEditorBin *editorbin; va_list args; - g_return_if_fail(parent != NULL); - g_return_if_fail(GST_IS_EDITOR_BIN(parent)); - g_return_if_fail(bin != NULL); - g_return_if_fail(GST_IS_BIN(bin)); + g_return_val_if_fail(parent != NULL, NULL); + g_return_val_if_fail(GST_IS_EDITOR_BIN(parent), NULL); + g_return_val_if_fail(bin != NULL, NULL); + g_return_val_if_fail(GST_IS_BIN(bin), NULL); editorbin = GST_EDITOR_BIN(gtk_type_new(GST_TYPE_EDITOR_BIN)); GST_EDITOR_ELEMENT(editorbin)->element = GST_ELEMENT(bin); @@ -150,6 +153,8 @@ static gint gst_editor_bin_event(GnomeCanvasItem *item, if (GST_EDITOR_ELEMENT_CLASS(parent_class)->event) return (*GST_EDITOR_ELEMENT_CLASS(parent_class)->event)(item,event,element); + + return TRUE; } @@ -202,7 +207,7 @@ void gst_editor_bin_connection_drag(GstEditorBin *bin, element = GST_EDITOR_ELEMENT(bin); bx = wx;by = wy; - gnome_canvas_item_w2i(GST_EDITOR_ELEMENT(bin)->group,&bx,&by); + gnome_canvas_item_w2i(GNOME_CANVAS_ITEM(GST_EDITOR_ELEMENT(bin)->group),&bx,&by); // first see if we're on top of an interesting pad underitem = gnome_canvas_get_item_at( diff --git a/editor/gsteditorcanvas.c b/editor/gsteditorcanvas.c index ec93b5ff4f..897053e291 100644 --- a/editor/gsteditorcanvas.c +++ b/editor/gsteditorcanvas.c @@ -22,6 +22,7 @@ #include #include "gsteditor.h" +#include "gsteditorcreate.h" /* signals and args */ enum { @@ -46,6 +47,9 @@ static gint gst_editor_canvas_button_release(GtkWidget *widget, static gint gst_editor_canvas_event(GnomeCanvasItem *item, GdkEvent *event, GstEditorElement *element); +static void gst_editor_canvas_set_arg(GtkObject *object,GtkArg *arg,guint id); +static void gst_editor_canvas_get_arg(GtkObject *object,GtkArg *arg,guint id); + //gint gst_editor_canvas_verbose_event(GtkWidget *widget,GdkEvent *event); @@ -72,8 +76,11 @@ GtkType gst_editor_canvas_get_type(void) { } static void gst_editor_canvas_class_init(GstEditorCanvasClass *klass) { + GtkObjectClass *object_class; GstEditorElementClass *element_class; + object_class = (GtkObjectClass*)klass; + element_class = (GstEditorElementClass*)klass; parent_class = gtk_type_class(gst_editor_bin_get_type()); @@ -81,6 +88,9 @@ static void gst_editor_canvas_class_init(GstEditorCanvasClass *klass) { gtk_object_add_arg_type("GstEditorCanvas::canvas",GTK_TYPE_POINTER, GTK_ARG_READABLE,ARG_CANVAS); + object_class->set_arg = gst_editor_canvas_set_arg; + object_class->get_arg = gst_editor_canvas_get_arg; + element_class->realize = gst_editor_canvas_realize; } @@ -90,15 +100,14 @@ static void gst_editor_canvas_init(GstEditorCanvas *editorcanvas) { GstEditorCanvas *gst_editor_canvas_new(GstBin *bin, const gchar *first_arg_name,...) { GstEditorCanvas *editorcanvas; - GstEditorBin *bin2; va_list args; - g_return_if_fail(bin != NULL); - g_return_if_fail(GST_IS_BIN(bin)); + g_return_val_if_fail(bin != NULL, NULL); + g_return_val_if_fail(GST_IS_BIN(bin), NULL); editorcanvas = GST_EDITOR_CANVAS(gtk_type_new(GST_TYPE_EDITOR_CANVAS)); GST_EDITOR_ELEMENT(editorcanvas)->element = GST_ELEMENT(bin); - GST_EDITOR_ELEMENT(editorcanvas)->parent = editorcanvas; + GST_EDITOR_ELEMENT(editorcanvas)->parent = GST_EDITOR_BIN(editorcanvas); va_start(args,first_arg_name); gst_editor_element_construct(GST_EDITOR_ELEMENT(editorcanvas),NULL, @@ -165,7 +174,7 @@ GtkWidget *gst_editor_canvas_get_canvas(GstEditorCanvas *canvas) { static gint gst_editor_canvas_button_release(GtkWidget *widget, GdkEvent *event, GstEditorCanvas *canvas) { - GstEditorBin *bin = GST_EDITOR_BIN(canvas); + //GstEditorBin *bin = GST_EDITOR_BIN(canvas); gdouble x,y; GstEditorElement *element; @@ -188,7 +197,7 @@ static gint gst_editor_canvas_button_release(GtkWidget *widget, gnome_canvas_window_to_world(GNOME_CANVAS(widget), event->button.x,event->button.y,&x,&y); // g_print("calling gst_editor_create_item()\n"); - if (element = gst_editor_create_item(GST_EDITOR_BIN(canvas),x,y)) + if ((element = gst_editor_create_item(GST_EDITOR_BIN(canvas),x,y)) != NULL) return TRUE; return FALSE; } diff --git a/editor/gsteditorconnection.c b/editor/gsteditorconnection.c index dbe4147dc3..95c8699eb0 100644 --- a/editor/gsteditorconnection.c +++ b/editor/gsteditorconnection.c @@ -14,9 +14,9 @@ static void gst_editor_connection_destroy(GtkObject *object); static void gst_editor_connection_realize(GstEditorConnection *connection); /* events fired by items within self */ -static gint gst_editor_connection_line_event(GnomeCanvasItem *item, - GdkEvent *event, - GstEditorConnection *connection); +//static gint gst_editor_connection_line_event(GnomeCanvasItem *item, +// GdkEvent *event, +// GstEditorConnection *connection); /* utility functions */ @@ -35,7 +35,7 @@ enum { }; static GtkObjectClass *parent_class; -static guint gst_editor_connection_signals[LAST_SIGNAL] = { 0 }; +//static guint gst_editor_connection_signals[LAST_SIGNAL] = { 0 }; GtkType gst_editor_connection_get_type() { static GtkType connection_type = 0; @@ -89,16 +89,16 @@ GstEditorConnection *gst_editor_connection_new(GstEditorBin *parent, GstEditorPad *frompad) { GstEditorConnection *connection; - g_return_if_fail(parent != NULL); - g_return_if_fail(GST_IS_EDITOR_BIN(parent)); - g_return_if_fail(frompad != NULL); - g_return_if_fail(GST_IS_EDITOR_PAD(frompad)); + g_return_val_if_fail(parent != NULL, NULL); + g_return_val_if_fail(GST_IS_EDITOR_BIN(parent), NULL); + g_return_val_if_fail(frompad != NULL, NULL); + g_return_val_if_fail(GST_IS_EDITOR_PAD(frompad), NULL); connection = GST_EDITOR_CONNECTION(gtk_type_new(GST_TYPE_EDITOR_CONNECTION)); connection->frompad = frompad; connection->frompad->connection = connection; connection->fromsrc = connection->frompad->issrc; - connection->parent = parent; + connection->parent = GST_EDITOR_ELEMENT(parent); gst_editor_connection_realize(connection); @@ -212,8 +212,8 @@ void gst_editor_connection_resize(GstEditorConnection *connection) { x2,y2: item coords relative to the bin's group This means translating the x1,y1 coords into world, then into bin. */ - gnome_canvas_item_i2w(connection->frompad->parent->group,&x1,&y1); - gnome_canvas_item_w2i(GST_EDITOR_ELEMENT_GROUP(connection->parent), + gnome_canvas_item_i2w(GNOME_CANVAS_ITEM(connection->frompad->parent->group),&x1,&y1); + gnome_canvas_item_w2i(GNOME_CANVAS_ITEM(GST_EDITOR_ELEMENT_GROUP(connection->parent)), &x1,&y1); } else { if (connection->fromsrc) { @@ -225,11 +225,11 @@ void gst_editor_connection_resize(GstEditorConnection *connection) { } y1 = connection->frompad->y + (connection->frompad->height / 2); y2 = connection->topad->y + (connection->topad->height / 2); - gnome_canvas_item_i2w(connection->frompad->parent->group,&x1,&y1); - gnome_canvas_item_w2i(GST_EDITOR_ELEMENT_GROUP(connection->parent), + gnome_canvas_item_i2w(GNOME_CANVAS_ITEM(connection->frompad->parent->group),&x1,&y1); + gnome_canvas_item_w2i(GNOME_CANVAS_ITEM(GST_EDITOR_ELEMENT_GROUP(connection->parent)), &x1,&y1); - gnome_canvas_item_i2w(connection->topad->parent->group,&x2,&y2); - gnome_canvas_item_w2i(GST_EDITOR_ELEMENT_GROUP(connection->parent), + gnome_canvas_item_i2w(GNOME_CANVAS_ITEM(connection->topad->parent->group),&x2,&y2); + gnome_canvas_item_w2i(GNOME_CANVAS_ITEM(GST_EDITOR_ELEMENT_GROUP(connection->parent)), &x2,&y2); } diff --git a/editor/gsteditorconnection.h b/editor/gsteditorconnection.h index 011edd3a8a..84ad6ed6d9 100644 --- a/editor/gsteditorconnection.h +++ b/editor/gsteditorconnection.h @@ -33,7 +33,7 @@ #define GST_IS_EDITOR_CONNECTION(obj) \ (GTK_CHECK_TYPE((obj),GST_TYPE_EDITOR_CONNECTION)) #define GST_IS_EDITOR_CONNECTION_CLASS(obj) \ - (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_EDITOR_CONNECTION))) + (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_EDITOR_CONNECTION)) typedef struct _GstEditorConnection GstEditorConnection; typedef struct _GstEditorConnectionClass GstEditorConnectionClass; @@ -57,5 +57,8 @@ struct _GstEditorConnectionClass { }; GtkType gst_editor_connection_get_type(); +GstEditorConnection *gst_editor_connection_new(GstEditorBin *parent, + GstEditorPad *frompad); + #endif /* __GST_EDITOR_CONNECTION_H__ */ diff --git a/editor/gsteditorcreate.c b/editor/gsteditorcreate.c index bfadd83d45..26c78dc133 100644 --- a/editor/gsteditorcreate.c +++ b/editor/gsteditorcreate.c @@ -30,7 +30,6 @@ GstEditorElement *gst_editor_create_item(GstEditorBin *bin, GstElementFactory *factory; GstElement *element; GstEditorElement *editorelement; - GtkType itemtype; factory = element_select_dialog(); if (factory) { diff --git a/editor/gsteditorpad.c b/editor/gsteditorpad.c index 9aea1f6c2c..db7c544276 100644 --- a/editor/gsteditorpad.c +++ b/editor/gsteditorpad.c @@ -31,9 +31,9 @@ static void gst_editor_pad_get_arg(GtkObject *object,GtkArg *arg,guint id); static void gst_editor_pad_realize(GstEditorPad *pad); /* class implementation functions */ -static void gst_editor_pad_update(GnomeCanvasItem *item,double *affine, - ArtSVP *clip_path,int flags); -static gint gst_editor_pad_event(GnomeCanvasItem *item,GdkEvent *event); +//static void gst_editor_pad_update(GnomeCanvasItem *item,double *affine, +// ArtSVP *clip_path,int flags); +//static gint gst_editor_pad_event(GnomeCanvasItem *item,GdkEvent *event); /* events fired by items within self */ static gint gst_editor_pad_padbox_event(GnomeCanvasItem *item, @@ -58,7 +58,7 @@ enum { }; static GtkObjectClass *parent_class; -static guint gst_editor_pad_signals[LAST_SIGNAL] = { 0 }; +//static guint gst_editor_pad_signals[LAST_SIGNAL] = { 0 }; GtkType gst_editor_pad_get_type() { static GtkType pad_type = 0; @@ -111,10 +111,10 @@ GstEditorPad *gst_editor_pad_new(GstEditorElement *parent,GstPad *pad, GstEditorPad *editorpad; va_list args; - g_return_if_fail(parent != NULL); - g_return_if_fail(GST_IS_EDITOR_ELEMENT(parent)); - g_return_if_fail(pad != NULL); - g_return_if_fail(GST_IS_PAD(pad)); + g_return_val_if_fail(parent != NULL, NULL); + g_return_val_if_fail(GST_IS_EDITOR_ELEMENT(parent), NULL); + g_return_val_if_fail(pad != NULL, NULL); + g_return_val_if_fail(GST_IS_PAD(pad), NULL); editorpad = GST_EDITOR_PAD(gtk_type_new(GST_TYPE_EDITOR_PAD)); editorpad->pad = pad; @@ -213,8 +213,6 @@ static void gst_editor_pad_get_arg(GtkObject *object,GtkArg *arg,guint id) { } static void gst_editor_pad_realize(GstEditorPad *pad) { - gint i; - // g_print("realizing editor pad %p\n",pad); /* we must be attached to an element */ @@ -376,7 +374,7 @@ static gint gst_editor_pad_padbox_event(GnomeCanvasItem *item, GstEditorBin *bin; // g_print("padbox has event %d\n",event->type); - g_return_if_fail(GST_IS_EDITOR_PAD(pad)); + g_return_val_if_fail(GST_IS_EDITOR_PAD(pad), FALSE); element = pad->parent; bin = element->parent; diff --git a/editor/gsteditorproperty.c b/editor/gsteditorproperty.c index 28ce43b910..e5b2cd2a68 100644 --- a/editor/gsteditorproperty.c +++ b/editor/gsteditorproperty.c @@ -18,6 +18,7 @@ */ +#include #include #include @@ -30,6 +31,8 @@ static void gst_editor_property_init(GstEditorProperty *property); static void gst_editor_property_set_arg(GtkObject *object,GtkArg *arg,guint id); static void gst_editor_property_get_arg(GtkObject *object,GtkArg *arg,guint id); +static GtkWidget *create_property_entry(GtkArg *arg); + enum { ARG_0, }; @@ -189,10 +192,10 @@ static gchar *make_readable_name(gchar *name) { colon = strstr(name, "::"); - if (colon) - new = g_strdup(&colon[2]); - else + if (!colon) new = g_strdup(name); + else + new = g_strdup(&colon[2]); new = g_strdelimit(new, G_STR_DELIMITERS, ' '); @@ -230,13 +233,13 @@ void gst_editor_property_show(GstEditorProperty *property, GstEditorElement *ele else { GtkArg *args; guint32 *flags; - guint num_args, i; - gchar *text; + guint num_args, i, count; table = gtk_table_new(1, 2, TRUE); + gtk_table_set_row_spacings(GTK_TABLE(table), 2); gtk_widget_show(table); - label = gtk_label_new("Name:"); + label = gtk_label_new(_("Name:")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); gtk_widget_show(label); entry = gtk_entry_new(); @@ -248,23 +251,23 @@ void gst_editor_property_show(GstEditorProperty *property, GstEditorElement *ele gtk_signal_connect(GTK_OBJECT(entry), "changed", on_name_changed, element); args = gtk_object_query_args(type, &flags, &num_args); + count = 1; for (i=0; ielement), 1, &args[i]); - label = gtk_label_new(g_strconcat(make_readable_name(args[i].name), ":", NULL)); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); - gtk_widget_show(label); - entry = gtk_entry_new(); - if (args[i].type == GTK_TYPE_STRING) { - text = GTK_VALUE_STRING(args[i]); - if (text) - gtk_entry_set_text(GTK_ENTRY(entry), GTK_VALUE_STRING(args[i])); - } - gtk_widget_show(entry); + entry = create_property_entry(&args[i]); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, i+1, i+2, GTK_FILL, 0, 0, 0); - gtk_table_attach(GTK_TABLE(table), entry, 1, 2, i+1, i+2, GTK_FILL|GTK_EXPAND, 0, 0, 0); + if (entry) { + label = gtk_label_new(g_strconcat(make_readable_name(args[i].name), ":", NULL)); + gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); + gtk_widget_show(label); + + gtk_table_attach(GTK_TABLE(table), label, 0, 1, count, count+1, GTK_FILL, 0, 0, 0); + gtk_table_attach(GTK_TABLE(table), entry, 1, 2, count, count+1, GTK_FILL|GTK_EXPAND, 0, 0, 0); + + count++; + } } } gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, TRUE, 0); @@ -275,6 +278,80 @@ void gst_editor_property_show(GstEditorProperty *property, GstEditorElement *ele } } +static void widget_show_toggled(GtkToggleButton *button, GtkArg *arg) { + GtkWidget *window; + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(GTK_VALUE_OBJECT(*arg))); + + gtk_widget_show(window); +} + +static GtkWidget *create_property_entry(GtkArg *arg) { + GtkWidget *entry = NULL; + + switch (arg->type) { + case GTK_TYPE_STRING: + { + gchar *text; + entry = gtk_entry_new(); + text = GTK_VALUE_STRING(*arg); + if (text) + gtk_entry_set_text(GTK_ENTRY(entry), text); + break; + } + case GTK_TYPE_BOOL: + { + gboolean toggle; + toggle = GTK_VALUE_BOOL(*arg); + entry = gtk_toggle_button_new_with_label((toggle? _("Yes"):_("No"))); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(entry), toggle); + break; + } + case GTK_TYPE_ULONG: + case GTK_TYPE_LONG: + case GTK_TYPE_UINT: + case GTK_TYPE_INT: + { + gint value; + GtkAdjustment *spinner_adj; + + value = GTK_VALUE_INT(*arg); + spinner_adj = (GtkAdjustment *) gtk_adjustment_new(50.0, 0.0, 100.0, 1.0, 5.0, 5.0); + entry = gtk_spin_button_new(spinner_adj, 1.0, 0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(entry), (gfloat) value); + break; + } + case GTK_TYPE_FLOAT: + case GTK_TYPE_DOUBLE: + { + gdouble value; + GtkAdjustment *spinner_adj; + + value = GTK_VALUE_DOUBLE(*arg); + spinner_adj = (GtkAdjustment *) gtk_adjustment_new(50.0, 0.0, 100.0, 0.1, 5.0, 5.0); + entry = gtk_spin_button_new(spinner_adj, 1.0, 3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(entry), (gfloat) value); + break; + } + default: + g_print("unknown type: %d\n", arg->type); + break; + } + if (!entry) { + if (arg->type == GTK_TYPE_WIDGET) + { + entry = gtk_toggle_button_new_with_label(_("Show...")); + gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(entry), FALSE); + gtk_signal_connect(GTK_OBJECT(entry), "toggled", widget_show_toggled, arg); + } + } + gtk_widget_show(entry); + + return entry; +} + @@ -290,5 +367,3 @@ void gst_editor_property_show(GstEditorProperty *property, GstEditorElement *ele - - diff --git a/editor/gstelementselect.c b/editor/gstelementselect.c index 4c7b0b9c84..36276dd86e 100644 --- a/editor/gstelementselect.c +++ b/editor/gstelementselect.c @@ -115,10 +115,9 @@ GstElementFactory *element_select_dialog() { GList *elements; GstElementFactory *element; gchar **classes, **class; - GSList *classlist; GSList *classtree, *treewalk; GSList **curlist; - struct element_select_classlist *branch; + struct element_select_classlist *branch = NULL; struct element_select_details details; /* first create the dialog and associated stuff */ diff --git a/gst/elements/gstaudiosink.c b/gst/elements/gstaudiosink.c index 337456862b..6b19125411 100644 --- a/gst/elements/gstaudiosink.c +++ b/gst/elements/gstaudiosink.c @@ -145,6 +145,7 @@ static void gst_audiosink_init(GstAudioSink *audiosink) { gst_clock_register(audiosink->clock, GST_OBJECT(audiosink)); //audiosink->clocktime = 0LL; + GST_FLAG_SET(audiosink, GST_ELEMENT_THREAD_SUGGESTED); } void gst_audiosink_sync_parms(GstAudioSink *audiosink) { diff --git a/gst/gstbin.c b/gst/gstbin.c index b88e4f17a7..430d656250 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -339,7 +339,7 @@ GstElement *gst_bin_get_by_name(GstBin *bin,gchar *name) { g_return_val_if_fail(GST_IS_BIN(bin), NULL); g_return_val_if_fail(name != NULL, NULL); - g_print("gstbin: lookup element \"%s\" in \"%s\"\n", name, gst_element_get_name(bin)); + g_print("gstbin: lookup element \"%s\" in \"%s\"\n", name, gst_element_get_name(GST_ELEMENT(bin))); children = bin->children; while (children) { child = GST_ELEMENT(children->data); diff --git a/gst/gstelement.h b/gst/gstelement.h index 9e94ecd220..a2df7842f4 100644 --- a/gst/gstelement.h +++ b/gst/gstelement.h @@ -76,10 +76,12 @@ static inline char *_gst_print_statename(int state) { (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_ELEMENT)) typedef enum { - GST_ELEMENT_MULTI_IN = (1 << 0), + GST_ELEMENT_MULTI_IN = (1 << 4), + GST_ELEMENT_THREAD_SUGGESTED = (1 << 5), } GstElementFlags; #define GST_ELEMENT_IS_MULTI_IN(obj) (GST_FLAGS(obj) & GST_ELEMENT_MULTI_IN) +#define GST_ELEMENT_IS_THREAD_SUGGESTED(obj) (GST_FLAGS(obj) & GST_ELEMENT_THREAD_SUGGESTED) typedef struct _GstElement GstElement; diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index 145f067d0a..cc841d5108 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -211,7 +211,7 @@ void gst_elementfactory_add_sink(GstElementFactory *elementfactory, guint16 id) */ xmlNodePtr gst_elementfactory_save_thyself(GstElementFactory *factory, xmlNodePtr parent) { GList *types; - xmlNodePtr subtree; + xmlNodePtr subtree, subsubtree; xmlNewChild(parent,NULL,"name",factory->name); xmlNewChild(parent,NULL,"longname", factory->details->longname); @@ -228,7 +228,8 @@ xmlNodePtr gst_elementfactory_save_thyself(GstElementFactory *factory, xmlNodePt guint16 typeid = GPOINTER_TO_UINT(types->data); GstType *type = gst_type_find_by_id(typeid); - gst_type_save_thyself(type, subtree); + subsubtree = xmlNewChild(subtree,NULL,"type",NULL); + gst_type_save_thyself(type, subsubtree); types = g_list_next(types); } @@ -240,7 +241,8 @@ xmlNodePtr gst_elementfactory_save_thyself(GstElementFactory *factory, xmlNodePt guint16 typeid = GPOINTER_TO_UINT(types->data); GstType *type = gst_type_find_by_id(typeid); - gst_type_save_thyself(type, subtree); + subsubtree = xmlNewChild(subtree,NULL,"type",NULL); + gst_type_save_thyself(type, subsubtree); types = g_list_next(types); } @@ -287,14 +289,26 @@ GstElementFactory *gst_elementfactory_load_thyself(xmlNodePtr parent) { factory->details->copyright = g_strdup(xmlNodeGetContent(children)); } if (!strcmp(children->name, "sources")) { - guint16 typeid = gst_type_load_thyself(children); + xmlNodePtr field = children->childs; + while (field) { + if (!strcmp(field->name, "type")) { + guint16 typeid = gst_type_load_thyself(field); - gst_type_add_src(typeid, factory); + gst_type_add_src(typeid, factory); + } + field = field->next; + } } if (!strcmp(children->name, "sinks")) { - guint16 typeid = gst_type_load_thyself(children); + xmlNodePtr field = children->childs; + while (field) { + if (!strcmp(field->name, "type")) { + guint16 typeid = gst_type_load_thyself(field); - gst_type_add_sink(typeid, factory); + gst_type_add_sink(typeid, factory); + } + field = field->next; + } } children = children->next; diff --git a/gst/gstfilter.c b/gst/gstfilter.c index fc8fcd4672..08e7fc5f92 100644 --- a/gst/gstfilter.c +++ b/gst/gstfilter.c @@ -37,7 +37,7 @@ static void gst_filter_init(GstFilter *filter); static GstElementClass *parent_class = NULL; -static guint gst_filter_signals[LAST_SIGNAL] = { 0 }; +//static guint gst_filter_signals[LAST_SIGNAL] = { 0 }; GtkType gst_filter_get_type(void) { diff --git a/gst/gstpad.c b/gst/gstpad.c index accfd018e2..c5cfc024ae 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -438,8 +438,8 @@ static void gst_pad_real_destroy(GtkObject *object) { */ void gst_pad_load_and_connect(xmlNodePtr parent, GstObject *element, GHashTable *elements) { xmlNodePtr field = parent->childs; - GstPad *pad, *targetpad; - guchar *peer; + GstPad *pad = NULL, *targetpad; + guchar *peer = NULL; gchar **split; GstElement *target; diff --git a/gst/gstpipeline.c b/gst/gstpipeline.c index b5f1289e1b..bb8e0aaa4a 100644 --- a/gst/gstpipeline.c +++ b/gst/gstpipeline.c @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -172,7 +173,8 @@ static void gst_pipeline_pads_autoplug_func(GstElement *src, GstPad *pad, GstEle GstPad *sinkpad; gboolean connected = FALSE; - g_print("gstpipeline: autoplug pad connect function type %d\n", pad->type); + g_print("gstpipeline: autoplug pad connect function type %d for \"%s\" to \"%s\"\n", pad->type, + gst_element_get_name(src), gst_element_get_name(sink)); sinkpads = gst_element_get_pad_list(sink); while (sinkpads) { @@ -284,7 +286,7 @@ void gst_pipeline_add_sink(GstPipeline *pipeline, GstElement *sink) g_return_if_fail(GST_IS_ELEMENT(sink)); pipeline->sinks = g_list_prepend(pipeline->sinks, sink); - gst_bin_add(GST_BIN(pipeline), sink); + //gst_bin_add(GST_BIN(pipeline), sink); } /** @@ -299,11 +301,11 @@ void gst_pipeline_add_sink(GstPipeline *pipeline, GstElement *sink) gboolean gst_pipeline_autoplug(GstPipeline *pipeline) { GList *elements; GstElement *element, *srcelement = NULL, *sinkelement= NULL; - GList *factories; + GList **factories; GstElementFactory *factory; GList *src_types; guint16 src_type = 0, sink_type = 0; - gboolean complete = FALSE; + guint i, numsinks; g_return_val_if_fail(pipeline != NULL, FALSE); g_return_val_if_fail(GST_IS_PIPELINE(pipeline), FALSE); @@ -348,6 +350,10 @@ gboolean gst_pipeline_autoplug(GstPipeline *pipeline) { elements = pipeline->sinks; + numsinks = g_list_length(elements); + factories = g_new0(GList *, numsinks); + + i = 0; // fase 2, loop over all the sinks.. while (elements) { GList *pads; @@ -362,23 +368,32 @@ gboolean gst_pipeline_autoplug(GstPipeline *pipeline) { if (pad->direction == GST_PAD_SINK) { sink_type = gst_pad_get_type_id(pad); - sinkelement = element; break; } pads = g_list_next(pads); } + + factories[i] = gst_type_get_sink_to_src(src_type, sink_type); + //factories[i] = g_list_append(factories[i], element); + i++; + elements = g_list_next(elements); } - factories = gst_type_get_sink_to_src(src_type, sink_type); + while (factories[0]) { + // fase 3: add common elements + factory = (GstElementFactory *)(factories[0]->data); - while (factories) { - // fase 3: find elements to form a pad - - factory = (GstElementFactory *)(factories->data); + // check to other paths for mathing elements (factories) + for (i=1; idata)) + goto differ; + factories[i] = g_list_next(factories[i]); + } + factory = (GstElementFactory *)(factories[0]->data); - g_print("GstPipeline: factory \"%s\"\n", factory->name); + g_print("GstPipeline: common factory \"%s\"\n", factory->name); element = gst_elementfactory_create(factory, factory->name); gst_bin_add(GST_BIN(pipeline), element); @@ -387,15 +402,88 @@ gboolean gst_pipeline_autoplug(GstPipeline *pipeline) { srcelement = element; - factories = g_list_next(factories); - - complete = TRUE; + factories[0] = g_list_next(factories[0]); } - if (complete) { - gst_pipeline_pads_autoplug(srcelement, sinkelement); - return TRUE; +differ: + // loop over all the sink elements + elements = pipeline->sinks; + + i = 0; + while (elements) { + GstElement *thesrcelement = srcelement; + GstElement *thebin = GST_ELEMENT(pipeline); + + sinkelement = (GstElement *)elements->data; + + while (factories[i] || sinkelement) { + // fase 4: add other elements... + + if (factories[i]) { + factory = (GstElementFactory *)(factories[i]->data); + g_print("GstPipeline: factory \"%s\"\n", factory->name); + element = gst_elementfactory_create(factory, factory->name); + factories[i] = g_list_next(factories[i]); + } + // we have arived to the final sink element + else { + element = sinkelement; + sinkelement = NULL; + } + + // this element suggests the use of a thread, so we set one up... + if (GST_ELEMENT_IS_THREAD_SUGGESTED(element)) { + GstElement *queue; + GList *sinkpads; + GstPad *srcpad, *sinkpad; + g_print("GstPipeline: sugest new thread for \"%s\" %08x\n", element->name, GST_FLAGS(element)); + + // create a new queue and add to the previous bin + queue = gst_elementfactory_make("queue", g_strconcat("queue_", gst_element_get_name(element), NULL)); + gst_bin_add(GST_BIN(pipeline), queue); + + // this will be the new bin for all following elements + thebin = gst_thread_new("thread"); + + srcpad = gst_element_get_pad(queue, "src"); + sinkpads = gst_element_get_pad_list(element); + while (sinkpads) { + sinkpad = (GstPad *)sinkpads->data; + + // FIXME connect matching pads, not just the first one... + if (sinkpad->direction == GST_PAD_SINK && + !GST_PAD_CONNECTED(sinkpad)) { + // the queue has the types of the element it connects + srcpad->type = sinkpad->type; + gst_element_get_pad(queue, "sink")->type = sinkpad->type; + gst_pad_connect(srcpad, sinkpad); + g_print("gstpipeline: autoconnect pad \"%s\" (%d) in element %s <-> ", + srcpad->name, srcpad->type, gst_element_get_name(queue)); + g_print("pad \"%s\" (%d) in element %s\n", sinkpad->name, + sinkpad->type, gst_element_get_name(element)); + break; + } + sinkpads = g_list_next(sinkpads); + } + + gst_bin_add(GST_BIN(thebin), element); + gst_bin_add(GST_BIN(pipeline), thebin); + element = queue; + } + // no thread needed, easy case + else { + gst_bin_add(GST_BIN(thebin), element); + } + gst_pipeline_pads_autoplug(thesrcelement, element); + + // this element is now the new source element + thesrcelement = element; + } + + elements = g_list_next(elements); + i++; } + return TRUE; g_print("GstPipeline: unable to autoplug pipeline \"%s\"\n", gst_element_get_name(GST_ELEMENT(pipeline))); diff --git a/gst/gstplugin.c b/gst/gstplugin.c index 9c1c102354..8ea28be4c9 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -517,10 +517,7 @@ void gst_plugin_load_thyself(xmlNodePtr parent) { } else if (!strcmp(field->name, "type")) { GstTypeFactory *factory = gst_typefactory_load_thyself(field); - guint16 typeid = gst_type_find_by_mime(factory->mime); - if (!typeid) { - typeid = gst_type_register(factory); - } + gst_type_register(factory); plugin->types = g_list_prepend(plugin->types, factory); typecount++; } diff --git a/gst/gstsink.c b/gst/gstsink.c index 2196292793..0e3d2720ea 100644 --- a/gst/gstsink.c +++ b/gst/gstsink.c @@ -38,7 +38,7 @@ static void gst_sink_init(GstSink *sink); static GstElementClass *parent_class = NULL; -static guint gst_sink_signals[LAST_SIGNAL] = { 0 }; +//static guint gst_sink_signals[LAST_SIGNAL] = { 0 }; GtkType gst_sink_get_type(void) { diff --git a/gst/gstthread.c b/gst/gstthread.c index 157a241bba..2a2cf246b7 100644 --- a/gst/gstthread.c +++ b/gst/gstthread.c @@ -54,7 +54,6 @@ static GstElementStateReturn gst_thread_change_state(GstElement *element); static xmlNodePtr gst_thread_save_thyself(GstElement *element,xmlNodePtr parent); static void gst_thread_restore_thyself(GstElement *element,xmlNodePtr parent, GHashTable *elements); -static void gst_thread_prepare(GstThread *thread); static void gst_thread_signal_thread(GstThread *thread); static void gst_thread_create_plan_dummy(GstBin *bin); diff --git a/gst/gsttype.c b/gst/gsttype.c index 375125d804..a7f21dc65d 100644 --- a/gst/gsttype.c +++ b/gst/gsttype.c @@ -73,6 +73,7 @@ guint16 gst_type_register(GstTypeFactory *factory) { g_return_val_if_fail(factory != NULL, 0); + g_print("gsttype: type register %s\n", factory->mime); id = gst_type_find_by_mime(factory->mime); if (!id) { type = g_new0(GstType, 1); @@ -396,37 +397,28 @@ GList *gst_type_get_list() { } xmlNodePtr gst_type_save_thyself(GstType *type, xmlNodePtr parent) { - xmlNodePtr tree; - tree = xmlNewChild(parent, NULL, "type", NULL); - - xmlNewChild(tree, NULL, "mime", type->mime); + xmlNewChild(parent, NULL, "mime", type->mime); - return tree; + return parent; } guint16 gst_type_load_thyself(xmlNodePtr parent) { - xmlNodePtr children = parent->childs; + xmlNodePtr field = parent->childs; guint16 typeid = 0; - while (children) { - if (!strcmp(children->name, "type")) { - xmlNodePtr field = children->childs; - while (field) { - if (!strcmp(field->name, "mime")) { - typeid = gst_type_find_by_mime(xmlNodeGetContent(field)); - if (!typeid) { - GstTypeFactory *factory = g_new0(GstTypeFactory, 1); + while (field) { + if (!strcmp(field->name, "mime")) { + typeid = gst_type_find_by_mime(xmlNodeGetContent(field)); + if (!typeid) { + GstTypeFactory *factory = g_new0(GstTypeFactory, 1); - factory->mime = g_strdup(xmlNodeGetContent(field)); - typeid = gst_type_register(factory); - } - return typeid; - } - field = field->next; + factory->mime = g_strdup(xmlNodeGetContent(field)); + typeid = gst_type_register(factory); } + return typeid; } - children = children->next; + field = field->next; } return typeid; diff --git a/gst/types/gsttypes.c b/gst/types/gsttypes.c index 1755c121e7..3dc7778a3d 100644 --- a/gst/types/gsttypes.c +++ b/gst/types/gsttypes.c @@ -31,10 +31,7 @@ GstTypeFactory _factories[] = { GstPlugin *plugin_init(GModule *module) { GstPlugin *plugin; - int i = 0; - - if (gst_plugin_find("gsttypes") != NULL) - return NULL; + gint i = 0; plugin = gst_plugin_new("gsttypes"); g_return_val_if_fail(plugin != NULL,NULL); diff --git a/plugins/elements/gstaudiosink.c b/plugins/elements/gstaudiosink.c index 337456862b..6b19125411 100644 --- a/plugins/elements/gstaudiosink.c +++ b/plugins/elements/gstaudiosink.c @@ -145,6 +145,7 @@ static void gst_audiosink_init(GstAudioSink *audiosink) { gst_clock_register(audiosink->clock, GST_OBJECT(audiosink)); //audiosink->clocktime = 0LL; + GST_FLAG_SET(audiosink, GST_ELEMENT_THREAD_SUGGESTED); } void gst_audiosink_sync_parms(GstAudioSink *audiosink) {