2009-10-27 15:27:45 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
2012-07-04 15:49:55 +00:00
|
|
|
#define GST_USE_UNSTABLE_API
|
2009-03-13 21:14:31 +00:00
|
|
|
#include "shell-recorder.h"
|
|
|
|
#include <clutter/clutter.h>
|
2012-10-25 21:26:17 +00:00
|
|
|
#include <gtk/gtk.h>
|
2009-03-13 21:14:31 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
/* Very simple test of the ShellRecorder class; shows some text strings
|
|
|
|
* moving around and records it.
|
|
|
|
*/
|
2012-05-02 14:23:28 +00:00
|
|
|
static ShellRecorder *recorder = NULL;
|
2009-03-13 21:14:31 +00:00
|
|
|
|
|
|
|
static gboolean
|
2012-07-26 21:31:11 +00:00
|
|
|
stop_recording_timeout (ClutterActor *stage)
|
2009-03-13 21:14:31 +00:00
|
|
|
{
|
2012-05-02 14:23:28 +00:00
|
|
|
if (recorder)
|
|
|
|
{
|
|
|
|
shell_recorder_close (recorder);
|
2012-07-26 21:44:56 +00:00
|
|
|
|
|
|
|
/* quit when the recorder finishes closing
|
|
|
|
*/
|
|
|
|
g_object_weak_ref (G_OBJECT (recorder),
|
|
|
|
(GWeakNotify)
|
|
|
|
clutter_actor_destroy,
|
|
|
|
stage);
|
|
|
|
|
2012-05-02 14:23:28 +00:00
|
|
|
g_object_unref (recorder);
|
|
|
|
}
|
2012-07-26 21:44:56 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
clutter_actor_destroy (stage);
|
|
|
|
}
|
2012-05-02 14:23:28 +00:00
|
|
|
|
2009-03-13 21:14:31 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-07-26 21:31:11 +00:00
|
|
|
on_animation_completed (ClutterAnimation *animation,
|
|
|
|
ClutterStage *stage)
|
2009-03-13 21:14:31 +00:00
|
|
|
{
|
2012-07-26 21:31:11 +00:00
|
|
|
g_timeout_add (1000, (GSourceFunc) stop_recording_timeout, stage);
|
2009-03-13 21:14:31 +00:00
|
|
|
}
|
|
|
|
|
2012-05-02 14:23:28 +00:00
|
|
|
static void
|
|
|
|
on_stage_realized (ClutterActor *stage,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
recorder = shell_recorder_new (CLUTTER_STAGE (stage));
|
2012-10-25 21:14:20 +00:00
|
|
|
shell_recorder_set_file_template (recorder, "test-recorder.ogg");
|
2012-05-02 14:23:28 +00:00
|
|
|
shell_recorder_record (recorder);
|
|
|
|
}
|
|
|
|
|
2009-03-13 21:14:31 +00:00
|
|
|
int main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
ClutterActor *stage;
|
|
|
|
ClutterActor *text;
|
|
|
|
ClutterAnimation *animation;
|
|
|
|
ClutterColor red, green, blue;
|
|
|
|
|
2012-10-25 21:26:17 +00:00
|
|
|
gtk_init (&argc, &argv);
|
2009-03-13 21:14:31 +00:00
|
|
|
gst_init (&argc, &argv);
|
2011-03-13 18:16:54 +00:00
|
|
|
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
|
2011-03-13 18:26:01 +00:00
|
|
|
return 1;
|
2009-03-13 21:14:31 +00:00
|
|
|
|
|
|
|
clutter_color_from_string (&red, "red");
|
|
|
|
clutter_color_from_string (&green, "green");
|
|
|
|
clutter_color_from_string (&blue, "blue");
|
2011-11-21 16:56:24 +00:00
|
|
|
stage = clutter_stage_new ();
|
|
|
|
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
|
2009-03-13 21:14:31 +00:00
|
|
|
|
|
|
|
text = g_object_new (CLUTTER_TYPE_TEXT,
|
|
|
|
"text", "Red",
|
|
|
|
"font-name", "Sans 40px",
|
|
|
|
"color", &red,
|
|
|
|
NULL);
|
2012-02-13 20:04:50 +00:00
|
|
|
clutter_actor_add_child (stage, text);
|
2009-03-13 21:14:31 +00:00
|
|
|
animation = clutter_actor_animate (text,
|
|
|
|
CLUTTER_EASE_IN_OUT_QUAD,
|
|
|
|
3000,
|
2012-05-02 14:20:52 +00:00
|
|
|
"x", 320.0,
|
|
|
|
"y", 240.0,
|
2009-03-13 21:14:31 +00:00
|
|
|
NULL);
|
|
|
|
g_signal_connect (animation, "completed",
|
2012-07-26 21:31:11 +00:00
|
|
|
G_CALLBACK (on_animation_completed), stage);
|
2009-03-13 21:14:31 +00:00
|
|
|
|
|
|
|
text = g_object_new (CLUTTER_TYPE_TEXT,
|
|
|
|
"text", "Blue",
|
|
|
|
"font-name", "Sans 40px",
|
|
|
|
"color", &blue,
|
2012-05-02 14:20:52 +00:00
|
|
|
"x", 640.0,
|
|
|
|
"y", 0.0,
|
2009-03-13 21:14:31 +00:00
|
|
|
NULL);
|
|
|
|
clutter_actor_set_anchor_point_from_gravity (text, CLUTTER_GRAVITY_NORTH_EAST);
|
2012-02-13 20:04:50 +00:00
|
|
|
clutter_actor_add_child (stage, text);
|
2009-03-13 21:14:31 +00:00
|
|
|
animation = clutter_actor_animate (text,
|
|
|
|
CLUTTER_EASE_IN_OUT_QUAD,
|
|
|
|
3000,
|
2012-05-02 14:20:52 +00:00
|
|
|
"x", 320.0,
|
|
|
|
"y", 240.0,
|
2009-03-13 21:14:31 +00:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
text = g_object_new (CLUTTER_TYPE_TEXT,
|
|
|
|
"text", "Green",
|
|
|
|
"font-name", "Sans 40px",
|
|
|
|
"color", &green,
|
2012-05-02 14:20:52 +00:00
|
|
|
"x", 0.0,
|
|
|
|
"y", 480.0,
|
2009-03-13 21:14:31 +00:00
|
|
|
NULL);
|
|
|
|
clutter_actor_set_anchor_point_from_gravity (text, CLUTTER_GRAVITY_SOUTH_WEST);
|
2012-02-13 20:04:50 +00:00
|
|
|
clutter_actor_add_child (stage, text);
|
2009-03-13 21:14:31 +00:00
|
|
|
animation = clutter_actor_animate (text,
|
|
|
|
CLUTTER_EASE_IN_OUT_QUAD,
|
|
|
|
3000,
|
2012-05-02 14:20:52 +00:00
|
|
|
"x", 320.0,
|
|
|
|
"y", 240.0,
|
2009-03-13 21:14:31 +00:00
|
|
|
NULL);
|
|
|
|
|
2012-05-02 14:23:28 +00:00
|
|
|
g_signal_connect_after (stage, "realize",
|
|
|
|
G_CALLBACK (on_stage_realized), NULL);
|
2009-03-13 21:14:31 +00:00
|
|
|
|
|
|
|
clutter_actor_show (stage);
|
|
|
|
|
|
|
|
clutter_main ();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|