summaryrefslogtreecommitdiff
path: root/ext/annodex
diff options
context:
space:
mode:
authorKibum Kim <kb0929.kim@samsung.com>2012-01-07 00:46:56 +0900
committerKibum Kim <kb0929.kim@samsung.com>2012-01-07 00:46:56 +0900
commit4fcf0a9192ac1dee34309a66be632530b66f6822 (patch)
treee09f9233b63b22f97084798dcf6ffd3c85cc3adb /ext/annodex
parentdfa84b358c7cdf0535eba1fead62fc4122cc56e6 (diff)
downloadgst-plugins-good0.10-4fcf0a9192ac1dee34309a66be632530b66f6822.tar.gz
gst-plugins-good0.10-4fcf0a9192ac1dee34309a66be632530b66f6822.tar.bz2
gst-plugins-good0.10-4fcf0a9192ac1dee34309a66be632530b66f6822.zip
Git init
Diffstat (limited to 'ext/annodex')
-rw-r--r--ext/annodex/Makefile.am19
-rw-r--r--ext/annodex/Makefile.in867
-rw-r--r--ext/annodex/gstannodex.c167
-rw-r--r--ext/annodex/gstannodex.h34
-rw-r--r--ext/annodex/gstcmmldec.c708
-rw-r--r--ext/annodex/gstcmmldec.h98
-rw-r--r--ext/annodex/gstcmmlenc.c631
-rw-r--r--ext/annodex/gstcmmlenc.h79
-rw-r--r--ext/annodex/gstcmmlparser.c648
-rw-r--r--ext/annodex/gstcmmlparser.h92
-rw-r--r--ext/annodex/gstcmmltag.c579
-rw-r--r--ext/annodex/gstcmmltag.h133
-rw-r--r--ext/annodex/gstcmmlutils.c388
-rw-r--r--ext/annodex/gstcmmlutils.h53
14 files changed, 4496 insertions, 0 deletions
diff --git a/ext/annodex/Makefile.am b/ext/annodex/Makefile.am
new file mode 100644
index 0000000..d20a01f
--- /dev/null
+++ b/ext/annodex/Makefile.am
@@ -0,0 +1,19 @@
+plugin_LTLIBRARIES = libgstannodex.la
+
+libgstannodex_la_SOURCES = \
+ gstannodex.c \
+ gstcmmlutils.c \
+ gstcmmldec.c \
+ gstcmmlenc.c \
+ gstcmmltag.c \
+ gstcmmlparser.c
+
+libgstannodex_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) \
+ $(GST_CFLAGS) $(ANNODEX_CFLAGS)
+libgstannodex_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) \
+ $(GST_LIBS) $(ANNODEX_LIBS) $(LIBM)
+libgstannodex_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstannodex_la_LIBTOOLFLAGS = --tag=disable-static
+
+noinst_HEADERS = gstannodex.h gstcmmlutils.h gstcmmltag.h gstcmmlparser.h \
+ gstcmmldec.h gstcmmlenc.h
diff --git a/ext/annodex/Makefile.in b/ext/annodex/Makefile.in
new file mode 100644
index 0000000..4f719df
--- /dev/null
+++ b/ext/annodex/Makefile.in
@@ -0,0 +1,867 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = ext/annodex
+DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/common/m4/as-ac-expand.m4 \
+ $(top_srcdir)/common/m4/as-auto-alt.m4 \
+ $(top_srcdir)/common/m4/as-compiler-flag.m4 \
+ $(top_srcdir)/common/m4/as-gcc-inline-assembly.m4 \
+ $(top_srcdir)/common/m4/as-objc.m4 \
+ $(top_srcdir)/common/m4/as-python.m4 \
+ $(top_srcdir)/common/m4/as-scrub-include.m4 \
+ $(top_srcdir)/common/m4/as-version.m4 \
+ $(top_srcdir)/common/m4/ax_create_stdint_h.m4 \
+ $(top_srcdir)/common/m4/gst-arch.m4 \
+ $(top_srcdir)/common/m4/gst-args.m4 \
+ $(top_srcdir)/common/m4/gst-check.m4 \
+ $(top_srcdir)/common/m4/gst-default.m4 \
+ $(top_srcdir)/common/m4/gst-dowhile.m4 \
+ $(top_srcdir)/common/m4/gst-error.m4 \
+ $(top_srcdir)/common/m4/gst-feature.m4 \
+ $(top_srcdir)/common/m4/gst-gettext.m4 \
+ $(top_srcdir)/common/m4/gst-glib2.m4 \
+ $(top_srcdir)/common/m4/gst-package-release-datetime.m4 \
+ $(top_srcdir)/common/m4/gst-platform.m4 \
+ $(top_srcdir)/common/m4/gst-plugin-docs.m4 \
+ $(top_srcdir)/common/m4/gst-plugindir.m4 \
+ $(top_srcdir)/common/m4/gst-x11.m4 \
+ $(top_srcdir)/common/m4/gst.m4 \
+ $(top_srcdir)/common/m4/gtk-doc.m4 \
+ $(top_srcdir)/common/m4/orc.m4 $(top_srcdir)/common/m4/pkg.m4 \
+ $(top_srcdir)/m4/aalib.m4 $(top_srcdir)/m4/esd.m4 \
+ $(top_srcdir)/m4/gconf-2.m4 $(top_srcdir)/m4/gettext.m4 \
+ $(top_srcdir)/m4/gst-fionread.m4 \
+ $(top_srcdir)/m4/gst-shout2.m4 $(top_srcdir)/m4/iconv.m4 \
+ $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \
+ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(plugindir)"
+LTLIBRARIES = $(plugin_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libgstannodex_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+am_libgstannodex_la_OBJECTS = libgstannodex_la-gstannodex.lo \
+ libgstannodex_la-gstcmmlutils.lo \
+ libgstannodex_la-gstcmmldec.lo libgstannodex_la-gstcmmlenc.lo \
+ libgstannodex_la-gstcmmltag.lo \
+ libgstannodex_la-gstcmmlparser.lo
+libgstannodex_la_OBJECTS = $(am_libgstannodex_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+libgstannodex_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
+ $(libgstannodex_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
+ $(CCLD) $(libgstannodex_la_CFLAGS) $(CFLAGS) \
+ $(libgstannodex_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+SOURCES = $(libgstannodex_la_SOURCES)
+DIST_SOURCES = $(libgstannodex_la_SOURCES)
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+AALIB_CFLAGS = @AALIB_CFLAGS@
+AALIB_CONFIG = @AALIB_CONFIG@
+AALIB_LIBS = @AALIB_LIBS@
+ACLOCAL = @ACLOCAL@
+ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+ANNODEX_CFLAGS = @ANNODEX_CFLAGS@
+ANNODEX_LIBS = @ANNODEX_LIBS@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BZ2_LIBS = @BZ2_LIBS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_GOBJECT_CFLAGS = @CAIRO_GOBJECT_CFLAGS@
+CAIRO_GOBJECT_LIBS = @CAIRO_GOBJECT_LIBS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFAULT_AUDIOSINK = @DEFAULT_AUDIOSINK@
+DEFAULT_AUDIOSRC = @DEFAULT_AUDIOSRC@
+DEFAULT_VIDEOSINK = @DEFAULT_VIDEOSINK@
+DEFAULT_VIDEOSRC = @DEFAULT_VIDEOSRC@
+DEFAULT_VISUALIZER = @DEFAULT_VISUALIZER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DEPRECATED_CFLAGS = @DEPRECATED_CFLAGS@
+DIRECTSOUND_CFLAGS = @DIRECTSOUND_CFLAGS@
+DIRECTSOUND_LDFLAGS = @DIRECTSOUND_LDFLAGS@
+DIRECTSOUND_LIBS = @DIRECTSOUND_LIBS@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+DV1394_CFLAGS = @DV1394_CFLAGS@
+DV1394_LIBS = @DV1394_LIBS@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+ERROR_CXXFLAGS = @ERROR_CXXFLAGS@
+ESD_CFLAGS = @ESD_CFLAGS@
+ESD_CONFIG = @ESD_CONFIG@
+ESD_LIBS = @ESD_LIBS@
+EXEEXT = @EXEEXT@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLAC_CFLAGS = @FLAC_CFLAGS@
+FLAC_LIBS = @FLAC_LIBS@
+GCONFTOOL = @GCONFTOOL@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GCONF_SCHEMA_CONFIG_SOURCE = @GCONF_SCHEMA_CONFIG_SOURCE@
+GCONF_SCHEMA_FILE_DIR = @GCONF_SCHEMA_FILE_DIR@
+GCOV = @GCOV@
+GCOV_CFLAGS = @GCOV_CFLAGS@
+GCOV_LIBS = @GCOV_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_PREFIX = @GLIB_PREFIX@
+GLIB_REQ = @GLIB_REQ@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+GSTPB_PLUGINS_DIR = @GSTPB_PLUGINS_DIR@
+GSTPB_PREFIX = @GSTPB_PREFIX@
+GST_ALL_LDFLAGS = @GST_ALL_LDFLAGS@
+GST_BASE_CFLAGS = @GST_BASE_CFLAGS@
+GST_BASE_LIBS = @GST_BASE_LIBS@
+GST_CFLAGS = @GST_CFLAGS@
+GST_CHECK_CFLAGS = @GST_CHECK_CFLAGS@
+GST_CHECK_LIBS = @GST_CHECK_LIBS@
+GST_CONTROLLER_CFLAGS = @GST_CONTROLLER_CFLAGS@
+GST_CONTROLLER_LIBS = @GST_CONTROLLER_LIBS@
+GST_CXXFLAGS = @GST_CXXFLAGS@
+GST_GDP_CFLAGS = @GST_GDP_CFLAGS@
+GST_GDP_LIBS = @GST_GDP_LIBS@
+GST_LEVEL_DEFAULT = @GST_LEVEL_DEFAULT@
+GST_LIBS = @GST_LIBS@
+GST_LICENSE = @GST_LICENSE@
+GST_LT_LDFLAGS = @GST_LT_LDFLAGS@
+GST_MAJORMINOR = @GST_MAJORMINOR@
+GST_OPTION_CFLAGS = @GST_OPTION_CFLAGS@
+GST_OPTION_CXXFLAGS = @GST_OPTION_CXXFLAGS@
+GST_PACKAGE_NAME = @GST_PACKAGE_NAME@
+GST_PACKAGE_ORIGIN = @GST_PACKAGE_ORIGIN@
+GST_PLUGINS_ALL = @GST_PLUGINS_ALL@
+GST_PLUGINS_BASE_CFLAGS = @GST_PLUGINS_BASE_CFLAGS@
+GST_PLUGINS_BASE_DIR = @GST_PLUGINS_BASE_DIR@
+GST_PLUGINS_BASE_LIBS = @GST_PLUGINS_BASE_LIBS@
+GST_PLUGINS_DIR = @GST_PLUGINS_DIR@
+GST_PLUGINS_SELECTED = @GST_PLUGINS_SELECTED@
+GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@
+GST_PREFIX = @GST_PREFIX@
+GST_TOOLS_DIR = @GST_TOOLS_DIR@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+GTK_CFLAGS = @GTK_CFLAGS@
+GTK_LIBS = @GTK_LIBS@
+GTK_X11_CFLAGS = @GTK_X11_CFLAGS@
+GTK_X11_LIBS = @GTK_X11_LIBS@
+GUDEV_CFLAGS = @GUDEV_CFLAGS@
+GUDEV_LIBS = @GUDEV_LIBS@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+HAVE_AVC1394 = @HAVE_AVC1394@
+HAVE_BZ2 = @HAVE_BZ2@
+HAVE_CXX = @HAVE_CXX@
+HAVE_DIRECTSOUND = @HAVE_DIRECTSOUND@
+HAVE_GCONFTOOL = @HAVE_GCONFTOOL@
+HAVE_ROM1394 = @HAVE_ROM1394@
+HAVE_SPEEX = @HAVE_SPEEX@
+HAVE_X = @HAVE_X@
+HAVE_XSHM = @HAVE_XSHM@
+HAVE_ZLIB = @HAVE_ZLIB@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+JACK_0_120_1_CFLAGS = @JACK_0_120_1_CFLAGS@
+JACK_0_120_1_LIBS = @JACK_0_120_1_LIBS@
+JACK_1_9_7_CFLAGS = @JACK_1_9_7_CFLAGS@
+JACK_1_9_7_LIBS = @JACK_1_9_7_LIBS@
+JACK_CFLAGS = @JACK_CFLAGS@
+JACK_LIBS = @JACK_LIBS@
+JPEG_LIBS = @JPEG_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBCACA_CFLAGS = @LIBCACA_CFLAGS@
+LIBCACA_CONFIG = @LIBCACA_CONFIG@
+LIBCACA_LIBS = @LIBCACA_LIBS@
+LIBDV_CFLAGS = @LIBDV_CFLAGS@
+LIBDV_LIBS = @LIBDV_LIBS@
+LIBICONV = @LIBICONV@
+LIBIEC61883_CFLAGS = @LIBIEC61883_CFLAGS@
+LIBIEC61883_LIBS = @LIBIEC61883_LIBS@
+LIBINTL = @LIBINTL@
+LIBM = @LIBM@
+LIBOBJS = @LIBOBJS@
+LIBPNG_CFLAGS = @LIBPNG_CFLAGS@
+LIBPNG_LIBS = @LIBPNG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBV4L2_CFLAGS = @LIBV4L2_CFLAGS@
+LIBV4L2_LIBS = @LIBV4L2_LIBS@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJC_LDFLAGS = @OBJC_LDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ORCC = @ORCC@
+ORCC_FLAGS = @ORCC_FLAGS@
+ORC_CFLAGS = @ORC_CFLAGS@
+ORC_LIBS = @ORC_LIBS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
+PACKAGE_VERSION_MICRO = @PACKAGE_VERSION_MICRO@
+PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
+PACKAGE_VERSION_NANO = @PACKAGE_VERSION_NANO@
+PACKAGE_VERSION_RELEASE = @PACKAGE_VERSION_RELEASE@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGINDIR = @PLUGINDIR@
+POSUB = @POSUB@
+PROFILE_CFLAGS = @PROFILE_CFLAGS@
+PULSE_0_9_11_CFLAGS = @PULSE_0_9_11_CFLAGS@
+PULSE_0_9_11_LIBS = @PULSE_0_9_11_LIBS@
+PULSE_0_9_12_CFLAGS = @PULSE_0_9_12_CFLAGS@
+PULSE_0_9_12_LIBS = @PULSE_0_9_12_LIBS@
+PULSE_0_9_13_CFLAGS = @PULSE_0_9_13_CFLAGS@
+PULSE_0_9_13_LIBS = @PULSE_0_9_13_LIBS@
+PULSE_0_9_15_CFLAGS = @PULSE_0_9_15_CFLAGS@
+PULSE_0_9_15_LIBS = @PULSE_0_9_15_LIBS@
+PULSE_0_9_16_CFLAGS = @PULSE_0_9_16_CFLAGS@
+PULSE_0_9_16_LIBS = @PULSE_0_9_16_LIBS@
+PULSE_0_9_20_CFLAGS = @PULSE_0_9_20_CFLAGS@
+PULSE_0_9_20_LIBS = @PULSE_0_9_20_LIBS@
+PULSE_CFLAGS = @PULSE_CFLAGS@
+PULSE_LIBS = @PULSE_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+RAW1394_CFLAGS = @RAW1394_CFLAGS@
+RAW1394_LIBS = @RAW1394_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHOUT2_CFLAGS = @SHOUT2_CFLAGS@
+SHOUT2_LIBS = @SHOUT2_LIBS@
+SOUP_CFLAGS = @SOUP_CFLAGS@
+SOUP_LIBS = @SOUP_LIBS@
+SPEEX_CFLAGS = @SPEEX_CFLAGS@
+SPEEX_LIBS = @SPEEX_LIBS@
+STRIP = @STRIP@
+TAGLIB_CFLAGS = @TAGLIB_CFLAGS@
+TAGLIB_CXXFLAGS = @TAGLIB_CXXFLAGS@
+TAGLIB_LIBS = @TAGLIB_LIBS@
+USE_NLS = @USE_NLS@
+VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
+VALGRIND_LIBS = @VALGRIND_LIBS@
+VALGRIND_PATH = @VALGRIND_PATH@
+VERSION = @VERSION@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+WARNING_CXXFLAGS = @WARNING_CXXFLAGS@
+WAVPACK_CFLAGS = @WAVPACK_CFLAGS@
+WAVPACK_LIBS = @WAVPACK_LIBS@
+WIN32_LIBS = @WIN32_LIBS@
+XDAMAGE_CFLAGS = @XDAMAGE_CFLAGS@
+XDAMAGE_LIBS = @XDAMAGE_LIBS@
+XFIXES_CFLAGS = @XFIXES_CFLAGS@
+XFIXES_LIBS = @XFIXES_LIBS@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+XMKMF = @XMKMF@
+XSHM_LIBS = @XSHM_LIBS@
+XVIDEO_LIBS = @XVIDEO_LIBS@
+X_CFLAGS = @X_CFLAGS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_LIBS = @X_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+ZLIB_LIBS = @ZLIB_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_OBJC = @ac_ct_OBJC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+plugindir = @plugindir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+plugin_LTLIBRARIES = libgstannodex.la
+libgstannodex_la_SOURCES = \
+ gstannodex.c \
+ gstcmmlutils.c \
+ gstcmmldec.c \
+ gstcmmlenc.c \
+ gstcmmltag.c \
+ gstcmmlparser.c
+
+libgstannodex_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) \
+ $(GST_CFLAGS) $(ANNODEX_CFLAGS)
+
+libgstannodex_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) \
+ $(GST_LIBS) $(ANNODEX_LIBS) $(LIBM)
+
+libgstannodex_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstannodex_la_LIBTOOLFLAGS = --tag=disable-static
+noinst_HEADERS = gstannodex.h gstcmmlutils.h gstcmmltag.h gstcmmlparser.h \
+ gstcmmldec.h gstcmmlenc.h
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ext/annodex/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu ext/annodex/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(plugindir)" || $(MKDIR_P) "$(DESTDIR)$(plugindir)"
+ @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \
+ }
+
+uninstall-pluginLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \
+ done
+
+clean-pluginLTLIBRARIES:
+ -test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES)
+ @list='$(plugin_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libgstannodex.la: $(libgstannodex_la_OBJECTS) $(libgstannodex_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(libgstannodex_la_LINK) -rpath $(plugindir) $(libgstannodex_la_OBJECTS) $(libgstannodex_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstannodex_la-gstannodex.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstannodex_la-gstcmmldec.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstannodex_la-gstcmmlenc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstannodex_la-gstcmmlparser.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstannodex_la-gstcmmltag.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstannodex_la-gstcmmlutils.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+libgstannodex_la-gstannodex.lo: gstannodex.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstannodex_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstannodex_la_CFLAGS) $(CFLAGS) -MT libgstannodex_la-gstannodex.lo -MD -MP -MF $(DEPDIR)/libgstannodex_la-gstannodex.Tpo -c -o libgstannodex_la-gstannodex.lo `test -f 'gstannodex.c' || echo '$(srcdir)/'`gstannodex.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstannodex_la-gstannodex.Tpo $(DEPDIR)/libgstannodex_la-gstannodex.Plo
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gstannodex.c' object='libgstannodex_la-gstannodex.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstannodex_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstannodex_la_CFLAGS) $(CFLAGS) -c -o libgstannodex_la-gstannodex.lo `test -f 'gstannodex.c' || echo '$(srcdir)/'`gstannodex.c
+
+libgstannodex_la-gstcmmlutils.lo: gstcmmlutils.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstannodex_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstannodex_la_CFLAGS) $(CFLAGS) -MT libgstannodex_la-gstcmmlutils.lo -MD -MP -MF $(DEPDIR)/libgstannodex_la-gstcmmlutils.Tpo -c -o libgstannodex_la-gstcmmlutils.lo `test -f 'gstcmmlutils.c' || echo '$(srcdir)/'`gstcmmlutils.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstannodex_la-gstcmmlutils.Tpo $(DEPDIR)/libgstannodex_la-gstcmmlutils.Plo
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gstcmmlutils.c' object='libgstannodex_la-gstcmmlutils.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstannodex_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstannodex_la_CFLAGS) $(CFLAGS) -c -o libgstannodex_la-gstcmmlutils.lo `test -f 'gstcmmlutils.c' || echo '$(srcdir)/'`gstcmmlutils.c
+
+libgstannodex_la-gstcmmldec.lo: gstcmmldec.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstannodex_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstannodex_la_CFLAGS) $(CFLAGS) -MT libgstannodex_la-gstcmmldec.lo -MD -MP -MF $(DEPDIR)/libgstannodex_la-gstcmmldec.Tpo -c -o libgstannodex_la-gstcmmldec.lo `test -f 'gstcmmldec.c' || echo '$(srcdir)/'`gstcmmldec.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstannodex_la-gstcmmldec.Tpo $(DEPDIR)/libgstannodex_la-gstcmmldec.Plo
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gstcmmldec.c' object='libgstannodex_la-gstcmmldec.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstannodex_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstannodex_la_CFLAGS) $(CFLAGS) -c -o libgstannodex_la-gstcmmldec.lo `test -f 'gstcmmldec.c' || echo '$(srcdir)/'`gstcmmldec.c
+
+libgstannodex_la-gstcmmlenc.lo: gstcmmlenc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstannodex_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstannodex_la_CFLAGS) $(CFLAGS) -MT libgstannodex_la-gstcmmlenc.lo -MD -MP -MF $(DEPDIR)/libgstannodex_la-gstcmmlenc.Tpo -c -o libgstannodex_la-gstcmmlenc.lo `test -f 'gstcmmlenc.c' || echo '$(srcdir)/'`gstcmmlenc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstannodex_la-gstcmmlenc.Tpo $(DEPDIR)/libgstannodex_la-gstcmmlenc.Plo
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gstcmmlenc.c' object='libgstannodex_la-gstcmmlenc.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstannodex_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstannodex_la_CFLAGS) $(CFLAGS) -c -o libgstannodex_la-gstcmmlenc.lo `test -f 'gstcmmlenc.c' || echo '$(srcdir)/'`gstcmmlenc.c
+
+libgstannodex_la-gstcmmltag.lo: gstcmmltag.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstannodex_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstannodex_la_CFLAGS) $(CFLAGS) -MT libgstannodex_la-gstcmmltag.lo -MD -MP -MF $(DEPDIR)/libgstannodex_la-gstcmmltag.Tpo -c -o libgstannodex_la-gstcmmltag.lo `test -f 'gstcmmltag.c' || echo '$(srcdir)/'`gstcmmltag.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstannodex_la-gstcmmltag.Tpo $(DEPDIR)/libgstannodex_la-gstcmmltag.Plo
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gstcmmltag.c' object='libgstannodex_la-gstcmmltag.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstannodex_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstannodex_la_CFLAGS) $(CFLAGS) -c -o libgstannodex_la-gstcmmltag.lo `test -f 'gstcmmltag.c' || echo '$(srcdir)/'`gstcmmltag.c
+
+libgstannodex_la-gstcmmlparser.lo: gstcmmlparser.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstannodex_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstannodex_la_CFLAGS) $(CFLAGS) -MT libgstannodex_la-gstcmmlparser.lo -MD -MP -MF $(DEPDIR)/libgstannodex_la-gstcmmlparser.Tpo -c -o libgstannodex_la-gstcmmlparser.lo `test -f 'gstcmmlparser.c' || echo '$(srcdir)/'`gstcmmlparser.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstannodex_la-gstcmmlparser.Tpo $(DEPDIR)/libgstannodex_la-gstcmmlparser.Plo
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gstcmmlparser.c' object='libgstannodex_la-gstcmmlparser.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstannodex_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstannodex_la_CFLAGS) $(CFLAGS) -c -o libgstannodex_la-gstcmmlparser.lo `test -f 'gstcmmlparser.c' || echo '$(srcdir)/'`gstcmmlparser.c
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(plugindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pluginLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pluginLTLIBRARIES
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pluginLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-pluginLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-pluginLTLIBRARIES \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-pluginLTLIBRARIES
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/ext/annodex/gstannodex.c b/ext/annodex/gstannodex.c
new file mode 100644
index 0000000..05e10c8
--- /dev/null
+++ b/ext/annodex/gstannodex.c
@@ -0,0 +1,167 @@
+/*
+ * gstannodex.c - GStreamer annodex plugin
+ * Copyright (C) 2005 Alessandro Decina
+ *
+ * Authors:
+ * Alessandro Decina <alessandro@nnva.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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 <math.h>
+#include <gst/tag/tag.h>
+#include "gstannodex.h"
+#include "gstcmmlparser.h"
+#include "gstcmmlenc.h"
+#include "gstcmmldec.h"
+
+GstClockTime
+gst_annodex_granule_to_time (gint64 granulepos, gint64 granulerate_n,
+ gint64 granulerate_d, guint8 granuleshift)
+{
+ gint64 keyindex, keyoffset;
+ gint64 granulerate;
+ GstClockTime res;
+
+ g_return_val_if_fail (granuleshift <= 64, GST_CLOCK_TIME_NONE);
+
+ if (granulepos == -1)
+ return GST_CLOCK_TIME_NONE;
+
+ if (granulepos == 0 || granulerate_n == 0 || granulerate_d == 0)
+ return 0;
+
+ if (granuleshift != 0 && granuleshift != 64) {
+ keyindex = granulepos >> granuleshift;
+ keyoffset = granulepos - (keyindex << granuleshift);
+ granulepos = keyindex + keyoffset;
+ }
+
+ /* GST_SECOND / (granulerate_n / granulerate_d) */
+ granulerate = gst_util_uint64_scale (GST_SECOND,
+ granulerate_d, granulerate_n);
+
+ /* granulepos * granulerate */
+ res = gst_util_uint64_scale (granulepos, granulerate, 1);
+
+ return res;
+}
+
+GValueArray *
+gst_annodex_parse_headers (const gchar * headers)
+{
+ GValueArray *array;
+ GValue val = { 0 };
+ gchar *header_name = NULL;
+ gchar *header_value = NULL;
+ gchar *line, *column, *space, *tmp;
+ gchar **lines;
+ gint i = 0;
+
+ array = g_value_array_new (0);
+ g_value_init (&val, G_TYPE_STRING);
+
+ lines = g_strsplit (headers, "\r\n", 0);
+ line = lines[i];
+ while (line != NULL && *line != '\0') {
+ if (line[0] == '\t' || line[0] == ' ') {
+ /* WSP: continuation line */
+ if (header_value == NULL)
+ /* continuation line without a previous value */
+ goto fail;
+
+ tmp = g_strjoin (" ", header_value, g_strstrip (line), NULL);
+ g_free (header_value);
+ header_value = tmp;
+ } else {
+ if (header_name) {
+ g_value_take_string (&val, header_name);
+ g_value_array_append (array, &val);
+ g_value_take_string (&val, header_value);
+ g_value_array_append (array, &val);
+ }
+ /* search the column starting from line[1] as an header name can't be
+ * empty */
+ column = g_strstr_len (line + 1, strlen (line) - 1, ":");
+ if (column == NULL)
+ /* bad syntax */
+ goto fail;
+
+ if (*(space = column + 1) != ' ')
+ /* bad syntax */
+ goto fail;
+
+ header_name = g_strndup (line, column - line);
+ header_value = g_strdup (space + 1);
+ }
+
+ line = lines[++i];
+ }
+
+ if (header_name) {
+ g_value_take_string (&val, header_name);
+ g_value_array_append (array, &val);
+ g_value_take_string (&val, header_value);
+ g_value_array_append (array, &val);
+ }
+
+ g_value_unset (&val);
+ g_strfreev (lines);
+
+ return array;
+
+fail:
+ GST_WARNING ("could not parse annodex headers");
+ g_free (header_name);
+ g_free (header_value);
+ g_strfreev (lines);
+ g_value_array_free (array);
+ g_value_unset (&val);
+ return NULL;
+}
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+ gst_tag_register (GST_TAG_CMML_STREAM, GST_TAG_FLAG_META,
+ GST_TYPE_CMML_TAG_STREAM, "cmml-stream", "annodex CMML stream tag", NULL);
+
+ gst_tag_register (GST_TAG_CMML_HEAD, GST_TAG_FLAG_META,
+ GST_TYPE_CMML_TAG_HEAD, "cmml-head", "annodex CMML head tag", NULL);
+
+ gst_tag_register (GST_TAG_CMML_CLIP, GST_TAG_FLAG_META,
+ GST_TYPE_CMML_TAG_CLIP, "cmml-clip", "annodex CMML clip tag", NULL);
+
+ gst_cmml_parser_init ();
+
+ if (!gst_cmml_enc_plugin_init (plugin))
+ return FALSE;
+
+ if (!gst_cmml_dec_plugin_init (plugin))
+ return FALSE;
+
+ return TRUE;
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "annodex",
+ "annodex stream manipulation (info about annodex: http://www.annodex.net)",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff --git a/ext/annodex/gstannodex.h b/ext/annodex/gstannodex.h
new file mode 100644
index 0000000..ca35e36
--- /dev/null
+++ b/ext/annodex/gstannodex.h
@@ -0,0 +1,34 @@
+/*
+ * gstannodex.h - GStreamer annodex utility functions
+ * Copyright (C) 2005 Alessandro Decina
+ *
+ * Authors:
+ * Alessandro Decina <alessandro@nnva.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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.
+ */
+
+#ifndef __GST_ANNODEX_H__
+#define __GST_ANNODEX_H__
+
+#include <gst/gst.h>
+
+GstClockTime gst_annodex_granule_to_time (gint64 granulepos,
+ gint64 granulerate_n, gint64 granulerate_d, guint8 granuleshift);
+gchar *gst_annodex_time_to_npt (GstClockTime time);
+GValueArray *gst_annodex_parse_headers (const gchar * headers);
+
+#endif /* __GST_ANNODEX_H__ */
diff --git a/ext/annodex/gstcmmldec.c b/ext/annodex/gstcmmldec.c
new file mode 100644
index 0000000..79b267a
--- /dev/null
+++ b/ext/annodex/gstcmmldec.c
@@ -0,0 +1,708 @@
+/*
+ * gstcmmldec.c - GStreamer annodex CMML decoder
+ * Copyright (C) 2005 Alessandro Decina
+ *
+ * Authors:
+ * Alessandro Decina <alessandro@nnva.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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.
+ */
+
+/**
+ * SECTION:element-cmmldec
+ * @see_also: cmmlenc, oggdemux
+ *
+ * Cmmldec extracts a CMML document from a CMML bitstream.<ulink
+ * url="http://www.annodex.net/TR/draft-pfeiffer-cmml-02.html">CMML</ulink> is
+ * an XML markup language for time-continuous data maintained by the <ulink
+ * url="http:/www.annodex.org/">Annodex Foundation</ulink>.
+ *
+ * <refsect2>
+ * <title>Example pipeline</title>
+ * |[
+ * gst-launch -v filesrc location=annotated.ogg ! oggdemux ! cmmldec ! filesink location=annotations.cmml
+ * ]|
+ * </refsect2>
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include <glib.h>
+
+#include <gst/tag/tag.h>
+#include "gstannodex.h"
+#include "gstcmmltag.h"
+#include "gstcmmldec.h"
+#include "gstcmmlutils.h"
+
+GST_DEBUG_CATEGORY_STATIC (cmmldec);
+#define GST_CAT_DEFAULT cmmldec
+
+#define CMML_IDENT_HEADER_SIZE 29
+
+enum
+{
+ ARG_0,
+ GST_CMML_DEC_WAIT_CLIP_END
+};
+
+enum
+{
+ LAST_SIGNAL
+};
+
+static GstStaticPadTemplate gst_cmml_dec_src_factory =
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("text/x-cmml, encoded = (boolean) false")
+ );
+
+static GstStaticPadTemplate gst_cmml_dec_sink_factory =
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("text/x-cmml, encoded = (boolean) true")
+ );
+
+/* GstCmmlDec */
+GST_BOILERPLATE (GstCmmlDec, gst_cmml_dec, GstElement, GST_TYPE_ELEMENT);
+static void gst_cmml_dec_get_property (GObject * dec, guint property_id,
+ GValue * value, GParamSpec * pspec);
+static void gst_cmml_dec_set_property (GObject * dec, guint property_id,
+ const GValue * value, GParamSpec * pspec);
+static const GstQueryType *gst_cmml_dec_query_types (GstPad * pad);
+static gboolean gst_cmml_dec_sink_query (GstPad * pad, GstQuery * query);
+static gboolean gst_cmml_dec_sink_event (GstPad * pad, GstEvent * event);
+static gboolean gst_cmml_dec_convert (GstPad * pad, GstFormat src_fmt,
+ gint64 src_val, GstFormat * dest_fmt, gint64 * dest_val);
+static GstStateChangeReturn gst_cmml_dec_change_state (GstElement * element,
+ GstStateChange transition);
+static GstFlowReturn gst_cmml_dec_chain (GstPad * pad, GstBuffer * buffer);
+
+static GstCmmlPacketType gst_cmml_dec_parse_packet_type (GstCmmlDec * dec,
+ GstBuffer * buffer);
+static void gst_cmml_dec_parse_ident_header (GstCmmlDec * dec, GstBuffer * buf);
+static void gst_cmml_dec_parse_first_header (GstCmmlDec * dec, GstBuffer * buf);
+static void gst_cmml_dec_parse_preamble (GstCmmlDec * dec,
+ guchar * preamble, guchar * cmml_root_element);
+static void gst_cmml_dec_parse_xml (GstCmmlDec * dec,
+ guchar * data, guint size);
+static void gst_cmml_dec_parse_head (GstCmmlDec * dec, GstCmmlTagHead * head);
+static void gst_cmml_dec_parse_clip (GstCmmlDec * dec, GstCmmlTagClip * clip);
+
+static GstFlowReturn gst_cmml_dec_new_buffer (GstCmmlDec * dec,
+ guchar * data, gint size, GstBuffer ** buffer);
+static void gst_cmml_dec_push_clip (GstCmmlDec * dec, GstCmmlTagClip * clip);
+static void gst_cmml_dec_send_clip_tag (GstCmmlDec * dec,
+ GstCmmlTagClip * clip);
+
+static void gst_cmml_dec_finalize (GObject * object);
+
+static void
+gst_cmml_dec_base_init (gpointer g_class)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_cmml_dec_sink_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_cmml_dec_src_factory));
+ gst_element_class_set_details_simple (element_class, "CMML stream decoder",
+ "Codec/Decoder",
+ "Decodes CMML streams", "Alessandro Decina <alessandro@nnva.org>");
+}
+
+static void
+gst_cmml_dec_class_init (GstCmmlDecClass * dec_class)
+{
+ GObjectClass *klass = G_OBJECT_CLASS (dec_class);
+
+ GST_ELEMENT_CLASS (klass)->change_state = gst_cmml_dec_change_state;
+
+ klass->set_property = gst_cmml_dec_set_property;
+ klass->get_property = gst_cmml_dec_get_property;
+ klass->finalize = gst_cmml_dec_finalize;
+
+ g_object_class_install_property (klass, GST_CMML_DEC_WAIT_CLIP_END,
+ g_param_spec_boolean ("wait-clip-end-time",
+ "Wait clip end time",
+ "Send a tag for a clip when the clip ends, setting its end-time. "
+ "Use when you need to know both clip's start-time and end-time.",
+ FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+}
+
+static void
+gst_cmml_dec_init (GstCmmlDec * dec, GstCmmlDecClass * klass)
+{
+ dec->sinkpad =
+ gst_pad_new_from_static_template (&gst_cmml_dec_sink_factory, "sink");
+ gst_pad_set_chain_function (dec->sinkpad, gst_cmml_dec_chain);
+ gst_pad_set_query_type_function (dec->sinkpad, gst_cmml_dec_query_types);
+ gst_pad_set_query_function (dec->sinkpad, gst_cmml_dec_sink_query);
+ gst_pad_set_event_function (dec->sinkpad, gst_cmml_dec_sink_event);
+ gst_element_add_pad (GST_ELEMENT (dec), dec->sinkpad);
+
+ dec->srcpad =
+ gst_pad_new_from_static_template (&gst_cmml_dec_src_factory, "src");
+ gst_element_add_pad (GST_ELEMENT (dec), dec->srcpad);
+
+ dec->wait_clip_end = FALSE;
+}
+
+static void
+gst_cmml_dec_get_property (GObject * object, guint property_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GstCmmlDec *dec = GST_CMML_DEC (object);
+
+ switch (property_id) {
+ case GST_CMML_DEC_WAIT_CLIP_END:
+ g_value_set_boolean (value, dec->wait_clip_end);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+gst_cmml_dec_set_property (GObject * object, guint property_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstCmmlDec *dec = GST_CMML_DEC (object);
+
+ switch (property_id) {
+ case GST_CMML_DEC_WAIT_CLIP_END:
+ dec->wait_clip_end = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (dec, property_id, pspec);
+ }
+}
+
+static void
+gst_cmml_dec_finalize (GObject * object)
+{
+ GstCmmlDec *dec = GST_CMML_DEC (object);
+
+ if (dec->tracks) {
+ gst_cmml_track_list_destroy (dec->tracks);
+ dec->tracks = NULL;
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static GstStateChangeReturn
+gst_cmml_dec_change_state (GstElement * element, GstStateChange transition)
+{
+ GstCmmlDec *dec = GST_CMML_DEC (element);
+ GstStateChangeReturn res;
+
+ switch (transition) {
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
+ dec->parser = gst_cmml_parser_new (GST_CMML_PARSER_DECODE);
+ dec->parser->user_data = dec;
+ dec->parser->preamble_callback =
+ (GstCmmlParserPreambleCallback) gst_cmml_dec_parse_preamble;
+ dec->parser->head_callback =
+ (GstCmmlParserHeadCallback) gst_cmml_dec_parse_head;
+ dec->parser->clip_callback =
+ (GstCmmlParserClipCallback) gst_cmml_dec_parse_clip;
+ dec->major = -1;
+ dec->minor = -1;
+ dec->granulerate_n = -1;
+ dec->granulerate_d = -1;
+ dec->granuleshift = 0;
+ dec->granulepos = 0;
+ dec->flow_return = GST_FLOW_OK;
+ dec->sent_root = FALSE;
+ dec->tracks = gst_cmml_track_list_new ();
+ break;
+ default:
+ break;
+ }
+
+ res = parent_class->change_state (element, transition);
+
+ switch (transition) {
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
+ gst_cmml_parser_free (dec->parser);
+ gst_cmml_track_list_destroy (dec->tracks);
+ dec->tracks = NULL;
+ break;
+ default:
+ break;
+ }
+
+ return res;
+}
+
+static const GstQueryType *
+gst_cmml_dec_query_types (GstPad * pad)
+{
+ static const GstQueryType query_types[] = {
+ GST_QUERY_CONVERT,
+ 0
+ };
+
+ return query_types;
+}
+
+static gboolean
+gst_cmml_dec_sink_query (GstPad * pad, GstQuery * query)
+{
+ gboolean res = FALSE;
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_CONVERT:
+ {
+ GstFormat src_fmt, dest_fmt;
+ gint64 src_val, dest_val;
+
+ gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
+ res = gst_cmml_dec_convert (pad, src_fmt, src_val, &dest_fmt, &dest_val);
+ if (res)
+ gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
+ break;
+ }
+ default:
+ break;
+ }
+
+ return res;
+}
+
+static gboolean
+gst_cmml_dec_convert (GstPad * pad,
+ GstFormat src_fmt, gint64 src_val, GstFormat * dest_fmt, gint64 * dest_val)
+{
+ GstCmmlDec *dec = GST_CMML_DEC (GST_PAD_PARENT (pad));
+ gboolean res = FALSE;
+
+ switch (src_fmt) {
+ case GST_FORMAT_DEFAULT:
+ switch (*dest_fmt) {
+ case GST_FORMAT_TIME:
+ {
+ *dest_val = gst_annodex_granule_to_time (src_val, dec->granulerate_n,
+ dec->granulerate_d, dec->granuleshift);
+ res = TRUE;
+ break;
+ }
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return res;
+}
+
+static gboolean
+gst_cmml_dec_sink_event (GstPad * pad, GstEvent * event)
+{
+ GstCmmlDec *dec = GST_CMML_DEC (GST_PAD_PARENT (pad));
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_EOS:
+ {
+ GstBuffer *buffer;
+ GstCmmlTagClip *clip;
+ GList *clips, *walk;
+
+ GST_INFO_OBJECT (dec, "got EOS, flushing clips");
+
+ /* since we output a clip when the next one in the same track is found, on
+ * EOS we need to output the last clip (if any) of every track
+ */
+ clips = gst_cmml_track_list_get_clips (dec->tracks);
+ for (walk = clips; walk; walk = g_list_next (walk)) {
+ clip = GST_CMML_TAG_CLIP (walk->data);
+ gst_cmml_dec_push_clip (dec, clip);
+ if (dec->wait_clip_end) {
+ clip->end_time = dec->timestamp;
+ gst_cmml_dec_send_clip_tag (dec, clip);
+ }
+ }
+ g_list_free (clips);
+
+ /* send the cmml end tag */
+ dec->flow_return = gst_cmml_dec_new_buffer (dec,
+ (guchar *) "</cmml>", strlen ("</cmml>"), &buffer);
+
+ if (dec->flow_return == GST_FLOW_OK)
+ dec->flow_return = gst_pad_push (dec->srcpad, buffer);
+ if (dec->flow_return == GST_FLOW_NOT_LINKED)
+ dec->flow_return = GST_FLOW_OK; /* Ignore NOT_LINKED */
+
+ break;
+ }
+ default:
+ break;
+ }
+
+ return gst_pad_event_default (pad, event);
+}
+
+static GstFlowReturn
+gst_cmml_dec_chain (GstPad * pad, GstBuffer * buffer)
+{
+ GstCmmlDec *dec = GST_CMML_DEC (GST_PAD_PARENT (pad));
+ GstCmmlPacketType packet;
+
+ if (GST_BUFFER_SIZE (buffer) == 0) {
+ /* the EOS page could be empty */
+ dec->flow_return = GST_FLOW_OK;
+ goto done;
+ }
+
+ dec->granulepos = GST_BUFFER_OFFSET_END (buffer);
+ dec->timestamp = gst_annodex_granule_to_time (dec->granulepos,
+ dec->granulerate_n, dec->granulerate_d, dec->granuleshift);
+
+ /* identify the packet type */
+ packet = gst_cmml_dec_parse_packet_type (dec, buffer);
+
+ /* handle the packet. the handler will set dec->flow_return */
+ switch (packet) {
+ case GST_CMML_PACKET_IDENT_HEADER:
+ if (dec->sent_root == FALSE)
+ /* don't parse the ident again in case of seeking to the beginning */
+ gst_cmml_dec_parse_ident_header (dec, buffer);
+ break;
+ case GST_CMML_PACKET_FIRST_HEADER:
+ if (dec->sent_root == FALSE)
+ /* don't parse the xml preamble if it has already been parsed because it
+ * would error out, so seeking to the beginning would fail */
+ gst_cmml_dec_parse_first_header (dec, buffer);
+ break;
+ case GST_CMML_PACKET_SECOND_HEADER:
+ case GST_CMML_PACKET_CLIP:
+ gst_cmml_dec_parse_xml (dec,
+ GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
+ break;
+ case GST_CMML_PACKET_UNKNOWN:
+ default:
+ GST_ELEMENT_ERROR (dec, STREAM, DECODE, (NULL), ("unknown packet type"));
+ dec->flow_return = GST_FLOW_ERROR;
+ }
+
+done:
+ gst_buffer_unref (buffer);
+ return dec->flow_return;
+}
+
+/* finds the packet type of the buffer
+ */
+static GstCmmlPacketType
+gst_cmml_dec_parse_packet_type (GstCmmlDec * dec, GstBuffer * buffer)
+{
+ GstCmmlPacketType packet_type = GST_CMML_PACKET_UNKNOWN;
+ gchar *data = (gchar *) GST_BUFFER_DATA (buffer);
+ guint size = GST_BUFFER_SIZE (buffer);
+
+ if (size >= 8 && !memcmp (data, "CMML\0\0\0\0", 8)) {
+ packet_type = GST_CMML_PACKET_IDENT_HEADER;
+ } else if (size >= 5) {
+ if (!strncmp (data, "<?xml", 5))
+ packet_type = GST_CMML_PACKET_FIRST_HEADER;
+ else if (!strncmp (data, "<head", 5))
+ packet_type = GST_CMML_PACKET_SECOND_HEADER;
+ else if (!strncmp (data, "<clip", 5))
+ packet_type = GST_CMML_PACKET_CLIP;
+ }
+
+ return packet_type;
+}
+
+/* creates a new buffer and sets caps and timestamp on it
+ */
+static GstFlowReturn
+gst_cmml_dec_new_buffer (GstCmmlDec * dec,
+ guchar * data, gint size, GstBuffer ** buffer)
+{
+ GstFlowReturn res;
+
+ res = gst_pad_alloc_buffer (dec->srcpad, GST_BUFFER_OFFSET_NONE,
+ size, gst_static_pad_template_get_caps (&gst_cmml_dec_src_factory),
+ buffer);
+
+ if (res == GST_FLOW_OK) {
+ if (data)
+ memcpy (GST_BUFFER_DATA (*buffer), data, size);
+ GST_BUFFER_TIMESTAMP (*buffer) = dec->timestamp;
+ } else if (res == GST_FLOW_NOT_LINKED) {
+ GST_DEBUG_OBJECT (dec, "alloc function return NOT-LINKED, ignoring");
+ } else {
+ GST_WARNING_OBJECT (dec, "alloc function returned error %s",
+ gst_flow_get_name (res));
+ }
+
+ return res;
+}
+
+/* parses the first CMML packet (the ident header)
+ */
+static void
+gst_cmml_dec_parse_ident_header (GstCmmlDec * dec, GstBuffer * buffer)
+{
+ guint8 *data = GST_BUFFER_DATA (buffer);
+
+ /* the ident header has a fixed length */
+ if (GST_BUFFER_SIZE (buffer) != CMML_IDENT_HEADER_SIZE) {
+ GST_ELEMENT_ERROR (dec, STREAM, DECODE,
+ (NULL), ("wrong ident header size: %d", GST_BUFFER_SIZE (buffer)));
+ dec->flow_return = GST_FLOW_ERROR;
+
+ return;
+ }
+
+ data += 8;
+ dec->major = GST_READ_UINT16_LE (data);
+ data += 2;
+ dec->minor = GST_READ_UINT16_LE (data);
+ data += 2;
+ dec->granulerate_n = GST_READ_UINT64_LE (data);
+ data += 8;
+ dec->granulerate_d = GST_READ_UINT64_LE (data);
+ data += 8;
+ dec->granuleshift = GST_READ_UINT8 (data);
+
+ GST_INFO_OBJECT (dec, "bitstream initialized "
+ "(major: %" G_GINT16_FORMAT " minor: %" G_GINT16_FORMAT
+ " granulerate_n: %" G_GINT64_FORMAT " granulerate_d: %" G_GINT64_FORMAT
+ " granuleshift: %d)",
+ dec->major, dec->minor,
+ dec->granulerate_n, dec->granulerate_d, dec->granuleshift);
+
+ dec->flow_return = GST_FLOW_OK;
+}
+
+/* parses the first secondary header.
+ * the first secondary header contains the xml version, the doctype and the
+ * optional "cmml" processing instruction.
+ */
+static void
+gst_cmml_dec_parse_first_header (GstCmmlDec * dec, GstBuffer * buffer)
+{
+ gst_cmml_dec_parse_xml (dec,
+ GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
+
+ /* if there is a processing instruction, gst_cmml_dec_parse_preamble
+ * will be triggered. Otherwise we need to call it manually.
+ */
+ if (dec->flow_return == GST_FLOW_OK && !dec->sent_root) {
+ guchar *preamble = (guchar *) g_strndup ((gchar *) GST_BUFFER_DATA (buffer),
+ GST_BUFFER_SIZE (buffer));
+
+ gst_cmml_dec_parse_preamble (dec, preamble, (guchar *) "<cmml>");
+ g_free (preamble);
+ }
+}
+
+/* feeds data into the cmml parser.
+ */
+static void
+gst_cmml_dec_parse_xml (GstCmmlDec * dec, guchar * data, guint size)
+{
+ GError *err = NULL;
+
+ if (!gst_cmml_parser_parse_chunk (dec->parser, (gchar *) data, size, &err)) {
+ GST_ELEMENT_ERROR (dec, STREAM, DECODE, (NULL), ("%s", err->message));
+ g_error_free (err);
+ dec->flow_return = GST_FLOW_ERROR;
+ }
+}
+
+static void
+gst_cmml_dec_parse_preamble (GstCmmlDec * dec, guchar * preamble,
+ guchar * root_element)
+{
+ GstBuffer *buffer;
+ guchar *encoded_preamble;
+
+ encoded_preamble = (guchar *) g_strconcat ((gchar *) preamble,
+ (gchar *) root_element, NULL);
+
+ /* send the root element to the internal parser */
+ gst_cmml_dec_parse_xml (dec, root_element, strlen ((gchar *) root_element));
+ dec->sent_root = TRUE;
+
+ /* push the root element */
+ dec->flow_return = gst_cmml_dec_new_buffer (dec,
+ encoded_preamble, strlen ((gchar *) encoded_preamble), &buffer);
+ if (dec->flow_return == GST_FLOW_OK) {
+ dec->flow_return = gst_pad_push (dec->srcpad, buffer);
+ }
+
+ if (dec->flow_return == GST_FLOW_OK) {
+ GST_INFO_OBJECT (dec, "preamble parsed");
+ }
+
+ g_free (encoded_preamble);
+ return;
+}
+
+/* outputs the cmml head element and send TITLE and CMML_HEAD tags.
+ * This callback is registered with dec->parser. It is called when the
+ * head element is parsed.
+ */
+static void
+gst_cmml_dec_parse_head (GstCmmlDec * dec, GstCmmlTagHead * head)
+{
+ GstTagList *tags;
+ GValue str_val = { 0 }, title_val = {
+ 0};
+ guchar *head_str;
+ GstBuffer *buffer;
+
+ GST_DEBUG_OBJECT (dec, "found CMML head (title: %s base: %s)",
+ head->title, head->base);
+
+ /* create the GST_TAG_TITLE tag */
+ g_value_init (&str_val, G_TYPE_STRING);
+ g_value_init (&title_val, gst_tag_get_type (GST_TAG_TITLE));
+ g_value_set_string (&str_val, (gchar *) head->title);
+ g_value_transform (&str_val, &title_val);
+
+ tags = gst_tag_list_new ();
+ gst_tag_list_add_values (tags, GST_TAG_MERGE_APPEND,
+ GST_TAG_TITLE, &title_val, NULL);
+ gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_CMML_HEAD, head, NULL);
+ gst_element_found_tags_for_pad (GST_ELEMENT (dec), dec->srcpad, tags);
+
+ g_value_unset (&str_val);
+ g_value_unset (&title_val);
+
+ head_str = gst_cmml_parser_tag_head_to_string (dec->parser, head);
+
+ dec->flow_return = gst_cmml_dec_new_buffer (dec,
+ head_str, strlen ((gchar *) head_str), &buffer);
+ g_free (head_str);
+ if (dec->flow_return == GST_FLOW_OK)
+ dec->flow_return = gst_pad_push (dec->srcpad, buffer);
+ if (dec->flow_return == GST_FLOW_NOT_LINKED)
+ dec->flow_return = GST_FLOW_OK; /* Ignore NOT_LINKED */
+}
+
+/* send a TAG_MESSAGE event for a clip */
+static void
+gst_cmml_dec_send_clip_tag (GstCmmlDec * dec, GstCmmlTagClip * clip)
+{
+ GstTagList *tags;
+
+ GST_DEBUG_OBJECT (dec, "sending clip tag %s", clip->id);
+
+ tags = gst_tag_list_new ();
+ gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_CMML_CLIP, clip, NULL);
+ gst_element_found_tags_for_pad (GST_ELEMENT (dec), dec->srcpad, tags);
+}
+
+/* push the string representation of a clip */
+static void
+gst_cmml_dec_push_clip (GstCmmlDec * dec, GstCmmlTagClip * clip)
+{
+ GstBuffer *buffer;
+ guchar *clip_str;
+
+ GST_DEBUG_OBJECT (dec, "pushing clip %s", clip->id);
+
+ clip_str = gst_cmml_parser_tag_clip_to_string (dec->parser, clip);
+ dec->flow_return = gst_cmml_dec_new_buffer (dec,
+ clip_str, strlen ((gchar *) clip_str), &buffer);
+ if (dec->flow_return == GST_FLOW_OK)
+ dec->flow_return = gst_pad_push (dec->srcpad, buffer);
+ if (dec->flow_return == GST_FLOW_NOT_LINKED)
+ dec->flow_return = GST_FLOW_OK; /* Ignore NOT_LINKED */
+
+ g_free (clip_str);
+}
+
+/* decode a clip tag
+ * this callback is registered with dec->parser. It is called whenever a
+ * clip is parsed.
+ */
+static void
+gst_cmml_dec_parse_clip (GstCmmlDec * dec, GstCmmlTagClip * clip)
+{
+ GstCmmlTagClip *prev_clip;
+
+ dec->flow_return = GST_FLOW_OK;
+
+ if (clip->empty)
+ GST_INFO_OBJECT (dec, "parsing empty clip");
+ else
+ GST_INFO_OBJECT (dec, "parsing clip (id: %s)", clip->id);
+
+ clip->start_time = dec->timestamp;
+ if (clip->start_time == GST_CLOCK_TIME_NONE) {
+ GST_ELEMENT_ERROR (dec, STREAM, DECODE,
+ (NULL), ("invalid clip start time"));
+
+ dec->flow_return = GST_FLOW_ERROR;
+ return;
+ }
+
+ /* get the last clip in the current track */
+ prev_clip = gst_cmml_track_list_get_track_last_clip (dec->tracks,
+ (gchar *) clip->track);
+ if (prev_clip) {
+ /* output the previous clip */
+ if (clip->empty)
+ /* the current clip marks the end of the previous one */
+ prev_clip->end_time = clip->start_time;
+
+ gst_cmml_dec_push_clip (dec, prev_clip);
+ }
+
+ if (dec->wait_clip_end) {
+ /* now it's time to send the tag for the previous clip */
+ if (prev_clip) {
+ prev_clip->end_time = clip->start_time;
+ gst_cmml_dec_send_clip_tag (dec, prev_clip);
+ }
+ } else if (!clip->empty) {
+ /* send the tag for the current clip */
+ gst_cmml_dec_send_clip_tag (dec, clip);
+ }
+
+ if (prev_clip)
+ gst_cmml_track_list_del_clip (dec->tracks, prev_clip);
+
+ if (!clip->empty)
+ if (!gst_cmml_track_list_has_clip (dec->tracks, clip))
+ gst_cmml_track_list_add_clip (dec->tracks, clip);
+}
+
+gboolean
+gst_cmml_dec_plugin_init (GstPlugin * plugin)
+{
+ if (!gst_element_register (plugin, "cmmldec", GST_RANK_PRIMARY,
+ GST_TYPE_CMML_DEC))
+ return FALSE;
+
+ GST_DEBUG_CATEGORY_INIT (cmmldec, "cmmldec", 0,
+ "annodex CMML decoding element");
+
+ return TRUE;
+}
diff --git a/ext/annodex/gstcmmldec.h b/ext/annodex/gstcmmldec.h
new file mode 100644
index 0000000..27a6c55
--- /dev/null
+++ b/ext/annodex/gstcmmldec.h
@@ -0,0 +1,98 @@
+/*
+ * gstcmmldec.h - GStreamer annodex CMML decoder
+ * Copyright (C) 2005 Alessandro Decina
+ *
+ * Authors:
+ * Alessandro Decina <alessandro@nnva.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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.
+ */
+
+#ifndef __GST_CMML_DEC_H__
+#define __GST_CMML_DEC_H__
+
+#include <gst/gst.h>
+#include <gst/gstformat.h>
+#include <gst/controller/gstcontroller.h>
+
+#include "gstcmmlparser.h"
+
+/* GstCmmlDec */
+#define GST_TYPE_CMML_DEC (gst_cmml_dec_get_type())
+#define GST_CMML_DEC(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_CMML_DEC, GstCmmlDec))
+#define GST_CMML_DEC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_CMML_DEC, GstCmmlDecClass))
+#define GST_IS_CMML_DEC(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_CMML_DEC))
+#define GST_IS_CMML_DEC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_CMML_DEC))
+#define GST_CMML_DEC_GET_CLASS(klass) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_CMML_DEC, GstCmmlDecClass))
+
+typedef struct _GstCmmlDec GstCmmlDec;
+typedef struct _GstCmmlDecClass GstCmmlDecClass;
+typedef enum _GstCmmlPacketType GstCmmlPacketType;
+
+enum _GstCmmlPacketType
+{
+ GST_CMML_PACKET_UNKNOWN,
+ GST_CMML_PACKET_IDENT_HEADER,
+ GST_CMML_PACKET_FIRST_HEADER,
+ GST_CMML_PACKET_SECOND_HEADER,
+ GST_CMML_PACKET_CLIP
+};
+
+struct _GstCmmlDec
+{
+ GstElement element;
+
+ /* element part */
+ GstPad *sinkpad;
+ GstPad *srcpad;
+
+ /* bitstream part */
+ gint16 major; /* bitstream version major */
+ gint16 minor; /* bitstream version minor */
+ gint64 granulerate_n; /* bitrstream granulerate numerator */
+ gint64 granulerate_d; /* bitstream granulerate denominator */
+ gint8 granuleshift; /* bitstreamgranuleshift */
+ gint64 granulepos; /* bitstream granule position */
+ GstClockTime timestamp; /* timestamp of the last buffer */
+
+ /* decoder part */
+ GstCmmlParser *parser; /* cmml parser */
+ gboolean sent_root;
+ GstFlowReturn flow_return; /* _chain return value */
+ gboolean wait_clip_end; /* when TRUE, the GST_TAG_MESSAGE for a
+ * clip is sent when the next clip (or EOS)
+ * is found, so that the clip end-time is
+ * known. This is useful for pre-extracting
+ * the clips.
+ */
+ GHashTable *tracks;
+};
+
+struct _GstCmmlDecClass
+{
+ GstElementClass parent_class;
+};
+
+GType gst_cmml_dec_get_type (void);
+
+gboolean gst_cmml_dec_plugin_init (GstPlugin * plugin);
+
+#endif /* __GST_CMML_DEC_H__ */
diff --git a/ext/annodex/gstcmmlenc.c b/ext/annodex/gstcmmlenc.c
new file mode 100644
index 0000000..a3255dc
--- /dev/null
+++ b/ext/annodex/gstcmmlenc.c
@@ -0,0 +1,631 @@
+/*
+ * gstcmmlenc.c - GStreamer CMML encoder
+ * Copyright (C) 2005 Alessandro Decina
+ *
+ * Authors:
+ * Alessandro Decina <alessandro@nnva.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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.
+ */
+
+/**
+ * SECTION:element-cmmlenc
+ * @see_also: cmmldec, oggmux
+ *
+ * Cmmlenc encodes a CMML document into a CMML stream. <ulink
+ * url="http://www.annodex.net/TR/draft-pfeiffer-cmml-02.html">CMML</ulink> is
+ * an XML markup language for time-continuous data maintained by the <ulink
+ * url="http:/www.annodex.org/">Annodex Foundation</ulink>.
+ *
+ * <refsect2>
+ * <title>Example pipeline</title>
+ * |[
+ * gst-launch -v filesrc location=annotations.cmml ! cmmlenc ! oggmux name=mux ! filesink location=annotated.ogg
+ * ]|
+ * </refsect2>
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include "gstcmmlenc.h"
+#include "gstannodex.h"
+
+GST_DEBUG_CATEGORY_STATIC (cmmlenc);
+#define GST_CAT_DEFAULT cmmlenc
+
+#define CMML_IDENT_HEADER_SIZE 29
+
+enum
+{
+ ARG_0,
+ GST_CMML_ENC_GRANULERATE_N,
+ GST_CMML_ENC_GRANULERATE_D,
+ GST_CMML_ENC_GRANULESHIFT
+};
+
+enum
+{
+ LAST_SIGNAL
+};
+
+static GstStaticPadTemplate gst_cmml_enc_src_factory =
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("text/x-cmml, encoded = (boolean) true")
+ );
+
+static GstStaticPadTemplate gst_cmml_enc_sink_factory =
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("text/x-cmml, encoded = (boolean) false")
+ );
+
+GST_BOILERPLATE (GstCmmlEnc, gst_cmml_enc, GstElement, GST_TYPE_ELEMENT);
+static void gst_cmml_enc_get_property (GObject * object, guint property_id,
+ GValue * value, GParamSpec * pspec);
+static void gst_cmml_enc_set_property (GObject * object, guint property_id,
+ const GValue * value, GParamSpec * pspec);
+static gboolean gst_cmml_enc_sink_event (GstPad * pad, GstEvent * event);
+static GstStateChangeReturn gst_cmml_enc_change_state (GstElement * element,
+ GstStateChange transition);
+static GstFlowReturn gst_cmml_enc_chain (GstPad * pad, GstBuffer * buffer);
+static void gst_cmml_enc_parse_preamble (GstCmmlEnc * enc,
+ guchar * preamble, guchar * processing_instruction);
+static void gst_cmml_enc_parse_end_tag (GstCmmlEnc * enc);
+static void gst_cmml_enc_parse_tag_head (GstCmmlEnc * enc,
+ GstCmmlTagHead * head);
+static void gst_cmml_enc_parse_tag_clip (GstCmmlEnc * enc,
+ GstCmmlTagClip * tag);
+static GstFlowReturn gst_cmml_enc_new_buffer (GstCmmlEnc * enc,
+ guchar * data, gint size, GstBuffer ** buffer);
+static GstFlowReturn gst_cmml_enc_push_clip (GstCmmlEnc * enc,
+ GstCmmlTagClip * clip, GstClockTime prev_clip_time);
+static GstFlowReturn gst_cmml_enc_push (GstCmmlEnc * enc, GstBuffer * buffer);
+
+static void gst_cmml_enc_finalize (GObject * object);
+
+static void
+gst_cmml_enc_base_init (gpointer g_class)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_cmml_enc_sink_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_cmml_enc_src_factory));
+ gst_element_class_set_details_simple (element_class, "CMML streams encoder",
+ "Codec/Encoder",
+ "Encodes CMML streams", "Alessandro Decina <alessandro@nnva.org>");
+}
+
+static void
+gst_cmml_enc_class_init (GstCmmlEncClass * enc_class)
+{
+ GObjectClass *klass = G_OBJECT_CLASS (enc_class);
+
+ klass->get_property = gst_cmml_enc_get_property;
+ klass->set_property = gst_cmml_enc_set_property;
+ klass->finalize = gst_cmml_enc_finalize;
+
+ g_object_class_install_property (klass, GST_CMML_ENC_GRANULERATE_N,
+ g_param_spec_int64 ("granule-rate-numerator",
+ "Granulerate numerator",
+ "Granulerate numerator",
+ 0, G_MAXINT64, 1000,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (klass, GST_CMML_ENC_GRANULERATE_D,
+ g_param_spec_int64 ("granule-rate-denominator",
+ "Granulerate denominator",
+ "Granulerate denominator",
+ 0, G_MAXINT64, 1,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (klass, GST_CMML_ENC_GRANULESHIFT,
+ g_param_spec_uchar ("granule-shift",
+ "Granuleshift",
+ "The number of lower bits to use for partitioning a granule position",
+ 0, 64, 32,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ GST_ELEMENT_CLASS (klass)->change_state = gst_cmml_enc_change_state;
+}
+
+static void
+gst_cmml_enc_init (GstCmmlEnc * enc, GstCmmlEncClass * klass)
+{
+ enc->sinkpad =
+ gst_pad_new_from_static_template (&gst_cmml_enc_sink_factory, "sink");
+ gst_pad_set_chain_function (enc->sinkpad, gst_cmml_enc_chain);
+ gst_pad_set_event_function (enc->sinkpad, gst_cmml_enc_sink_event);
+ gst_element_add_pad (GST_ELEMENT (enc), enc->sinkpad);
+
+ enc->srcpad =
+ gst_pad_new_from_static_template (&gst_cmml_enc_src_factory, "src");
+ gst_element_add_pad (GST_ELEMENT (enc), enc->srcpad);
+
+ enc->major = 3;
+ enc->minor = 0;
+}
+
+static void
+gst_cmml_enc_set_property (GObject * object, guint property_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstCmmlEnc *enc = GST_CMML_ENC (object);
+
+ switch (property_id) {
+ case GST_CMML_ENC_GRANULERATE_N:
+ /* XXX: may need to flush clips */
+ enc->granulerate_n = g_value_get_int64 (value);
+ break;
+ case GST_CMML_ENC_GRANULERATE_D:
+ enc->granulerate_d = g_value_get_int64 (value);
+ break;
+ case GST_CMML_ENC_GRANULESHIFT:
+ enc->granuleshift = g_value_get_uchar (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+gst_cmml_enc_get_property (GObject * object, guint property_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GstCmmlEnc *enc = GST_CMML_ENC (object);
+
+ switch (property_id) {
+ case GST_CMML_ENC_GRANULERATE_N:
+ g_value_set_int64 (value, enc->granulerate_n);
+ break;
+ case GST_CMML_ENC_GRANULERATE_D:
+ g_value_set_int64 (value, enc->granulerate_d);
+ break;
+ case GST_CMML_ENC_GRANULESHIFT:
+ g_value_set_uchar (value, enc->granuleshift);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+gst_cmml_enc_finalize (GObject * object)
+{
+ GstCmmlEnc *enc = GST_CMML_ENC (object);
+
+ if (enc->tracks) {
+ gst_cmml_track_list_destroy (enc->tracks);
+ enc->tracks = NULL;
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static GstStateChangeReturn
+gst_cmml_enc_change_state (GstElement * element, GstStateChange transition)
+{
+ GstCmmlEnc *enc = GST_CMML_ENC (element);
+ GstStateChangeReturn res;
+
+ switch (transition) {
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
+ enc->parser = gst_cmml_parser_new (GST_CMML_PARSER_ENCODE);
+ enc->parser->user_data = enc;
+ enc->parser->preamble_callback =
+ (GstCmmlParserPreambleCallback) gst_cmml_enc_parse_preamble;
+ enc->parser->head_callback =
+ (GstCmmlParserHeadCallback) gst_cmml_enc_parse_tag_head;
+ enc->parser->clip_callback =
+ (GstCmmlParserClipCallback) gst_cmml_enc_parse_tag_clip;
+ enc->parser->cmml_end_callback =
+ (GstCmmlParserCmmlEndCallback) gst_cmml_enc_parse_end_tag;
+ enc->tracks = gst_cmml_track_list_new ();
+ enc->sent_headers = FALSE;
+ enc->sent_eos = FALSE;
+ enc->flow_return = GST_FLOW_OK;
+ break;
+ default:
+ break;
+ }
+
+ res = parent_class->change_state (element, transition);
+
+ switch (transition) {
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
+ {
+ gst_cmml_track_list_destroy (enc->tracks);
+ enc->tracks = NULL;
+ g_free (enc->preamble);
+ enc->preamble = NULL;
+ gst_cmml_parser_free (enc->parser);
+ break;
+ }
+ default:
+ break;
+ }
+
+ return res;
+}
+
+static gboolean
+gst_cmml_enc_sink_event (GstPad * pad, GstEvent * event)
+{
+ GstCmmlEnc *enc = GST_CMML_ENC (GST_PAD_PARENT (pad));
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_EOS:
+ {
+ if (!enc->sent_eos)
+ gst_cmml_enc_parse_end_tag (enc);
+
+ break;
+ }
+ default:
+ break;
+ }
+
+ return gst_pad_event_default (pad, event);
+}
+
+static GstFlowReturn
+gst_cmml_enc_new_buffer (GstCmmlEnc * enc,
+ guchar * data, gint size, GstBuffer ** buffer)
+{
+ GstFlowReturn res;
+
+ res = gst_pad_alloc_buffer (enc->srcpad, GST_BUFFER_OFFSET_NONE, size,
+ NULL, buffer);
+ if (res == GST_FLOW_OK) {
+ if (data)
+ memcpy (GST_BUFFER_DATA (*buffer), data, size);
+ } else {
+ GST_WARNING_OBJECT (enc, "alloc function returned error %s",
+ gst_flow_get_name (res));
+ }
+
+ return res;
+}
+
+static GstCaps *
+gst_cmml_enc_set_header_on_caps (GstCmmlEnc * enc, GstCaps * caps,
+ GstBuffer * ident, GstBuffer * preamble, GstBuffer * head)
+{
+ GValue array = { 0 };
+ GValue value = { 0 };
+ GstStructure *structure;
+ GstBuffer *buffer;
+
+ caps = gst_caps_make_writable (caps);
+ structure = gst_caps_get_structure (caps, 0);
+
+ g_value_init (&array, GST_TYPE_ARRAY);
+ g_value_init (&value, GST_TYPE_BUFFER);
+
+ /* Make copies of header buffers to avoid circular references */
+ buffer = gst_buffer_copy (ident);
+ gst_value_set_buffer (&value, buffer);
+ gst_value_array_append_value (&array, &value);
+ gst_buffer_unref (buffer);
+
+ buffer = gst_buffer_copy (preamble);
+ gst_value_set_buffer (&value, buffer);
+ gst_value_array_append_value (&array, &value);
+ gst_buffer_unref (buffer);
+
+ buffer = gst_buffer_copy (head);
+ gst_value_set_buffer (&value, buffer);
+ gst_value_array_append_value (&array, &value);
+ gst_buffer_unref (buffer);
+
+ GST_BUFFER_FLAG_SET (ident, GST_BUFFER_FLAG_IN_CAPS);
+ GST_BUFFER_FLAG_SET (preamble, GST_BUFFER_FLAG_IN_CAPS);
+ GST_BUFFER_FLAG_SET (head, GST_BUFFER_FLAG_IN_CAPS);
+
+ gst_structure_set_value (structure, "streamheader", &array);
+
+ g_value_unset (&value);
+ g_value_unset (&array);
+
+ return caps;
+}
+
+/* create a CMML ident header buffer
+ */
+static GstFlowReturn
+gst_cmml_enc_new_ident_header (GstCmmlEnc * enc, GstBuffer ** buffer)
+{
+ guint8 ident_header[CMML_IDENT_HEADER_SIZE];
+ guint8 *wptr = ident_header;
+
+ memcpy (wptr, "CMML\0\0\0\0", 8);
+ wptr += 8;
+ GST_WRITE_UINT16_LE (wptr, enc->major);
+ wptr += 2;
+ GST_WRITE_UINT16_LE (wptr, enc->minor);
+ wptr += 2;
+ GST_WRITE_UINT64_LE (wptr, enc->granulerate_n);
+ wptr += 8;
+ GST_WRITE_UINT64_LE (wptr, enc->granulerate_d);
+ wptr += 8;
+ *wptr = enc->granuleshift;
+
+ return gst_cmml_enc_new_buffer (enc,
+ (guchar *) & ident_header, CMML_IDENT_HEADER_SIZE, buffer);
+}
+
+/* parse the CMML preamble */
+static void
+gst_cmml_enc_parse_preamble (GstCmmlEnc * enc,
+ guchar * preamble, guchar * processing_instruction)
+{
+ GST_INFO_OBJECT (enc, "parsing preamble");
+
+ /* save the preamble: it will be pushed when the head tag is found */
+ enc->preamble = (guchar *) g_strconcat ((gchar *) preamble,
+ (gchar *) processing_instruction, NULL);
+}
+
+/* parse the CMML end tag */
+static void
+gst_cmml_enc_parse_end_tag (GstCmmlEnc * enc)
+{
+ GstBuffer *buffer;
+
+ GST_INFO_OBJECT (enc, "parsing end tag");
+
+ /* push an empty buffer to signal EOS */
+ enc->flow_return = gst_cmml_enc_new_buffer (enc, NULL, 0, &buffer);
+ if (enc->flow_return == GST_FLOW_OK) {
+ /* set granulepos 0 on EOS */
+ GST_BUFFER_OFFSET_END (buffer) = 0;
+ enc->flow_return = gst_cmml_enc_push (enc, buffer);
+ enc->sent_eos = TRUE;
+ }
+
+ return;
+}
+
+/* encode the CMML head tag and push the CMML headers
+ */
+static void
+gst_cmml_enc_parse_tag_head (GstCmmlEnc * enc, GstCmmlTagHead * head)
+{
+ GList *headers = NULL;
+ GList *walk;
+ guchar *head_string;
+ GstCaps *caps;
+ GstBuffer *ident_buf, *preamble_buf, *head_buf;
+ GstBuffer *buffer;
+
+ if (enc->preamble == NULL)
+ goto flow_unexpected;
+
+ GST_INFO_OBJECT (enc, "parsing head tag");
+
+ enc->flow_return = gst_cmml_enc_new_ident_header (enc, &ident_buf);
+ if (enc->flow_return != GST_FLOW_OK)
+ goto alloc_error;
+ headers = g_list_append (headers, ident_buf);
+
+ enc->flow_return = gst_cmml_enc_new_buffer (enc,
+ enc->preamble, strlen ((gchar *) enc->preamble), &preamble_buf);
+ if (enc->flow_return != GST_FLOW_OK)
+ goto alloc_error;
+ headers = g_list_append (headers, preamble_buf);
+
+ head_string = gst_cmml_parser_tag_head_to_string (enc->parser, head);
+ enc->flow_return = gst_cmml_enc_new_buffer (enc,
+ head_string, strlen ((gchar *) head_string), &head_buf);
+ g_free (head_string);
+ if (enc->flow_return != GST_FLOW_OK)
+ goto alloc_error;
+ headers = g_list_append (headers, head_buf);
+
+ caps = gst_pad_get_caps (enc->srcpad);
+ caps = gst_cmml_enc_set_header_on_caps (enc, caps,
+ ident_buf, preamble_buf, head_buf);
+
+ while (headers) {
+ buffer = GST_BUFFER (headers->data);
+ /* set granulepos 0 on headers */
+ GST_BUFFER_OFFSET_END (buffer) = 0;
+ gst_buffer_set_caps (buffer, caps);
+
+ enc->flow_return = gst_cmml_enc_push (enc, buffer);
+ headers = g_list_delete_link (headers, headers);
+
+ if (enc->flow_return != GST_FLOW_OK)
+ goto push_error;
+ }
+
+ gst_caps_unref (caps);
+
+ enc->sent_headers = TRUE;
+ return;
+
+flow_unexpected:
+ GST_ELEMENT_ERROR (enc, STREAM, ENCODE,
+ (NULL), ("got head tag before preamble"));
+ enc->flow_return = GST_FLOW_ERROR;
+ return;
+push_error:
+ gst_caps_unref (caps);
+ /* fallthrough */
+alloc_error:
+ for (walk = headers; walk; walk = walk->next)
+ gst_buffer_unref (GST_BUFFER (walk->data));
+ g_list_free (headers);
+ return;
+}
+
+/* encode a CMML clip tag
+ * remove the start and end attributes (GstCmmlParser does this itself) and
+ * push the tag with the timestamp of its start attribute. If the tag has the
+ * end attribute, create a new empty clip and encode it.
+ */
+static void
+gst_cmml_enc_parse_tag_clip (GstCmmlEnc * enc, GstCmmlTagClip * clip)
+{
+ GstCmmlTagClip *prev_clip;
+ GstClockTime prev_clip_time = GST_CLOCK_TIME_NONE;
+
+ /* this can happen if there's a programming error (eg user forgets to set
+ * the start-time property) or if one of the gst_cmml_clock_time_from_*
+ * overflows in GstCmmlParser */
+ if (clip->start_time == GST_CLOCK_TIME_NONE) {
+ GST_ELEMENT_ERROR (enc, STREAM, ENCODE,
+ (NULL), ("invalid start time for clip (%s)", clip->id));
+ enc->flow_return = GST_FLOW_ERROR;
+
+ return;
+ }
+
+ /* get the previous clip's start time to encode the current granulepos */
+ prev_clip = gst_cmml_track_list_get_track_last_clip (enc->tracks,
+ (gchar *) clip->track);
+ if (prev_clip) {
+ prev_clip_time = prev_clip->start_time;
+ if (prev_clip_time > clip->start_time) {
+ GST_ELEMENT_ERROR (enc, STREAM, ENCODE,
+ (NULL), ("previous clip start time > current clip (%s) start time",
+ clip->id));
+ enc->flow_return = GST_FLOW_ERROR;
+ return;
+ }
+
+ /* we don't need the prev clip anymore */
+ gst_cmml_track_list_del_clip (enc->tracks, prev_clip);
+ }
+
+ /* add the current clip to the tracklist */
+ gst_cmml_track_list_add_clip (enc->tracks, clip);
+
+ enc->flow_return = gst_cmml_enc_push_clip (enc, clip, prev_clip_time);
+}
+
+static GstFlowReturn
+gst_cmml_enc_push_clip (GstCmmlEnc * enc, GstCmmlTagClip * clip,
+ GstClockTime prev_clip_time)
+{
+ GstFlowReturn res;
+ GstBuffer *buffer;
+ gchar *clip_string;
+ gint64 granulepos;
+
+ /* encode the clip */
+ clip_string =
+ (gchar *) gst_cmml_parser_tag_clip_to_string (enc->parser, clip);
+
+ res = gst_cmml_enc_new_buffer (enc,
+ (guchar *) clip_string, strlen (clip_string), &buffer);
+ g_free (clip_string);
+ if (res != GST_FLOW_OK)
+ goto done;
+
+ GST_INFO_OBJECT (enc, "encoding clip"
+ "(start-time: %" GST_TIME_FORMAT " end-time: %" GST_TIME_FORMAT,
+ GST_TIME_ARGS (clip->start_time), GST_TIME_ARGS (clip->end_time));
+
+ /* set the granulepos */
+ granulepos = gst_cmml_clock_time_to_granule (prev_clip_time, clip->start_time,
+ enc->granulerate_n, enc->granulerate_d, enc->granuleshift);
+ if (granulepos == -1) {
+ gst_buffer_unref (buffer);
+ goto granule_overflow;
+ }
+
+ GST_BUFFER_OFFSET (buffer) = clip->start_time;
+ GST_BUFFER_OFFSET_END (buffer) = granulepos;
+ GST_BUFFER_TIMESTAMP (buffer) = clip->start_time;
+
+ res = gst_cmml_enc_push (enc, buffer);
+ if (res != GST_FLOW_OK)
+ goto done;
+
+ if (clip->end_time != GST_CLOCK_TIME_NONE) {
+ /* create a new empty clip for the same cmml track starting at end_time
+ */
+ GObject *end_clip = g_object_new (GST_TYPE_CMML_TAG_CLIP,
+ "start-time", clip->end_time, "track", clip->track, NULL);
+
+ /* encode the empty end clip */
+ gst_cmml_enc_push_clip (enc, GST_CMML_TAG_CLIP (end_clip),
+ clip->start_time);
+ g_object_unref (end_clip);
+ }
+done:
+ return res;
+
+granule_overflow:
+ GST_ELEMENT_ERROR (enc, STREAM, ENCODE, (NULL), ("granulepos overflow"));
+ return GST_FLOW_ERROR;
+}
+
+static GstFlowReturn
+gst_cmml_enc_push (GstCmmlEnc * enc, GstBuffer * buffer)
+{
+ GstFlowReturn res;
+
+ res = gst_pad_push (enc->srcpad, buffer);
+ if (res != GST_FLOW_OK)
+ GST_WARNING_OBJECT (enc, "push returned: %s", gst_flow_get_name (res));
+
+ return res;
+}
+
+static GstFlowReturn
+gst_cmml_enc_chain (GstPad * pad, GstBuffer * buffer)
+{
+ GError *err = NULL;
+ GstCmmlEnc *enc = GST_CMML_ENC (GST_PAD_PARENT (pad));
+
+ /* the CMML handlers registered with enc->parser will override this when
+ * encoding/pushing the buffers downstream
+ */
+ enc->flow_return = GST_FLOW_OK;
+
+ if (!gst_cmml_parser_parse_chunk (enc->parser,
+ (gchar *) GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer), &err)) {
+ GST_ELEMENT_ERROR (enc, STREAM, ENCODE, (NULL), ("%s", err->message));
+ g_error_free (err);
+ enc->flow_return = GST_FLOW_ERROR;
+ }
+
+ gst_buffer_unref (buffer);
+ return enc->flow_return;
+}
+
+gboolean
+gst_cmml_enc_plugin_init (GstPlugin * plugin)
+{
+ if (!gst_element_register (plugin, "cmmlenc", GST_RANK_NONE,
+ GST_TYPE_CMML_ENC))
+ return FALSE;
+
+ GST_DEBUG_CATEGORY_INIT (cmmlenc, "cmmlenc", 0,
+ "annodex cmml decoding element");
+
+ return TRUE;
+}
diff --git a/ext/annodex/gstcmmlenc.h b/ext/annodex/gstcmmlenc.h
new file mode 100644
index 0000000..4f28e4c
--- /dev/null
+++ b/ext/annodex/gstcmmlenc.h
@@ -0,0 +1,79 @@
+/*
+ * gstcmmlenc.h - GStreamer CMML encoder
+ * Copyright (C) 2005 Alessandro Decina
+ *
+ * Authors:
+ * Alessandro Decina <alessandro@nnva.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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.
+ */
+
+#ifndef __GST_CMML_ENC_H__
+#define __GST_CMML_ENC_H__
+
+#define GST_TYPE_CMML_ENC (gst_cmml_enc_get_type())
+#define GST_CMML_ENC(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_CMML_ENC, GstCmmlEnc))
+#define GST_CMML_ENC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_CMML_ENC, GstCmmlEncClass))
+#define GST_IS_CMML_ENC(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_CMML_ENC))
+#define GST_IS_CMML_ENC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_CMML_ENC))
+#define GST_CMML_ENC_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_CMML_ENC, GstCmmlEncClass))
+
+#include <glib.h>
+#include <gst/gst.h>
+
+#include "gstcmmlparser.h"
+#include "gstcmmlutils.h"
+
+typedef struct _GstCmmlEnc GstCmmlEnc;
+typedef struct _GstCmmlEncClass GstCmmlEncClass;
+
+struct _GstCmmlEnc
+{
+ GstElement element;
+
+ GstPad *sinkpad;
+ GstPad *srcpad;
+
+ gint16 major;
+ gint16 minor;
+ gint64 granulerate_n;
+ gint64 granulerate_d;
+ gint8 granuleshift;
+
+ GstCmmlParser *parser;
+ gboolean streaming;
+ GHashTable *tracks;
+ GstFlowReturn flow_return;
+ guchar *preamble;
+ gboolean sent_headers;
+ gboolean sent_eos;
+};
+
+struct _GstCmmlEncClass
+{
+ GstElementClass parent_class;
+};
+
+GType gst_cmml_enc_get_type (void);
+
+gboolean gst_cmml_enc_plugin_init (GstPlugin * plugin);
+
+#endif /* __GST_CMML_ENC_H__ */
diff --git a/ext/annodex/gstcmmlparser.c b/ext/annodex/gstcmmlparser.c
new file mode 100644
index 0000000..0e2f7cd
--- /dev/null
+++ b/ext/annodex/gstcmmlparser.c
@@ -0,0 +1,648 @@
+/*
+ * gstcmmlparser.c - GStreamer CMML document parser
+ * Copyright (C) 2005 Alessandro Decina
+ *
+ * Authors:
+ * Alessandro Decina <alessandro@nnva.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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.
+ */
+
+#include <string.h>
+#include <stdarg.h>
+#include <gst/gst.h>
+
+#include "gstcmmlparser.h"
+#include "gstannodex.h"
+#include "gstcmmlutils.h"
+
+GST_DEBUG_CATEGORY_STATIC (cmmlparser);
+#define GST_CAT_DEFAULT cmmlparser
+
+static void gst_cmml_parser_generic_error (void *ctx, const char *msg, ...);
+static xmlNodePtr gst_cmml_parser_new_node (GstCmmlParser * parser,
+ const gchar * name, ...);
+static void
+gst_cmml_parser_parse_start_element_ns (xmlParserCtxt * ctxt,
+ const xmlChar * name, const xmlChar * prefix, const xmlChar * URI,
+ int nb_preferences, const xmlChar ** namespaces,
+ int nb_attributes, int nb_defaulted, const xmlChar ** attributes);
+static void gst_cmml_parser_parse_end_element_ns (xmlParserCtxt * ctxt,
+ const xmlChar * name, const xmlChar * prefix, const xmlChar * URI);
+static void gst_cmml_parser_parse_processing_instruction (xmlParserCtxtPtr ctxt,
+ const xmlChar * target, const xmlChar * data);
+static void gst_cmml_parser_meta_to_string (GstCmmlParser * parser,
+ xmlNodePtr parent, GValueArray * meta);
+
+/* initialize the parser */
+void
+gst_cmml_parser_init (void)
+{
+ GST_DEBUG_CATEGORY_INIT (cmmlparser, "cmmlparser", 0, "annodex CMML parser");
+
+ xmlGenericError = gst_cmml_parser_generic_error;
+}
+
+/* create a new CMML parser
+ */
+GstCmmlParser *
+gst_cmml_parser_new (GstCmmlParserMode mode)
+{
+ GstCmmlParser *parser = g_malloc (sizeof (GstCmmlParser));
+
+ parser->mode = mode;
+ parser->context = xmlCreatePushParserCtxt (NULL, NULL,
+ NULL, 0, "cmml-bitstream");
+ xmlCtxtUseOptions (parser->context, XML_PARSE_NONET | XML_PARSE_NOERROR);
+ parser->context->_private = parser;
+ parser->context->sax->startElementNs =
+ (startElementNsSAX2Func) gst_cmml_parser_parse_start_element_ns;
+ parser->context->sax->endElementNs =
+ (endElementNsSAX2Func) gst_cmml_parser_parse_end_element_ns;
+ parser->context->sax->processingInstruction = (processingInstructionSAXFunc)
+ gst_cmml_parser_parse_processing_instruction;
+ parser->preamble_callback = NULL;
+ parser->cmml_end_callback = NULL;
+ parser->stream_callback = NULL;
+ parser->head_callback = NULL;
+ parser->clip_callback = NULL;
+ parser->user_data = NULL;
+
+ return parser;
+}
+
+/* free a CMML parser instance
+ */
+void
+gst_cmml_parser_free (GstCmmlParser * parser)
+{
+ if (parser) {
+ xmlFreeDoc (parser->context->myDoc);
+ xmlFreeParserCtxt (parser->context);
+ g_free (parser);
+ }
+}
+
+/* parse an xml chunk
+ *
+ * returns false if the xml is invalid
+ */
+gboolean
+gst_cmml_parser_parse_chunk (GstCmmlParser * parser,
+ const gchar * data, guint size, GError ** err)
+{
+ gint xmlres;
+
+ xmlres = xmlParseChunk (parser->context, data, size, 0);
+ if (xmlres != XML_ERR_OK) {
+ xmlErrorPtr xml_error = xmlCtxtGetLastError (parser->context);
+
+ GST_DEBUG ("Error occurred decoding chunk %s", data);
+ g_set_error (err,
+ GST_LIBRARY_ERROR, GST_LIBRARY_ERROR_FAILED, "%s", xml_error->message);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* convert an xmlNodePtr to a string
+ */
+static guchar *
+gst_cmml_parser_node_to_string (GstCmmlParser * parser, xmlNodePtr node)
+{
+ xmlBufferPtr xml_buffer;
+ xmlDocPtr doc;
+ guchar *str;
+
+ if (parser)
+ doc = parser->context->myDoc;
+ else
+ doc = NULL;
+
+ xml_buffer = xmlBufferCreate ();
+ xmlNodeDump (xml_buffer, doc, node, 0, 0);
+ str = xmlStrndup (xml_buffer->content, xml_buffer->use);
+ xmlBufferFree (xml_buffer);
+
+ return str;
+}
+
+guchar *
+gst_cmml_parser_tag_stream_to_string (GstCmmlParser * parser,
+ GstCmmlTagStream * stream)
+{
+ xmlNodePtr node;
+ xmlNodePtr import;
+ guchar *ret;
+
+ node = gst_cmml_parser_new_node (parser, "stream", NULL);
+ if (stream->timebase)
+ xmlSetProp (node, (xmlChar *) "timebase", stream->timebase);
+
+ if (stream->utc)
+ xmlSetProp (node, (xmlChar *) "utc", stream->utc);
+
+ if (stream->imports) {
+ gint i;
+ GValue *val;
+
+ for (i = 0; i < stream->imports->n_values; ++i) {
+ val = g_value_array_get_nth (stream->imports, i);
+ import = gst_cmml_parser_new_node (parser, "import",
+ "src", g_value_get_string (val), NULL);
+ xmlAddChild (node, import);
+ }
+ }
+
+ ret = gst_cmml_parser_node_to_string (parser, node);
+
+ xmlUnlinkNode (node);
+ xmlFreeNode (node);
+
+ return ret;
+}
+
+/* convert a GstCmmlTagHead to its string representation
+ */
+guchar *
+gst_cmml_parser_tag_head_to_string (GstCmmlParser * parser,
+ GstCmmlTagHead * head)
+{
+ xmlNodePtr node;
+ xmlNodePtr tmp;
+ guchar *ret;
+
+ node = gst_cmml_parser_new_node (parser, "head", NULL);
+ if (head->title) {
+ tmp = gst_cmml_parser_new_node (parser, "title", NULL);
+ xmlNodeSetContent (tmp, head->title);
+ xmlAddChild (node, tmp);
+ }
+
+ if (head->base) {
+ tmp = gst_cmml_parser_new_node (parser, "base", "uri", head->base, NULL);
+ xmlAddChild (node, tmp);
+ }
+
+ if (head->meta)
+ gst_cmml_parser_meta_to_string (parser, node, head->meta);
+
+ ret = gst_cmml_parser_node_to_string (parser, node);
+
+ xmlUnlinkNode (node);
+ xmlFreeNode (node);
+
+ return ret;
+}
+
+/* convert a GstCmmlTagClip to its string representation
+ */
+guchar *
+gst_cmml_parser_tag_clip_to_string (GstCmmlParser * parser,
+ GstCmmlTagClip * clip)
+{
+ xmlNodePtr node;
+ xmlNodePtr tmp;
+ guchar *ret;
+
+ node = gst_cmml_parser_new_node (parser, "clip",
+ "id", clip->id, "track", clip->track, NULL);
+ /* add the anchor element */
+ if (clip->anchor_href) {
+ tmp = gst_cmml_parser_new_node (parser, "a",
+ "href", clip->anchor_href, NULL);
+ if (clip->anchor_text)
+ xmlNodeSetContent (tmp, clip->anchor_text);
+
+ xmlAddChild (node, tmp);
+ }
+ /* add the img element */
+ if (clip->img_src) {
+ tmp = gst_cmml_parser_new_node (parser, "img",
+ "src", clip->img_src, "alt", clip->img_alt, NULL);
+
+ xmlAddChild (node, tmp);
+ }
+ /* add the desc element */
+ if (clip->desc_text) {
+ tmp = gst_cmml_parser_new_node (parser, "desc", NULL);
+ xmlNodeSetContent (tmp, clip->desc_text);
+
+ xmlAddChild (node, tmp);
+ }
+ /* add the meta elements */
+ if (clip->meta)
+ gst_cmml_parser_meta_to_string (parser, node, clip->meta);
+
+ if (parser->mode == GST_CMML_PARSER_DECODE) {
+ gchar *time_str;
+
+ time_str = gst_cmml_clock_time_to_npt (clip->start_time);
+ if (time_str == NULL)
+ goto fail;
+
+ xmlSetProp (node, (xmlChar *) "start", (xmlChar *) time_str);
+ g_free (time_str);
+
+ if (clip->end_time != GST_CLOCK_TIME_NONE) {
+ time_str = gst_cmml_clock_time_to_npt (clip->end_time);
+ if (time_str == NULL)
+ goto fail;
+
+ xmlSetProp (node, (xmlChar *) "end", (xmlChar *) time_str);
+ g_free (time_str);
+ }
+ }
+
+ ret = gst_cmml_parser_node_to_string (parser, node);
+
+ xmlUnlinkNode (node);
+ xmlFreeNode (node);
+
+ return ret;
+fail:
+ xmlUnlinkNode (node);
+ xmlFreeNode (node);
+ return NULL;
+}
+
+guchar *
+gst_cmml_parser_tag_object_to_string (GstCmmlParser * parser, GObject * tag)
+{
+ guchar *tag_string = NULL;
+ GType tag_type = G_OBJECT_TYPE (tag);
+
+ if (tag_type == GST_TYPE_CMML_TAG_STREAM)
+ tag_string = gst_cmml_parser_tag_stream_to_string (parser,
+ GST_CMML_TAG_STREAM (tag));
+ else if (tag_type == GST_TYPE_CMML_TAG_HEAD)
+ tag_string = gst_cmml_parser_tag_head_to_string (parser,
+ GST_CMML_TAG_HEAD (tag));
+ else if (tag_type == GST_TYPE_CMML_TAG_CLIP)
+ tag_string = gst_cmml_parser_tag_clip_to_string (parser,
+ GST_CMML_TAG_CLIP (tag));
+ else
+ g_warning ("could not convert object to cmml");
+
+ return tag_string;
+}
+
+/*** private section ***/
+
+/* create a new node
+ *
+ * helper to create a node and set its attributes
+ */
+static xmlNodePtr
+gst_cmml_parser_new_node (GstCmmlParser * parser, const gchar * name, ...)
+{
+ va_list args;
+ xmlNodePtr node;
+ xmlChar *prop_name, *prop_value;
+
+ node = xmlNewNode (NULL, (xmlChar *) name);
+
+ va_start (args, name);
+
+ prop_name = va_arg (args, xmlChar *);
+ while (prop_name != NULL) {
+ prop_value = va_arg (args, xmlChar *);
+ if (prop_value != NULL)
+ xmlSetProp (node, prop_name, prop_value);
+
+ prop_name = va_arg (args, xmlChar *);
+ }
+ va_end (args);
+
+ return node;
+}
+
+/* get the last node of the stream
+ *
+ * returns the last node at depth 1 (if any) or the root node
+ */
+static xmlNodePtr
+gst_cmml_parser_get_last_element (GstCmmlParser * parser)
+{
+ xmlNodePtr node;
+
+ node = xmlDocGetRootElement (parser->context->myDoc);
+ if (!node) {
+ g_warning ("no last cmml element");
+ return NULL;
+ }
+
+ if (node->children)
+ node = xmlGetLastChild (node);
+
+ return node;
+}
+
+static void
+gst_cmml_parser_parse_preamble (GstCmmlParser * parser,
+ const guchar * attributes)
+{
+ gchar *preamble;
+ gchar *element;
+ const gchar *version;
+ const gchar *encoding;
+ const gchar *standalone;
+ xmlDocPtr doc;
+
+ doc = parser->context->myDoc;
+
+ version = doc->version ? (gchar *) doc->version : "1.0";
+ encoding = doc->encoding ? (gchar *) doc->encoding : "UTF-8";
+ standalone = doc->standalone ? "yes" : "no";
+
+ preamble = g_strdup_printf ("<?xml version=\"%s\""
+ " encoding=\"%s\" standalone=\"%s\"?>\n"
+ "<!DOCTYPE cmml SYSTEM \"cmml.dtd\">\n", version, encoding, standalone);
+
+ if (attributes == NULL)
+ attributes = (guchar *) "";
+
+ if (parser->mode == GST_CMML_PARSER_ENCODE)
+ element = g_strdup_printf ("<?cmml %s?>", attributes);
+ else
+ element = g_strdup_printf ("<cmml %s>", attributes);
+
+ parser->preamble_callback (parser->user_data,
+ (guchar *) preamble, (guchar *) element);
+
+ g_free (preamble);
+ g_free (element);
+}
+
+/* parse the cmml stream tag */
+static void
+gst_cmml_parser_parse_stream (GstCmmlParser * parser, xmlNodePtr stream)
+{
+ GstCmmlTagStream *stream_tag;
+ GValue str_val = { 0 };
+ xmlNodePtr walk;
+ guchar *timebase;
+
+ g_value_init (&str_val, G_TYPE_STRING);
+
+ /* read the timebase and utc attributes */
+ timebase = xmlGetProp (stream, (xmlChar *) "timebase");
+ if (timebase == NULL)
+ timebase = (guchar *) g_strdup ("0");
+
+ stream_tag = g_object_new (GST_TYPE_CMML_TAG_STREAM,
+ "timebase", timebase, NULL);
+ g_free (timebase);
+
+ stream_tag->utc = xmlGetProp (stream, (xmlChar *) "utc");
+
+ /* walk the children nodes */
+ for (walk = stream->children; walk; walk = walk->next) {
+ /* for every import tag add its src attribute to stream_tag->imports */
+ if (!xmlStrcmp (walk->name, (xmlChar *) "import")) {
+ g_value_take_string (&str_val,
+ (gchar *) xmlGetProp (walk, (xmlChar *) "src"));
+
+ if (stream_tag->imports == NULL)
+ stream_tag->imports = g_value_array_new (0);
+
+ g_value_array_append (stream_tag->imports, &str_val);
+ }
+ }
+ g_value_unset (&str_val);
+
+ parser->stream_callback (parser->user_data, stream_tag);
+ g_object_unref (stream_tag);
+}
+
+/* parse the cmml head tag */
+static void
+gst_cmml_parser_parse_head (GstCmmlParser * parser, xmlNodePtr head)
+{
+ GstCmmlTagHead *head_tag;
+ xmlNodePtr walk;
+ GValue str_val = { 0 };
+
+ head_tag = g_object_new (GST_TYPE_CMML_TAG_HEAD, NULL);
+
+ g_value_init (&str_val, G_TYPE_STRING);
+
+ /* Parse the content of the node and setup the GST_TAG_CMML_HEAD tag.
+ * Create a GST_TAG_TITLE when we find the title element.
+ */
+ for (walk = head->children; walk; walk = walk->next) {
+ if (!xmlStrcmp (walk->name, (xmlChar *) "title")) {
+ head_tag->title = xmlNodeGetContent (walk);
+ } else if (!xmlStrcmp (walk->name, (xmlChar *) "base")) {
+ head_tag->base = xmlGetProp (walk, (xmlChar *) "uri");
+ } else if (!xmlStrcmp (walk->name, (xmlChar *) "meta")) {
+ if (head_tag->meta == NULL)
+ head_tag->meta = g_value_array_new (0);
+ /* add a pair name, content to the meta value array */
+ g_value_take_string (&str_val,
+ (gchar *) xmlGetProp (walk, (xmlChar *) "name"));
+ g_value_array_append (head_tag->meta, &str_val);
+ g_value_take_string (&str_val,
+ (gchar *) xmlGetProp (walk, (xmlChar *) "content"));
+ g_value_array_append (head_tag->meta, &str_val);
+ }
+ }
+ g_value_unset (&str_val);
+
+ parser->head_callback (parser->user_data, head_tag);
+ g_object_unref (head_tag);
+}
+
+/* parse a cmml clip tag */
+static void
+gst_cmml_parser_parse_clip (GstCmmlParser * parser, xmlNodePtr clip)
+{
+ GstCmmlTagClip *clip_tag;
+ GValue str_val = { 0 };
+ guchar *id, *track, *start, *end;
+ xmlNodePtr walk;
+ GstClockTime start_time = GST_CLOCK_TIME_NONE;
+ GstClockTime end_time = GST_CLOCK_TIME_NONE;
+
+ start = xmlGetProp (clip, (xmlChar *) "start");
+ if (parser->mode == GST_CMML_PARSER_ENCODE && start == NULL)
+ /* XXX: validate the document */
+ return;
+
+ id = xmlGetProp (clip, (xmlChar *) "id");
+ track = xmlGetProp (clip, (xmlChar *) "track");
+ end = xmlGetProp (clip, (xmlChar *) "end");
+
+ if (track == NULL)
+ track = (guchar *) g_strdup ("default");
+
+ if (start) {
+ if (!strncmp ((gchar *) start, "smpte", 5))
+ start_time = gst_cmml_clock_time_from_smpte ((gchar *) start);
+ else
+ start_time = gst_cmml_clock_time_from_npt ((gchar *) start);
+ }
+
+ if (end) {
+ if (!strncmp ((gchar *) end, "smpte", 5))
+ start_time = gst_cmml_clock_time_from_smpte ((gchar *) end);
+ else
+ end_time = gst_cmml_clock_time_from_npt ((gchar *) end);
+ }
+
+ clip_tag = g_object_new (GST_TYPE_CMML_TAG_CLIP, "id", id,
+ "track", track, "start-time", start_time, "end-time", end_time, NULL);
+
+ g_free (id);
+ g_free (track);
+ g_free (start);
+ g_free (end);
+
+ g_value_init (&str_val, G_TYPE_STRING);
+
+ /* parse the children */
+ for (walk = clip->children; walk; walk = walk->next) {
+ /* the clip is not empty */
+ clip_tag->empty = FALSE;
+
+ if (!xmlStrcmp (walk->name, (xmlChar *) "a")) {
+ clip_tag->anchor_href = xmlGetProp (walk, (xmlChar *) "href");
+ clip_tag->anchor_text = xmlNodeGetContent (walk);
+ } else if (!xmlStrcmp (walk->name, (xmlChar *) "img")) {
+ clip_tag->img_src = xmlGetProp (walk, (xmlChar *) "src");
+ clip_tag->img_alt = xmlGetProp (walk, (xmlChar *) "alt");
+ } else if (!xmlStrcmp (walk->name, (xmlChar *) "desc")) {
+ clip_tag->desc_text = xmlNodeGetContent (walk);
+ } else if (!xmlStrcmp (walk->name, (xmlChar *) "meta")) {
+ if (clip_tag->meta == NULL)
+ clip_tag->meta = g_value_array_new (0);
+ /* add a pair name, content to the meta value array */
+ g_value_take_string (&str_val,
+ (char *) xmlGetProp (walk, (xmlChar *) "name"));
+ g_value_array_append (clip_tag->meta, &str_val);
+ g_value_take_string (&str_val,
+ (char *) xmlGetProp (walk, (xmlChar *) "content"));
+ g_value_array_append (clip_tag->meta, &str_val);
+ }
+ }
+ g_value_unset (&str_val);
+
+ parser->clip_callback (parser->user_data, clip_tag);
+ g_object_unref (clip_tag);
+}
+
+void
+gst_cmml_parser_meta_to_string (GstCmmlParser * parser,
+ xmlNodePtr parent, GValueArray * array)
+{
+ gint i;
+ xmlNodePtr node;
+ GValue *name, *content;
+
+ for (i = 0; i < array->n_values - 1; i += 2) {
+ name = g_value_array_get_nth (array, i);
+ content = g_value_array_get_nth (array, i + 1);
+ node = gst_cmml_parser_new_node (parser, "meta",
+ "name", g_value_get_string (name),
+ "content", g_value_get_string (content), NULL);
+ xmlAddChild (parent, node);
+ }
+}
+
+static void
+gst_cmml_parser_generic_error (void *ctx, const char *msg, ...)
+{
+#ifndef GST_DISABLE_GST_DEBUG
+ va_list varargs;
+
+ va_start (varargs, msg);
+ gst_debug_log_valist (GST_CAT_DEFAULT, GST_LEVEL_WARNING,
+ "", "", 0, NULL, msg, varargs);
+ va_end (varargs);
+#endif /* GST_DISABLE_GST_DEBUG */
+}
+
+/* sax handler called when an element start tag is found
+ * this is used to parse the cmml start tag
+ */
+static void
+gst_cmml_parser_parse_start_element_ns (xmlParserCtxt * ctxt,
+ const xmlChar * name, const xmlChar * prefix, const xmlChar * URI,
+ int nb_preferences, const xmlChar ** namespaces,
+ int nb_attributes, int nb_defaulted, const xmlChar ** attributes)
+{
+ GstCmmlParser *parser = (GstCmmlParser *) ctxt->_private;
+
+ xmlSAX2StartElementNs (ctxt, name, prefix, URI, nb_preferences, namespaces,
+ nb_attributes, nb_defaulted, attributes);
+
+ if (parser->mode == GST_CMML_PARSER_ENCODE)
+ if (!xmlStrcmp (name, (xmlChar *) "cmml"))
+ if (parser->preamble_callback)
+ /* FIXME: parse attributes */
+ gst_cmml_parser_parse_preamble (parser, NULL);
+}
+
+/* sax processing instruction handler
+ * used to parse the cmml processing instruction
+ */
+static void
+gst_cmml_parser_parse_processing_instruction (xmlParserCtxtPtr ctxt,
+ const xmlChar * target, const xmlChar * data)
+{
+ GstCmmlParser *parser = (GstCmmlParser *) ctxt->_private;
+
+ xmlSAX2ProcessingInstruction (ctxt, target, data);
+
+ if (parser->mode == GST_CMML_PARSER_DECODE)
+ if (!xmlStrcmp (target, (xmlChar *) "cmml"))
+ if (parser->preamble_callback)
+ gst_cmml_parser_parse_preamble (parser, data);
+}
+
+/* sax handler called when an xml end tag is found
+ * used to parse the stream, head and clip nodes
+ */
+static void
+gst_cmml_parser_parse_end_element_ns (xmlParserCtxt * ctxt,
+ const xmlChar * name, const xmlChar * prefix, const xmlChar * URI)
+{
+ xmlNodePtr node;
+ GstCmmlParser *parser = (GstCmmlParser *) ctxt->_private;
+
+ xmlSAX2EndElementNs (ctxt, name, prefix, URI);
+
+ if (!xmlStrcmp (name, (xmlChar *) "clip")) {
+ if (parser->clip_callback) {
+ node = gst_cmml_parser_get_last_element (parser);
+ gst_cmml_parser_parse_clip (parser, node);
+ }
+ } else if (!xmlStrcmp (name, (xmlChar *) "cmml")) {
+ if (parser->cmml_end_callback)
+ parser->cmml_end_callback (parser->user_data);
+ } else if (!xmlStrcmp (name, (xmlChar *) "stream")) {
+ if (parser->stream_callback) {
+ node = gst_cmml_parser_get_last_element (parser);
+ gst_cmml_parser_parse_stream (parser, node);
+ }
+ } else if (!xmlStrcmp (name, (xmlChar *) "head")) {
+ if (parser->head_callback) {
+ node = gst_cmml_parser_get_last_element (parser);
+ gst_cmml_parser_parse_head (parser, node);
+ }
+ }
+}
diff --git a/ext/annodex/gstcmmlparser.h b/ext/annodex/gstcmmlparser.h
new file mode 100644
index 0000000..89c2bff
--- /dev/null
+++ b/ext/annodex/gstcmmlparser.h
@@ -0,0 +1,92 @@
+/*
+ * gstcmmlparser.h - GStreamer CMML document parser
+ * Copyright (C) 2005 Alessandro Decina
+ *
+ * Authors:
+ * Alessandro Decina <alessandro@nnva.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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.
+ */
+
+#ifndef __GST_CMML_PARSER_H__
+#define __GST_CMML_PARSER_H__
+
+#include <libxml/parser.h>
+#include <glib.h>
+
+#include "gstcmmltag.h"
+
+typedef struct _GstCmmlParser GstCmmlParser;
+typedef enum _GstCmmlParserMode GstCmmlParserMode;
+
+typedef void (*GstCmmlParserPreambleCallback) (void *user_data,
+ const guchar * xml_preamble, const guchar * cmml_attrs);
+
+typedef void (*GstCmmlParserCmmlEndCallback) (void *user_data);
+
+typedef void (*GstCmmlParserStreamCallback) (void *user_data,
+ GstCmmlTagStream * stream);
+
+typedef void (*GstCmmlParserHeadCallback) (void *user_data,
+ GstCmmlTagHead * head);
+
+typedef void (*GstCmmlParserClipCallback) (void *user_data,
+ GstCmmlTagClip * clip);
+
+enum _GstCmmlParserMode
+{
+ GST_CMML_PARSER_ENCODE,
+ GST_CMML_PARSER_DECODE
+};
+
+struct _GstCmmlParser
+{
+ GstCmmlParserMode mode;
+
+ xmlParserCtxtPtr context;
+
+ const gchar *preamble;
+ guint preamble_size;
+
+ void *user_data;
+ GstCmmlParserPreambleCallback preamble_callback;
+ GstCmmlParserStreamCallback stream_callback;
+ GstCmmlParserCmmlEndCallback cmml_end_callback;
+ GstCmmlParserHeadCallback head_callback;
+ GstCmmlParserClipCallback clip_callback;
+};
+
+void gst_cmml_parser_init (void);
+
+GstCmmlParser *gst_cmml_parser_new (GstCmmlParserMode mode);
+void gst_cmml_parser_free (GstCmmlParser * parser);
+
+gboolean gst_cmml_parser_parse_chunk (GstCmmlParser * parser,
+ const gchar * data, guint size, GError ** error);
+
+guchar *gst_cmml_parser_tag_stream_to_string (GstCmmlParser * parser,
+ GstCmmlTagStream * stream);
+
+guchar *gst_cmml_parser_tag_head_to_string (GstCmmlParser * parser,
+ GstCmmlTagHead * head);
+
+guchar *gst_cmml_parser_tag_clip_to_string (GstCmmlParser * parser,
+ GstCmmlTagClip * clip);
+
+guchar *gst_cmml_parser_tag_object_to_string (GstCmmlParser * parser,
+ GObject * tag);
+
+#endif /* __GST_CMML_PARSER_H__ */
diff --git a/ext/annodex/gstcmmltag.c b/ext/annodex/gstcmmltag.c
new file mode 100644
index 0000000..2cf5d5f
--- /dev/null
+++ b/ext/annodex/gstcmmltag.c
@@ -0,0 +1,579 @@
+/*
+ * gstcmmltags.c - GStreamer CMML tag support
+ * Copyright (C) 2005 Alessandro Decina
+ *
+ * Authors:
+ * Alessandro Decina <alessandro@nnva.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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 <string.h>
+
+#include "gstcmmlparser.h"
+#include "gstcmmltag.h"
+#include "gstannodex.h"
+
+enum
+{
+ ARG_0,
+ GST_CMML_TAG_STREAM_TIMEBASE,
+ GST_CMML_TAG_STREAM_UTC,
+ GST_CMML_TAG_STREAM_IMPORTS,
+ GST_CMML_TAG_HEAD_TITLE,
+ GST_CMML_TAG_HEAD_BASE,
+ GST_CMML_TAG_HEAD_META,
+ GST_CMML_TAG_CLIP_EMPTY,
+ GST_CMML_TAG_CLIP_ID,
+ GST_CMML_TAG_CLIP_TRACK,
+ GST_CMML_TAG_CLIP_START_TIME,
+ GST_CMML_TAG_CLIP_END_TIME,
+ GST_CMML_TAG_CLIP_ANCHOR_HREF,
+ GST_CMML_TAG_CLIP_ANCHOR_TEXT,
+ GST_CMML_TAG_CLIP_IMG_SRC,
+ GST_CMML_TAG_CLIP_IMG_ALT,
+ GST_CMML_TAG_CLIP_DESC_TEXT,
+ GST_CMML_TAG_CLIP_META,
+};
+
+G_DEFINE_TYPE (GstCmmlTagStream, gst_cmml_tag_stream, G_TYPE_OBJECT);
+static void gst_cmml_tag_stream_finalize (GObject * object);
+static void gst_cmml_tag_stream_set_property (GObject * object,
+ guint property_id, const GValue * value, GParamSpec * pspec);
+static void gst_cmml_tag_stream_get_property (GObject * object,
+ guint property_id, GValue * value, GParamSpec * pspec);
+static void gst_cmml_tag_stream_value_from_string_value (const GValue * src,
+ GValue * dest);
+
+G_DEFINE_TYPE (GstCmmlTagHead, gst_cmml_tag_head, G_TYPE_OBJECT);
+static void gst_cmml_tag_head_finalize (GObject * object);
+static void gst_cmml_tag_head_set_property (GObject * object, guint property_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_cmml_tag_head_get_property (GObject * object, guint property_id,
+ GValue * value, GParamSpec * pspec);
+static void gst_cmml_tag_head_value_from_string_value (const GValue * src,
+ GValue * dest);
+
+G_DEFINE_TYPE (GstCmmlTagClip, gst_cmml_tag_clip, G_TYPE_OBJECT);
+static void gst_cmml_tag_clip_finalize (GObject * object);
+static void gst_cmml_tag_clip_set_property (GObject * object, guint property_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_cmml_tag_clip_get_property (GObject * object, guint property_id,
+ GValue * value, GParamSpec * pspec);
+
+static void gst_cmml_tag_clip_value_from_string_value (const GValue * src,
+ GValue * dest);
+
+static void set_object_on_value (GObject * object, GValue * dest);
+
+static const gchar default_preamble[] =
+ "<?xml version=\"1.0\" standalone=\"yes\"?>";
+
+/* Stream tag */
+static void
+gst_cmml_tag_stream_class_init (GstCmmlTagStreamClass * stream_class)
+{
+ GObjectClass *klass = G_OBJECT_CLASS (stream_class);
+
+ klass->set_property = gst_cmml_tag_stream_set_property;
+ klass->get_property = gst_cmml_tag_stream_get_property;
+ klass->finalize = gst_cmml_tag_stream_finalize;
+
+ g_object_class_install_property (klass, GST_CMML_TAG_STREAM_TIMEBASE,
+ g_param_spec_string ("base-time",
+ "Base time",
+ "Playback time (in seconds) of the first data packet",
+ "0", G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (klass, GST_CMML_TAG_STREAM_UTC,
+ g_param_spec_string ("calendar-base-time",
+ "Calendar base time",
+ "Date and wall-clock time (expressed as UTC time in the format "
+ "YYYYMMDDTHHMMSS.sssZ) associated with the base-time",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (klass, GST_CMML_TAG_STREAM_IMPORTS,
+ g_param_spec_value_array ("input-streams",
+ "Input streams",
+ "List of input streams that compose this bitstream",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_value_register_transform_func (G_TYPE_STRING, GST_TYPE_CMML_TAG_STREAM,
+ gst_cmml_tag_stream_value_from_string_value);
+}
+
+static void
+gst_cmml_tag_stream_init (GstCmmlTagStream * stream)
+{
+}
+
+static void
+gst_cmml_tag_stream_finalize (GObject * object)
+{
+ GstCmmlTagStream *stream = GST_CMML_TAG_STREAM (object);
+
+ g_free (stream->timebase);
+ g_free (stream->utc);
+ if (stream->imports)
+ g_value_array_free (stream->imports);
+
+ if (G_OBJECT_CLASS (gst_cmml_tag_stream_parent_class)->finalize)
+ G_OBJECT_CLASS (gst_cmml_tag_stream_parent_class)->finalize (object);
+}
+
+static void
+gst_cmml_tag_stream_set_property (GObject * object, guint property_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstCmmlTagStream *stream = GST_CMML_TAG_STREAM (object);
+
+ switch (property_id) {
+ case GST_CMML_TAG_STREAM_TIMEBASE:
+ g_free (stream->timebase);
+ stream->timebase = (guchar *) g_value_dup_string (value);
+ break;
+ case GST_CMML_TAG_STREAM_UTC:
+ g_free (stream->utc);
+ stream->utc = (guchar *) g_value_dup_string (value);
+ break;
+ case GST_CMML_TAG_STREAM_IMPORTS:
+ {
+ GValueArray *va = g_value_get_boxed (value);
+
+ if (stream->imports)
+ g_value_array_free (stream->imports);
+ stream->imports = va != NULL ? g_value_array_copy (va) : NULL;
+ break;
+ }
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+
+static void
+gst_cmml_tag_stream_value_from_string_value (const GValue * src, GValue * dest)
+{
+ GstCmmlParser *parser;
+ const gchar *str;
+ guint size;
+
+ parser = gst_cmml_parser_new (GST_CMML_PARSER_DECODE);
+ parser->user_data = dest;
+ parser->stream_callback = (GstCmmlParserStreamCallback) set_object_on_value;
+ gst_cmml_parser_parse_chunk (parser,
+ default_preamble, strlen (default_preamble), NULL);
+
+ str = g_value_get_string (src);
+ size = strlen (str);
+ gst_cmml_parser_parse_chunk (parser, str, size, NULL);
+
+ gst_cmml_parser_free (parser);
+}
+
+static void
+gst_cmml_tag_stream_get_property (GObject * object, guint property_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GstCmmlTagStream *stream = GST_CMML_TAG_STREAM (object);
+
+ switch (property_id) {
+ case GST_CMML_TAG_STREAM_TIMEBASE:
+ g_value_set_string (value, (gchar *) stream->timebase);
+ break;
+ case GST_CMML_TAG_STREAM_UTC:
+ g_value_set_string (value, (gchar *) stream->utc);
+ break;
+ case GST_CMML_TAG_STREAM_IMPORTS:
+ g_value_set_boxed (value, stream->imports);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+/* Head tag */
+static void
+gst_cmml_tag_head_class_init (GstCmmlTagHeadClass * head_class)
+{
+ GObjectClass *klass = G_OBJECT_CLASS (head_class);
+
+ klass->set_property = gst_cmml_tag_head_set_property;
+ klass->get_property = gst_cmml_tag_head_get_property;
+ klass->finalize = gst_cmml_tag_head_finalize;
+
+ g_object_class_install_property (klass, GST_CMML_TAG_HEAD_TITLE,
+ g_param_spec_string ("title",
+ "Title",
+ "Title of the bitstream",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (klass, GST_CMML_TAG_HEAD_BASE,
+ g_param_spec_string ("base-uri",
+ "Base URI",
+ "Base URI of the bitstream. All relative URIs are relative to this",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (klass, GST_CMML_TAG_HEAD_META,
+ g_param_spec_value_array ("meta",
+ "Meta annotations",
+ "Meta annotations for the complete Annodex bitstream",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_value_register_transform_func (G_TYPE_STRING, GST_TYPE_CMML_TAG_HEAD,
+ gst_cmml_tag_head_value_from_string_value);
+}
+
+static void
+gst_cmml_tag_head_init (GstCmmlTagHead * head)
+{
+}
+
+static void
+gst_cmml_tag_head_finalize (GObject * object)
+{
+ GstCmmlTagHead *head = GST_CMML_TAG_HEAD (object);
+
+ g_free (head->title);
+ g_free (head->base);
+ if (head->meta)
+ g_value_array_free (head->meta);
+
+ if (G_OBJECT_CLASS (gst_cmml_tag_head_parent_class)->finalize)
+ G_OBJECT_CLASS (gst_cmml_tag_head_parent_class)->finalize (object);
+}
+
+static void
+gst_cmml_tag_head_set_property (GObject * object, guint property_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstCmmlTagHead *head = GST_CMML_TAG_HEAD (object);
+
+ switch (property_id) {
+ case GST_CMML_TAG_HEAD_TITLE:
+ g_free (head->title);
+ head->title = (guchar *) g_value_dup_string (value);
+ break;
+ case GST_CMML_TAG_HEAD_BASE:
+ g_free (head->base);
+ head->base = (guchar *) g_value_dup_string (value);
+ break;
+ case GST_CMML_TAG_HEAD_META:
+ {
+ GValueArray *va = g_value_get_boxed (value);
+
+ if (head->meta)
+ g_value_array_free (head->meta);
+ head->meta = va != NULL ? g_value_array_copy (va) : NULL;
+ break;
+ }
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+gst_cmml_tag_head_get_property (GObject * object, guint property_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GstCmmlTagHead *head = GST_CMML_TAG_HEAD (object);
+
+ switch (property_id) {
+ case GST_CMML_TAG_HEAD_TITLE:
+ g_value_set_string (value, (gchar *) head->title);
+ break;
+ case GST_CMML_TAG_HEAD_BASE:
+ g_value_set_string (value, (gchar *) head->base);
+ break;
+ case GST_CMML_TAG_HEAD_META:
+ g_value_set_boxed (value, head->meta);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+gst_cmml_tag_head_value_from_string_value (const GValue * src, GValue * dest)
+{
+ GstCmmlParser *parser;
+ const gchar *str;
+ guint size;
+
+ parser = gst_cmml_parser_new (GST_CMML_PARSER_DECODE);
+ parser->user_data = dest;
+ parser->head_callback = (GstCmmlParserHeadCallback) set_object_on_value;
+ gst_cmml_parser_parse_chunk (parser,
+ default_preamble, strlen (default_preamble), NULL);
+
+ str = g_value_get_string (src);
+ size = strlen (str);
+ gst_cmml_parser_parse_chunk (parser, str, size, NULL);
+
+ gst_cmml_parser_free (parser);
+}
+
+/* Clip tag */
+static void
+gst_cmml_tag_clip_class_init (GstCmmlTagClipClass * clip_class)
+{
+ GObjectClass *klass = G_OBJECT_CLASS (clip_class);
+
+ klass->set_property = gst_cmml_tag_clip_set_property;
+ klass->get_property = gst_cmml_tag_clip_get_property;
+ klass->finalize = gst_cmml_tag_clip_finalize;
+
+ g_object_class_install_property (klass, GST_CMML_TAG_CLIP_EMPTY,
+ g_param_spec_boolean ("empty",
+ "Empty clip flag",
+ "An empty clip only marks the end of the previous clip",
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (klass, GST_CMML_TAG_CLIP_ID,
+ g_param_spec_string ("id",
+ "Clip id",
+ "Id of the clip", NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (klass, GST_CMML_TAG_CLIP_TRACK,
+ g_param_spec_string ("track",
+ "Track number",
+ "The track this clip belongs to",
+ "default",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (klass, GST_CMML_TAG_CLIP_START_TIME,
+ g_param_spec_uint64 ("start-time",
+ "Start time",
+ "The start time (in seconds) of the clip",
+ 0, G_MAXUINT64, GST_CLOCK_TIME_NONE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (klass, GST_CMML_TAG_CLIP_END_TIME,
+ g_param_spec_uint64 ("end-time",
+ "End time",
+ "The end time (in seconds) of the clip (only set if extract-mode=true)",
+ 0, G_MAXUINT64, GST_CLOCK_TIME_NONE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (klass, GST_CMML_TAG_CLIP_ANCHOR_HREF,
+ g_param_spec_string ("anchor-uri",
+ "Anchor URI",
+ "The location of a Web resource closely connected to the clip",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (klass, GST_CMML_TAG_CLIP_ANCHOR_TEXT,
+ g_param_spec_string ("anchor-text",
+ "Anchor text",
+ "A short description of the resource pointed by anchor-uri",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (klass, GST_CMML_TAG_CLIP_IMG_SRC,
+ g_param_spec_string ("img-uri",
+ "Image URI",
+ "The URI of a representative image for the clip",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (klass, GST_CMML_TAG_CLIP_IMG_ALT,
+ g_param_spec_string ("img-alt",
+ "Image alternative text",
+ "Alternative text to be displayed instead of the image "
+ "specified in img-uri", NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (klass, GST_CMML_TAG_CLIP_DESC_TEXT,
+ g_param_spec_string ("description",
+ "Description",
+ "A textual description of the content of the clip",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (klass, GST_CMML_TAG_CLIP_META,
+ g_param_spec_value_array ("meta",
+ "Meta annotations",
+ "Meta annotations for the clip",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ g_value_register_transform_func (G_TYPE_STRING, GST_TYPE_CMML_TAG_CLIP,
+ gst_cmml_tag_clip_value_from_string_value);
+}
+
+static void
+gst_cmml_tag_clip_init (GstCmmlTagClip * clip)
+{
+}
+
+static void
+gst_cmml_tag_clip_finalize (GObject * object)
+{
+ GstCmmlTagClip *clip = GST_CMML_TAG_CLIP (object);
+
+ g_free (clip->id);
+ g_free (clip->track);
+ g_free (clip->anchor_href);
+ g_free (clip->anchor_text);
+ g_free (clip->img_src);
+ g_free (clip->img_alt);
+ g_free (clip->desc_text);
+ if (clip->meta)
+ g_value_array_free (clip->meta);
+
+ if (G_OBJECT_CLASS (gst_cmml_tag_clip_parent_class)->finalize)
+ G_OBJECT_CLASS (gst_cmml_tag_clip_parent_class)->finalize (object);
+}
+
+static void
+gst_cmml_tag_clip_set_property (GObject * object, guint property_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstCmmlTagClip *clip = GST_CMML_TAG_CLIP (object);
+
+ switch (property_id) {
+ case GST_CMML_TAG_CLIP_EMPTY:
+ clip->empty = g_value_get_boolean (value);
+ break;
+ case GST_CMML_TAG_CLIP_ID:
+ g_free (clip->id);
+ clip->id = (guchar *) g_value_dup_string (value);
+ break;
+ case GST_CMML_TAG_CLIP_TRACK:
+ g_free (clip->track);
+ clip->track = (guchar *) g_value_dup_string (value);
+ break;
+ case GST_CMML_TAG_CLIP_START_TIME:
+ clip->start_time = g_value_get_uint64 (value);
+ break;
+ case GST_CMML_TAG_CLIP_END_TIME:
+ clip->end_time = g_value_get_uint64 (value);
+ break;
+ case GST_CMML_TAG_CLIP_ANCHOR_HREF:
+ g_free (clip->anchor_href);
+ clip->anchor_href = (guchar *) g_value_dup_string (value);
+ break;
+ case GST_CMML_TAG_CLIP_ANCHOR_TEXT:
+ g_free (clip->anchor_text);
+ clip->anchor_text = (guchar *) g_value_dup_string (value);
+ break;
+ case GST_CMML_TAG_CLIP_IMG_SRC:
+ g_free (clip->img_src);
+ clip->img_src = (guchar *) g_value_dup_string (value);
+ break;
+ case GST_CMML_TAG_CLIP_IMG_ALT:
+ g_free (clip->img_alt);
+ clip->img_alt = (guchar *) g_value_dup_string (value);
+ break;
+ case GST_CMML_TAG_CLIP_DESC_TEXT:
+ g_free (clip->desc_text);
+ clip->desc_text = (guchar *) g_value_dup_string (value);
+ break;
+ case GST_CMML_TAG_CLIP_META:
+ {
+ GValueArray *va = (GValueArray *) g_value_get_boxed (value);
+
+ if (clip->meta)
+ g_value_array_free (clip->meta);
+
+ clip->meta = va != NULL ? g_value_array_copy (va) : NULL;
+
+ break;
+ }
+ }
+}
+
+static void
+gst_cmml_tag_clip_get_property (GObject * object, guint property_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GstCmmlTagClip *clip = GST_CMML_TAG_CLIP (object);
+
+ switch (property_id) {
+ case GST_CMML_TAG_CLIP_EMPTY:
+ g_value_set_boolean (value, clip->empty);
+ break;
+ case GST_CMML_TAG_CLIP_ID:
+ g_value_set_string (value, (gchar *) clip->id);
+ break;
+ case GST_CMML_TAG_CLIP_TRACK:
+ g_value_set_string (value, (gchar *) clip->track);
+ break;
+ case GST_CMML_TAG_CLIP_START_TIME:
+ g_value_set_uint64 (value, clip->start_time);
+ break;
+ case GST_CMML_TAG_CLIP_END_TIME:
+ g_value_set_uint64 (value, clip->end_time);
+ break;
+ case GST_CMML_TAG_CLIP_ANCHOR_HREF:
+ g_value_set_string (value, (gchar *) clip->anchor_href);
+ break;
+ case GST_CMML_TAG_CLIP_ANCHOR_TEXT:
+ g_value_set_string (value, (gchar *) clip->anchor_text);
+ break;
+ case GST_CMML_TAG_CLIP_IMG_SRC:
+ g_value_set_string (value, (gchar *) clip->img_src);
+ break;
+ case GST_CMML_TAG_CLIP_IMG_ALT:
+ g_value_set_string (value, (gchar *) clip->img_alt);
+ break;
+ case GST_CMML_TAG_CLIP_DESC_TEXT:
+ g_value_set_string (value, (gchar *) clip->desc_text);
+ break;
+ case GST_CMML_TAG_CLIP_META:
+ g_value_set_boxed (value, clip->meta);
+ break;
+ }
+}
+
+static void
+gst_cmml_tag_clip_value_from_string_value (const GValue * src, GValue * dest)
+{
+ GstCmmlParser *parser;
+ const gchar *str;
+ guint size;
+
+ parser = gst_cmml_parser_new (GST_CMML_PARSER_DECODE);
+ parser->user_data = dest;
+ parser->clip_callback = (GstCmmlParserClipCallback) set_object_on_value;
+
+ gst_cmml_parser_parse_chunk (parser, default_preamble,
+ strlen (default_preamble), NULL);
+
+ str = g_value_get_string (src);
+ size = strlen (str);
+
+ gst_cmml_parser_parse_chunk (parser, str, size, NULL);
+
+ gst_cmml_parser_free (parser);
+}
+
+static void
+set_object_on_value (GObject * tag, GValue * dest)
+{
+ g_value_take_object (dest, tag);
+}
diff --git a/ext/annodex/gstcmmltag.h b/ext/annodex/gstcmmltag.h
new file mode 100644
index 0000000..e8c9bbb
--- /dev/null
+++ b/ext/annodex/gstcmmltag.h
@@ -0,0 +1,133 @@
+/*
+ * gstcmmltag.h - GStreamer annodex CMML tag support
+ * Copyright (C) 2005 Alessandro Decina
+ *
+ * Authors:
+ * Alessandro Decina <alessandro@nnva.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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.
+ */
+
+#ifndef __GST_CMML_TAG_H__
+#define __GST_CMML_TAG_H__
+
+#include <gst/gst.h>
+
+/* GstCmmlTagStream */
+#define GST_TYPE_CMML_TAG_STREAM (gst_cmml_tag_stream_get_type ())
+#define GST_CMML_TAG_STREAM(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GST_TYPE_CMML_TAG_STREAM, GstCmmlTagStream))
+#define GST_CMML_TAG_STREAM_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ GST_TYPE_CMML_TAG_STREAM, GstCmmlTagStreamClass))
+#define GST_CMML_TAG_STREAM_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ GST_TYPE_CMML_TAG_STREAM, GstCmmlTagStreamClass))
+
+/* GstCmmlTagHead */
+#define GST_TYPE_CMML_TAG_HEAD (gst_cmml_tag_head_get_type ())
+#define GST_CMML_TAG_HEAD(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_CMML_TAG_HEAD, GstCmmlTagHead))
+#define GST_CMML_TAG_HEAD_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_CMML_TAG_HEAD, GstCmmlTagHeadClass))
+#define GST_CMML_TAG_HEAD_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ GST_TYPE_CMML_TAG_HEAD, GstCmmlTagHeadClass))
+
+/* GstCmmlTagClip */
+#define GST_TYPE_CMML_TAG_CLIP (gst_cmml_tag_clip_get_type ())
+#define GST_CMML_TAG_CLIP(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_CMML_TAG_CLIP, GstCmmlTagClip))
+#define GST_CMML_TAG_CLIP_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_CMML_TAG_CLIP, GstCmmlTagClipClass))
+#define GST_CMML_TAG_CLIP_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ GST_TYPE_CMML_TAG_CLIP, GstCmmlTagClipClass))
+
+typedef struct _GstCmmlTagStream GstCmmlTagStream;
+typedef struct _GstCmmlTagStreamClass GstCmmlTagStreamClass;
+typedef struct _GstCmmlTagHead GstCmmlTagHead;
+typedef struct _GstCmmlTagHeadClass GstCmmlTagHeadClass;
+typedef struct _GstCmmlTagClip GstCmmlTagClip;
+typedef struct _GstCmmlTagClipClass GstCmmlTagClipClass;
+
+struct _GstCmmlTagStream {
+ GObject object;
+
+ guchar *timebase;
+ guchar *utc;
+
+ GValueArray *imports;
+};
+
+struct _GstCmmlTagStreamClass {
+ GObjectClass parent_class;
+};
+
+struct _GstCmmlTagHead {
+ GObject object;
+
+ guchar *title; /* title of the media */
+ guchar *base;
+ GValueArray *meta; /* metadata attached to the media.
+ * The elements are positioned in key-value
+ * pairs ie (key, content, key2, content2,
+ * ...)
+ */
+};
+
+struct _GstCmmlTagHeadClass {
+ GObjectClass parent_class;
+};
+
+struct _GstCmmlTagClip {
+ GObject object;
+
+ gboolean empty; /* empty flag. An empty clip marks the
+ * end of the previous clip.
+ */
+
+ guchar *id; /* clip id */
+ guchar *track; /* clip track */
+
+ GstClockTime start_time; /* clip start time */
+ GstClockTime end_time; /* clip end time */
+
+ guchar *anchor_href; /* anchor href URI */
+ guchar *anchor_text; /* anchor text */
+
+ guchar *img_src; /* image URI */
+ guchar *img_alt; /* image alternative text */
+
+ guchar *desc_text; /* clip description */
+
+ GValueArray *meta; /* metadata attached to the clip
+ * The elements are positioned in key-value
+ * pairs ie (key, content, key2, content2,
+ * ...)
+ */
+};
+
+struct _GstCmmlTagClipClass {
+ GObjectClass parent_class;
+};
+
+GType gst_cmml_tag_stream_get_type (void);
+GType gst_cmml_tag_head_get_type (void);
+GType gst_cmml_tag_clip_get_type (void);
+
+#endif /* __GST_CMML_TAG_H__ */
diff --git a/ext/annodex/gstcmmlutils.c b/ext/annodex/gstcmmlutils.c
new file mode 100644
index 0000000..a66b3f0
--- /dev/null
+++ b/ext/annodex/gstcmmlutils.c
@@ -0,0 +1,388 @@
+/*
+ * gstcmmlutils.c - GStreamer CMML utility functions
+ * Copyright (C) 2005 Alessandro Decina
+ *
+ * Authors:
+ * Alessandro Decina <alessandro@nnva.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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.
+ */
+
+#include "gstcmmlutils.h"
+
+#include <math.h>
+#include <stdio.h>
+#include <string.h>
+
+typedef struct
+{
+ GList *clips;
+ gpointer user_data;
+} GstCmmlTrack;
+
+GstClockTime
+gst_cmml_clock_time_from_npt (const gchar * time)
+{
+ GstClockTime res;
+ gint fields;
+ gint hours = 0;
+ gint minutes = 0;
+ gint seconds = 0;
+ gint mseconds = 0;
+ GstClockTime hours_t = 0, seconds_t = 0;
+
+ if (!strncmp (time, "npt:", 4))
+ time += 4;
+
+ /* parse npt-hhmmss */
+ fields = sscanf (time, "%d:%d:%d.%d", &hours, &minutes, &seconds, &mseconds);
+ if (fields == 4) {
+ if (hours < 0 || (guint) minutes > 59 || (guint) seconds > 59)
+ goto bad_input;
+
+ hours_t = gst_util_uint64_scale (hours, GST_SECOND * 3600, 1);
+ if (hours_t == G_MAXUINT64)
+ goto overflow;
+
+ seconds_t = seconds * GST_SECOND;
+ } else {
+ guint64 u64seconds;
+
+ /* parse npt-sec */
+ hours_t = 0;
+ minutes = 0;
+ fields = sscanf (time, "%" G_GUINT64_FORMAT ".%d", &u64seconds, &mseconds);
+ if (seconds < 0)
+ goto bad_input;
+
+ seconds_t = gst_util_uint64_scale_int (u64seconds, GST_SECOND, 1);
+ if (seconds_t == G_MAXUINT64)
+ goto overflow;
+ }
+
+ if ((guint) mseconds > 999)
+ goto bad_input;
+
+ res = (minutes * 60) * GST_SECOND + mseconds * GST_MSECOND;
+ if (G_MAXUINT64 - hours_t - seconds_t < res)
+ goto overflow;
+
+ res += hours_t + seconds_t;
+
+ return res;
+
+bad_input:
+overflow:
+ return GST_CLOCK_TIME_NONE;
+}
+
+GstClockTime
+gst_cmml_clock_time_from_smpte (const gchar * time)
+{
+ GstClockTime res;
+ GstClockTime hours_t;
+ gint hours, minutes, seconds;
+ gdouble framerate;
+ gfloat frames;
+ gint fields;
+
+ if (!strncmp (time, "smpte-24:", 9)) {
+ framerate = 24.0;
+ time += 9;
+ } else if (!strncmp (time, "smpte-24-drop:", 14)) {
+ framerate = 23.976;
+ time += 14;
+ } else if (!strncmp (time, "smpte-25:", 9)) {
+ framerate = 25.0;
+ time += 9;
+ } else if (!strncmp (time, "smpte-30:", 9)) {
+ framerate = 30.0;
+ time += 9;
+ } else if (!strncmp (time, "smpte-30-drop:", 14)) {
+ framerate = 29.976;
+ time += 14;
+ } else if (!strncmp (time, "smpte-50:", 9)) {
+ framerate = 50.0;
+ time += 9;
+ } else if (!strncmp (time, "smpte-60:", 9)) {
+ framerate = 60.0;
+ time += 9;
+ } else if (!strncmp (time, "smpte-60-drop:", 14)) {
+ framerate = 59.94;
+ time += 14;
+ } else {
+ return GST_CLOCK_TIME_NONE;
+ }
+
+ fields = sscanf (time, "%d:%d:%d:%f", &hours, &minutes, &seconds, &frames);
+ if (fields == 4) {
+ if (hours < 0 || (guint) minutes > 59 || (guint) seconds > 59 ||
+ frames < 0 || frames > ceil (framerate)) {
+ res = GST_CLOCK_TIME_NONE;
+ } else {
+ hours_t = gst_util_uint64_scale (hours, GST_SECOND * 3600, 1);
+ if (hours_t == G_MAXUINT64)
+ goto overflow;
+
+ res = ((minutes * 60) + seconds + (frames / framerate))
+ * GST_SECOND;
+ if (G_MAXUINT64 - hours_t < res)
+ goto overflow;
+
+ res = hours_t + res;
+ }
+ } else {
+ res = GST_CLOCK_TIME_NONE;
+ }
+
+ return res;
+overflow:
+ return GST_CLOCK_TIME_NONE;
+}
+
+gchar *
+gst_cmml_clock_time_to_npt (const GstClockTime time)
+{
+ guint seconds, hours, minutes, mseconds;
+ gchar *res;
+
+ g_return_val_if_fail (time != GST_CLOCK_TIME_NONE, NULL);
+
+ hours = time / (GST_SECOND * 3600);
+ minutes = (time / ((GST_SECOND * 60)) % 60);
+ seconds = (time / GST_SECOND) % 60;
+ mseconds = (time % GST_SECOND) / GST_MSECOND;
+
+ if (mseconds < 100)
+ mseconds *= 10;
+
+ res = g_strdup_printf ("%u:%02u:%02u.%03u",
+ hours, minutes, seconds, mseconds);
+
+ return res;
+}
+
+gint64
+gst_cmml_clock_time_to_granule (GstClockTime prev_time,
+ GstClockTime current_time, gint64 granulerate_n, gint64 granulerate_d,
+ guint8 granuleshift)
+{
+ guint64 keyindex, keyoffset, granulepos, maxoffset;
+ gint64 granulerate;
+
+ g_return_val_if_fail (granulerate_d != 0, -1);
+ g_return_val_if_fail (granuleshift > 0, -1);
+ g_return_val_if_fail (granuleshift <= 64, -1);
+
+ if (prev_time == GST_CLOCK_TIME_NONE)
+ prev_time = 0;
+
+ if (prev_time > current_time)
+ return -1;
+
+ /* GST_SECOND / (granulerate_n / granulerate_d) */
+ granulerate = gst_util_uint64_scale (GST_SECOND,
+ granulerate_d, granulerate_n);
+
+ prev_time = prev_time / granulerate;
+
+ /* granuleshift == 64 should be a << 0 shift, which is defined */
+ maxoffset = ((guint64) 1 << (64 - granuleshift)) - 1;
+ if (prev_time > maxoffset)
+ /* we need more than 64 - granuleshift bits to encode prev_time */
+ goto overflow;
+
+ keyindex = prev_time << granuleshift;
+
+ keyoffset = (current_time / granulerate) - prev_time;
+ /* make sure we don't shift to the limits of the types as this is undefined. */
+ if (granuleshift == 64)
+ maxoffset = G_MAXUINT64;
+ else
+ maxoffset = ((guint64) 1 << granuleshift) - 1;
+
+ if (keyoffset > maxoffset)
+ /* we need more than granuleshift bits to encode prev_time - current_time */
+ goto overflow;
+
+ granulepos = keyindex + keyoffset;
+
+ return granulepos;
+
+overflow:
+ return -1;
+}
+
+/* track list */
+GHashTable *
+gst_cmml_track_list_new (void)
+{
+ return g_hash_table_new (g_str_hash, g_str_equal);
+}
+
+static gboolean
+gst_cmml_track_list_destroy_track (gchar * key,
+ GstCmmlTrack * track, gpointer user_data)
+{
+ GList *walk;
+
+ for (walk = track->clips; walk; walk = g_list_next (walk))
+ g_object_unref (G_OBJECT (walk->data));
+
+ g_free (key);
+ g_list_free (track->clips);
+ g_free (track);
+
+ return TRUE;
+}
+
+void
+gst_cmml_track_list_destroy (GHashTable * tracks)
+{
+ g_hash_table_foreach_remove (tracks,
+ (GHRFunc) gst_cmml_track_list_destroy_track, NULL);
+ g_hash_table_destroy (tracks);
+}
+
+static gint
+gst_cmml_track_list_compare_clips (GstCmmlTagClip * a, GstCmmlTagClip * b)
+{
+ if (a->start_time < b->start_time)
+ return -1;
+
+ return 1;
+}
+
+void
+gst_cmml_track_list_add_clip (GHashTable * tracks, GstCmmlTagClip * clip)
+{
+ gpointer key, value;
+ GstCmmlTrack *track;
+ gchar *track_name;
+
+ g_return_if_fail (clip->track != NULL);
+
+ if (g_hash_table_lookup_extended (tracks, clip->track, &key, &value)) {
+ track_name = (gchar *) key;
+ track = (GstCmmlTrack *) value;
+ } else {
+ track_name = g_strdup ((gchar *) clip->track);
+ track = g_new0 (GstCmmlTrack, 1);
+ g_hash_table_insert (tracks, track_name, track);
+ }
+
+ /* add clip to the tracklist */
+ track->clips = g_list_insert_sorted (track->clips, g_object_ref (clip),
+ (GCompareFunc) gst_cmml_track_list_compare_clips);
+}
+
+gboolean
+gst_cmml_track_list_del_clip (GHashTable * tracks, GstCmmlTagClip * clip)
+{
+ GstCmmlTrack *track;
+ GList *link;
+ gboolean res = FALSE;
+
+ g_return_val_if_fail (clip->track != NULL, FALSE);
+
+ track = g_hash_table_lookup (tracks, clip->track);
+ if (track) {
+ link = g_list_find (track->clips, clip);
+ if (link) {
+ g_object_unref (G_OBJECT (link->data));
+ track->clips = g_list_delete_link (track->clips, link);
+ res = TRUE;
+ }
+ }
+
+ return res;
+}
+
+gboolean
+gst_cmml_track_list_has_clip (GHashTable * tracks, GstCmmlTagClip * clip)
+{
+ GstCmmlTrack *track;
+ GList *walk;
+ GstCmmlTagClip *tmp;
+ gboolean res = FALSE;
+
+ track = g_hash_table_lookup (tracks, (gchar *) clip->track);
+ if (track) {
+ for (walk = track->clips; walk; walk = g_list_next (walk)) {
+ tmp = GST_CMML_TAG_CLIP (walk->data);
+ if (tmp->start_time == clip->start_time) {
+ res = TRUE;
+ break;
+ }
+ }
+ }
+
+ return res;
+}
+
+static gboolean
+gst_cmml_track_list_merge_track (gchar * track_name,
+ GstCmmlTrack * track, GList ** list)
+{
+ GList *walk;
+ GstCmmlTagClip *cur;
+
+ for (walk = track->clips; walk; walk = g_list_next (walk)) {
+ cur = GST_CMML_TAG_CLIP (walk->data);
+ *list = g_list_insert_sorted (*list, cur,
+ (GCompareFunc) gst_cmml_track_list_compare_clips);
+ }
+
+ return TRUE;
+}
+
+GList *
+gst_cmml_track_list_get_track_clips (GHashTable * tracks,
+ const gchar * track_name)
+{
+ GstCmmlTrack *track;
+
+ g_return_val_if_fail (track_name != NULL, NULL);
+
+ track = g_hash_table_lookup (tracks, track_name);
+ return track ? track->clips : NULL;
+}
+
+GList *
+gst_cmml_track_list_get_clips (GHashTable * tracks)
+{
+ GList *list = NULL;
+
+ g_hash_table_foreach (tracks,
+ (GHFunc) gst_cmml_track_list_merge_track, &list);
+ return list;
+}
+
+GstCmmlTagClip *
+gst_cmml_track_list_get_track_last_clip (GHashTable * tracks,
+ const gchar * track_name)
+{
+ GstCmmlTrack *track;
+ GList *res = NULL;
+
+ g_return_val_if_fail (track_name != NULL, NULL);
+
+ track = g_hash_table_lookup (tracks, track_name);
+ if (track && track->clips)
+ res = g_list_last (track->clips);
+
+ return res ? GST_CMML_TAG_CLIP (res->data) : NULL;
+}
diff --git a/ext/annodex/gstcmmlutils.h b/ext/annodex/gstcmmlutils.h
new file mode 100644
index 0000000..5aa2416
--- /dev/null
+++ b/ext/annodex/gstcmmlutils.h
@@ -0,0 +1,53 @@
+/*
+ * gstcmmlutils.h - GStreamer CMML utility functions
+ * Copyright (C) 2005 Alessandro Decina
+ *
+ * Authors:
+ * Alessandro Decina <alessandro@nnva.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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.
+ */
+
+#ifndef __GST_CMML_CLOCK_TIME_H__
+#define __GST_CMML_CLOCK_TIME_H__
+
+#include <gst/gst.h>
+#include "gstcmmltag.h"
+
+/* time utils */
+GstClockTime gst_cmml_clock_time_from_npt (const gchar * time);
+GstClockTime gst_cmml_clock_time_from_smpte (const gchar * time);
+gchar * gst_cmml_clock_time_to_npt (const GstClockTime time);
+gint64 gst_cmml_clock_time_to_granule (GstClockTime prev_time,
+ GstClockTime current_time, gint64 granulerate_n, gint64 granulerate_d,
+ guint8 granuleshift);
+
+/* tracklist */
+GHashTable * gst_cmml_track_list_new (void);
+void gst_cmml_track_list_destroy (GHashTable * tracks);
+void gst_cmml_track_list_add_clip (GHashTable * tracks, GstCmmlTagClip * clip);
+gboolean gst_cmml_track_list_del_clip (GHashTable * tracks,
+ GstCmmlTagClip * clip);
+gboolean gst_cmml_track_list_has_clip (GHashTable * tracks,
+ GstCmmlTagClip * clip);
+GstCmmlTagClip * gst_cmml_track_list_get_track_last_clip (GHashTable * tracks,
+ const gchar * track_name);
+GList * gst_cmml_track_list_get_track_clips (GHashTable * tracks,
+ const gchar * track_name);
+GList * gst_cmml_track_list_get_clips (GHashTable * tracks);
+void gst_cmml_track_list_set_track_data (GHashTable * tracks, gpointer data);
+gpointer gst_cmml_track_list_get_track_data (GHashTable * tracks);
+#endif /* __GST_CMML_CLOCK_TIME_H__ */