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