diff options
author | Lionel Landwerlin <llandwerlin@gmail.com> | 2013-04-14 18:23:28 +0200 |
---|---|---|
committer | Lionel Landwerlin <llandwerlin@gmail.com> | 2013-04-25 16:33:33 +0100 |
commit | ab09d2bc6cafcb4b4db3c3c838cf3fd50d961dff (patch) | |
tree | e27b3fbff0aa63348c2f0243668b0fb19177109c | |
parent | 9a540099a323f580cd848322f6524bac860ca719 (diff) | |
download | clutter-gst-ab09d2bc6cafcb4b4db3c3c838cf3fd50d961dff.tar.gz |
introduce ClutterGstPipeline to allow custom Gstreamer pipelines to feed Actors
-rw-r--r-- | clutter-gst/Makefile.am | 2 | ||||
-rw-r--r-- | clutter-gst/clutter-gst-pipeline.c | 376 | ||||
-rw-r--r-- | clutter-gst/clutter-gst-pipeline.h | 90 | ||||
-rw-r--r-- | clutter-gst/clutter-gst.h | 5 | ||||
-rw-r--r-- | tests/test-alpha.c | 34 | ||||
-rw-r--r-- | tests/test-rgb-upload.c | 30 | ||||
-rw-r--r-- | tests/test-start-stop.c | 62 | ||||
-rw-r--r-- | tests/test-video-actor-new-unref-loop.c | 2 | ||||
-rw-r--r-- | tests/test-yuv-upload.c | 26 |
9 files changed, 552 insertions, 75 deletions
diff --git a/clutter-gst/Makefile.am b/clutter-gst/Makefile.am index 94c9dea..661e69c 100644 --- a/clutter-gst/Makefile.am +++ b/clutter-gst/Makefile.am @@ -32,6 +32,7 @@ source_h = \ $(srcdir)/clutter-gst-player.h \ $(srcdir)/clutter-gst-aspectratio.h \ $(srcdir)/clutter-gst-crop.h \ + $(srcdir)/clutter-gst-pipeline.h \ $(NULL) source_priv_h = \ @@ -52,6 +53,7 @@ source_c = \ $(srcdir)/clutter-gst-util.c \ $(srcdir)/clutter-gst-aspectratio.c \ $(srcdir)/clutter-gst-crop.c \ + $(srcdir)/clutter-gst-pipeline.c \ $(glib_enum_c) \ $(NULL) diff --git a/clutter-gst/clutter-gst-pipeline.c b/clutter-gst/clutter-gst-pipeline.c new file mode 100644 index 0000000..ba718d7 --- /dev/null +++ b/clutter-gst/clutter-gst-pipeline.c @@ -0,0 +1,376 @@ +/* + * Clutter-GStreamer. + * + * GStreamer integration library for Clutter. + * + * clutter-gst-aspectratio.c - An actor rendering a video with respect + * to its aspect ratio. + * + * Authored by Lionel Landwerlin <lionel.g.landwerlin@linux.intel.com> + * + * Copyright (C) 2013 Intel Corporation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "clutter-gst-debug.h" +#include "clutter-gst-enum-types.h" +#include "clutter-gst-pipeline.h" +#include "clutter-gst-player.h" +#include "clutter-gst-private.h" + +static void player_iface_init (ClutterGstPlayerIface *iface); + +void clutter_gst_pipeline_set_video_sink_internal (ClutterGstPipeline *self, + CoglGstVideoSink *sink); + +G_DEFINE_TYPE_WITH_CODE (ClutterGstPipeline, clutter_gst_pipeline, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (CLUTTER_GST_TYPE_PLAYER, player_iface_init)) + +#define PIPELINE_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), CLUTTER_GST_TYPE_PIPELINE, ClutterGstPipelinePrivate)) + +enum +{ + PROP_0, + + PROP_PLAYING, + PROP_IDLE, + PROP_AUDIO_VOLUME, + PROP_VIDEO_SINK +}; + +struct _ClutterGstPipelinePrivate +{ + CoglGstVideoSink *sink; + GstElement *pipeline; + + ClutterGstFrame *current_frame; +}; + +/**/ + +static gboolean +get_playing (ClutterGstPipeline *player) +{ + ClutterGstPipelinePrivate *priv = player->priv; + GstState state, pending; + gboolean playing; + + if (!priv->pipeline) + return FALSE; + + gst_element_get_state (priv->pipeline, &state, &pending, 0); + + if (pending) + playing = (pending == GST_STATE_PLAYING); + else + playing = (state == GST_STATE_PLAYING); + + CLUTTER_GST_NOTE (MEDIA, "get playing: %d", playing); + + return playing; +} + +/**/ + +static ClutterGstFrame * +clutter_gst_pipeline_get_frame (ClutterGstPlayer *self) +{ + ClutterGstPipelinePrivate *priv = CLUTTER_GST_PIPELINE (self)->priv; + + return priv->current_frame; +} + +static GstElement * +clutter_gst_pipeline_get_pipeline (ClutterGstPlayer *self) +{ + ClutterGstPipelinePrivate *priv = CLUTTER_GST_PIPELINE (self)->priv; + + return priv->pipeline; +} + +static gboolean +clutter_gst_pipeline_get_idle (ClutterGstPlayer *self) +{ + return FALSE; +} + +static gdouble +clutter_gst_pipeline_get_audio_volume (ClutterGstPlayer *self) +{ + return 0.0; +} + +static void +clutter_gst_pipeline_set_audio_volume (ClutterGstPlayer *self, + gdouble volume) +{ +} + +static gboolean +clutter_gst_pipeline_get_playing (ClutterGstPlayer *self) +{ + return get_playing (CLUTTER_GST_PIPELINE (self)); +} + +static void +clutter_gst_pipeline_set_playing (ClutterGstPlayer *self, + gboolean playing) +{ +} + +static void +player_iface_init (ClutterGstPlayerIface *iface) +{ + iface->get_frame = clutter_gst_pipeline_get_frame; + iface->get_pipeline = clutter_gst_pipeline_get_pipeline; + iface->get_idle = clutter_gst_pipeline_get_idle; + + iface->get_audio_volume = clutter_gst_pipeline_get_audio_volume; + iface->set_audio_volume = clutter_gst_pipeline_set_audio_volume; + + iface->get_playing = clutter_gst_pipeline_get_playing; + iface->set_playing = clutter_gst_pipeline_set_playing; +} + +/**/ + +static void +clutter_gst_pipeline_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + ClutterGstPipeline *self = CLUTTER_GST_PIPELINE (object); + ClutterGstPipelinePrivate *priv = self->priv; + + switch (property_id) + { + case PROP_IDLE: + g_value_set_boolean (value, + clutter_gst_pipeline_get_playing (CLUTTER_GST_PLAYER (self))); + break; + + case PROP_PLAYING: + g_value_set_boolean (value, + clutter_gst_pipeline_get_playing (CLUTTER_GST_PLAYER (self))); + break; + + case PROP_AUDIO_VOLUME: + g_value_set_double (value, + clutter_gst_pipeline_get_audio_volume (CLUTTER_GST_PLAYER (self))); + break; + + case PROP_VIDEO_SINK: + g_value_set_object (value, G_OBJECT (priv->sink)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +clutter_gst_pipeline_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) + { + case PROP_PLAYING: + clutter_gst_pipeline_set_playing (CLUTTER_GST_PLAYER (object), + g_value_get_boolean (value)); + break; + + case PROP_AUDIO_VOLUME: + clutter_gst_pipeline_set_audio_volume (CLUTTER_GST_PLAYER (object), + g_value_get_boolean (value)); + break; + + case PROP_VIDEO_SINK: + clutter_gst_pipeline_set_video_sink_internal (CLUTTER_GST_PIPELINE (object), + (CoglGstVideoSink *) g_value_get_object (value)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +clutter_gst_pipeline_dispose (GObject *object) +{ + ClutterGstPipelinePrivate *priv = CLUTTER_GST_PIPELINE (object)->priv; + + g_clear_object (&priv->sink); + priv->pipeline = NULL; + + if (priv->current_frame) + { + g_boxed_free (CLUTTER_GST_TYPE_FRAME, priv->current_frame); + priv->current_frame = NULL; + } + + G_OBJECT_CLASS (clutter_gst_pipeline_parent_class)->dispose (object); +} + +static void +clutter_gst_pipeline_finalize (GObject *object) +{ + G_OBJECT_CLASS (clutter_gst_pipeline_parent_class)->finalize (object); +} + +static void +clutter_gst_pipeline_class_init (ClutterGstPipelineClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GParamSpec *pspec; + + g_type_class_add_private (klass, sizeof (ClutterGstPipelinePrivate)); + + object_class->get_property = clutter_gst_pipeline_get_property; + object_class->set_property = clutter_gst_pipeline_set_property; + object_class->dispose = clutter_gst_pipeline_dispose; + object_class->finalize = clutter_gst_pipeline_finalize; + + pspec = g_param_spec_object ("video-sink", + "Video Sink", + "Video Sink", + COGL_GST_TYPE_VIDEO_SINK, + CLUTTER_GST_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_VIDEO_SINK, pspec); + + g_object_class_override_property (object_class, + PROP_IDLE, "idle"); + g_object_class_override_property (object_class, + PROP_PLAYING, "playing"); + g_object_class_override_property (object_class, + PROP_AUDIO_VOLUME, "audio-volume"); +} + +static void +clutter_gst_pipeline_init (ClutterGstPipeline *self) +{ + ClutterGstPipelinePrivate *priv; + + self->priv = priv = PIPELINE_PRIVATE (self); + + priv->current_frame = clutter_gst_create_blank_frame (NULL); +} + +ClutterGstPipeline * +clutter_gst_pipeline_new (void) +{ + return g_object_new (CLUTTER_GST_TYPE_PIPELINE, NULL); +} + +/**/ + +static void +_new_frame_from_pipeline (CoglGstVideoSink *sink, ClutterGstPipeline *self) +{ + ClutterGstPipelinePrivate *priv = self->priv; + + clutter_gst_player_update_frame (CLUTTER_GST_PLAYER (self), + &priv->current_frame, + cogl_gst_video_sink_get_pipeline (sink)); +} + +static void +_ready_from_pipeline (CoglGstVideoSink *sink, ClutterGstPipeline *self) +{ + g_signal_emit_by_name (self, "ready"); +} + +static void +_pixel_aspect_ratio_changed (CoglGstVideoSink *sink, + GParamSpec *spec, + ClutterGstPipeline *self) +{ + clutter_gst_frame_update_pixel_aspect_ratio (self->priv->current_frame, sink); +} + +void +clutter_gst_pipeline_set_video_sink_internal (ClutterGstPipeline *self, + CoglGstVideoSink *sink) +{ + ClutterGstPipelinePrivate *priv = self->priv; + + if (priv->sink == sink) + return; + + if (priv->sink) + { + g_signal_handlers_disconnect_by_func (priv->sink, + _new_frame_from_pipeline, self); + g_signal_handlers_disconnect_by_func (priv->sink, + _ready_from_pipeline, self); + g_signal_handlers_disconnect_by_func (priv->sink, + _pixel_aspect_ratio_changed, self); + g_clear_object (&priv->sink); + priv->pipeline = NULL; + } + + if (sink) + { + GstObject *tmpobj; + CoglPipeline *pipeline; + + priv->pipeline = GST_ELEMENT (sink); + while ((tmpobj = gst_element_get_parent (priv->pipeline))) + priv->pipeline = GST_ELEMENT (tmpobj); + + priv->sink = g_object_ref_sink (sink); + g_signal_connect (priv->sink, "new-frame", + G_CALLBACK (_new_frame_from_pipeline), self); + g_signal_connect (priv->sink, "pipeline-ready", + G_CALLBACK (_ready_from_pipeline), self); + g_signal_connect (priv->sink, "notify::pixel-aspect-ratio", + G_CALLBACK (_pixel_aspect_ratio_changed), self); + + pipeline = cogl_gst_video_sink_get_pipeline (priv->sink); + if (pipeline) + clutter_gst_player_update_frame (CLUTTER_GST_PLAYER (self), + &priv->current_frame, + pipeline); + } + + g_object_notify (G_OBJECT (self), "video-sink"); +} + +void +clutter_gst_pipeline_set_video_sink (ClutterGstPipeline *self, + CoglGstVideoSink *sink) +{ + g_return_if_fail (CLUTTER_GST_IS_PIPELINE (self)); + g_return_if_fail (COGL_GST_IS_VIDEO_SINK (sink)); + + clutter_gst_pipeline_set_video_sink_internal (self, sink); +} + +CoglGstVideoSink * +clutter_gst_pipeline_get_video_sink (ClutterGstPipeline *self) +{ + g_return_val_if_fail (CLUTTER_GST_IS_PIPELINE (self), NULL); + + return self->priv->sink; +} diff --git a/clutter-gst/clutter-gst-pipeline.h b/clutter-gst/clutter-gst-pipeline.h new file mode 100644 index 0000000..0bce803 --- /dev/null +++ b/clutter-gst/clutter-gst-pipeline.h @@ -0,0 +1,90 @@ +/* + * Clutter-GStreamer. + * + * GStreamer integration library for Clutter. + * + * clutter-gst-aspectratio.c - An actor rendering a video with respect + * to its aspect ratio. + * + * Authored by Lionel Landwerlin <lionel.g.landwerlin@linux.intel.com> + * + * Copyright (C) 2013 Intel Corporation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#if !defined(__CLUTTER_GST_H_INSIDE__) && !defined(CLUTTER_GST_COMPILATION) +#error "Only <clutter-gst/clutter-gst.h> can be include directly." +#endif + +#ifndef __CLUTTER_GST_PIPELINE_H__ +#define __CLUTTER_GST_PIPELINE_H__ + +#include <glib-object.h> + +#include <cogl-gst/cogl-gst.h> + +G_BEGIN_DECLS + +#define CLUTTER_GST_TYPE_PIPELINE clutter_gst_pipeline_get_type() + +#define CLUTTER_GST_PIPELINE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ + CLUTTER_GST_TYPE_PIPELINE, ClutterGstPipeline)) + +#define CLUTTER_GST_PIPELINE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), \ + CLUTTER_GST_TYPE_PIPELINE, ClutterGstPipelineClass)) + +#define CLUTTER_GST_IS_PIPELINE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ + CLUTTER_GST_TYPE_PIPELINE)) + +#define CLUTTER_GST_IS_PIPELINE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), \ + CLUTTER_GST_TYPE_PIPELINE)) + +#define CLUTTER_GST_PIPELINE_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), \ + CLUTTER_GST_TYPE_PIPELINE, ClutterGstPipelineClass)) + +typedef struct _ClutterGstPipeline ClutterGstPipeline; +typedef struct _ClutterGstPipelineClass ClutterGstPipelineClass; +typedef struct _ClutterGstPipelinePrivate ClutterGstPipelinePrivate; + +struct _ClutterGstPipeline +{ + GObject parent; + + ClutterGstPipelinePrivate *priv; +}; + +struct _ClutterGstPipelineClass +{ + GObjectClass parent_class; +}; + +GType clutter_gst_pipeline_get_type (void) G_GNUC_CONST; + +ClutterGstPipeline *clutter_gst_pipeline_new (void); + +CoglGstVideoSink *clutter_gst_pipeline_get_video_sink (ClutterGstPipeline *self); +void clutter_gst_pipeline_set_video_sink (ClutterGstPipeline *self, + CoglGstVideoSink *sink); + +G_END_DECLS + +#endif /* __CLUTTER_GST_PIPELINE_H__ */ diff --git a/clutter-gst/clutter-gst.h b/clutter-gst/clutter-gst.h index 6b57d8c..b517766 100644 --- a/clutter-gst/clutter-gst.h +++ b/clutter-gst/clutter-gst.h @@ -37,9 +37,10 @@ #include "clutter-gst-camera-device.h" #include "clutter-gst-camera.h" #include "clutter-gst-crop.h" +#include "clutter-gst-pipeline.h" +#include "clutter-gst-playback.h" +#include "clutter-gst-player.h" #include "clutter-gst-util.h" #include "clutter-gst-version.h" -#include "clutter-gst-player.h" -#include "clutter-gst-playback.h" #endif /* __CLUTTER_GST_H__ */ 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); |