diff options
author | Damien Lespiau <damien.lespiau@intel.com> | 2010-12-06 12:37:02 +0000 |
---|---|---|
committer | Damien Lespiau <damien.lespiau@intel.com> | 2010-12-06 16:44:06 +0000 |
commit | 4e188f60ff5106bcc386589763c57a632b0ea7b1 (patch) | |
tree | 3eacac00e4a515d41cfdae4a68ae88e4aef5417c | |
parent | e9c7ccaf7c16c46f1ed85bd338eeebbd67c39697 (diff) |
video-texture: Allow to make accurate seeks
ClutterGstVideoTexture has now a property (and its equivalent getter
and setter) to set seek flags to customize a bit the seek done by
set_progress(). For now, we have an "ACCURATE" flag that maps directly
to GST_SEEK_FLAG_ACCURATE.
To be able to export correctly this new API to g-i and bindings, we need
to generate the enum types for ClutterGstSeekFlags.
Fixes: http://bugzilla.clutter-project.org/show_bug.cgi?id=2279
-rw-r--r-- | build/autotools/Makefile.am.enums | 51 | ||||
-rw-r--r-- | clutter-gst/.gitignore | 3 | ||||
-rw-r--r-- | clutter-gst/Makefile.am | 25 | ||||
-rw-r--r-- | clutter-gst/clutter-gst-enum-types.c.in | 40 | ||||
-rw-r--r-- | clutter-gst/clutter-gst-enum-types.h.in | 26 | ||||
-rw-r--r-- | clutter-gst/clutter-gst-video-texture.c | 80 | ||||
-rw-r--r-- | clutter-gst/clutter-gst-video-texture.h | 36 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | doc/reference/clutter-gst-sections.txt | 5 |
9 files changed, 250 insertions, 17 deletions
diff --git a/build/autotools/Makefile.am.enums b/build/autotools/Makefile.am.enums new file mode 100644 index 0000000..ec1a6c1 --- /dev/null +++ b/build/autotools/Makefile.am.enums @@ -0,0 +1,51 @@ +# Rules for generating enumeration types using glib-mkenums +# +# Define: +# glib_enum_h = header template file +# glib_enum_c = source template file +# glib_enum_headers = list of headers to parse +# +# before including Makefile.am.enums. You will also need to have +# the following targets already defined: +# +# CLEANFILES +# DISTCLEANFILES +# BUILT_SOURCES +# EXTRA_DIST +# +# Author: Emmanuele Bassi <ebassi@linux.intel.com> + +# Basic sanity checks +$(if $(GLIB_MKENUMS),,$(error Need to define GLIB_MKENUMS)) + +$(if $(or $(glib_enum_h), \ + $(glib_enum_c)),, \ + $(error Need to define glib_enum_h and glib_enum_c)) + +$(if $(glib_enum_headers),,$(error Need to define glib_enum_headers)) + +enum_tmpl_h=$(addprefix $(srcdir)/, $(glib_enum_h:.h=.h.in)) +enum_tmpl_c=$(addprefix $(srcdir)/, $(glib_enum_c:.c=.c.in)) + +CLEANFILES += stamp-enum-types +DISTCLEANFILES += $(glib_enum_h) $(glib_enum_c) +BUILT_SOURCES += $(glib_enum_h) $(glib_enum_c) +EXTRA_DIST += $(enum_tmpl_h) $(enum_tmpl_c) + +stamp-enum-types: $(glib_enum_headers) $(enum_tmpl_h) + $(AM_V_GEN)$(GLIB_MKENUMS) \ + --template $(enum_tmpl_h) \ + $(glib_enum_headers) | sed -e 's/_TYPE_GST/_TYPE/g' > xgen-eh \ + && (cmp -s xgen-eh $(glib_enum_h) || cp -f xgen-eh $(glib_enum_h)) \ + && rm -f xgen-eh \ + && echo timestamp > $(@F) + +$(glib_enum_h): stamp-enum-types + @true + +$(glib_enum_c): $(glib_enum_headers) $(glib_enum_h) $(enum_tmpl_c) + $(AM_V_GEN)$(GLIB_MKENUMS) \ + --template $(enum_tmpl_c) \ + $(glib_enum_headers) > xgen-ec \ + && cp -f xgen-ec $(glib_enum_c) \ + && rm -f xgen-ec diff --git a/clutter-gst/.gitignore b/clutter-gst/.gitignore index 5a9a203..6537c91 100644 --- a/clutter-gst/.gitignore +++ b/clutter-gst/.gitignore @@ -1 +1,4 @@ clutter-gst-version.h +clutter-gst-enum-types.h +clutter-gst-enum-types.c +stamp-enum-types diff --git a/clutter-gst/Makefile.am b/clutter-gst/Makefile.am index 68de98d..e56a70a 100644 --- a/clutter-gst/Makefile.am +++ b/clutter-gst/Makefile.am @@ -5,15 +5,24 @@ NULL = # SUBDIRS = shaders CLEANFILES = # +DISTCLEANFILES = # +EXTRA_DIST = # +BUILT_SOURCES = # + +# glib-mkenums +glib_enum_h = clutter-gst-enum-types.h +glib_enum_c = clutter-gst-enum-types.c +glib_enum_headers = $(source_h) +include $(top_srcdir)/build/autotools/Makefile.am.enums source_h = \ + $(srcdir)/clutter-gst.h \ $(srcdir)/clutter-gst-util.h \ $(srcdir)/clutter-gst-version.h \ $(srcdir)/clutter-gst-video-sink.h \ $(srcdir)/clutter-gst-video-texture.h \ $(NULL) - source_priv_h = \ $(srcdir)/clutter-gst-debug.h \ $(srcdir)/clutter-gst-private.h \ @@ -25,12 +34,16 @@ source_c = \ $(srcdir)/clutter-gst-video-sink.c \ $(srcdir)/clutter-gst-video-texture.c \ $(srcdir)/clutter-gst-util.c \ + $(glib_enum_c) \ $(NULL) -libclutter_gst_@CLUTTER_GST_MAJORMINOR@_la_SOURCES = $(MARSHALFILES) \ - $(source_c) \ - $(source_priv_h) \ - $(source_h) +libclutter_gst_@CLUTTER_GST_MAJORMINOR@_la_SOURCES = \ + $(MARSHALFILES) \ + $(source_c) \ + $(source_priv_h) \ + $(source_h) \ + $(glib_enum_h) \ + $(NULL) INCLUDES = \ -I$(top_srcdir) \ @@ -60,7 +73,7 @@ libclutter_gst_@CLUTTER_GST_MAJORMINOR@_la_LIBADD = @CLUTTER_GST_LIBS@ $(GST_LI libclutter_gst_@CLUTTER_GST_MAJORMINOR@_la_LDFLAGS = @CLUTTER_GST_LT_LDFLAGS@ cluttergstheadersdir = $(includedir)/clutter-@CLUTTER_API_VERSION@/clutter-gst -cluttergstheaders_HEADERS = $(source_h) $(srcdir)/clutter-gst.h +cluttergstheaders_HEADERS = $(source_h) $(glib_enum_h) # # Introspection data diff --git a/clutter-gst/clutter-gst-enum-types.c.in b/clutter-gst/clutter-gst-enum-types.c.in new file mode 100644 index 0000000..a750f4b --- /dev/null +++ b/clutter-gst/clutter-gst-enum-types.c.in @@ -0,0 +1,40 @@ +/*** BEGIN file-header ***/ +#include "clutter-gst-enum-types.h" +/*** END file-header ***/ + +/*** BEGIN file-production ***/ + +/* enumerations from "@filename@" */ +#include "@filename@" + +/*** END file-production ***/ + +/*** BEGIN value-header ***/ +GType +@enum_name@_get_type (void) +{ + static volatile gsize g_enum_type_id__volatile = 0; + + if (g_once_init_enter (&g_enum_type_id__volatile)) + { + static const G@Type@Value values[] = { +/*** END value-header ***/ + +/*** BEGIN value-production ***/ + { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, +/*** END value-production ***/ + +/*** BEGIN value-tail ***/ + { 0, NULL, NULL } + }; + GType g_enum_type_id; + + g_enum_type_id = + g_@type@_register_static (g_intern_static_string ("@EnumName@"), values); + + g_once_init_leave (&g_enum_type_id__volatile, g_enum_type_id); + } + + return g_enum_type_id__volatile; +} +/*** END value-tail ***/ diff --git a/clutter-gst/clutter-gst-enum-types.h.in b/clutter-gst/clutter-gst-enum-types.h.in new file mode 100644 index 0000000..dab1c7e --- /dev/null +++ b/clutter-gst/clutter-gst-enum-types.h.in @@ -0,0 +1,26 @@ +/*** BEGIN file-header ***/ +#ifndef __CLUTTER_GST_ENUM_TYPES_H__ +#define __CLUTTER_GST_ENUM_TYPES_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS + +/*** END file-header ***/ + +/*** BEGIN file-production ***/ +/* enumerations from "@filename@" */ +/*** END file-production ***/ + +/*** BEGIN file-tail ***/ +G_END_DECLS + +#endif /* !__CLUTTER_GST_ENUM_TYPES_H__ */ +/*** END file-tail ***/ + +/*** BEGIN value-header ***/ +GType @enum_name@_get_type (void) G_GNUC_CONST; +#define CLUTTER_GST_TYPE_@ENUMSHORT@ (@enum_name@_get_type()) + +/*** END value-header ***/ + diff --git a/clutter-gst/clutter-gst-video-texture.c b/clutter-gst/clutter-gst-video-texture.c index 617d46f..ad4b3a7 100644 --- a/clutter-gst/clutter-gst-video-texture.c +++ b/clutter-gst/clutter-gst-video-texture.c @@ -48,6 +48,7 @@ #include "clutter-gst-debug.h" #include "clutter-gst-private.h" +#include "clutter-gst-enum-types.h" #include "clutter-gst-video-sink.h" #include "clutter-gst-video-texture.h" @@ -85,6 +86,8 @@ struct _ClutterGstVideoTexturePrivate CoglHandle idle_material; CoglColor idle_color_unpre; + + GstSeekFlags seek_flags; /* flags for the seek in set_progress(); */ }; enum { @@ -102,7 +105,8 @@ enum { PROP_DURATION, PROP_IDLE_MATERIAL, - PROP_USER_AGENT + PROP_USER_AGENT, + PROP_SEEK_FLAGS }; @@ -495,7 +499,7 @@ set_progress (ClutterGstVideoTexture *video_texture, gst_element_seek (priv->pipeline, 1.0, GST_FORMAT_TIME, - GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT, + GST_SEEK_FLAG_FLUSH | priv->seek_flags, GST_SEEK_TYPE_SET, position, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE); @@ -952,6 +956,11 @@ clutter_gst_video_texture_set_property (GObject *object, g_value_get_string (value)); break; + case PROP_SEEK_FLAGS: + clutter_gst_video_texture_set_seek_flags (video_texture, + g_value_get_flags (value)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } @@ -1022,6 +1031,15 @@ clutter_gst_video_texture_get_property (GObject *object, } break; + case PROP_SEEK_FLAGS: + { + ClutterGstSeekFlags seek_flags; + + seek_flags = clutter_gst_video_texture_get_seek_flags (video_texture); + g_value_set_flags (value, seek_flags); + } + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } @@ -1083,6 +1101,14 @@ clutter_gst_video_texture_class_init (ClutterGstVideoTextureClass *klass) NULL, CLUTTER_GST_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_USER_AGENT, pspec); + + pspec = g_param_spec_flags ("seek-flags", + "Seek Flags", + "Flags to use when seeking", + CLUTTER_GST_TYPE_SEEK_FLAGS, + CLUTTER_GST_SEEK_FLAG_NONE, + CLUTTER_GST_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_SEEK_FLAGS, pspec); } static void @@ -1321,6 +1347,9 @@ clutter_gst_video_texture_init (ClutterGstVideoTexture *video_texture) priv->par_n = priv->par_d = 1; + /* Default to a fast seek, ie. same effect than set_seek_flags (NONE); */ + priv->seek_flags = GST_SEEK_FLAG_KEY_UNIT; + bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline)); gst_bus_add_signal_watch (bus); @@ -1534,3 +1563,50 @@ clutter_gst_video_texture_set_user_agent (ClutterGstVideoTexture *texture, set_user_agent (texture, user_agent); } + +/** + * clutter_gst_video_texture_get_seek_flags: + * @texture: a #ClutterGstVideoTexture + * + * Get the current value of the seek-flags property. + * + * Return value: a combination of #ClutterGstSeekFlags + * + * Since: 1.4 + */ +ClutterGstSeekFlags +clutter_gst_video_texture_get_seek_flags (ClutterGstVideoTexture *texture) +{ + g_return_val_if_fail (CLUTTER_GST_IS_VIDEO_TEXTURE (texture), + CLUTTER_GST_SEEK_FLAG_NONE); + + if (texture->priv->seek_flags == GST_SEEK_FLAG_ACCURATE) + return CLUTTER_GST_SEEK_FLAG_ACCURATE; + else + return CLUTTER_GST_SEEK_FLAG_NONE; +} + +/** + * clutter_gst_video_texture_set_seek_flags: + * @texture: a #ClutterGstVideoTexture + * @flags: a combination of #ClutterGstSeekFlags + * + * Seeking can be done with several trade-offs. Clutter-gst defaults + * to %CLUTTER_GST_SEEK_FLAG_NONE. + * + * Since: 1.4 + */ +void +clutter_gst_video_texture_set_seek_flags (ClutterGstVideoTexture *texture, + ClutterGstSeekFlags flags) +{ + ClutterGstVideoTexturePrivate *priv; + + g_return_if_fail (CLUTTER_GST_IS_VIDEO_TEXTURE (texture)); + priv = texture->priv; + + if (flags == CLUTTER_GST_SEEK_FLAG_NONE) + priv->seek_flags = GST_SEEK_FLAG_KEY_UNIT; + else if (flags & CLUTTER_GST_SEEK_FLAG_ACCURATE) + priv->seek_flags = GST_SEEK_FLAG_ACCURATE; +} diff --git a/clutter-gst/clutter-gst-video-texture.h b/clutter-gst/clutter-gst-video-texture.h index 7ca4f30..eba4468 100644 --- a/clutter-gst/clutter-gst-video-texture.h +++ b/clutter-gst/clutter-gst-video-texture.h @@ -61,6 +61,21 @@ G_BEGIN_DECLS (G_TYPE_INSTANCE_GET_CLASS ((obj), \ CLUTTER_GST_TYPE_VIDEO_TEXTURE, ClutterGstVideoTextureClass)) +/** + * ClutterGstSeekFlags: + * @CLUTTER_GST_SEEK_FLAG_NONE: Fast seeks (key frame boundaries, default) + * @CLUTTER_GST_SEEK_FLAG_ACCURATE: Accurate seeks (potentially slower) + * + * Flags that can be given to clutter_gst_video_texture_set_seek_flags(). + * + * Since: 1.4 + */ +typedef enum _ClutterGstSeekFlags +{ + CLUTTER_GST_SEEK_FLAG_NONE = 0, + CLUTTER_GST_SEEK_FLAG_ACCURATE = 1 << 0 +} ClutterGstSeekFlags; + typedef struct _ClutterGstVideoTexture ClutterGstVideoTexture; typedef struct _ClutterGstVideoTextureClass ClutterGstVideoTextureClass; typedef struct _ClutterGstVideoTexturePrivate ClutterGstVideoTexturePrivate; @@ -99,17 +114,20 @@ struct _ClutterGstVideoTextureClass void (* _clutter_reserved6) (void); }; -GType clutter_gst_video_texture_get_type (void) G_GNUC_CONST; -ClutterActor * clutter_gst_video_texture_new (void); +GType clutter_gst_video_texture_get_type (void) G_GNUC_CONST; +ClutterActor * clutter_gst_video_texture_new (void); -GstElement * clutter_gst_video_texture_get_pipeline (ClutterGstVideoTexture *texture); +GstElement * clutter_gst_video_texture_get_pipeline (ClutterGstVideoTexture *texture); -CoglHandle clutter_gst_video_texture_get_idle_material (ClutterGstVideoTexture *texture); -void clutter_gst_video_texture_set_idle_material (ClutterGstVideoTexture *texture, - CoglHandle material); -gchar * clutter_gst_video_texture_get_user_agent (ClutterGstVideoTexture *texture); -void clutter_gst_video_texture_set_user_agent (ClutterGstVideoTexture *texture, - const gchar * user_agent); +CoglHandle clutter_gst_video_texture_get_idle_material (ClutterGstVideoTexture *texture); +void clutter_gst_video_texture_set_idle_material (ClutterGstVideoTexture *texture, + CoglHandle material); +gchar * clutter_gst_video_texture_get_user_agent (ClutterGstVideoTexture *texture); +void clutter_gst_video_texture_set_user_agent (ClutterGstVideoTexture *texture, + const gchar * user_agent); +ClutterGstSeekFlags clutter_gst_video_texture_get_seek_flags (ClutterGstVideoTexture *texture); +void clutter_gst_video_texture_set_seek_flags (ClutterGstVideoTexture *texture, + ClutterGstSeekFlags flags); G_END_DECLS diff --git a/configure.ac b/configure.ac index ac77c32..4542cc1 100644 --- a/configure.ac +++ b/configure.ac @@ -69,6 +69,7 @@ AM_PROG_CC_C_O AC_DISABLE_STATIC AC_PROG_LIBTOOL DOLT +AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums]) # Checks for header files. AC_HEADER_STDC diff --git a/doc/reference/clutter-gst-sections.txt b/doc/reference/clutter-gst-sections.txt index e2a730b..b88d287 100644 --- a/doc/reference/clutter-gst-sections.txt +++ b/doc/reference/clutter-gst-sections.txt @@ -1,6 +1,7 @@ <SECTION> <FILE>clutter-gst-video-texture</FILE> <TITLE>ClutterGstVideoTexture</TITLE> +ClutterGstSeekFlags ClutterGstVideoTexture ClutterGstVideoTextureClass clutter_gst_video_texture_new @@ -9,7 +10,10 @@ clutter_gst_video_texture_get_idle_material clutter_gst_video_texture_set_idle_material clutter_gst_video_texture_get_user_agent clutter_gst_video_texture_set_user_agent +clutter_gst_video_texture_set_seek_flags +clutter_gst_video_texture_get_seek_flags <SUBSECTION Standard> +clutter_gst_seek_flags_get_type CLUTTER_GST_VIDEO_TEXTURE CLUTTER_GST_IS_VIDEO_TEXTURE CLUTTER_GST_TYPE_VIDEO_TEXTURE @@ -28,6 +32,7 @@ ClutterGstVideoSink ClutterGstVideoSinkClass clutter_gst_video_sink_new <SUBSECTION Standard> +CLUTTER_GST_TYPE_SEEK_FLAGS CLUTTER_GST_VIDEO_SINK CLUTTER_GST_IS_VIDEO_SINK CLUTTER_GST_TYPE_VIDEO_SINK |