Comments and cosmetics

This commit is contained in:
Xavi Artigas 2012-07-10 16:21:33 +02:00
parent 669b10b6f6
commit 37de9e77c6

View file

@ -1,6 +1,3 @@
#ifdef _WIN32
#include <windows.h>
#endif
#include <clutter-gst/clutter-gst.h>
/* Setup the video texture once its size is known */
@ -16,7 +13,7 @@ void size_change (ClutterActor *texture, gint width, gint height, gpointer user_
clutter_actor_get_size (stage, &stage_width, &stage_height);
/* Center video on window */
/* Center video on window and calculate new size preserving aspect ratio */
new_height = (height * stage_width) / width;
if (new_height <= stage_height) {
new_width = stage_width;
@ -32,8 +29,8 @@ void size_change (ClutterActor *texture, gint width, gint height, gpointer user_
}
clutter_actor_set_position (texture, new_x, new_y);
clutter_actor_set_size (texture, new_width, new_height);
/* Animate it */
clutter_actor_set_rotation (texture, CLUTTER_Y_AXIS, 0.0, stage_width / 2, 0, 0);
/* Animate it */
animation = clutter_actor_animate (texture, CLUTTER_LINEAR, 10000, "rotation-angle-y", 360.0, NULL);
clutter_animation_set_loop (animation, TRUE);
}
@ -43,6 +40,7 @@ int main(int argc, char *argv[]) {
ClutterTimeline *timeline;
ClutterActor *stage, *texture;
/* clutter-gst takes care of initializing Clutter and GStreamer */
if (clutter_gst_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) {
g_error ("Failed to initialize clutter\n");
return -1;
@ -54,13 +52,11 @@ int main(int argc, char *argv[]) {
timeline = clutter_timeline_new (1000);
g_object_set(timeline, "loop", TRUE, NULL);
/* We need to set certain props on the target texture currently for
* efficient/correct playback onto the texture */
/* Create new texture and disable slicing so the video is properly mapped onto it */
texture = CLUTTER_ACTOR (g_object_new (CLUTTER_TYPE_TEXTURE, "disable-slicing", TRUE, NULL));
g_signal_connect (texture, "size-change", G_CALLBACK (size_change), NULL);
/* Build the pipeline */
/* Build the GStreamer pipeline */
pipeline = gst_parse_launch ("playbin2 uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm", NULL);
/* Instantiate the Clutter sink */
@ -70,7 +66,7 @@ int main(int argc, char *argv[]) {
sink = gst_element_factory_make ("cluttersink", NULL);
}
if (sink == NULL) {
g_printerr ("Unable to find a Cluttre sink.\n");
g_printerr ("Unable to find a Clutter sink.\n");
return -1;
}
@ -86,6 +82,7 @@ int main(int argc, char *argv[]) {
/* start the timeline */
clutter_timeline_start (timeline);
/* Add texture to the stage, and show it */
clutter_group_add (CLUTTER_GROUP (stage), texture);
clutter_actor_show_all (stage);