summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLionel Landwerlin <llandwerlin@gmail.com>2013-04-14 18:23:28 +0200
committerLionel Landwerlin <llandwerlin@gmail.com>2013-04-25 16:33:33 +0100
commitab09d2bc6cafcb4b4db3c3c838cf3fd50d961dff (patch)
treee27b3fbff0aa63348c2f0243668b0fb19177109c /tests
parent9a540099a323f580cd848322f6524bac860ca719 (diff)
downloadclutter-gst-ab09d2bc6cafcb4b4db3c3c838cf3fd50d961dff.tar.gz
introduce ClutterGstPipeline to allow custom Gstreamer pipelines to feed Actors
Diffstat (limited to 'tests')
-rw-r--r--tests/test-alpha.c34
-rw-r--r--tests/test-rgb-upload.c30
-rw-r--r--tests/test-start-stop.c62
-rw-r--r--tests/test-video-actor-new-unref-loop.c2
-rw-r--r--tests/test-yuv-upload.c26
5 files changed, 81 insertions, 73 deletions
diff --git a/tests/test-alpha.c b/tests/test-alpha.c
index 4f54315..6faaac5 100644
--- a/tests/test-alpha.c
+++ b/tests/test-alpha.c
@@ -65,11 +65,11 @@ parse_fourcc (const gchar *fourcc)
return GST_STR_FOURCC (fourcc);
}
-void
-size_change (ClutterActor *actor,
- gint width,
- gint height,
- gpointer user_data)
+static void
+size_change (ClutterGstPlayer *player,
+ gint width,
+ gint height,
+ ClutterActor *actor)
{
ClutterActor *stage;
gfloat new_x, new_y, new_width, new_height;
@@ -98,6 +98,7 @@ size_change (ClutterActor *actor,
new_y = 0;
}
+ g_message ("resize %fx%f @ %fx%f", new_width, new_height, new_x, new_y);
clutter_actor_set_position (actor, new_x, new_y);
clutter_actor_set_size (actor, new_width, new_height);
}
@@ -115,6 +116,7 @@ main (int argc, char *argv[])
ClutterActor *actor;
ClutterActor *rectangle;
ClutterTransition *animation;
+ ClutterGstPlayer *player;
GstPipeline *pipeline;
GstElement *src;
@@ -122,9 +124,6 @@ main (int argc, char *argv[])
GstElement *sink;
GstCaps *caps;
- if (!g_thread_supported ())
- g_thread_init (NULL);
-
result = clutter_gst_init_with_args (&argc,
&argv,
" - Test alpha with video actors",
@@ -153,21 +152,16 @@ main (int argc, char *argv[])
rectangle_geom.size.width,
rectangle_geom.size.height);
- actor = g_object_new (CLUTTER_GST_TYPE_ACTOR, NULL);
+ actor = clutter_gst_actor_new ();
clutter_actor_set_opacity (actor, 0);
- g_signal_connect (actor,
- "size-change",
- G_CALLBACK (size_change), NULL);
-
/* Set up pipeline */
pipeline = GST_PIPELINE(gst_pipeline_new (NULL));
src = gst_element_factory_make ("videotestsrc", NULL);
g_object_set (G_OBJECT (src), "pattern", 1, NULL);
capsfilter = gst_element_factory_make ("capsfilter", NULL);
- sink = gst_element_factory_make ("cluttersink", NULL);
- g_object_set (G_OBJECT (sink), "actor", actor, NULL);
+ sink = clutter_gst_create_video_sink ();
/* make videotestsrc spit the format we want */
if (g_strcmp0 (opt_fourcc, "RGB ") == 0)
@@ -198,10 +192,20 @@ main (int argc, char *argv[])
g_critical("Could not link elements");
gst_element_set_state (GST_ELEMENT(pipeline), GST_STATE_PLAYING);
+ player = CLUTTER_GST_PLAYER (g_object_new (CLUTTER_GST_TYPE_PIPELINE,
+ "video-sink", sink, NULL));
+
+ g_signal_connect (player,
+ "size-change",
+ G_CALLBACK (size_change), actor);
+
clutter_actor_add_child (stage, rectangle);
clutter_actor_add_child (stage, actor);
clutter_actor_show (stage);
+ clutter_gst_actor_set_player (CLUTTER_GST_ACTOR (actor), player);
+
+
clutter_actor_save_easing_state (actor);
clutter_actor_set_easing_mode (actor, CLUTTER_LINEAR);
clutter_actor_set_easing_duration (actor, 6000);
diff --git a/tests/test-rgb-upload.c b/tests/test-rgb-upload.c
index 3dcbd55..eae4d5d 100644
--- a/tests/test-rgb-upload.c
+++ b/tests/test-rgb-upload.c
@@ -64,10 +64,10 @@ static GOptionEntry options[] =
};
void
-size_change (ClutterActor *actor,
- gint width,
- gint height,
- gpointer user_data)
+size_change (ClutterGstPlayer *player,
+ gint width,
+ gint height,
+ ClutterActor *actor)
{
ClutterActor *stage;
gfloat new_x, new_y, new_width, new_height;
@@ -113,10 +113,7 @@ main (int argc, char *argv[])
GstElement *sink;
GstCaps *caps;
GstVideoFormat format;
-
- if (!g_thread_supported ())
- g_thread_init (NULL);
-
+ ClutterGstPlayer *player;
result = clutter_gst_init_with_args (&argc,
&argv,
@@ -135,19 +132,14 @@ main (int argc, char *argv[])
stage = clutter_stage_new ();
clutter_actor_set_size (CLUTTER_ACTOR (stage), 320.0f, 240.0f);
- actor = g_object_new (CLUTTER_GST_TYPE_ACTOR, NULL);
-
- g_signal_connect (actor,
- "size-change",
- G_CALLBACK (size_change), NULL);
+ actor = clutter_gst_actor_new ();
/* Set up pipeline */
pipeline = GST_PIPELINE(gst_pipeline_new (NULL));
src = gst_element_factory_make ("videotestsrc", NULL);
capsfilter = gst_element_factory_make ("capsfilter", NULL);
- sink = gst_element_factory_make ("cluttersink", NULL);
- g_object_set (sink, "actor", actor, NULL);
+ sink = clutter_gst_create_video_sink ();
format = gst_video_format_from_masks(opt_depth, opt_bpp, G_BIG_ENDIAN,
0xff0000,
@@ -168,6 +160,14 @@ main (int argc, char *argv[])
g_critical("Could not link elements");
gst_element_set_state (GST_ELEMENT(pipeline), GST_STATE_PLAYING);
+
+ player = CLUTTER_GST_PLAYER (g_object_new (CLUTTER_GST_TYPE_PIPELINE,
+ "video-sink", sink, NULL));
+ clutter_gst_actor_set_player (CLUTTER_GST_ACTOR (actor), player);
+ g_signal_connect (player,
+ "size-change",
+ G_CALLBACK (size_change), actor);
+
clutter_actor_add_child (stage, actor);
clutter_actor_show (stage);
diff --git a/tests/test-start-stop.c b/tests/test-start-stop.c
index d9b9e7e..a9efe4d 100644
--- a/tests/test-start-stop.c
+++ b/tests/test-start-stop.c
@@ -33,36 +33,42 @@
char *video_files[] = {NULL, NULL};
void
-size_change (ClutterActor *actor,
- gint width,
- gint height,
- gpointer user_data)
+size_change (ClutterGstPlayer *player,
+ gint width,
+ gint height,
+ ClutterActor *actor)
{
- ClutterActor *stage = (ClutterActor *)user_data;
+ ClutterActor *stage = clutter_actor_get_stage (actor);
gfloat new_x, new_y, new_width, new_height;
gfloat stage_width, stage_height;
+ g_message ("size change %ix%i", width, height);
+
clutter_actor_get_size (stage, &stage_width, &stage_height);
- new_height = (height * stage_width) / width;
- if (new_height <= stage_height)
- {
- new_width = stage_width;
+ /* new_height = (height * stage_width) / width; */
+ /* if (new_height <= stage_height) */
+ /* { */
+ /* new_width = stage_width; */
- new_x = 0;
- new_y = (stage_height - new_height) / 2;
- }
- else
- {
- new_width = (width * stage_height) / height;
- new_height = stage_height;
+ /* new_x = 0; */
+ /* new_y = (stage_height - new_height) / 2; */
+ /* } */
+ /* else */
+ /* { */
+ /* new_width = (width * stage_height) / height; */
+ /* new_height = stage_height; */
- new_x = (stage_width - new_width) / 2;
- new_y = 0;
- }
+ /* new_x = (stage_width - new_width) / 2; */
+ /* new_y = 0; */
+ /* } */
+
+ /* clutter_actor_set_position (actor, new_x, new_y); */
+ clutter_actor_set_size (actor, stage_width, stage_height);
+
+ g_message (" new pos/size -> x,y=%.2fx%.2f w,h=%.2fx%.2f",
+ new_x, new_y, stage_width, stage_height);
- clutter_actor_set_position (actor, new_x, new_y);
- clutter_actor_set_size (actor, new_width, new_height);
}
void
@@ -145,23 +151,21 @@ main (int argc, char *argv[])
stage = clutter_stage_new ();
clutter_actor_set_background_color (stage, &stage_color);
- player = clutter_gst_playback_new ();
+ video = clutter_gst_aspectratio_new ();
- video = /* clutter_gst_actor_new () */ g_object_new (CLUTTER_GST_TYPE_ACTOR,
- NULL);
- g_assert (CLUTTER_GST_IS_ACTOR (video));
+ player = clutter_gst_playback_new ();
clutter_gst_actor_set_player (CLUTTER_GST_ACTOR (video), CLUTTER_GST_PLAYER (player));
clutter_actor_add_child (stage, video);
- g_signal_connect (video,
+ g_signal_connect (player,
"size-change",
G_CALLBACK(size_change),
- stage);
+ video);
g_signal_connect (player,
"error",
G_CALLBACK(on_error),
- stage);
- g_timeout_add (5000, test, video);
+ video);
+ g_timeout_add (5000, test, player);
clutter_gst_playback_set_filename (player, video_files[0]);
clutter_gst_player_set_audio_volume (CLUTTER_GST_PLAYER (player), 0.5);
clutter_gst_player_set_playing (CLUTTER_GST_PLAYER (player), TRUE);
diff --git a/tests/test-video-actor-new-unref-loop.c b/tests/test-video-actor-new-unref-loop.c
index 942f56a..fd98a6a 100644
--- a/tests/test-video-actor-new-unref-loop.c
+++ b/tests/test-video-actor-new-unref-loop.c
@@ -43,7 +43,7 @@ main (int argc, char *argv[])
for (i = 0; ; i++)
{
g_debug("VideoActor #%d", i);
- vactor = g_object_new (CLUTTER_GST_TYPE_ACTOR, NULL);
+ vactor = clutter_gst_actor_new ();
g_object_ref_sink (vactor);
g_object_unref (vactor);
}
diff --git a/tests/test-yuv-upload.c b/tests/test-yuv-upload.c
index 66668c4..1a451bf 100644
--- a/tests/test-yuv-upload.c
+++ b/tests/test-yuv-upload.c
@@ -53,10 +53,10 @@ static GOptionEntry options[] =
};
void
-size_change (ClutterActor *actor,
- gint width,
- gint height,
- gpointer user_data)
+size_change (ClutterGstPlayer *player,
+ gint width,
+ gint height,
+ ClutterActor *actor)
{
ClutterActor *stage;
gfloat new_x, new_y, new_width, new_height;
@@ -101,9 +101,7 @@ main (int argc, char *argv[])
GstElement *capsfilter;
GstElement *sink;
GstCaps *caps;
-
- if (!g_thread_supported ())
- g_thread_init (NULL);
+ ClutterGstPlayer *player;
result = clutter_gst_init_with_args (&argc,
&argv,
@@ -124,17 +122,12 @@ main (int argc, char *argv[])
actor = g_object_new (CLUTTER_GST_TYPE_ACTOR, NULL);
- g_signal_connect (actor,
- "size-change",
- G_CALLBACK (size_change), NULL);
-
/* Set up pipeline */
pipeline = GST_PIPELINE(gst_pipeline_new (NULL));
src = gst_element_factory_make ("videotestsrc", NULL);
capsfilter = gst_element_factory_make ("capsfilter", NULL);
- sink = gst_element_factory_make ("cluttersink", NULL);
- g_object_set (sink, "actor", actor, NULL);
+ sink = clutter_gst_create_video_sink ();
/* make videotestsrc spit the format we want */
caps = gst_caps_new_simple ("video/x-raw",
@@ -150,6 +143,13 @@ main (int argc, char *argv[])
g_critical("Could not link elements");
gst_element_set_state (GST_ELEMENT(pipeline), GST_STATE_PLAYING);
+ player = CLUTTER_GST_PLAYER (g_object_new (CLUTTER_GST_TYPE_PIPELINE,
+ "video-sink", sink, NULL));
+ clutter_gst_actor_set_player (CLUTTER_GST_ACTOR (actor), player);
+ g_signal_connect (player,
+ "size-change",
+ G_CALLBACK (size_change), actor);
+
clutter_actor_add_child (stage, actor);
/* clutter_actor_set_opacity (texture, 0x11); */
clutter_actor_show (stage);