diff options
author | Filippo Argiolas <filippo.argiolas@gmail.com> | 2009-04-25 23:03:48 +0200 |
---|---|---|
committer | Filippo Argiolas <filippo.argiolas@gmail.com> | 2009-04-25 23:10:08 +0200 |
commit | 682fd98e492e29aee08bf45de3aee3212483a630 (patch) | |
tree | 2d7760b8a6aca66c0b256c0d28d4eeadee56df9d | |
parent | f81021d143a3f38389f7b5f0279c141bb779a367 (diff) |
Bind each actor to a gstreamer sink
Bind each actor to a sink and a function in the layout to retrieve the
correspondent actor for a sink so the xoverlay window can be set in a
definite order and not randomly as before.
-rw-r--r-- | src/cheese-grid.c | 21 | ||||
-rw-r--r-- | src/cheese-grid.h | 3 | ||||
-rw-r--r-- | src/cheese-stage.c | 43 |
3 files changed, 43 insertions, 24 deletions
diff --git a/src/cheese-grid.c b/src/cheese-grid.c index 82c4e40..97938da 100644 --- a/src/cheese-grid.c +++ b/src/cheese-grid.c @@ -362,6 +362,26 @@ cheese_grid_get_preferred_height (ClutterActor *self, *natural_height_p = natural_height; } +ClutterActor * +cheese_grid_get_actor_for_sink (CheeseGrid *self, + GstElement *element) +{ + CheeseGridPrivate *priv = CHEESE_GRID_GET_PRIVATE (self); + GList *iter; + + for (iter = priv->list; iter; iter = iter->next) + { + GObject *child = G_OBJECT (iter->data); + GstElement *sink; + g_object_get (child, "sink", &sink, NULL); + if (sink == element) { +// g_print ("found actor for: %s\n", GST_ELEMENT_NAME (element)); + return CLUTTER_ACTOR (child); + } + } + return NULL; +} + static void cheese_grid_allocate (ClutterActor *self, const ClutterActorBox *box, @@ -452,3 +472,4 @@ cheese_grid_allocate (ClutterActor *self, } } } + diff --git a/src/cheese-grid.h b/src/cheese-grid.h index ff17556..24bcc1d 100644 --- a/src/cheese-grid.h +++ b/src/cheese-grid.h @@ -27,6 +27,7 @@ #define __CHEESE_GRID_H__ #include <clutter/clutter.h> +#include <gst/gst.h> G_BEGIN_DECLS @@ -70,6 +71,8 @@ GType cheese_grid_get_type (void) G_GNUC_CONST; ClutterActor *cheese_grid_new (void); +ClutterActor * cheese_grid_get_actor_for_sink (CheeseGrid *self, GstElement *sink); + G_END_DECLS #endif /* __CHEESE_GRID_H__ */ diff --git a/src/cheese-stage.c b/src/cheese-stage.c index 376acff..489df63 100644 --- a/src/cheese-stage.c +++ b/src/cheese-stage.c @@ -35,7 +35,7 @@ static GstBusSyncReply create_window (GstBus * bus, GstMessage * message, gpointer data) { - CheeseActor **actor = (CheeseActor **) data; + CheeseGrid *layout = CHEESE_GRID (data); static gint count = 0; static GMutex *mutex = NULL; Window win; @@ -51,13 +51,10 @@ create_window (GstBus * bus, GstMessage * message, gpointer data) g_mutex_lock (mutex); - if (count < N_ACTORS) { - g_object_get (G_OBJECT (actor[count]), "window", &win, NULL); - g_message ("adding actor: %d win: %ld", count, win); - gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (GST_MESSAGE_SRC (message)), - win); - count++; - } + ClutterActor *actor = cheese_grid_get_actor_for_sink (layout, GST_MESSAGE_SRC (message)); + g_object_get (G_OBJECT (actor), "window", &win, NULL); + gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (GST_MESSAGE_SRC (message)), + win); g_mutex_unlock (mutex); @@ -181,6 +178,8 @@ main (int argc, char *argv[]) g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); + gtk_window_set_default_size (GTK_WINDOW (window), DEFAULT_W*3, DEFAULT_H*3); + clutter = gtk_clutter_embed_new (); gtk_container_add (GTK_CONTAINER (window), clutter); @@ -197,21 +196,6 @@ main (int argc, char *argv[]) G_CALLBACK (on_window_configure), layout); - for (i = 0; i < N_ACTORS; i++) { - actor[i] = cheese_texture_new (); - clutter_actor_set_scale_with_gravity (actor[i], 1.0, 1.0, - CLUTTER_GRAVITY_CENTER); - clutter_container_add_actor (CLUTTER_CONTAINER (layout), actor[i]); - clutter_actor_set_reactive (actor[i], TRUE); - g_signal_connect (actor[i], "button-press-event", G_CALLBACK (on_button_animate), NULL); -// g_signal_connect (actor[i], "enter-event", G_CALLBACK (on_enter_animate), NULL); -// g_signal_connect (actor[i], "leave-event", G_CALLBACK (on_leave_animate), NULL); - if (xpos > (COLS - 1) * W) { - xpos = 0; - ypos += H + 1; - } else - xpos += W + 1; - } /* desc = g_strdup_printf ("v4l2src ! " "video/x-raw-rgb, width=320, height=240, framerate=30/1 ! " "videoscale ! " @@ -251,6 +235,17 @@ main (int argc, char *argv[]) gst_bin_add_many (GST_BIN (pipeline), queue[i], fx[i], sink[i], NULL); } + for (i = 0; i < N_ACTORS; i++) { + actor[i] = g_object_new (CHEESE_TYPE_ACTOR, "sink", sink[i], NULL); + clutter_actor_set_scale_with_gravity (actor[i], 1.0, 1.0, + CLUTTER_GRAVITY_CENTER); + clutter_container_add_actor (CLUTTER_CONTAINER (layout), actor[i]); + clutter_actor_set_reactive (actor[i], TRUE); + g_signal_connect (actor[i], "button-press-event", G_CALLBACK (on_button_animate), NULL); + } +// g_signal_connect (actor[i], "enter-event", G_CALLBACK (on_enter_animate), NULL); +// g_signal_connect (actor[i], "leave-event", G_CALLBACK (on_leave_animate), NULL); + gst_element_link_many (srcbin, tee, NULL); for (i = 0; i < N_ACTORS; i++) { @@ -262,7 +257,7 @@ main (int argc, char *argv[]) bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); - gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, actor); + gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, layout); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); |