summaryrefslogtreecommitdiff
path: root/libjava/classpath/native/jni/gstreamer-peer
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libjava/classpath/native/jni/gstreamer-peer
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libjava/classpath/native/jni/gstreamer-peer')
-rw-r--r--libjava/classpath/native/jni/gstreamer-peer/Makefile.am29
-rw-r--r--libjava/classpath/native/jni/gstreamer-peer/Makefile.in637
-rw-r--r--libjava/classpath/native/jni/gstreamer-peer/gst_classpath_src.c408
-rw-r--r--libjava/classpath/native/jni/gstreamer-peer/gst_classpath_src.h88
-rw-r--r--libjava/classpath/native/jni/gstreamer-peer/gst_input_stream.c290
-rw-r--r--libjava/classpath/native/jni/gstreamer-peer/gst_input_stream.h71
-rw-r--r--libjava/classpath/native/jni/gstreamer-peer/gst_native_data_line.c251
-rw-r--r--libjava/classpath/native/jni/gstreamer-peer/gst_native_pipeline.c611
-rw-r--r--libjava/classpath/native/jni/gstreamer-peer/gst_native_pipeline.h63
-rw-r--r--libjava/classpath/native/jni/gstreamer-peer/gst_peer.c83
-rw-r--r--libjava/classpath/native/jni/gstreamer-peer/gst_peer.h59
-rw-r--r--libjava/classpath/native/jni/gstreamer-peer/gstreamer_io_peer.c739
12 files changed, 3329 insertions, 0 deletions
diff --git a/libjava/classpath/native/jni/gstreamer-peer/Makefile.am b/libjava/classpath/native/jni/gstreamer-peer/Makefile.am
new file mode 100644
index 000000000..d15f0a2ad
--- /dev/null
+++ b/libjava/classpath/native/jni/gstreamer-peer/Makefile.am
@@ -0,0 +1,29 @@
+nativeexeclib_LTLIBRARIES = libgstreamerpeer.la
+
+libgstreamerpeer_la_SOURCES = gst_peer.c \
+ gstreamer_io_peer.c \
+ gst_native_data_line.c \
+ gst_input_stream.c \
+ gst_native_pipeline.c \
+ gst_classpath_src.c \
+ gst_peer.h \
+ gst_classpath_src.h \
+ gst_input_stream.h \
+ gst_native_pipeline.h
+
+libgstreamerpeer_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo
+
+libgstreamerpeer_la_LDFLAGS = $(AM_LDFLAGS) @GST_PLUGIN_LDFLAGS@ -avoid-version
+
+AM_LDFLAGS = @CLASSPATH_MODULE@ @GSTREAMER_LIBS@ @GSTREAMER_BASE_LIBS@ \
+ @GSTREAMER_PLUGINS_BASE_LIBS@ @GDK_LIBS@
+
+AM_CPPFLAGS = @CLASSPATH_INCLUDES@
+
+# We cannot use -Wwrite-strings and the strict flags since
+# gstreamer contain broken prototypes (by design).
+AM_CFLAGS = @WARNING_CFLAGS@ -Wno-write-strings \
+ -Wno-missing-field-initializers \
+ @ERROR_CFLAGS@ -Wno-unused-parameter @GSTREAMER_BASE_CFLAGS@ \
+ @GDK_CFLAGS@ @GSTREAMER_CFLAGS@ @GSTREAMER_PLUGINS_BASE_CFLAGS@ \
+ @EXTRA_CFLAGS@
diff --git a/libjava/classpath/native/jni/gstreamer-peer/Makefile.in b/libjava/classpath/native/jni/gstreamer-peer/Makefile.in
new file mode 100644
index 000000000..4985ff631
--- /dev/null
+++ b/libjava/classpath/native/jni/gstreamer-peer/Makefile.in
@@ -0,0 +1,637 @@
+# 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@
+target_triplet = @target@
+subdir = native/jni/gstreamer-peer
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/../../config/depstand.m4 \
+ $(top_srcdir)/../../config/lead-dot.m4 \
+ $(top_srcdir)/../../config/lib-ld.m4 \
+ $(top_srcdir)/../../config/lib-link.m4 \
+ $(top_srcdir)/../../config/lib-prefix.m4 \
+ $(top_srcdir)/../../config/multi.m4 \
+ $(top_srcdir)/../../config/no-executables.m4 \
+ $(top_srcdir)/../../config/override.m4 \
+ $(top_srcdir)/../../libtool.m4 \
+ $(top_srcdir)/../../ltoptions.m4 \
+ $(top_srcdir)/../../ltsugar.m4 \
+ $(top_srcdir)/../../ltversion.m4 \
+ $(top_srcdir)/../../lt~obsolete.m4 \
+ $(top_srcdir)/m4/ac_prog_antlr.m4 \
+ $(top_srcdir)/m4/ac_prog_java.m4 \
+ $(top_srcdir)/m4/ac_prog_java_works.m4 \
+ $(top_srcdir)/m4/ac_prog_javac.m4 \
+ $(top_srcdir)/m4/ac_prog_javac_works.m4 \
+ $(top_srcdir)/m4/acattribute.m4 $(top_srcdir)/m4/accross.m4 \
+ $(top_srcdir)/m4/acinclude.m4 \
+ $(top_srcdir)/m4/ax_create_stdint_h.m4 \
+ $(top_srcdir)/m4/ax_func_which_gethostbyname_r.m4 \
+ $(top_srcdir)/m4/gcc_attribute.m4 $(top_srcdir)/m4/iconv.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/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)$(nativeexeclibdir)"
+LTLIBRARIES = $(nativeexeclib_LTLIBRARIES)
+libgstreamerpeer_la_DEPENDENCIES = \
+ $(top_builddir)/native/jni/classpath/jcl.lo
+am_libgstreamerpeer_la_OBJECTS = gst_peer.lo gstreamer_io_peer.lo \
+ gst_native_data_line.lo gst_input_stream.lo \
+ gst_native_pipeline.lo gst_classpath_src.lo
+libgstreamerpeer_la_OBJECTS = $(am_libgstreamerpeer_la_OBJECTS)
+libgstreamerpeer_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(libgstreamerpeer_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+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) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libgstreamerpeer_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+ANTLR = @ANTLR@
+ANTLR_JAR = @ANTLR_JAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CLASSPATH_CONVENIENCE = @CLASSPATH_CONVENIENCE@
+CLASSPATH_INCLUDES = @CLASSPATH_INCLUDES@
+CLASSPATH_MODULE = @CLASSPATH_MODULE@
+COLLECTIONS_PREFIX = @COLLECTIONS_PREFIX@
+CP = @CP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+ECJ_JAR = @ECJ_JAR@
+EGREP = @EGREP@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+EXAMPLESDIR = @EXAMPLESDIR@
+EXEEXT = @EXEEXT@
+EXTRA_CFLAGS = @EXTRA_CFLAGS@
+FGREP = @FGREP@
+FIND = @FIND@
+FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
+FREETYPE2_LIBS = @FREETYPE2_LIBS@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
+GJDOC = @GJDOC@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GMP_CFLAGS = @GMP_CFLAGS@
+GMP_LIBS = @GMP_LIBS@
+GREP = @GREP@
+GSTREAMER_BASE_CFLAGS = @GSTREAMER_BASE_CFLAGS@
+GSTREAMER_BASE_LIBS = @GSTREAMER_BASE_LIBS@
+GSTREAMER_CFLAGS = @GSTREAMER_CFLAGS@
+GSTREAMER_FILE_READER = @GSTREAMER_FILE_READER@
+GSTREAMER_LIBS = @GSTREAMER_LIBS@
+GSTREAMER_MIXER_PROVIDER = @GSTREAMER_MIXER_PROVIDER@
+GSTREAMER_PLUGINS_BASE_CFLAGS = @GSTREAMER_PLUGINS_BASE_CFLAGS@
+GSTREAMER_PLUGINS_BASE_LIBS = @GSTREAMER_PLUGINS_BASE_LIBS@
+GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@
+GTK_CFLAGS = @GTK_CFLAGS@
+GTK_LIBS = @GTK_LIBS@
+INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+JAR = @JAR@
+JAVA = @JAVA@
+JAVAC = @JAVAC@
+JAVAC_IS_GCJ = @JAVAC_IS_GCJ@
+JAVAC_MEM_OPT = @JAVAC_MEM_OPT@
+JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION = @JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION@
+JAY = @JAY@
+JAY_SKELETON = @JAY_SKELETON@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBDEBUG = @LIBDEBUG@
+LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVERSION = @LIBVERSION@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBICONV = @LTLIBICONV@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR = @MKDIR@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+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@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
+PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
+QT_CFLAGS = @QT_CFLAGS@
+QT_LIBS = @QT_LIBS@
+RANLIB = @RANLIB@
+REMOVE = @REMOVE@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRICT_WARNING_CFLAGS = @STRICT_WARNING_CFLAGS@
+STRIP = @STRIP@
+TOOLSDIR = @TOOLSDIR@
+USER_JAVAH = @USER_JAVAH@
+VERSION = @VERSION@
+WANT_NATIVE_BIG_INTEGER = @WANT_NATIVE_BIG_INTEGER@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+XMKMF = @XMKMF@
+XML_CFLAGS = @XML_CFLAGS@
+XML_LIBS = @XML_LIBS@
+XSLT_CFLAGS = @XSLT_CFLAGS@
+XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
+X_CFLAGS = @X_CFLAGS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_LIBS = @X_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+ZIP = @ZIP@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_ANTLR = @ac_ct_ANTLR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+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@
+default_toolkit = @default_toolkit@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+glibjdir = @glibjdir@
+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@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+multi_basedir = @multi_basedir@
+nativeexeclibdir = @nativeexeclibdir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+toolexeclibdir = @toolexeclibdir@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+uudecode = @uudecode@
+vm_classes = @vm_classes@
+nativeexeclib_LTLIBRARIES = libgstreamerpeer.la
+libgstreamerpeer_la_SOURCES = gst_peer.c \
+ gstreamer_io_peer.c \
+ gst_native_data_line.c \
+ gst_input_stream.c \
+ gst_native_pipeline.c \
+ gst_classpath_src.c \
+ gst_peer.h \
+ gst_classpath_src.h \
+ gst_input_stream.h \
+ gst_native_pipeline.h
+
+libgstreamerpeer_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo
+libgstreamerpeer_la_LDFLAGS = $(AM_LDFLAGS) @GST_PLUGIN_LDFLAGS@ -avoid-version
+AM_LDFLAGS = @CLASSPATH_MODULE@ @GSTREAMER_LIBS@ @GSTREAMER_BASE_LIBS@ \
+ @GSTREAMER_PLUGINS_BASE_LIBS@ @GDK_LIBS@
+
+AM_CPPFLAGS = @CLASSPATH_INCLUDES@
+
+# We cannot use -Wwrite-strings and the strict flags since
+# gstreamer contain broken prototypes (by design).
+AM_CFLAGS = @WARNING_CFLAGS@ -Wno-write-strings \
+ -Wno-missing-field-initializers \
+ @ERROR_CFLAGS@ -Wno-unused-parameter @GSTREAMER_BASE_CFLAGS@ \
+ @GDK_CFLAGS@ @GSTREAMER_CFLAGS@ @GSTREAMER_PLUGINS_BASE_CFLAGS@ \
+ @EXTRA_CFLAGS@
+
+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 native/jni/gstreamer-peer/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu native/jni/gstreamer-peer/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-nativeexeclibLTLIBRARIES: $(nativeexeclib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(nativeexeclibdir)" || $(MKDIR_P) "$(DESTDIR)$(nativeexeclibdir)"
+ @list='$(nativeexeclib_LTLIBRARIES)'; test -n "$(nativeexeclibdir)" || 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)$(nativeexeclibdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(nativeexeclibdir)"; \
+ }
+
+uninstall-nativeexeclibLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(nativeexeclib_LTLIBRARIES)'; test -n "$(nativeexeclibdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(nativeexeclibdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(nativeexeclibdir)/$$f"; \
+ done
+
+clean-nativeexeclibLTLIBRARIES:
+ -test -z "$(nativeexeclib_LTLIBRARIES)" || rm -f $(nativeexeclib_LTLIBRARIES)
+ @list='$(nativeexeclib_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
+libgstreamerpeer.la: $(libgstreamerpeer_la_OBJECTS) $(libgstreamerpeer_la_DEPENDENCIES)
+ $(libgstreamerpeer_la_LINK) -rpath $(nativeexeclibdir) $(libgstreamerpeer_la_OBJECTS) $(libgstreamerpeer_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gst_classpath_src.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gst_input_stream.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gst_native_data_line.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gst_native_pipeline.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gst_peer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gstreamer_io_peer.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@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@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@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 $@ $<
+
+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
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(nativeexeclibdir)"; 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-nativeexeclibLTLIBRARIES \
+ 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-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-nativeexeclibLTLIBRARIES
+
+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-nativeexeclibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-nativeexeclibLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags 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-nativeexeclibLTLIBRARIES install-pdf install-pdf-am \
+ 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-nativeexeclibLTLIBRARIES
+
+
+# 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/libjava/classpath/native/jni/gstreamer-peer/gst_classpath_src.c b/libjava/classpath/native/jni/gstreamer-peer/gst_classpath_src.c
new file mode 100644
index 000000000..80c679592
--- /dev/null
+++ b/libjava/classpath/native/jni/gstreamer-peer/gst_classpath_src.c
@@ -0,0 +1,408 @@
+/*gstclasspathsrc.c - Class file for the GstClasspathPlugin
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/*
+ * We don't really use version numbering here, we give it the same version
+ * number of classpath, so that gstreamer is happy.
+ * TODO: Maybe this should be moved in config.h instead?
+ */
+#define CLASSPATH_GST_PLUGIN_VERSION PACKAGE_VERSION
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <gst/gst.h>
+#include <gst/base/gstbasesrc.h>
+#include <gst/base/gstpushsrc.h>
+
+#include <glib.h>
+#include <glib/gprintf.h>
+
+#include <gdk/gdk.h>
+
+#include "gst_classpath_src.h"
+#include "gst_input_stream.h"
+
+GST_DEBUG_CATEGORY_STATIC (gst_classpath_src_debug);
+#define GST_CAT_DEFAULT gst_classpath_src_debug
+
+enum
+{
+ ARG_0,
+ ARG_INPUTSTREAM
+};
+
+struct _GstClasspathSrcPrivate
+{
+ GstInputStream *istream;
+ GstCaps *caps;
+};
+
+static const GstElementDetails gst_classpath_src_details =
+GST_ELEMENT_DETAILS ("ClasspathSrc",
+ "Source/Network",
+ "Read from a java input stream",
+ "Mario Torre <neugens@limasoftware.net>");
+
+static GstStaticPadTemplate _template =
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
+
+/* ***** plugin init ***** */
+
+static void
+_do_init (GType filesrc_type __attribute__ ((unused)))
+{
+ GST_DEBUG_CATEGORY_INIT (gst_classpath_src_debug, "classpathsrc",
+ 0, "classpathsrc");
+}
+
+GST_BOILERPLATE_FULL (GstClasspathSrc, gst_classpath_src, GstPushSrc,
+ GST_TYPE_PUSH_SRC, _do_init);
+
+static gboolean
+plugin_init (GstPlugin *plugin)
+{
+ return gst_element_register (plugin, "classpathsrc",
+ GST_RANK_NONE, GST_TYPE_CLASSPATH_SRC);
+}
+
+GST_PLUGIN_DEFINE_STATIC (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "classpathsrc",
+ "Java InputStream Reader",
+ plugin_init, CLASSPATH_GST_PLUGIN_VERSION,
+ GST_LICENSE_UNKNOWN, /* GPL + Exception */
+ "Classpath", "http://www.classpath.org/")
+
+/* ***** public class methods ***** */
+
+static void gst_classpath_src_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+static void gst_classpath_src_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static void gst_classpath_src_finalize (GObject *object);
+
+static GstCaps *gst_classpath_src_getcaps (GstBaseSrc *basesrc);
+
+static gboolean gst_classpath_src_start (GstBaseSrc *basesrc);
+
+static gboolean gst_classpath_src_stop (GstBaseSrc *basesrc);
+
+static GstFlowReturn gst_classpath_src_create (GstPushSrc *src,
+ GstBuffer **buffer);
+
+static GstFlowReturn
+gst_classpath_src_create_stream (GstClasspathSrc *src, GstBuffer **buffer);
+
+static GstFlowReturn
+check_read (GstClasspathSrc *src, int read, int buffer_size,
+ GstBuffer **buffer);
+
+/* ***** public class methods: end ***** */
+
+static void
+gst_classpath_src_base_init (gpointer gclass)
+{
+ GstElementClass *gstelement_class = GST_ELEMENT_CLASS (gclass);
+
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&_template));
+
+ gst_element_class_set_details (gstelement_class, &gst_classpath_src_details);
+}
+
+static void
+gst_classpath_src_class_init (GstClasspathSrcClass *klass)
+{
+ GObjectClass *gobject_class;
+ GstElementClass *gstelement_class;
+ GstBaseSrcClass *gstbasesrc_class;
+ GstPushSrcClass *gstpushsrc_class;
+
+ GParamSpec *pspec;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ gstelement_class = GST_ELEMENT_CLASS (klass);
+ gstbasesrc_class = GST_BASE_SRC_CLASS (klass);
+ gstpushsrc_class = GST_PUSH_SRC_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GstClasspathSrcPrivate));
+
+ /* getter and setters */
+
+ gobject_class->set_property = gst_classpath_src_set_property;
+ gobject_class->get_property = gst_classpath_src_get_property;
+
+ /* register properties */
+ pspec = g_param_spec_pointer (GST_CLASSPATH_SRC_ISTREAM,
+ "GstInputStream instance",
+ "GstInputStream instance",
+ G_PARAM_READWRITE);
+ g_object_class_install_property (gobject_class, ARG_INPUTSTREAM, pspec);
+
+ /* register callbacks */
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_classpath_src_finalize);
+
+ gstbasesrc_class->get_caps = GST_DEBUG_FUNCPTR (gst_classpath_src_getcaps);
+ gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_classpath_src_start);
+ gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_classpath_src_stop);
+
+ gstpushsrc_class->create = GST_DEBUG_FUNCPTR (gst_classpath_src_create);
+}
+
+/* ***** */
+
+static void
+gst_classpath_src_init (GstClasspathSrc *src,
+ GstClasspathSrcClass * g_class __attribute__ ((unused)))
+{
+ src->priv = G_TYPE_INSTANCE_GET_PRIVATE (src, GST_TYPE_CLASSPATH_SRC,
+ GstClasspathSrcPrivate);
+
+ src->priv->istream = NULL;
+ src->priv->caps = NULL;
+}
+
+static void
+gst_classpath_src_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+/* ************************************************************************** */
+
+static void
+gst_classpath_src_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GstClasspathSrc *src;
+
+ g_return_if_fail (GST_IS_CLASSPATH_SRC (object));
+
+ src = GST_CLASSPATH_SRC (object);
+
+ GST_OBJECT_LOCK (src);
+ switch (prop_id)
+ {
+ case ARG_INPUTSTREAM:
+ {
+ GST_STATE_LOCK (src);
+ {
+ GstState state;
+ state = GST_STATE (src);
+
+ if (state != GST_STATE_READY && state != GST_STATE_NULL)
+ {
+ GST_DEBUG_OBJECT (src, "setting reader in wrong state");
+ GST_STATE_UNLOCK (src);
+ break;
+ }
+ }
+ GST_STATE_UNLOCK (src);
+
+ /* FIXME: check if this is a valid instance of GstInputStream */
+ src->priv->istream = g_value_get_pointer (value);
+ }
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+ GST_OBJECT_UNLOCK (src);
+}
+
+static void
+gst_classpath_src_get_property (GObject *object,
+ guint prop_id __attribute__ ((unused)),
+ GValue *value __attribute__ ((unused)),
+ GParamSpec *pspec __attribute__ ((unused)))
+{
+ /* TODO */
+}
+
+/* ************************************************************************** */
+
+static GstCaps *gst_classpath_src_getcaps (GstBaseSrc *basesrc)
+{
+ GstClasspathSrc *src;
+ GstCaps *caps = NULL;
+
+ src = GST_CLASSPATH_SRC (basesrc);
+
+ if (src->priv->caps)
+ caps = gst_caps_copy (src->priv->caps);
+ else
+ caps = gst_caps_new_any ();
+
+ GST_DEBUG_OBJECT (src, "returning caps %" GST_PTR_FORMAT, caps);
+ g_assert (GST_IS_CAPS (caps));
+
+ return caps;
+}
+
+static GstFlowReturn
+gst_classpath_src_create_stream (GstClasspathSrc *src, GstBuffer **buffer)
+{
+ int buffer_size = 2048;
+ int read = -1;
+
+ buffer_size = gst_input_stream_available (src->priv->istream);
+ if (buffer_size < 0)
+ return GST_FLOW_ERROR;
+ else if (buffer_size == 0)
+ return GST_FLOW_WRONG_STATE;
+
+ *buffer = gst_buffer_new_and_alloc (buffer_size);
+ if (*buffer == NULL)
+ {
+ return GST_FLOW_ERROR;
+ }
+
+ read = gst_input_stream_read (src->priv->istream,
+ (int *) GST_BUFFER_DATA (*buffer),
+ 0,
+ buffer_size);
+
+ return check_read (src, read, buffer_size, buffer);
+}
+
+GstFlowReturn
+check_read (GstClasspathSrc *src, int read, int buffer_size, GstBuffer **buffer)
+{
+ if (G_UNLIKELY (read < 0))
+ {
+ g_warning("GST_FLOW_UNEXPECTED (read < 0)");
+
+ gst_buffer_unref (*buffer);
+ *buffer = NULL;
+
+ return GST_FLOW_ERROR;
+ }
+ else if (G_UNLIKELY (read == 0))
+ {
+ g_warning("GST_FLOW_WRONG_STATE (read == 0)");
+
+ gst_buffer_unref (*buffer);
+ *buffer = NULL;
+
+ return GST_FLOW_WRONG_STATE;
+ }
+ else if (G_UNLIKELY (read < buffer_size))
+ {
+ g_warning("shorter read");
+ gst_buffer_unref (*buffer);
+ *buffer = NULL;
+
+ return GST_FLOW_ERROR;
+ }
+
+ GST_BUFFER_SIZE (*buffer) = read;
+ gst_buffer_set_caps (*buffer, src->priv->caps);
+
+ return GST_FLOW_OK;
+}
+
+static GstFlowReturn
+gst_classpath_src_create (GstPushSrc *basesrc, GstBuffer **buffer)
+{
+ GstClasspathSrc *src = NULL;
+ GstFlowReturn ret = GST_FLOW_OK;
+
+ src = GST_CLASSPATH_SRC (basesrc);
+
+ /* create the buffer */
+ ret = gst_classpath_src_create_stream (src, buffer);
+
+ return ret;
+}
+
+static gboolean
+gst_classpath_src_start (GstBaseSrc *basesrc)
+{
+ GstClasspathSrc *src;
+
+ src = GST_CLASSPATH_SRC (basesrc);
+
+ if (src->priv->istream == NULL)
+ {
+ g_warning("GstInputStream is still null. You need to " \
+ "pass a valid InputStream object");
+
+ GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
+ ("GstInputStream is still null. You need to " \
+ "pass a valid InputStream"));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean
+gst_classpath_src_stop (GstBaseSrc *basesrc)
+{
+ GstClasspathSrc *src;
+
+ src = GST_CLASSPATH_SRC (basesrc);
+
+ /* clean the stream */
+ if (src->priv->istream != NULL)
+ gst_input_stream_clean (src->priv->istream);
+
+ if (src->priv->caps) {
+ gst_caps_unref (src->priv->caps);
+ src->priv->caps = NULL;
+ }
+
+ return TRUE;
+}
diff --git a/libjava/classpath/native/jni/gstreamer-peer/gst_classpath_src.h b/libjava/classpath/native/jni/gstreamer-peer/gst_classpath_src.h
new file mode 100644
index 000000000..9e2acb0f2
--- /dev/null
+++ b/libjava/classpath/native/jni/gstreamer-peer/gst_classpath_src.h
@@ -0,0 +1,88 @@
+/*gstclasspathsrc.h - Header file for the GstClasspathPlugin
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+#ifndef __GST_CLASSPATH_SRC_H__
+#define __GST_CLASSPATH_SRC_H__
+
+#include <gst/gst.h>
+#include <gst/base/gstpushsrc.h>
+
+#include "gst_input_stream.h"
+
+G_BEGIN_DECLS
+
+/* #defines don't like whitespacey bits */
+#define GST_TYPE_CLASSPATH_SRC (gst_classpath_src_get_type())
+
+#define GST_CLASSPATH_SRC(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CLASSPATH_SRC,GstClasspathSrc))
+
+#define GST_CLASSPATH_SRC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CLASSPATH_SRC,GstClasspathSrcClass))
+
+#define GST_IS_CLASSPATH_SRC(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CLASSPATH_SRC))
+
+#define GST_IS_CLASSPATH_SRC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CLASSPATH_SRC))
+
+typedef struct _GstClasspathSrcPrivate GstClasspathSrcPrivate;
+typedef struct _GstClasspathSrc GstClasspathSrc;
+typedef struct _GstClasspathSrcClass GstClasspathSrcClass;
+
+struct _GstClasspathSrc
+{
+ GstPushSrc element;
+
+ /* instance members */
+ GstClasspathSrcPrivate *priv;
+};
+
+struct _GstClasspathSrcClass
+{
+ GstPushSrcClass parent_class;
+};
+
+GType gst_classpath_src_get_type (void);
+
+/* exported properties */
+
+#define GST_CLASSPATH_SRC_ISTREAM "input-stream"
+
+G_END_DECLS
+
+#endif /* __GST_CLASSPATH_SRC_H__ */
diff --git a/libjava/classpath/native/jni/gstreamer-peer/gst_input_stream.c b/libjava/classpath/native/jni/gstreamer-peer/gst_input_stream.c
new file mode 100644
index 000000000..c5e512954
--- /dev/null
+++ b/libjava/classpath/native/jni/gstreamer-peer/gst_input_stream.c
@@ -0,0 +1,290 @@
+/*GstInputStream.c - Header file for the GstClasspathPlugin
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+#include <jni.h>
+#include <jcl.h>
+
+#include <string.h>
+#include <stdlib.h>
+
+#include <gdk/gdk.h>
+
+#include <glib.h>
+
+#include "gst_peer.h"
+
+#include "gnu_javax_sound_sampled_gstreamer_io_GstInputStream.h"
+#include "gst_input_stream.h"
+
+/* for caching */
+static jmethodID readID = NULL;
+static jmethodID pointerConstructorID = NULL;
+static jmethodID availableID = NULL;
+
+static jfieldID streamID = NULL;
+static jfieldID pointerDataID = NULL;
+
+struct _GstInputStreamPrivate
+{
+ JavaVM *vm;
+ jclass readerClass;
+ jclass pointerClass;
+
+ jobject reader;
+};
+
+/* ************************************************************************** */
+
+static void init_pointer_IDs (JNIEnv* env);
+
+/* ************************************************************************** */
+
+/* JNI Methods */
+
+JNIEXPORT void JNICALL
+Java_gnu_javax_sound_sampled_gstreamer_io_GstInputStream_init_1id_1cache
+ (JNIEnv *env, jclass clazz)
+{
+ readID = (*env)->GetMethodID(env, clazz, "read", "([BII)I");
+ availableID = (*env)->GetMethodID(env, clazz, "available", "()I");
+
+ streamID = (*env)->GetFieldID(env, clazz, "gstInputStream",
+ "Lgnu/classpath/Pointer;");
+ init_pointer_IDs(env);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_javax_sound_sampled_gstreamer_io_GstInputStream_init_1instance
+ (JNIEnv *env, jobject reader)
+{
+ GstInputStream *istream = NULL;
+
+ jclass localReader = NULL;
+ jclass localPointer = NULL;
+ jobject _pointer = NULL;
+
+ istream = (GstInputStream *) JCL_malloc (env, sizeof (GstInputStream));
+ if (istream == NULL)
+ return;
+
+ istream->priv = (GstInputStreamPrivate *)
+ JCL_malloc (env, sizeof (GstInputStreamPrivate));
+ if (istream->priv == NULL)
+ {
+ JCL_free (env, istream);
+ return;
+ }
+
+ /* get a local references first */
+ localReader = (*env)->GetObjectClass(env, reader);
+ if (localReader == NULL)
+ {
+ JCL_free (env, istream->priv);
+ JCL_free (env, istream);
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "Class Initialization failed.");
+
+ return;
+ }
+
+#if SIZEOF_VOID_P == 8
+ localPointer = JCL_FindClass (env, "gnu/classpath/Pointer64");
+#else
+# if SIZEOF_VOID_P == 4
+ localPointer = JCL_FindClass (env, "gnu/classpath/Pointer32");
+# else
+# error "Pointer size is not supported."
+# endif /* SIZEOF_VOID_P == 4 */
+#endif /* SIZEOF_VOID_P == 8 */
+
+ if (localReader == NULL || localPointer == NULL)
+ {
+ JCL_free (env, istream->priv);
+ JCL_free (env, istream);
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "Class Initialization failed.");
+ return;
+ }
+
+ /* fill out our structure */
+ istream->priv->readerClass = (*env)->NewGlobalRef(env, localReader);
+ istream->priv->pointerClass = (*env)->NewGlobalRef(env, localPointer);
+ (*env)->GetJavaVM(env, &istream->priv->vm);
+ istream->priv->reader = (*env)->NewGlobalRef(env, reader);
+
+ _pointer = (*env)->GetObjectField(env, reader, streamID);
+
+ /* this should be always null */
+ if (_pointer == NULL)
+ {
+#if SIZEOF_VOID_P == 8
+ _pointer = (*env)->NewObject(env, istream->priv->pointerClass,
+ pointerConstructorID, (jlong) istream);
+#else
+ _pointer = (*env)->NewObject(env, istream->priv->pointerClass,
+ pointerConstructorID, (jint) istream);
+#endif
+ }
+ else
+ {
+#if SIZEOF_VOID_P == 8
+ (*env)->SetLongField(env, reader, streamID, (jlong) istream);
+#else
+ (*env)->SetIntField(env, reader, streamID, (jint) istream);
+#endif
+ }
+
+ /* store back our pointer into the calling class */
+ (*env)->SetObjectField(env, reader, streamID, _pointer);
+}
+
+/* exported library functions */
+
+void
+gst_input_stream_clean (GstInputStream *self)
+{
+ JNIEnv *env = NULL;
+
+ env = gst_get_jenv (self->priv->vm);
+
+ (*env)->DeleteGlobalRef (env, self->priv->reader);
+ (*env)->DeleteGlobalRef (env, self->priv->readerClass);
+ (*env)->DeleteGlobalRef (env, self->priv->pointerClass);
+
+ JCL_free (env, self->priv);
+ JCL_free (env, self);
+}
+
+int
+gst_input_stream_available (GstInputStream *self)
+{
+ JNIEnv *env = NULL;
+
+ if (self == NULL || self->priv == NULL ||
+ self->priv->vm == NULL || self->priv->reader == NULL)
+ {
+ return -1;
+ }
+
+ env = gst_get_jenv (self->priv->vm);
+ if (env == NULL)
+ {
+ g_warning("GstInputStream::gst_input_stream_available " \
+ "failed to get java env");
+ return -1;
+ }
+
+ return (*env)->CallIntMethod (env, self->priv->reader, availableID);
+}
+
+int
+gst_input_stream_read (GstInputStream *self, int *data, int offset,
+ int length)
+{
+ JNIEnv *env = NULL;
+
+ int ret = -1;
+ jbyteArray buffer;
+ jbyte *bytes = NULL;
+
+ if (self == NULL || self->priv == NULL ||
+ self->priv->vm == NULL || self->priv->reader == NULL)
+ {
+ return -1;
+ }
+
+ env = gst_get_jenv (self->priv->vm);
+ if (env == NULL)
+ {
+ g_warning("GstInputStream::gst_input_stream_read failed to get java env");
+ return -1;
+ }
+
+ buffer = (*env)->NewByteArray (env, length);
+ if (buffer == NULL)
+ {
+ g_warning ("GstInputStream::gst_input_stream_read called, failed");
+ return -1;
+ }
+
+ ret = (*env)->CallIntMethod (env, self->priv->reader, readID, buffer, 0,
+ length);
+ if (ret < 0)
+ {
+ (*env)->DeleteLocalRef(env, buffer);
+ return ret;
+ }
+
+ bytes = (*env)->GetByteArrayElements (env, buffer, NULL);
+
+ /* copy bytes and release */
+ memcpy (data + offset, bytes, ret);
+
+ (*env)->ReleaseByteArrayElements (env, buffer, bytes, 0);
+ (*env)->DeleteLocalRef (env, buffer);
+
+ return ret;
+}
+
+/* private functions */
+
+static void init_pointer_IDs (JNIEnv* env)
+{
+ jclass pointerClass = NULL;
+
+#if SIZEOF_VOID_P == 8
+ pointerClass = JCL_FindClass (env, "gnu/classpath/Pointer64");
+ if (pointerClass != NULL)
+ {
+ pointerDataID = (*env)->GetFieldID (env, pointerClass, "data", "J");
+ pointerConstructorID = (*env)->GetMethodID (env, pointerClass, "<init>",
+ "(J)V");
+ }
+#else
+# if SIZEOF_VOID_P == 4
+ pointerClass = JCL_FindClass (env, "gnu/classpath/Pointer32");
+ if (pointerClass != NULL)
+ {
+ pointerDataID = (*env)->GetFieldID(env, pointerClass, "data", "I");
+ pointerConstructorID = (*env)->GetMethodID(env, pointerClass,
+ "<init>", "(I)V");
+ }
+# else
+# error "Pointer size is not supported."
+# endif /* SIZEOF_VOID_P == 4 */
+#endif /* SIZEOF_VOID_P == 8 */
+}
diff --git a/libjava/classpath/native/jni/gstreamer-peer/gst_input_stream.h b/libjava/classpath/native/jni/gstreamer-peer/gst_input_stream.h
new file mode 100644
index 000000000..8e9d3cf42
--- /dev/null
+++ b/libjava/classpath/native/jni/gstreamer-peer/gst_input_stream.h
@@ -0,0 +1,71 @@
+/*gstinputstream.h - Header file for the GstClasspathPlugin
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+#ifndef __GST_INPUT_STREAM_H__
+#define __GST_INPUT_STREAM_H__
+
+typedef struct _GstInputStream GstInputStream;
+typedef struct _GstInputStreamPrivate GstInputStreamPrivate;
+
+struct _GstInputStream
+{
+ /* instance members */
+ GstInputStreamPrivate *priv;
+};
+
+/**
+ * Clean the given instance of GstInputStream so that the garbage
+ * collector can collect the cached Java classes.
+ * Call this fuction when you don't need anymore to use this instance of
+ * GstInputStream. Note that failure to call this routine will result in
+ * memroy leaks.
+ */
+void gst_input_stream_clean (GstInputStream *self);
+
+/**
+ * Perform the "read" operation on this GstInputStream.
+ */
+int gst_input_stream_read (GstInputStream *self, int *data, int offset,
+ int length);
+
+/**
+ * Returns the number of byte currently available for read in this
+ * GstInputStream.
+ */
+int gst_input_stream_available (GstInputStream *self);
+
+#endif /* __GST_INPUT_STREAM_H__ */
diff --git a/libjava/classpath/native/jni/gstreamer-peer/gst_native_data_line.c b/libjava/classpath/native/jni/gstreamer-peer/gst_native_data_line.c
new file mode 100644
index 000000000..84e76a1dc
--- /dev/null
+++ b/libjava/classpath/native/jni/gstreamer-peer/gst_native_data_line.c
@@ -0,0 +1,251 @@
+/*gst_native_data_line.c - Implements the native methods of GstNativeDataLine
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+#include <jni.h>
+
+#include <gst/gst.h>
+
+#include "jcl.h"
+#include "gnu_javax_sound_sampled_gstreamer_lines_GstNativeDataLine.h"
+
+#include "gst_peer.h"
+#include "gst_classpath_src.h"
+#include "gst_native_pipeline.h"
+
+static jfieldID pointerDataFID = NULL;
+
+/* ************************************************************************** */
+
+static GstElement *setup_pipeline (GstNativePipeline *jpipeline, int fd);
+static void
+gst_newpad (GstElement *decodebin, GstPad *pad, gboolean last, gpointer data);
+
+/* ************************************************************************** */
+
+JNIEXPORT void JNICALL
+Java_gnu_javax_sound_sampled_gstreamer_lines_GstNativeDataLine_init_1id_1cache
+ (JNIEnv *env __attribute__ ((unused)), jclass clazz __attribute__ ((unused)))
+{
+ jclass pointerClass = NULL;
+
+#if SIZEOF_VOID_P == 8
+ pointerClass = JCL_FindClass (env, "gnu/classpath/Pointer64");
+ if (pointerClass != NULL)
+ {
+ pointerDataFID = (*env)->GetFieldID (env, pointerClass, "data", "J");
+ }
+#else
+# if SIZEOF_VOID_P == 4
+ pointerClass = JCL_FindClass (env, "gnu/classpath/Pointer32");
+ if (pointerClass != NULL)
+ {
+ pointerDataFID = (*env)->GetFieldID(env, pointerClass, "data", "I");
+ }
+# else
+# error "Pointer size is not supported."
+# endif /* SIZEOF_VOID_P == 4 */
+#endif /* SIZEOF_VOID_P == 8 */
+}
+
+JNIEXPORT jboolean JNICALL
+Java_gnu_javax_sound_sampled_gstreamer_lines_GstNativeDataLine_setup_1sink_1pipeline
+ (JNIEnv *env, jclass clazz __attribute__ ((unused)),
+ jobject pointer)
+{
+ GstNativePipeline *jpipeline = NULL;
+
+ GstElement *pipeline = NULL;
+ GstElement *sink = NULL;
+ GstElement *audioconv= NULL;
+ GstElement *resample = NULL;
+ GstElement *audio = NULL;
+ GstElement *decodebin = NULL;
+
+ GstPad *audiopad = NULL;
+
+ gst_init (NULL, NULL);
+
+ /* get the pipeline from the pointer, then create it if needed */
+ jpipeline = (GstNativePipeline *) get_object_from_pointer (env, pointer,
+ pointerDataFID);
+ if (jpipeline == NULL)
+ return JNI_FALSE;
+
+ pipeline = setup_pipeline (jpipeline,
+ gst_native_pipeline_get_pipeline_fd (jpipeline));
+ if (pipeline == NULL)
+ return JNI_FALSE;
+
+ /* add the audio sink to the pipeline */
+ /* TODO: hardcoded values */
+ sink = gst_element_factory_make ("autoaudiosink", "alsa-output");
+ if (sink == NULL)
+ {
+ gst_object_unref(GST_OBJECT(pipeline));
+ gst_object_unref(GST_OBJECT(sink));
+
+ g_warning ("unable to create sink\n");
+ return JNI_FALSE;
+ }
+
+ audioconv = gst_element_factory_make ("audioconvert", "aconv");
+ if (audioconv == NULL)
+ {
+ gst_object_unref(GST_OBJECT(pipeline));
+ gst_object_unref(GST_OBJECT(sink));
+ gst_object_unref(GST_OBJECT(decodebin));
+
+ g_warning ("unable to create audioconv\n");
+ return JNI_FALSE;
+ }
+
+ audio = gst_bin_new ("audiobin");
+ if (audio == NULL)
+ {
+ gst_object_unref(GST_OBJECT(pipeline));
+ gst_object_unref(GST_OBJECT(sink));
+ gst_object_unref(GST_OBJECT(decodebin));
+
+ g_warning ("unable to create audioconv\n");
+ return JNI_FALSE;
+ }
+
+ resample = gst_element_factory_make ("audioresample", "audioresample");
+ if (audioconv == NULL)
+ {
+ gst_object_unref(GST_OBJECT(pipeline));
+ gst_object_unref(GST_OBJECT(sink));
+ gst_object_unref(GST_OBJECT(decodebin));
+ gst_object_unref(GST_OBJECT(audio));
+
+ g_warning ("unable to create resample\n");
+ return JNI_FALSE;
+ }
+
+ audiopad = gst_element_get_pad (audioconv, "sink");
+ gst_bin_add_many (GST_BIN (audio), audioconv, resample, sink, NULL);
+ gst_element_link (audioconv, sink);
+
+ gst_element_add_pad (audio, gst_ghost_pad_new ("sink", audiopad));
+
+ gst_object_unref (audiopad);
+ gst_bin_add (GST_BIN (pipeline), audio);
+
+ decodebin = gst_bin_get_by_name (GST_BIN (pipeline), "decodebin");
+ g_signal_connect (decodebin, "new-decoded-pad", G_CALLBACK (gst_newpad),
+ audio);
+
+ gst_native_pipeline_set_pipeline (jpipeline, pipeline);
+
+ return JNI_TRUE;
+}
+
+/* ************************************************************************** */
+
+static GstElement *setup_pipeline (GstNativePipeline *jpipeline, int fd)
+{
+ GstElement *decodebin = NULL;
+ GstElement *source = NULL;
+
+ GstElement *pipeline = NULL;
+
+ if (fd < 0)
+ return NULL;
+
+ pipeline = gst_pipeline_new ("java sound pipeline");
+ if (pipeline == NULL)
+ return NULL;
+
+ decodebin = gst_element_factory_make ("decodebin", "decodebin");
+ if (decodebin == NULL)
+ {
+ gst_object_unref(GST_OBJECT(pipeline));
+ gst_object_unref(GST_OBJECT(source));
+
+ g_warning ("unable to create decodebin\n");
+ return NULL;
+ }
+
+ source = gst_element_factory_make ("fdsrc", "source");
+ if (source == NULL)
+ {
+ gst_object_unref(GST_OBJECT(pipeline));
+ gst_object_unref(GST_OBJECT(source));
+ gst_object_unref(GST_OBJECT(decodebin));
+
+ g_warning ("unable to create a source");
+ return JNI_FALSE;
+ }
+ g_object_set (G_OBJECT (source), "fd", fd, NULL);
+
+ gst_bin_add_many (GST_BIN (pipeline), source, decodebin, NULL);
+ gst_element_link (source, decodebin);
+
+ return pipeline;
+}
+
+static void
+gst_newpad (GstElement *decodebin, GstPad *pad, gboolean last, gpointer data)
+{
+ GstCaps *caps;
+ GstStructure *str;
+ GstPad *audiopad;
+
+ GstElement *audio = (GstElement *) data;
+
+ /* only link once */
+ audiopad = gst_element_get_pad (audio, "sink");
+ if (GST_PAD_IS_LINKED (audiopad))
+ {
+ g_object_unref (audiopad);
+ return;
+ }
+
+ /* check media type */
+ caps = gst_pad_get_caps (pad);
+ str = gst_caps_get_structure (caps, 0);
+ if (!g_strrstr (gst_structure_get_name (str), "audio"))
+ {
+ gst_caps_unref (caps);
+ gst_object_unref (audiopad);
+ return;
+ }
+ gst_caps_unref (caps);
+
+ /* link'n'play */
+ gst_pad_link (pad, audiopad);
+}
diff --git a/libjava/classpath/native/jni/gstreamer-peer/gst_native_pipeline.c b/libjava/classpath/native/jni/gstreamer-peer/gst_native_pipeline.c
new file mode 100644
index 000000000..e0caa4775
--- /dev/null
+++ b/libjava/classpath/native/jni/gstreamer-peer/gst_native_pipeline.c
@@ -0,0 +1,611 @@
+/*gst_native_pipeline.c - Header file for the GstClasspathPlugin
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+#include <jni.h>
+#include <jcl.h>
+
+#include <string.h>
+#include <stdlib.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+
+#include <unistd.h>
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif /* HAVE_FCNTL_H */
+
+#if defined(HAVE_SYS_IOCTL_H)
+#define BSD_COMP /* Get FIONREAD on Solaris2 */
+#include <sys/ioctl.h>
+#endif
+#if defined(HAVE_SYS_FILIO_H) /* Get FIONREAD on Solaris 2.5 */
+#include <sys/filio.h>
+#endif
+
+#include <gdk/gdk.h>
+#include <glib.h>
+
+#include <gst/gst.h>
+
+#include "cpio.h"
+#include "gst_peer.h"
+
+#include "gnu_javax_sound_sampled_gstreamer_lines_GstPipeline.h"
+#include "gst_native_pipeline.h"
+
+static jmethodID pointerConstructorMID = NULL;
+
+static jfieldID pipelineFID = NULL;
+static jfieldID pointerDataFID = NULL;
+static jfieldID nameFID = NULL;
+static jfieldID capacityFID = NULL;
+
+/*
+ * Needed to compute the size of the data still available for processing in the
+ * pipeline. We give a default here but this will be overwritten by the
+ * detection routines.
+ */
+static long GST_DETECTED_PIPE_CAPACITY = 65536;
+
+/*
+ * Note: the Java code uses enum classes, these are not mapped into constants
+ * by the javah tool, changes to these values should be reflected in the Java
+ * side.
+ */
+enum
+{
+ PLAY,
+ PAUSE,
+ STOP
+};
+
+/*
+ * Defined as constants in the Java code, hence mapped by javah.
+ */
+enum
+{
+ READ = gnu_javax_sound_sampled_gstreamer_lines_GstPipeline_READ,
+ WRITE = gnu_javax_sound_sampled_gstreamer_lines_GstPipeline_WRITE
+};
+
+struct _GstNativePipelinePrivate
+{
+ JavaVM *vm;
+ jclass GstPipelineClass;
+ jclass PointerClass;
+
+ jobject jni_pipeline;
+
+ char *name;
+ int fd;
+
+ GstElement *pipeline;
+};
+
+/* ************************************************************************** */
+/*
+static void gst_native_pipeline_clean (GstNativePipeline *self);*/
+static char *create_name (void);
+static void init_pointer_IDs (JNIEnv* env);
+static jint get_free_space (int fd);
+static void detect_pipe_max (void);
+
+/* ************************************************************************** */
+
+/* JNI Methods */
+
+JNIEXPORT void JNICALL
+Java_gnu_javax_sound_sampled_gstreamer_lines_GstPipeline_init_1id_1cache
+ (JNIEnv *env, jclass clazz)
+{
+ pipelineFID = (*env)->GetFieldID (env, clazz, "pipeline",
+ "Lgnu/classpath/Pointer;");
+ nameFID = (*env)->GetFieldID (env, clazz, "name", "Ljava/lang/String;");
+ capacityFID = (*env)->GetFieldID (env, clazz, "capacity", "J");
+
+ init_pointer_IDs (env);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_javax_sound_sampled_gstreamer_lines_GstPipeline_init_1instance
+ (JNIEnv *env, jobject pipeline)
+{
+ GstNativePipeline *_pipeline = NULL;
+
+ jclass localGstPipelineClass = NULL;
+ jclass localPointerClass = NULL;
+ jobject _pointer = NULL;
+
+ _pipeline =
+ (GstNativePipeline *) JCL_malloc (env, sizeof (GstNativePipeline));
+ if (_pipeline == NULL)
+ return;
+
+ _pipeline->priv = (GstNativePipelinePrivate *)
+ JCL_malloc (env, sizeof (GstNativePipelinePrivate));
+ if (_pipeline->priv == NULL)
+ {
+ JCL_free (env, _pipeline);
+ return;
+ }
+
+#if SIZEOF_VOID_P == 8
+ localPointerClass = JCL_FindClass (env, "gnu/classpath/Pointer64");
+#else
+# if SIZEOF_VOID_P == 4
+ localPointerClass = JCL_FindClass (env, "gnu/classpath/Pointer32");
+# else
+# error "Pointer size is not supported."
+# endif /* SIZEOF_VOID_P == 4 */
+#endif /* SIZEOF_VOID_P == 8 */
+
+ localGstPipelineClass = (*env)->GetObjectClass(env, pipeline);
+ if (localGstPipelineClass == NULL || localGstPipelineClass == NULL)
+ {
+ JCL_free (env, _pipeline->priv);
+ JCL_free (env, _pipeline);
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "Class Initialization failed.");
+ return;
+ }
+
+ GST_DETECTED_PIPE_CAPACITY = (long) (*env)->GetLongField(env, pipeline,
+ capacityFID);
+
+ /* fill the object */
+ (*env)->GetJavaVM(env, &_pipeline->priv->vm);
+ _pipeline->priv->jni_pipeline = (*env)->NewGlobalRef(env, pipeline);
+ _pipeline->priv->GstPipelineClass =
+ (*env)->NewGlobalRef(env, localGstPipelineClass);
+ _pipeline->priv->PointerClass = (*env)->NewGlobalRef(env, localPointerClass);
+ _pipeline->priv->pipeline = NULL;
+
+ _pointer = (*env)->GetObjectField(env, pipeline, pipelineFID);
+
+ if (_pointer == NULL)
+ {
+#if SIZEOF_VOID_P == 8
+ _pointer = (*env)->NewObject(env, _pipeline->priv->PointerClass,
+ pointerConstructorMID, (jlong) _pipeline);
+#else
+ _pointer = (*env)->NewObject(env, _pipeline->priv->PointerClass,
+ pointerConstructorMID, (jint) _pipeline);
+#endif
+ }
+ else
+ {
+#if SIZEOF_VOID_P == 8
+ (*env)->SetLongField(env, pipeline, pipelineFID, (jlong) _pipeline);
+#else
+ (*env)->SetIntField(env, pipeline, pipelineFID, (jint) _pipeline);
+#endif
+ }
+
+ /* store back our pointer into the calling class */
+ (*env)->SetObjectField(env, pipeline, pipelineFID, _pointer);
+}
+
+JNIEXPORT jboolean JNICALL
+Java_gnu_javax_sound_sampled_gstreamer_lines_GstPipeline_set_1state
+ (JNIEnv *env, jclass clazz, jobject pointer, jint state)
+{
+ GstNativePipeline *jpipeline = NULL;
+ jboolean result = JNI_FALSE;
+
+ if (pointer == NULL)
+ {
+ JCL_ThrowException (env, "javax/sound/sampled/LineUnavailableException",
+ "Can't change pipeline state: " \
+ "pipeline not initialized");
+ return result;
+ }
+
+ jpipeline = (GstNativePipeline *) get_object_from_pointer (env, pointer,
+ pointerDataFID);
+ if (jpipeline == NULL)
+ return JNI_FALSE;
+
+ switch (state)
+ {
+ case (PLAY):
+ gst_element_set_state(GST_ELEMENT(jpipeline->priv->pipeline),
+ GST_STATE_PLAYING);
+ result = JNI_TRUE;
+ break;
+
+ case (PAUSE):
+ gst_element_set_state(GST_ELEMENT(jpipeline->priv->pipeline),
+ GST_STATE_PAUSED);
+ result = JNI_TRUE;
+ break;
+
+ case (STOP):
+#ifndef WITHOUT_FILESYSTEM
+ /* clean the pipeline and kill named pipe */
+ if (jpipeline->priv->name)
+ {
+ cpio_removeFile (jpipeline->priv->name);
+ g_free (jpipeline->priv->name);
+ jpipeline->priv->name = NULL;
+ }
+#endif /* WITHOUT_FILESYSTEM */
+
+ if (jpipeline->priv->pipeline != NULL)
+ gst_object_unref (GST_OBJECT(jpipeline->priv->pipeline));
+ result = JNI_TRUE;
+ break;
+
+ default:
+ /* nothing */
+ result = JNI_FALSE;
+ break;
+ }
+
+ return result;
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_javax_sound_sampled_gstreamer_lines_GstPipeline_open_1native_1pipe
+ (JNIEnv *env, jclass clazz, jobject pointer, jint mode)
+{
+ GstNativePipeline *jpipeline = NULL;
+
+ jpipeline = (GstNativePipeline *) get_object_from_pointer (env, pointer,
+ pointerDataFID);
+ switch (mode)
+ {
+ case (READ):
+ jpipeline->priv->fd =
+ open (jpipeline->priv->name, O_RDONLY | O_NONBLOCK);
+ break;
+
+ case (WRITE):
+ /* TODO: no-op currently */
+ break;
+ }
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_javax_sound_sampled_gstreamer_lines_GstPipeline_close_1native_1pipe
+ (JNIEnv *env, jclass clazz, jobject pointer)
+{
+#ifndef WITHOUT_FILESYSTEM
+ GstNativePipeline *jpipeline = NULL;
+ jpipeline = (GstNativePipeline *) get_object_from_pointer (env, pointer,
+ pointerDataFID);
+ /* kill the named pipe */
+ if (jpipeline->priv->name)
+ {
+ cpio_removeFile (jpipeline->priv->name);
+ g_free (jpipeline->priv->name);
+ jpipeline->priv->name = NULL;
+ }
+#endif /* WITHOUT_FILESYSTEM */
+}
+
+JNIEXPORT jboolean JNICALL
+Java_gnu_javax_sound_sampled_gstreamer_lines_GstPipeline_create_1named_1pipe
+ (JNIEnv *env, jobject GstPipeline, jobject pointer)
+{
+#ifndef WITHOUT_FILESYSTEM
+ /*
+ * We get a temp name for the named pipe, create the named pipe and then
+ * set the relative field in the java class.
+ */
+ GstNativePipeline *jpipeline = NULL;
+ jstring *name = NULL;
+
+ jpipeline = (GstNativePipeline *) get_object_from_pointer (env, pointer,
+ pointerDataFID);
+ if (jpipeline == NULL)
+ return JNI_FALSE;
+
+ jpipeline->priv->name = create_name ();
+ if (jpipeline->priv->name == NULL)
+ return JNI_FALSE;
+
+ if (mkfifo (jpipeline->priv->name, 0600) < 0)
+ {
+ if (jpipeline->priv->name != NULL)
+ free (jpipeline->priv->name);
+ return JNI_FALSE;
+ }
+
+ /* now set the String field */
+ name = (*env)->NewStringUTF(env, jpipeline->priv->name);
+ if (name == NULL)
+ {
+ cpio_removeFile (jpipeline->priv->name);
+ if (jpipeline->priv->name != NULL)
+ free (jpipeline->priv->name);
+
+ return JNI_FALSE;
+ }
+
+ (*env)->SetObjectField(env, GstPipeline, nameFID, name);
+
+ return JNI_TRUE;
+
+#else /* not WITHOUT_FILESYSTEM */
+ return JNI_FALSE;
+#endif /* not WITHOUT_FILESYSTEM */
+}
+
+JNIEXPORT jint JNICALL
+Java_gnu_javax_sound_sampled_gstreamer_lines_GstPipeline_available
+ (JNIEnv *env, jclass clazz, jobject pointer, jint mode)
+{
+ jint result = -1;
+
+#ifndef WITHOUT_FILESYSTEM
+
+ GstNativePipeline *jpipeline = NULL;
+ jpipeline = (GstNativePipeline *) get_object_from_pointer (env, pointer,
+ pointerDataFID);
+
+ if (mode == READ)
+ {
+ result = get_free_space (jpipeline->priv->fd);
+ }
+ else
+ {
+# if defined (FIONREAD)
+ if (ioctl (jpipeline->priv->fd, FIONREAD, &result) == -1)
+ g_warning("IMPLEMENT ME: ioctl failed");
+
+# else /* not defined (FIONREAD) */
+ g_warning("IMPLEMENT ME: !defined (FIONREAD");
+# endif /* defined (FIONREAD) */
+
+ } /* if (mode == READ) */
+
+#endif /* not WITHOUT_FILESYSTEM */
+
+ return result;
+}
+
+JNIEXPORT jlong JNICALL
+Java_gnu_javax_sound_sampled_gstreamer_lines_GstPipeline_detect_1pipe_1size
+ (JNIEnv *env, jobject GstPipeline)
+{
+ detect_pipe_max ();
+
+ return GST_DETECTED_PIPE_CAPACITY;
+}
+
+/* exported library functions */
+/*
+static void gst_native_pipeline_clean (GstNativePipeline *self)
+{
+ JNIEnv *env = NULL;
+
+ env = gst_get_jenv (self->priv->vm);
+
+ (*env)->DeleteGlobalRef (env, self->priv->jni_pipeline);
+ (*env)->DeleteGlobalRef (env, self->priv->GstPipelineClass);
+ (*env)->DeleteGlobalRef (env, self->priv->PointerClass);
+
+ if (self->priv->pipeline != NULL)
+ gst_object_unref (GST_OBJECT (self->priv->pipeline));
+
+ if (self->priv->name)
+ {
+ cpio_removeFile (self->priv->name);
+ g_free (self->priv->name);
+ self->priv->name = NULL;
+ }
+
+ JCL_free (env, self->priv);
+ JCL_free (env, self);
+}
+*/
+void gst_native_pipeline_set_pipeline (GstNativePipeline *self,
+ GstElement *pipeline)
+{
+ if (self->priv->pipeline != NULL)
+ gst_object_unref (GST_OBJECT (self->priv->pipeline));
+
+ self->priv->pipeline = pipeline;
+}
+
+GstElement *gst_native_pipeline_get_pipeline (GstNativePipeline *self)
+{
+ return self->priv->pipeline;
+}
+
+char *gst_native_pipeline_get_pipeline_name (GstNativePipeline *self)
+{
+ return self->priv->name;
+}
+
+int gst_native_pipeline_get_pipeline_fd (GstNativePipeline *self)
+{
+ return self->priv->fd;
+}
+
+/* private functions */
+
+static void init_pointer_IDs (JNIEnv* env)
+{
+ jclass PointerClass = NULL;
+
+#if SIZEOF_VOID_P == 8
+ PointerClass = JCL_FindClass (env, "gnu/classpath/Pointer64");
+ if (PointerClass != NULL)
+ {
+ pointerDataFID = (*env)->GetFieldID (env, PointerClass, "data", "J");
+ pointerConstructorMID = (*env)->GetMethodID (env, PointerClass, "<init>",
+ "(J)V");
+ }
+#else
+# if SIZEOF_VOID_P == 4
+ PointerClass = JCL_FindClass (env, "gnu/classpath/Pointer32");
+ if (PointerClass != NULL)
+ {
+ pointerDataFID = (*env)->GetFieldID(env, PointerClass, "data", "I");
+ pointerConstructorMID = (*env)->GetMethodID(env, PointerClass,
+ "<init>", "(I)V");
+ }
+# else
+# error "Pointer size is not supported."
+# endif /* SIZEOF_VOID_P == 4 */
+#endif /* SIZEOF_VOID_P == 8 */
+}
+
+static jint get_free_space (int fd)
+{
+ jint result = -1;
+
+#if defined (FIONSPACE)
+
+ if (ioctl (fd, FIONSPACE, &result) == -1)
+ {
+ g_warning("IMPLEMENT ME: ioctl failed");
+ }
+
+#elif defined (FIONREAD)
+
+ if (ioctl (fd, FIONREAD, &result) == -1)
+ {
+ g_warning("IMPLEMENT ME: ioctl failed");
+ }
+
+ result = GST_DETECTED_PIPE_CAPACITY - result;
+
+#else
+ g_warning("IMPLEMENT ME!!! - !defined (FIONSPACE), !defined (FIONREAD");
+
+#endif
+
+ return result;
+}
+
+static char *create_name (void)
+{
+ char *buffer = NULL;
+ char *tmp = NULL;
+
+ buffer = (char *) g_malloc0 (_GST_MALLOC_SIZE_);
+ if (buffer == NULL)
+ {
+ /* huston, we have a problem... */
+ return NULL;
+ }
+
+ tmp = tempnam (NULL, _GST_PIPELINE_PREFIX_);
+ if (tmp == NULL)
+ {
+ g_free (buffer);
+ return NULL;
+ }
+
+ g_snprintf (buffer, _GST_MALLOC_SIZE_, "%s%s", tmp, _GST_PIPELINE_SUFFIX_);
+ g_free (tmp);
+
+ return buffer;
+}
+
+static void detect_pipe_max (void)
+{
+ int read_fd;
+ int write_fd;
+
+ /* can be anything! */
+ char *character = "a";
+ char *pipe = NULL;
+
+ gboolean available = TRUE;
+ int w = 0;
+ long wrote = 0;
+
+ pipe = create_name ();
+ if (pipe == NULL)
+ {
+ g_warning ("can't create test pipe name");
+ return;
+ }
+
+ if (mkfifo (pipe, 0600) < 0)
+ {
+ g_warning ("unable to create test pipe...");
+ g_free (pipe);
+
+ return;
+ }
+
+ /* open both end of the pipe */
+ read_fd = open (pipe, O_RDONLY | O_NONBLOCK);
+ if (read_fd < 0)
+ {
+ cpio_removeFile (pipe);
+ g_free (pipe);
+
+ return;
+ }
+
+ write_fd = open (pipe, O_WRONLY | O_NONBLOCK);
+ if (write_fd < 0)
+ {
+ cpio_closeFile (write_fd);
+ cpio_removeFile (pipe);
+ g_free (pipe);
+
+ return;
+ }
+
+ while (available)
+ {
+ w = 0;
+
+ cpio_write (write_fd, character, 1, &w);
+ if (w < 0)
+ available = FALSE;
+ else
+ wrote += w;
+ }
+
+ GST_DETECTED_PIPE_CAPACITY = wrote;
+
+ cpio_closeFile (write_fd);
+ cpio_closeFile (read_fd);
+ cpio_removeFile (pipe);
+
+ g_free (pipe);
+}
diff --git a/libjava/classpath/native/jni/gstreamer-peer/gst_native_pipeline.h b/libjava/classpath/native/jni/gstreamer-peer/gst_native_pipeline.h
new file mode 100644
index 000000000..b5a45b40a
--- /dev/null
+++ b/libjava/classpath/native/jni/gstreamer-peer/gst_native_pipeline.h
@@ -0,0 +1,63 @@
+/*gst_native_pipeline.h - Header file for the GstClasspathPlugin
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+#ifndef __GST_NATIVE_PIPELINE_H__
+#define __GST_NATIVE_PIPELINE_H__
+
+#include <glib.h>
+
+#include <gst/gst.h>
+
+typedef struct _GstNativePipeline GstNativePipeline;
+typedef struct _GstNativePipelinePrivate GstNativePipelinePrivate;
+
+struct _GstNativePipeline
+{
+ /* instance members */
+ GstNativePipelinePrivate *priv;
+};
+
+void gst_native_pipeline_set_pipeline (GstNativePipeline *self,
+ GstElement *pipeline);
+
+GstElement *gst_native_pipeline_get_pipeline (GstNativePipeline *self);
+
+char *gst_native_pipeline_get_pipeline_name (GstNativePipeline *self);
+
+int gst_native_pipeline_get_pipeline_fd (GstNativePipeline *self);
+
+#endif /* __GST_NATIVE_PIPELINE_H__ */
diff --git a/libjava/classpath/native/jni/gstreamer-peer/gst_peer.c b/libjava/classpath/native/jni/gstreamer-peer/gst_peer.c
new file mode 100644
index 000000000..da83b006b
--- /dev/null
+++ b/libjava/classpath/native/jni/gstreamer-peer/gst_peer.c
@@ -0,0 +1,83 @@
+/*gst_peer.c - Common utility functions for the native peer.
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+#include <glib.h>
+
+#include <jni.h>
+#include "jcl.h"
+
+#include "gst_peer.h"
+
+JNIEnv *gst_get_jenv (JavaVM *vm)
+{
+ void *env = NULL;
+
+ if ((*vm)->GetEnv(vm, &env, JNI_VERSION_1_2) != JNI_OK)
+ {
+ if ((*vm)->AttachCurrentThreadAsDaemon(vm, &env, NULL) < 0)
+ {
+ g_warning ("GstNativePipeline:- env not attached");
+ return NULL;
+ }
+ }
+
+ return (JNIEnv *) env;
+}
+
+void *
+get_object_from_pointer (JNIEnv *env, jobject pointer, jfieldID pointerDataFID)
+{
+ void *_object = NULL;
+
+ if (env == NULL)
+ return NULL;
+
+ if ((*env)->IsSameObject(env, pointer, NULL) == JNI_TRUE)
+ return NULL;
+
+#if SIZEOF_VOID_P == 8
+ _object = (void *) (*env)->GetLongField(env, pointer, pointerDataFID);
+#else
+# if SIZEOF_VOID_P == 4
+ _object = (void *) (*env)->GetIntField(env, pointer, pointerDataFID);
+# else
+# error "Pointer size is not supported."
+# endif /* SIZEOF_VOID_P == 4 */
+#endif /* SIZEOF_VOID_P == 8 */
+
+ return _object;
+}
diff --git a/libjava/classpath/native/jni/gstreamer-peer/gst_peer.h b/libjava/classpath/native/jni/gstreamer-peer/gst_peer.h
new file mode 100644
index 000000000..4500001b0
--- /dev/null
+++ b/libjava/classpath/native/jni/gstreamer-peer/gst_peer.h
@@ -0,0 +1,59 @@
+/*gst_peer.h - Common utility functions for the native peer.
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+#include <jni.h>
+#include "jcl.h"
+
+#ifdef MAXPATHLEN
+# define _GST_MALLOC_SIZE_ MAXPATHLEN
+#else
+# define _GST_MALLOC_SIZE_ 1024
+#endif
+
+#define _GST_PIPELINE_PREFIX_ "cp-"
+#define _GST_PIPELINE_SUFFIX_ "-classpath-gst-audio"
+
+/**
+ * Return a reference to the object stored in this Pointer.
+ */
+void *
+get_object_from_pointer (JNIEnv *env, jobject pointer, jfieldID pointerDataFID);
+
+/**
+ * Return the JNIEnv valid under the current thread context.
+ */
+JNIEnv *gst_get_jenv (JavaVM *vm);
diff --git a/libjava/classpath/native/jni/gstreamer-peer/gstreamer_io_peer.c b/libjava/classpath/native/jni/gstreamer-peer/gstreamer_io_peer.c
new file mode 100644
index 000000000..7e38b91f8
--- /dev/null
+++ b/libjava/classpath/native/jni/gstreamer-peer/gstreamer_io_peer.c
@@ -0,0 +1,739 @@
+/* gstreamer_io_peer.c -- Implements native methods for class
+ GStreamerNativePeer
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath 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
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+#include <stdio.h>
+#include <string.h>
+
+#include <jni.h>
+
+#include <glib.h>
+#include <glib/gprintf.h>
+
+#include <gdk/gdk.h>
+
+#include <gst/gst.h>
+
+#include "jcl.h"
+
+#include "gst_peer.h"
+
+#include "gnu_javax_sound_sampled_gstreamer_io_GstAudioFileReaderNativePeer.h"
+
+#include "gst_classpath_src.h"
+#include "gst_input_stream.h"
+
+/* for caching */
+static jfieldID fileFID = NULL;
+static jfieldID pointerDataID = NULL;
+
+static jfieldID mimetypeFID = NULL;
+static jfieldID endiannessFID = NULL;
+static jfieldID channelsFID = NULL;
+static jfieldID rateFID = NULL;
+static jfieldID widthFID = NULL;
+static jfieldID depthFID = NULL;
+static jfieldID isSignedFID = NULL;
+static jfieldID nameFID = NULL;
+static jfieldID layerFID = NULL;
+static jfieldID bitrateFID = NULL;
+static jfieldID framedFID = NULL;
+static jfieldID typeFID = NULL;
+
+typedef struct _AudioProperties AudioProperties;
+struct _AudioProperties
+{
+ /*
+ * NOTE: descriptions of the properties are taken from:
+ * http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/section-types-definitions.html#table-audio-types
+ */
+
+ /* decoder name */
+ const char *name;
+
+ /* audio endiannes */
+ const char *endianness;
+
+ /* header size */
+ const char *header_size;
+
+ /* mime */
+ const char *mimetype;
+
+ /* The sample rate of the data, in samples (per channel) per second */
+ const char *samplerate;
+
+ /* The number of channels of audio data */
+ const char *channels;
+
+ const char *layer;
+
+ const char *bitrate;
+
+ const char *framed;
+
+ /*
+ * Defines if the values of the integer samples are signed or not.
+ * Signed samples use one bit to indicate sign (negative or positive)
+ * of the value. Unsigned samples are always positive.
+ */
+ const char *signess;
+
+ /* */
+ const char *rate;
+
+ /* Number of bits allocated per sample. */
+ const char *width;
+
+ /*
+ * The number of bits used per sample.
+ * If the depth is less than the width, the low bits are assumed to be the
+ * ones used. For example, a width of 32 and a depth of 24 means that
+ * each sample is stored in a 32 bit word, but only the low
+ * 24 bits are actually used.
+ */
+ const char *depth;
+
+ /*
+ * This is set in the case of the mpeg files.
+ */
+ const char *type;
+
+ gboolean done;
+};
+
+/* ***** PRIVATE FUNCTIONS DECLARATION ***** */
+
+static gboolean
+set_strings (JNIEnv *env, const AudioProperties *properties, jobject header);
+
+static gboolean
+typefind_callback(GstElement *typefind, guint probability, const GstCaps *caps,
+ gpointer data);
+
+static void
+element_added (GstBin *bin, GstElement *element, gpointer data);
+
+static void
+new_decoded_pad (GstElement *decoder, GstPad *pad,
+ gboolean last, gpointer data);
+
+static gboolean
+fill_info (GstElement *decoder, AudioProperties *properties);
+
+static gchar *
+get_string_property (const GstStructure *structure, const gchar *property);
+
+static gchar *
+get_boolean_property (const GstStructure *structure, const gchar *property);
+
+static gboolean
+set_string (JNIEnv *env, jobject header, jfieldID fieldID,
+ const gchar *property);
+
+static void
+free_properties (AudioProperties *properties);
+
+static void
+reset_properties (AudioProperties *properties);
+
+static jboolean process_audio (GstElement *source, JNIEnv *env, jobject header);
+
+/* ***** END: PRIVATE FUNCTIONS DECLARATION ***** */
+
+/* ***** NATIVE FUNCTIONS ***** */
+
+JNIEXPORT void JNICALL
+Java_gnu_javax_sound_sampled_gstreamer_io_GstAudioFileReaderNativePeer_init_1id_1cache
+ (JNIEnv *env, jclass clazz __attribute__ ((unused)))
+{
+ jclass pointerClass = NULL;
+ jclass GstHeader = NULL;
+
+ GstHeader = JCL_FindClass(env, "gnu/javax/sound/sampled/gstreamer/io/GstAudioFileReaderNativePeer$GstHeader");
+ fileFID = (*env)->GetFieldID(env, GstHeader, "file", "Ljava/lang/String;");
+
+ mimetypeFID = (*env)->GetFieldID(env, GstHeader, "mimetype",
+ "Ljava/lang/String;");
+ endiannessFID = (*env)->GetFieldID(env, GstHeader, "endianness",
+ "Ljava/lang/String;");
+ channelsFID = (*env)->GetFieldID(env, GstHeader, "channels",
+ "Ljava/lang/String;");
+ rateFID = (*env)->GetFieldID(env, GstHeader, "rate", "Ljava/lang/String;");
+ widthFID = (*env)->GetFieldID(env, GstHeader, "width", "Ljava/lang/String;");
+ depthFID = (*env)->GetFieldID(env, GstHeader, "depth", "Ljava/lang/String;");
+ isSignedFID = (*env)->GetFieldID(env, GstHeader, "isSigned",
+ "Ljava/lang/String;");
+ nameFID = (*env)->GetFieldID(env, GstHeader, "name", "Ljava/lang/String;");
+ layerFID = (*env)->GetFieldID(env, GstHeader, "layer", "Ljava/lang/String;");
+ bitrateFID = (*env)->GetFieldID(env, GstHeader, "bitrate",
+ "Ljava/lang/String;");
+ framedFID = (*env)->GetFieldID(env, GstHeader, "framed",
+ "Ljava/lang/String;");
+ typeFID = (*env)->GetFieldID(env, GstHeader, "type", "Ljava/lang/String;");
+
+#if SIZEOF_VOID_P == 8
+ pointerClass = JCL_FindClass (env, "gnu/classpath/Pointer64");
+ if (pointerClass != NULL)
+ {
+ pointerDataID = (*env)->GetFieldID (env, pointerClass, "data", "J");
+ }
+#else
+# if SIZEOF_VOID_P == 4
+ pointerClass = JCL_FindClass (env, "gnu/classpath/Pointer32");
+ if (pointerClass != NULL)
+ {
+ pointerDataID = (*env)->GetFieldID(env, pointerClass, "data", "I");
+ }
+# else
+# error "Pointer size is not supported."
+# endif /* SIZEOF_VOID_P == 4 */
+#endif /* SIZEOF_VOID_P == 8 */
+
+}
+
+JNIEXPORT jboolean JNICALL
+Java_gnu_javax_sound_sampled_gstreamer_io_GstAudioFileReaderNativePeer_gstreamer_1get_1audio_1format_1stream
+ (JNIEnv *env, jclass clazz __attribute__ ((unused)), jobject header,
+ jobject pointer)
+{
+ GstInputStream *istream = NULL;
+ GstElement *source = NULL;
+ gboolean result = JNI_FALSE;
+
+ if (header == NULL)
+ return JNI_FALSE;
+
+ if (pointer == NULL)
+ return JNI_FALSE;
+
+ gst_init (NULL, NULL);
+
+ istream = (GstInputStream *) get_object_from_pointer (env, pointer,
+ pointerDataID);
+ if (istream == NULL)
+ return JNI_FALSE;
+
+ /* init gstreamer */
+ gst_init (NULL, NULL);
+
+ /* SOURCE */
+ source = gst_element_factory_make ("classpathsrc", "source");
+ if (source == NULL)
+ {
+ g_warning ("unable to create a source");
+ return JNI_FALSE;
+ }
+ g_object_set (G_OBJECT (source), GST_CLASSPATH_SRC_ISTREAM, istream, NULL);
+
+ result = process_audio (source, env, header);
+
+ return result;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_gnu_javax_sound_sampled_gstreamer_io_GstAudioFileReaderNativePeer_gstreamer_1get_1audio_1format_1file
+ (JNIEnv *env, jclass clazz __attribute__ ((unused)), jobject header)
+{
+ /* source file */
+ const char *file = NULL;
+
+ /* GStreamer elements */
+ GstElement *source = NULL;
+
+ jboolean result = JNI_FALSE;
+
+ /* java fields */
+ jstring _file = NULL;
+
+ _file = (*env)->GetObjectField(env, header, fileFID);
+ file = JCL_jstring_to_cstring (env, _file);
+ if (file == NULL)
+ {
+ return JNI_FALSE;
+ }
+
+ gst_init (NULL, NULL);
+
+ /* create the source element, will be used to read the file */
+ source = gst_element_factory_make ("filesrc", "source");
+ if (source == NULL)
+ {
+ JCL_free_cstring (env, _file, file);
+ return JNI_FALSE;
+ }
+
+ /* set the file name */
+ g_object_set (G_OBJECT (source), "location", file, NULL);
+
+ result = process_audio (source, env, header);
+
+ /* free stuff */
+ JCL_free_cstring (env, _file, file);
+
+ return result;
+}
+
+/* ***** END: NATIVE FUNCTIONS ***** */
+
+/* ***** PRIVATE FUNCTIONS IMPLEMENTATION ***** */
+
+static jboolean process_audio (GstElement *source, JNIEnv *env, jobject header)
+{
+ /* will contain the properties we need to put into the given GstHeader */
+ AudioProperties *properties = NULL;
+
+ /* GStreamer elements */
+ GstElement *pipeline = NULL;
+ GstElement *decoder = NULL;
+
+ GstElement *typefind = NULL;
+
+ GstStateChangeReturn res;
+
+ jboolean result = JNI_FALSE;
+
+ properties = (AudioProperties *) g_malloc0 (sizeof (AudioProperties));
+ if (properties == NULL)
+ {
+ return result;
+ }
+ reset_properties(properties);
+
+ /*
+ * create the decoder element, this will decode the stream and retrieve
+ * its properties.
+ * We connect a signal to this element, to be informed when it is done
+ * in decoding the stream and to get the needed informations about the
+ * audio file.
+ */
+ decoder = gst_element_factory_make ("decodebin", "decoder");
+ if (decoder == NULL)
+ {
+ free_properties(properties);
+ return result;
+ }
+
+ /* now, we create a pipeline and fill it with the other elements */
+ pipeline = gst_pipeline_new ("pipeline");
+ if (pipeline == NULL)
+ {
+ gst_object_unref (GST_OBJECT (decoder));
+ free_properties(properties);
+ return result;
+ }
+
+ g_signal_connect (decoder, "new-decoded-pad", G_CALLBACK (new_decoded_pad),
+ pipeline);
+ g_signal_connect (G_OBJECT (decoder), "element-added",
+ G_CALLBACK (element_added), properties);
+
+ /*
+ * we get the typefind from the decodebin to catch the additional properties
+ * that the decodebin does not expose to us
+ */
+ typefind = gst_bin_get_by_name (GST_BIN (decoder), "typefind");
+ if (typefind != NULL)
+ {
+ /*
+ * NOTE: the above is not a typo, we can live without the typefind,
+ * just, our stream detection will not be as accurate as we would.
+ * Anyway, if this fails, there is some problem, probabily a memory
+ * error.
+ */
+ g_signal_connect (G_OBJECT (typefind), "have-type",
+ G_CALLBACK (typefind_callback), properties);
+ }
+
+ gst_bin_add_many (GST_BIN (pipeline), source, decoder, NULL);
+ gst_element_link (source, decoder);
+
+ /*
+ * now, we set the pipeline playing state to pause and traverse it
+ * to get the info we need.
+ */
+
+ res = gst_element_set_state (pipeline, GST_STATE_PAUSED);
+ if (res == GST_STATE_CHANGE_FAILURE)
+ {
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+ gst_object_unref (GST_OBJECT (pipeline));
+
+ free_properties(properties);
+
+ return result;
+ }
+
+ res = gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
+ if (res != GST_STATE_CHANGE_SUCCESS)
+ {
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+ gst_object_unref (GST_OBJECT (pipeline));
+
+ free_properties(properties);
+
+ return result;
+ }
+
+ if (fill_info (decoder, properties))
+ {
+ result = set_strings (env, properties, header);
+ }
+
+ /* free stuff */
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+
+ free_properties (properties);
+
+ gst_object_unref (GST_OBJECT (pipeline));
+
+ return result;
+}
+
+
+static gboolean typefind_callback(GstElement *typefind __attribute__ ((unused)),
+ guint probability __attribute__ ((unused)),
+ const GstCaps *caps,
+ gpointer data)
+{
+ GstStructure *structure = NULL;
+ AudioProperties *properties = NULL;
+
+ const char *mpeg = NULL;
+
+ properties = (AudioProperties *) data;
+
+ structure = gst_caps_get_structure (caps, 0);
+
+ /* MIMETYPE */
+ properties->mimetype = gst_structure_get_name (structure);
+ mpeg = get_string_property(structure, "mpegversion");
+
+ if (mpeg != NULL)
+ {
+ properties->layer = get_string_property(structure, "layer");
+ properties->type = (gchar *) g_malloc0 (_GST_MALLOC_SIZE_);
+ g_snprintf ((gpointer) properties->type, _GST_MALLOC_SIZE_,
+ "MPEG%sV%s", mpeg,
+ properties->layer);
+
+ g_free ((gpointer) mpeg);
+ }
+
+ return TRUE;
+}
+
+static void
+new_decoded_pad (GstElement *decoder __attribute__ ((unused)),
+ GstPad *pad,
+ gboolean last __attribute__ ((unused)),
+ gpointer data)
+{
+ GstElement *pipeline = NULL;
+ GstElement *fakesink = NULL;
+ GstPad *sinkpad = NULL;
+
+ pipeline = (GstElement *) data;
+ if (pipeline == NULL)
+ return;
+
+ fakesink = gst_element_factory_make ("fakesink", NULL);
+ if (fakesink == NULL)
+ return;
+
+ gst_bin_add (GST_BIN (pipeline), fakesink);
+ sinkpad = gst_element_get_pad (fakesink, "sink");
+ if (GST_PAD_LINK_FAILED (gst_pad_link (pad, sinkpad)))
+ {
+ gst_bin_remove (GST_BIN (pipeline), fakesink);
+ }
+ else
+ {
+ gst_element_set_state (fakesink, GST_STATE_PAUSED);
+ }
+}
+
+static gboolean
+set_strings (JNIEnv *env, const AudioProperties *properties, jobject header)
+{
+ gboolean result = FALSE;
+
+ /*
+ * we only need at least one of them to be sure we can handle this
+ * kind of audio data.
+ */
+
+ /* now, map our properties to the java class */
+ set_string (env, header, mimetypeFID, properties->mimetype);
+
+ if (set_string (env, header, endiannessFID, properties->endianness))
+ result = JNI_TRUE;
+
+ if (set_string (env, header, channelsFID, properties->channels))
+ result = JNI_TRUE;
+
+ if (set_string (env, header, rateFID, properties->rate))
+ result = JNI_TRUE;
+
+ if (set_string (env, header, widthFID, properties->width))
+ result = JNI_TRUE;
+
+ if (set_string (env, header, depthFID, properties->depth))
+ result = JNI_TRUE;
+
+ if (set_string (env, header, isSignedFID, properties->signess))
+ result = JNI_TRUE;
+
+ if (set_string (env, header, nameFID, properties->name))
+ result = JNI_TRUE;
+
+ /* non primary properties */
+ set_string (env, header, layerFID, properties->layer);
+ set_string (env, header, bitrateFID, properties->bitrate);
+ set_string (env, header, framedFID, properties->framed);
+ set_string (env, header, typeFID, properties->type);
+
+ return result;
+}
+
+static gboolean fill_info (GstElement *decoder, AudioProperties *properties)
+{
+ GstIterator *it = NULL;
+ gpointer data = NULL;
+ gboolean result = FALSE;
+
+ it = gst_element_iterate_src_pads (decoder);
+ while (gst_iterator_next (it, &data) == GST_ITERATOR_OK)
+ {
+ GstPad *pad = GST_PAD (data);
+ GstCaps *caps;
+
+ GstStructure *structure;
+
+ const gchar *caps_string = NULL;
+
+ caps = gst_pad_get_caps (pad);
+ caps_string = gst_caps_to_string (caps);
+
+ if (g_str_has_prefix (caps_string, "video"))
+ {
+ /* no video support, this is an audio library */
+
+ g_free ((gpointer) caps_string);
+ gst_caps_unref (caps);
+ gst_object_unref (pad);
+
+ continue;
+ }
+
+ g_free ((gpointer) caps_string);
+
+ structure = gst_caps_get_structure (GST_CAPS (caps), 0);
+
+ /* fill the properties we need */
+
+ /* SIGNESS */
+ properties->signess = get_boolean_property(structure, "signed");
+ if (properties->signess != NULL)
+ {
+ result = TRUE;
+ }
+
+ /* ENDIANNESS */
+ properties->endianness = get_string_property(structure, "endianness");
+ if (properties->endianness != NULL)
+ {
+ result = TRUE;
+ }
+
+ /* CHANNELS */
+ properties->channels = get_string_property(structure, "channels");
+ if (properties->channels != NULL)
+ {
+ result = TRUE;
+ }
+
+ /* RATE */
+ properties->rate = get_string_property(structure, "rate");
+ if (properties->rate != NULL)
+ {
+ result = TRUE;
+ }
+
+ /* WIDTH */
+ properties->width = get_string_property(structure, "width");
+ if (properties->width != NULL)
+ {
+ result = TRUE;
+ }
+
+ /* DEPTH */
+ properties->depth = get_string_property(structure, "depth");
+ if (properties->depth != NULL)
+ {
+ result = TRUE;
+ }
+
+ gst_caps_unref (caps);
+ gst_object_unref (pad);
+ }
+
+ return result;
+}
+
+static void
+free_properties (AudioProperties *properties __attribute__ ((unused)))
+{
+ /* FIXME this causes a segfault, a string not allocated by us? double free? */
+ /*
+ if (properties->name != NULL) g_free((gpointer) properties->name);
+ if (properties->endianness != NULL) g_free((gpointer) properties->endianness);
+ if (properties->channels != NULL) g_free((gpointer) properties->channels);
+ if (properties->rate != NULL) g_free((gpointer) properties->rate);
+ if (properties->width != NULL) g_free((gpointer) properties->width);
+ if (properties->depth != NULL) g_free((gpointer) properties->depth);
+ if (properties->layer != NULL) g_free((gpointer) properties->layer);
+ if (properties->bitrate != NULL) g_free((gpointer) properties->bitrate);
+ if (properties->framed != NULL) g_free((gpointer) properties->framed);
+
+ if (properties != NULL) g_free ((gpointer) properties);
+ */
+}
+
+static void reset_properties (AudioProperties *properties)
+{
+ properties->done = FALSE;
+ properties->signess = FALSE;
+ properties->name = NULL;
+ properties->endianness = NULL;
+ properties->channels = NULL;
+ properties->rate = NULL;
+ properties->width = NULL;
+ properties->depth = NULL;
+ properties->layer = NULL;
+ properties->bitrate = NULL;
+ properties->framed = NULL;
+}
+
+static gchar *get_string_property (const GstStructure *structure,
+ const gchar *property)
+{
+ int props = 0;
+ gchar *result = NULL;
+
+ if (property == NULL)
+ {
+ return NULL;
+ }
+
+ /* we don't need more */
+ result = (gchar *) g_malloc0 (_GST_MALLOC_SIZE_);
+ if (result == NULL)
+ {
+ /* huston, we have a problem here... */
+ return NULL;
+ }
+
+ if (gst_structure_get_int (structure, property, &props))
+ {
+ g_snprintf (result, _GST_MALLOC_SIZE_, "%d", props);
+ }
+ else
+ {
+ g_free ((gpointer) result);
+ return NULL;
+ }
+
+ return result;
+}
+
+static gchar *get_boolean_property (const GstStructure *structure,
+ const gchar *property)
+{
+ gchar *result = NULL;
+ gboolean props = FALSE;
+
+ result = (gchar *) g_malloc0 (_GST_MALLOC_SIZE_);
+ if (result == NULL)
+ {
+ /* huston, we have a problem here... */
+ return NULL;
+ }
+
+ if (gst_structure_get_boolean (structure, property, &props))
+ {
+ g_snprintf (result, _GST_MALLOC_SIZE_, "%s", (props ? "true" : "false" ));
+ }
+ else
+ {
+ g_free ((gpointer) result);
+ return NULL;
+ }
+
+ return result;
+}
+
+static gboolean set_string (JNIEnv *env, jobject header, jfieldID fieldID,
+ const gchar *property)
+{
+ jstring property_string_field = NULL;
+
+ if (property == NULL || header == NULL)
+ {
+ return JNI_FALSE;
+ }
+
+ property_string_field = (*env)->NewStringUTF(env, property);
+ if (property_string_field == NULL)
+ {
+ return JNI_FALSE;
+ }
+
+ (*env)->SetObjectField(env, header, fieldID, property_string_field);
+
+ return JNI_TRUE;
+}
+
+static void element_added (GstBin *bin, GstElement *element, gpointer data)
+{
+ GstElementFactory *factory;
+
+ factory = gst_element_get_factory (element);
+ ((AudioProperties *) data)->name = gst_element_factory_get_longname (factory);
+}
+
+/* ***** END: PRIVATE FUNCTIONS IMPLEMENTATION ***** */