summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippo Argiolas <filippo.argiolas@gmail.com>2009-04-27 21:41:20 +0200
committerFilippo Argiolas <filippo.argiolas@gmail.com>2009-04-27 22:22:32 +0200
commitf1c7337ef3864e69aab0b8610c43a7ef86add979 (patch)
tree451bab8fc2185cd05069ebdd54db365f8eac0b29
parent584a8cd104470e9f75e5e8d8ab25b47497438ba8 (diff)
Dynamically remove videoscale from the pipelinepadblock
Remove an element (videoscale) from the pipeline without stopping nor pausing it. GStreamer is just great! glimagesink seems to suck a little bit here, I cannot manage to make it work after unblocking the pipeline without the little trick to destroy each and recreate each sink from scratch.
-rw-r--r--src/cheese-stage.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/cheese-stage.c b/src/cheese-stage.c
index 61f1457..e178ffa 100644
--- a/src/cheese-stage.c
+++ b/src/cheese-stage.c
@@ -38,6 +38,7 @@ GstPipeline *pipeline;
GstBus *bus;
GstElement *srcbin;
+GstElement *csp;
GstElement *scalebin;
GstElement *tee;
GstElement *fx[N_ACTORS];
@@ -182,19 +183,32 @@ on_blocked (GstPad *pad, gboolean blocked, gpointer data)
gint i;
GstPad *srcpad = gst_element_get_static_pad (scalebin, "src");
- gst_element_unlink (srcbin, scalebin);
+ gst_element_unlink (srcbin, csp);
+ gst_element_unlink (csp, scalebin);
gst_element_unlink (scalebin, tee);
+
for (i = 0; i < N_ACTORS; i++) {
- gst_element_unlink_many (tee, queue[i], fx[i], sink[i], NULL);
+ ClutterActor *actor = cheese_grid_get_actor_for_sink (layout, sink[i]);
+ gst_element_unlink (fx[i], sink[i]);
+ gst_bin_remove (GST_BIN (pipeline), sink[i]);
+ sink[i] = gst_element_factory_make ("glimagesink", NULL);
+ g_object_set (G_OBJECT (actor), "sink", sink[i], NULL);
+ gst_bin_add (GST_BIN (pipeline), sink[i]);
+ gst_element_link (fx[i], sink[i]);
}
- ClutterActor *actor = cheese_grid_get_actor_for_sink (layout, sink[0]);
- gst_bin_remove_many (GST_BIN (pipeline), sink[0],NULL);
- sink[0] = gst_element_factory_make ("glimagesink", NULL);
- gst_bin_add_many (GST_BIN (pipeline), sink[0],NULL);
- g_object_set (G_OBJECT (actor), "sink", sink[0], NULL);
+ gst_element_link_filtered (srcbin, csp, gst_caps_new_simple ("video/x-raw-rgb", NULL));
+ gst_element_link_many (csp, tee, NULL);
+
+
+// ClutterActor *actor = cheese_grid_get_actor_for_sink (layout, sink[0]);
+// gst_bin_remove_many (GST_BIN (pipeline), sink[ NULL);
+// sink[0] = gst_element_factory_make ("glimagesink", NULL);
+// fx[0] = gst_element_factory_make ("quarktv", NULL);
+// gst_bin_add_many (GST_BIN (pipeline), sink[0], fx[0], NULL);
+// g_object_set (G_OBJECT (actor), "sink", sink[0], NULL);
- gst_element_link_many (srcbin, tee, queue[0], fx[0], sink[0], NULL);
+// if (!gst_element_link_many (srcbin, csp, scale, sink[0], NULL)) g_error ("AAAA");
/* for (i = 0; i < N_ACTORS; i++) {
@@ -315,13 +329,14 @@ main (int argc, char *argv[])
srcbin = gst_parse_bin_from_description (desc, TRUE, NULL);
g_free (desc);
- desc = g_strdup_printf ("videoscale ! video/x-raw-rgb, width=%d, height=%d ! ffmpegcolorspace ! identity", W, H);
+ desc = g_strdup_printf ("videoscale ! video/x-raw-rgb, width=%d, height=%d ! identity", W, H);
scalebin = gst_parse_bin_from_description (desc, TRUE, NULL);
+ csp = gst_element_factory_make ("ffmpegcolorspace", NULL);
tee = gst_element_factory_make ("tee", NULL);
id = gst_element_factory_make ("identity", NULL);
- gst_bin_add_many (GST_BIN (pipeline), srcbin, scalebin, tee, NULL);
+ gst_bin_add_many (GST_BIN (pipeline), srcbin, csp, scalebin, tee, NULL);
fx[0] = gst_parse_bin_from_description ("identity", TRUE, NULL);
// fx[1] = gst_parse_bin_from_description ("ffmpegcolorspace ! videobalance saturation=0 ! ffmpegcolorspace", TRUE, NULL);
@@ -356,8 +371,8 @@ main (int argc, char *argv[])
// 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, scalebin, tee, NULL);
+ gst_element_link_filtered (srcbin, csp, gst_caps_new_simple ("video/x-raw-rgb", NULL));
+ gst_element_link_many (csp, scalebin, tee, NULL);
for (i = 0; i < N_ACTORS; i++) {
ok |= gst_element_link_many (tee, queue[i], fx[i], sink[i], NULL);