gnome-shell/src/test-recorder.c
Owen W. Taylor afceea3fe6 Add a built-in screencast recording facility
For development and demonstration purposes, it's neat to be able to
record a screencast of gnome-shell without any external setup.
Built-in recording can also give much better quality than is possible
with a generic desktop recording, since we hook right into the paint
loop.

src/shell-recorder.[ch]: A general-purposes object to record a Clutter
 stage to a GStreamer stream.
src/shell-recorder-src.[ch]: A simple GStreamer source element (similar
 to appsrc in the most recent versions of GStreamer) for injecting
 captured data into a GStreamer pipeline.
src/test-recorder.c: Test program that records a simple animation.

configure.ac src/Makefile.am: Add machinery to conditionally build
 ShellRecorder.
tools/build/gnome-shell-build-setup.sh: Add gstreamer packages
 to the list of required packages for Fedora.

js/ui/main.js: Hook up the recorder to a MetaScreen ::toggle-recording
 keybinding.

http://bugzilla.gnome.org/show_bug.cgi?id=575290
2009-03-20 16:53:50 -04:00

96 lines
2.4 KiB
C

#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.
*/
static ShellRecorder *recorder;
static gboolean
stop_recording_timeout (gpointer data)
{
shell_recorder_close (recorder);
return FALSE;
}
static void
on_animation_completed (ClutterAnimation *animation)
{
g_timeout_add (1000, stop_recording_timeout, NULL);
}
int main (int argc, char **argv)
{
ClutterActor *stage;
ClutterActor *text;
ClutterAnimation *animation;
ClutterColor red, green, blue;
g_thread_init (NULL);
gst_init (&argc, &argv);
clutter_init (&argc, &argv);
clutter_color_from_string (&red, "red");
clutter_color_from_string (&green, "green");
clutter_color_from_string (&blue, "blue");
stage = clutter_stage_get_default ();
text = g_object_new (CLUTTER_TYPE_TEXT,
"text", "Red",
"font-name", "Sans 40px",
"color", &red,
NULL);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), text);
animation = clutter_actor_animate (text,
CLUTTER_EASE_IN_OUT_QUAD,
3000,
"x", 320,
"y", 240,
NULL);
g_signal_connect (animation, "completed",
G_CALLBACK (on_animation_completed), NULL);
text = g_object_new (CLUTTER_TYPE_TEXT,
"text", "Blue",
"font-name", "Sans 40px",
"color", &blue,
"x", 640,
"y", 0,
NULL);
clutter_actor_set_anchor_point_from_gravity (text, CLUTTER_GRAVITY_NORTH_EAST);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), text);
animation = clutter_actor_animate (text,
CLUTTER_EASE_IN_OUT_QUAD,
3000,
"x", 320,
"y", 240,
NULL);
text = g_object_new (CLUTTER_TYPE_TEXT,
"text", "Green",
"font-name", "Sans 40px",
"color", &green,
"x", 0,
"y", 480,
NULL);
clutter_actor_set_anchor_point_from_gravity (text, CLUTTER_GRAVITY_SOUTH_WEST);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), text);
animation = clutter_actor_animate (text,
CLUTTER_EASE_IN_OUT_QUAD,
3000,
"x", 320,
"y", 240,
NULL);
recorder = shell_recorder_new (CLUTTER_STAGE (stage));
shell_recorder_set_filename (recorder, "test-recorder.ogg");
clutter_actor_show (stage);
shell_recorder_record (recorder);
clutter_main ();
return 0;
}