summaryrefslogtreecommitdiff
path: root/Source/DirectFB/src/media
diff options
context:
space:
mode:
Diffstat (limited to 'Source/DirectFB/src/media')
-rwxr-xr-xSource/DirectFB/src/media/Makefile.am29
-rwxr-xr-xSource/DirectFB/src/media/Makefile.in570
-rwxr-xr-xSource/DirectFB/src/media/idirectfbdatabuffer.c264
-rwxr-xr-xSource/DirectFB/src/media/idirectfbdatabuffer.h104
-rwxr-xr-xSource/DirectFB/src/media/idirectfbdatabuffer_file.c297
-rwxr-xr-xSource/DirectFB/src/media/idirectfbdatabuffer_memory.c266
-rwxr-xr-xSource/DirectFB/src/media/idirectfbdatabuffer_streamed.c529
-rwxr-xr-xSource/DirectFB/src/media/idirectfbfont.c965
-rwxr-xr-xSource/DirectFB/src/media/idirectfbfont.h82
-rwxr-xr-xSource/DirectFB/src/media/idirectfbimageprovider.c167
-rwxr-xr-xSource/DirectFB/src/media/idirectfbimageprovider.h48
-rwxr-xr-xSource/DirectFB/src/media/idirectfbvideoprovider.c387
-rwxr-xr-xSource/DirectFB/src/media/idirectfbvideoprovider.h54
13 files changed, 3762 insertions, 0 deletions
diff --git a/Source/DirectFB/src/media/Makefile.am b/Source/DirectFB/src/media/Makefile.am
new file mode 100755
index 0000000..cb2ae12
--- /dev/null
+++ b/Source/DirectFB/src/media/Makefile.am
@@ -0,0 +1,29 @@
+## Makefile.am for DirectFB/src/media
+
+INCLUDES = \
+ -I$(top_builddir)/lib \
+ -I$(top_builddir)/include \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/src
+
+
+internalincludedir = $(INTERNALINCLUDEDIR)/media
+
+internalinclude_HEADERS = \
+ idirectfbdatabuffer.h \
+ idirectfbfont.h \
+ idirectfbimageprovider.h \
+ idirectfbvideoprovider.h
+
+
+noinst_LTLIBRARIES = libdirectfb_media.la
+
+libdirectfb_media_la_SOURCES = \
+ idirectfbdatabuffer.c \
+ idirectfbdatabuffer_file.c \
+ idirectfbdatabuffer_memory.c \
+ idirectfbdatabuffer_streamed.c \
+ idirectfbfont.c \
+ idirectfbimageprovider.c \
+ idirectfbvideoprovider.c
diff --git a/Source/DirectFB/src/media/Makefile.in b/Source/DirectFB/src/media/Makefile.in
new file mode 100755
index 0000000..930fe11
--- /dev/null
+++ b/Source/DirectFB/src/media/Makefile.in
@@ -0,0 +1,570 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 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@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@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 = src/media
+DIST_COMMON = $(internalinclude_HEADERS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libdirectfb_media_la_LIBADD =
+am_libdirectfb_media_la_OBJECTS = idirectfbdatabuffer.lo \
+ idirectfbdatabuffer_file.lo idirectfbdatabuffer_memory.lo \
+ idirectfbdatabuffer_streamed.lo idirectfbfont.lo \
+ idirectfbimageprovider.lo idirectfbvideoprovider.lo
+libdirectfb_media_la_OBJECTS = $(am_libdirectfb_media_la_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+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 = $(libdirectfb_media_la_SOURCES)
+DIST_SOURCES = $(libdirectfb_media_la_SOURCES)
+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 = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(internalincludedir)"
+internalincludeHEADERS_INSTALL = $(INSTALL_HEADER)
+HEADERS = $(internalinclude_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+ASFLAGS = @ASFLAGS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATADIR = @DATADIR@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DFB_CFLAGS_OMIT_FRAME_POINTER = @DFB_CFLAGS_OMIT_FRAME_POINTER@
+DFB_INTERNAL_CFLAGS = @DFB_INTERNAL_CFLAGS@
+DFB_LDFLAGS = @DFB_LDFLAGS@
+DFB_SMOOTH_SCALING = @DFB_SMOOTH_SCALING@
+DIRECTFB_BINARY_AGE = @DIRECTFB_BINARY_AGE@
+DIRECTFB_CSOURCE = @DIRECTFB_CSOURCE@
+DIRECTFB_INTERFACE_AGE = @DIRECTFB_INTERFACE_AGE@
+DIRECTFB_MAJOR_VERSION = @DIRECTFB_MAJOR_VERSION@
+DIRECTFB_MICRO_VERSION = @DIRECTFB_MICRO_VERSION@
+DIRECTFB_MINOR_VERSION = @DIRECTFB_MINOR_VERSION@
+DIRECTFB_VERSION = @DIRECTFB_VERSION@
+DIRECT_BUILD_DEBUG = @DIRECT_BUILD_DEBUG@
+DIRECT_BUILD_DEBUGS = @DIRECT_BUILD_DEBUGS@
+DIRECT_BUILD_GETTID = @DIRECT_BUILD_GETTID@
+DIRECT_BUILD_NETWORK = @DIRECT_BUILD_NETWORK@
+DIRECT_BUILD_STDBOOL = @DIRECT_BUILD_STDBOOL@
+DIRECT_BUILD_TEXT = @DIRECT_BUILD_TEXT@
+DIRECT_BUILD_TRACE = @DIRECT_BUILD_TRACE@
+DSYMUTIL = @DSYMUTIL@
+DYNLIB = @DYNLIB@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+FREETYPE_PROVIDER = @FREETYPE_PROVIDER@
+FUSION_BUILD_KERNEL = @FUSION_BUILD_KERNEL@
+FUSION_BUILD_MULTI = @FUSION_BUILD_MULTI@
+FUSION_MESSAGE_SIZE = @FUSION_MESSAGE_SIZE@
+GIF_PROVIDER = @GIF_PROVIDER@
+GREP = @GREP@
+HAVE_LINUX = @HAVE_LINUX@
+INCLUDEDIR = @INCLUDEDIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTERNALINCLUDEDIR = @INTERNALINCLUDEDIR@
+JPEG_PROVIDER = @JPEG_PROVIDER@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBJPEG = @LIBJPEG@
+LIBOBJS = @LIBOBJS@
+LIBPNG = @LIBPNG@
+LIBPNG_CONFIG = @LIBPNG_CONFIG@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LT_AGE = @LT_AGE@
+LT_BINARY = @LT_BINARY@
+LT_CURRENT = @LT_CURRENT@
+LT_RELEASE = @LT_RELEASE@
+LT_REVISION = @LT_REVISION@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAN2HTML = @MAN2HTML@
+MKDIR_P = @MKDIR_P@
+MODULEDIR = @MODULEDIR@
+MODULEDIRNAME = @MODULEDIRNAME@
+NMEDIT = @NMEDIT@
+OBJEXT = @OBJEXT@
+OSX_LIBS = @OSX_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PNG_PROVIDER = @PNG_PROVIDER@
+RANLIB = @RANLIB@
+RUNTIME_SYSROOT = @RUNTIME_SYSROOT@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOPATH = @SOPATH@
+STRIP = @STRIP@
+SYSCONFDIR = @SYSCONFDIR@
+SYSFS_LIBS = @SYSFS_LIBS@
+THREADFLAGS = @THREADFLAGS@
+THREADLIB = @THREADLIB@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+VERSION = @VERSION@
+VNC_CFLAGS = @VNC_CFLAGS@
+VNC_CONFIG = @VNC_CONFIG@
+VNC_LIBS = @VNC_LIBS@
+X11_CFLAGS = @X11_CFLAGS@
+X11_LIBS = @X11_LIBS@
+ZLIB_LIBS = @ZLIB_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+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@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = \
+ -I$(top_builddir)/lib \
+ -I$(top_builddir)/include \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/src
+
+internalincludedir = $(INTERNALINCLUDEDIR)/media
+internalinclude_HEADERS = \
+ idirectfbdatabuffer.h \
+ idirectfbfont.h \
+ idirectfbimageprovider.h \
+ idirectfbvideoprovider.h
+
+noinst_LTLIBRARIES = libdirectfb_media.la
+libdirectfb_media_la_SOURCES = \
+ idirectfbdatabuffer.c \
+ idirectfbdatabuffer_file.c \
+ idirectfbdatabuffer_memory.c \
+ idirectfbdatabuffer_streamed.c \
+ idirectfbfont.c \
+ idirectfbimageprovider.c \
+ idirectfbvideoprovider.c
+
+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 \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/media/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/media/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
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_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
+libdirectfb_media.la: $(libdirectfb_media_la_OBJECTS) $(libdirectfb_media_la_DEPENDENCIES)
+ $(LINK) $(libdirectfb_media_la_OBJECTS) $(libdirectfb_media_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idirectfbdatabuffer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idirectfbdatabuffer_file.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idirectfbdatabuffer_memory.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idirectfbdatabuffer_streamed.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idirectfbfont.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idirectfbimageprovider.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idirectfbvideoprovider.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(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@ mv -f $(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@ mv -f $(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
+install-internalincludeHEADERS: $(internalinclude_HEADERS)
+ @$(NORMAL_INSTALL)
+ test -z "$(internalincludedir)" || $(MKDIR_P) "$(DESTDIR)$(internalincludedir)"
+ @list='$(internalinclude_HEADERS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(internalincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(internalincludedir)/$$f'"; \
+ $(internalincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(internalincludedir)/$$f"; \
+ done
+
+uninstall-internalincludeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(internalinclude_HEADERS)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(internalincludedir)/$$f'"; \
+ rm -f "$(DESTDIR)$(internalincludedir)/$$f"; \
+ done
+
+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; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ 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; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ 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)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(internalincludedir)"; 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)
+
+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-noinstLTLIBRARIES \
+ 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
+
+info: info-am
+
+info-am:
+
+install-data-am: install-internalincludeHEADERS
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: 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-internalincludeHEADERS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am \
+ install-internalincludeHEADERS install-man 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-internalincludeHEADERS
+
+# 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/Source/DirectFB/src/media/idirectfbdatabuffer.c b/Source/DirectFB/src/media/idirectfbdatabuffer.c
new file mode 100755
index 0000000..68ccc4e
--- /dev/null
+++ b/Source/DirectFB/src/media/idirectfbdatabuffer.c
@@ -0,0 +1,264 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <string.h>
+#include <errno.h>
+
+#include <sys/time.h>
+
+#include <pthread.h>
+
+#include <fusion/reactor.h>
+#include <direct/list.h>
+
+#include <directfb.h>
+
+#include <core/coredefs.h>
+#include <core/coretypes.h>
+
+#include <core/input.h>
+#include <core/windows.h>
+
+#include <misc/util.h>
+#include <direct/interface.h>
+#include <direct/mem.h>
+
+#include <media/idirectfbdatabuffer.h>
+#include <media/idirectfbfont.h>
+#include <media/idirectfbimageprovider.h>
+#include <media/idirectfbvideoprovider.h>
+
+
+void
+IDirectFBDataBuffer_Destruct( IDirectFBDataBuffer *thiz )
+{
+ IDirectFBDataBuffer_data *data = (IDirectFBDataBuffer_data*) thiz->priv;
+
+ if (data->filename)
+ D_FREE( data->filename );
+
+ DIRECT_DEALLOCATE_INTERFACE( thiz );
+}
+
+static DirectResult
+IDirectFBDataBuffer_AddRef( IDirectFBDataBuffer *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer)
+
+ data->ref++;
+
+ return DFB_OK;
+}
+
+static DirectResult
+IDirectFBDataBuffer_Release( IDirectFBDataBuffer *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer)
+
+ if (--data->ref == 0)
+ IDirectFBDataBuffer_Destruct( thiz );
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Flush( IDirectFBDataBuffer *thiz )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Finish( IDirectFBDataBuffer *thiz )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBDataBuffer_SeekTo( IDirectFBDataBuffer *thiz,
+ unsigned int offset )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBDataBuffer_GetPosition( IDirectFBDataBuffer *thiz,
+ unsigned int *offset )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBDataBuffer_GetLength( IDirectFBDataBuffer *thiz,
+ unsigned int *length )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBDataBuffer_WaitForData( IDirectFBDataBuffer *thiz,
+ unsigned int length )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBDataBuffer_WaitForDataWithTimeout( IDirectFBDataBuffer *thiz,
+ unsigned int length,
+ unsigned int seconds,
+ unsigned int milli_seconds )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBDataBuffer_GetData( IDirectFBDataBuffer *thiz,
+ unsigned int length,
+ void *data,
+ unsigned int *read )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBDataBuffer_PeekData( IDirectFBDataBuffer *thiz,
+ unsigned int length,
+ int offset,
+ void *data,
+ unsigned int *read )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBDataBuffer_HasData( IDirectFBDataBuffer *thiz )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBDataBuffer_PutData( IDirectFBDataBuffer *thiz,
+ const void *data,
+ unsigned int length )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBDataBuffer_CreateImageProvider( IDirectFBDataBuffer *thiz,
+ IDirectFBImageProvider **interface )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer)
+
+ /* Check arguments */
+ if (!interface)
+ return DFB_INVARG;
+
+#ifndef DIRECTFB_PURE_VOODOO
+ return IDirectFBImageProvider_CreateFromBuffer( thiz, data->core, interface );
+#else
+ D_BUG( "%s in pure Voodoo build", __FUNCTION__ );
+ return DFB_BUG;
+#endif
+}
+
+static DFBResult
+IDirectFBDataBuffer_CreateVideoProvider( IDirectFBDataBuffer *thiz,
+ IDirectFBVideoProvider **interface )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer)
+
+ /* Check arguments */
+ if (!interface)
+ return DFB_INVARG;
+
+#ifndef DIRECTFB_PURE_VOODOO
+ return IDirectFBVideoProvider_CreateFromBuffer( thiz, data->core, interface );
+#else
+ D_BUG( "%s in pure Voodoo build", __FUNCTION__ );
+ return DFB_BUG;
+#endif
+}
+
+static DFBResult
+IDirectFBDataBuffer_CreateFont( IDirectFBDataBuffer *thiz,
+ const DFBFontDescription *desc,
+ IDirectFBFont **interface )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer)
+
+ /* Check arguments */
+ if (!interface || !desc)
+ return DFB_INVARG;
+
+#ifndef DIRECTFB_PURE_VOODOO
+ return IDirectFBFont_CreateFromBuffer( thiz, data->core, desc, interface );
+#else
+ D_BUG( "%s in pure Voodoo build", __FUNCTION__ );
+ return DFB_BUG;
+#endif
+}
+
+DFBResult
+IDirectFBDataBuffer_Construct( IDirectFBDataBuffer *thiz,
+ const char *filename,
+ CoreDFB *core )
+{
+ DIRECT_ALLOCATE_INTERFACE_DATA(thiz, IDirectFBDataBuffer)
+
+ data->ref = 1;
+ data->core = core;
+
+ if (filename)
+ data->filename = D_STRDUP( filename );
+
+ thiz->AddRef = IDirectFBDataBuffer_AddRef;
+ thiz->Release = IDirectFBDataBuffer_Release;
+ thiz->Flush = IDirectFBDataBuffer_Flush;
+ thiz->Finish = IDirectFBDataBuffer_Finish;
+ thiz->SeekTo = IDirectFBDataBuffer_SeekTo;
+ thiz->GetPosition = IDirectFBDataBuffer_GetPosition;
+ thiz->GetLength = IDirectFBDataBuffer_GetLength;
+ thiz->WaitForData = IDirectFBDataBuffer_WaitForData;
+ thiz->WaitForDataWithTimeout = IDirectFBDataBuffer_WaitForDataWithTimeout;
+ thiz->GetData = IDirectFBDataBuffer_GetData;
+ thiz->PeekData = IDirectFBDataBuffer_PeekData;
+ thiz->HasData = IDirectFBDataBuffer_HasData;
+ thiz->PutData = IDirectFBDataBuffer_PutData;
+ thiz->CreateImageProvider = IDirectFBDataBuffer_CreateImageProvider;
+ thiz->CreateVideoProvider = IDirectFBDataBuffer_CreateVideoProvider;
+ thiz->CreateFont = IDirectFBDataBuffer_CreateFont;
+
+ return DFB_OK;
+}
+
diff --git a/Source/DirectFB/src/media/idirectfbdatabuffer.h b/Source/DirectFB/src/media/idirectfbdatabuffer.h
new file mode 100755
index 0000000..4b19eb0
--- /dev/null
+++ b/Source/DirectFB/src/media/idirectfbdatabuffer.h
@@ -0,0 +1,104 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __IDIRECTFBDATABUFFER_H__
+#define __IDIRECTFBDATABUFFER_H__
+
+#include <core/core.h>
+
+/*
+ * private data struct of IDirectFBDataBuffer
+ */
+typedef struct {
+ int ref; /* reference counter */
+ char *filename; /* Only set if databuffer is created from file. */
+
+ CoreDFB *core;
+
+ bool is_memory;
+} IDirectFBDataBuffer_data;
+
+/*
+ * private data struct of IDirectFBDataBuffer_File
+ */
+typedef struct {
+ IDirectFBDataBuffer_data base;
+
+ DirectStream *stream;
+ pthread_mutex_t mutex;
+} IDirectFBDataBuffer_File_data;
+
+/*
+ * private data struct of IDirectFBDataBuffer_Memory
+ */
+typedef struct {
+ IDirectFBDataBuffer_data base;
+
+ const void *buffer;
+ unsigned int length;
+
+ unsigned int pos;
+} IDirectFBDataBuffer_Memory_data;
+
+/*
+ * base constructor
+ *
+ * If the databuffer is created for a file, the filename can be provided
+ * for fallbacks.
+ */
+DFBResult IDirectFBDataBuffer_Construct( IDirectFBDataBuffer *thiz,
+ const char *filename,
+ CoreDFB *core );
+
+/*
+ * base destructor
+ */
+void IDirectFBDataBuffer_Destruct( IDirectFBDataBuffer *thiz );
+
+/*
+ * generic streamed data buffer
+ */
+DFBResult IDirectFBDataBuffer_Streamed_Construct( IDirectFBDataBuffer *thiz,
+ CoreDFB *core );
+
+/*
+ * file based static data buffer
+ */
+DFBResult IDirectFBDataBuffer_File_Construct( IDirectFBDataBuffer *thiz,
+ const char *filename,
+ CoreDFB *core );
+
+/*
+ * memory based static data buffer
+ */
+DFBResult IDirectFBDataBuffer_Memory_Construct( IDirectFBDataBuffer *thiz,
+ const void *data,
+ unsigned int length,
+ CoreDFB *core );
+
+#endif
diff --git a/Source/DirectFB/src/media/idirectfbdatabuffer_file.c b/Source/DirectFB/src/media/idirectfbdatabuffer_file.c
new file mode 100755
index 0000000..245ce02
--- /dev/null
+++ b/Source/DirectFB/src/media/idirectfbdatabuffer_file.c
@@ -0,0 +1,297 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+#include <string.h>
+#include <errno.h>
+
+#include <pthread.h>
+
+#include <fusion/reactor.h>
+#include <direct/list.h>
+
+#include <directfb.h>
+
+#include <core/coredefs.h>
+#include <core/coretypes.h>
+
+#include <core/input.h>
+#include <core/windows.h>
+
+#include <misc/util.h>
+
+#include <direct/interface.h>
+#include <direct/mem.h>
+#include <direct/messages.h>
+#include <direct/stream.h>
+#include <direct/util.h>
+
+#include <media/idirectfbdatabuffer.h>
+
+
+
+static void
+IDirectFBDataBuffer_File_Destruct( IDirectFBDataBuffer *thiz )
+{
+ IDirectFBDataBuffer_File_data *data =
+ (IDirectFBDataBuffer_File_data*) thiz->priv;
+
+ direct_stream_destroy( data->stream );
+
+ pthread_mutex_destroy( &data->mutex );
+
+ IDirectFBDataBuffer_Destruct( thiz );
+}
+
+static DirectResult
+IDirectFBDataBuffer_File_Release( IDirectFBDataBuffer *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer)
+
+ if (--data->ref == 0)
+ IDirectFBDataBuffer_File_Destruct( thiz );
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_File_Flush( IDirectFBDataBuffer *thiz )
+{
+ return DFB_UNSUPPORTED;
+}
+
+static DFBResult
+IDirectFBDataBuffer_File_Finish( IDirectFBDataBuffer *thiz )
+{
+ return DFB_UNSUPPORTED;
+}
+
+static DFBResult
+IDirectFBDataBuffer_File_SeekTo( IDirectFBDataBuffer *thiz,
+ unsigned int offset )
+{
+ DFBResult ret;
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_File)
+
+ if (!direct_stream_seekable( data->stream ))
+ return DFB_UNSUPPORTED;
+
+ pthread_mutex_lock( &data->mutex );
+ ret = direct_stream_seek( data->stream, offset );
+ pthread_mutex_unlock( &data->mutex );
+
+ return ret;
+}
+
+static DFBResult
+IDirectFBDataBuffer_File_GetPosition( IDirectFBDataBuffer *thiz,
+ unsigned int *offset )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_File)
+
+ if (!offset)
+ return DFB_INVARG;
+
+ *offset = direct_stream_offset( data->stream );
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_File_GetLength( IDirectFBDataBuffer *thiz,
+ unsigned int *length )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_File)
+
+ if (!length)
+ return DFB_INVARG;
+
+ *length = direct_stream_length( data->stream );
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_File_WaitForData( IDirectFBDataBuffer *thiz,
+ unsigned int length )
+{
+ DFBResult ret;
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_File)
+
+ pthread_mutex_lock( &data->mutex );
+ ret = direct_stream_wait( data->stream, length, NULL );
+ pthread_mutex_unlock( &data->mutex );
+
+ return ret;
+}
+
+static DFBResult
+IDirectFBDataBuffer_File_WaitForDataWithTimeout( IDirectFBDataBuffer *thiz,
+ unsigned int length,
+ unsigned int seconds,
+ unsigned int milli_seconds )
+{
+ DFBResult ret;
+ struct timeval tv;
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_File)
+
+ tv.tv_sec = seconds;
+ tv.tv_usec = milli_seconds*1000;
+
+ while (pthread_mutex_trylock( &data->mutex )) {
+ struct timespec t, r;
+
+ if (errno != EBUSY)
+ return errno2result( errno );
+
+ t.tv_sec = 0;
+ t.tv_nsec = 10000;
+ nanosleep( &t, &r );
+
+ tv.tv_usec -= (t.tv_nsec - r.tv_nsec + 500) / 1000;
+ if (tv.tv_usec < 0) {
+ if (tv.tv_sec < 1)
+ return DFB_TIMEOUT;
+
+ tv.tv_sec--;
+ tv.tv_usec += 999999;
+ }
+ }
+
+ ret = direct_stream_wait( data->stream, length, &tv );
+
+ pthread_mutex_unlock( &data->mutex );
+
+ return ret;
+}
+
+static DFBResult
+IDirectFBDataBuffer_File_GetData( IDirectFBDataBuffer *thiz,
+ unsigned int length,
+ void *data_buffer,
+ unsigned int *read_out )
+{
+ DFBResult ret;
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_File)
+
+ if (!data_buffer || !length)
+ return DFB_INVARG;
+
+ pthread_mutex_lock( &data->mutex );
+ ret = direct_stream_read( data->stream, length, data_buffer, read_out );
+ pthread_mutex_unlock( &data->mutex );
+
+ return ret;
+}
+
+static DFBResult
+IDirectFBDataBuffer_File_PeekData( IDirectFBDataBuffer *thiz,
+ unsigned int length,
+ int offset,
+ void *data_buffer,
+ unsigned int *read_out )
+{
+ DFBResult ret;
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_File)
+
+ if (!data_buffer || !length)
+ return DFB_INVARG;
+
+ pthread_mutex_lock( &data->mutex );
+ ret = direct_stream_peek( data->stream, length,
+ offset, data_buffer, read_out );
+ pthread_mutex_unlock( &data->mutex );
+
+ return ret;
+}
+
+static DFBResult
+IDirectFBDataBuffer_File_HasData( IDirectFBDataBuffer *thiz )
+{
+ struct timeval tv = {0,0};
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_File)
+
+ return direct_stream_wait( data->stream, 1, &tv );
+}
+
+static DFBResult
+IDirectFBDataBuffer_File_PutData( IDirectFBDataBuffer *thiz,
+ const void *data_buffer,
+ unsigned int length )
+{
+ return DFB_UNSUPPORTED;
+}
+
+DFBResult
+IDirectFBDataBuffer_File_Construct( IDirectFBDataBuffer *thiz,
+ const char *filename,
+ CoreDFB *core )
+{
+ DFBResult ret;
+
+ DIRECT_ALLOCATE_INTERFACE_DATA(thiz, IDirectFBDataBuffer_File)
+
+ ret = IDirectFBDataBuffer_Construct( thiz, filename, core );
+ if (ret)
+ return ret;
+
+ ret = direct_stream_create( filename, &data->stream );
+ if (ret) {
+ DIRECT_DEALLOCATE_INTERFACE( thiz );
+ return ret;
+ }
+
+ direct_util_recursive_pthread_mutex_init( &data->mutex );
+
+ thiz->Release = IDirectFBDataBuffer_File_Release;
+ thiz->Flush = IDirectFBDataBuffer_File_Flush;
+ thiz->Finish = IDirectFBDataBuffer_File_Finish;
+ thiz->SeekTo = IDirectFBDataBuffer_File_SeekTo;
+ thiz->GetPosition = IDirectFBDataBuffer_File_GetPosition;
+ thiz->GetLength = IDirectFBDataBuffer_File_GetLength;
+ thiz->WaitForData = IDirectFBDataBuffer_File_WaitForData;
+ thiz->WaitForDataWithTimeout = IDirectFBDataBuffer_File_WaitForDataWithTimeout;
+ thiz->GetData = IDirectFBDataBuffer_File_GetData;
+ thiz->PeekData = IDirectFBDataBuffer_File_PeekData;
+ thiz->HasData = IDirectFBDataBuffer_File_HasData;
+ thiz->PutData = IDirectFBDataBuffer_File_PutData;
+
+ return DFB_OK;
+}
+
diff --git a/Source/DirectFB/src/media/idirectfbdatabuffer_memory.c b/Source/DirectFB/src/media/idirectfbdatabuffer_memory.c
new file mode 100755
index 0000000..233e4b4
--- /dev/null
+++ b/Source/DirectFB/src/media/idirectfbdatabuffer_memory.c
@@ -0,0 +1,266 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <string.h>
+#include <errno.h>
+
+#include <sys/time.h>
+
+#include <pthread.h>
+
+#include <fusion/reactor.h>
+#include <direct/list.h>
+
+#include <directfb.h>
+
+#include <core/coredefs.h>
+#include <core/coretypes.h>
+
+#include <core/input.h>
+#include <core/windows.h>
+
+#include <direct/interface.h>
+#include <direct/mem.h>
+#include <direct/memcpy.h>
+#include <direct/util.h>
+
+#include <media/idirectfbdatabuffer.h>
+
+
+static void
+IDirectFBDataBuffer_Memory_Destruct( IDirectFBDataBuffer *thiz )
+{
+ IDirectFBDataBuffer_Destruct( thiz );
+}
+
+static DirectResult
+IDirectFBDataBuffer_Memory_Release( IDirectFBDataBuffer *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer)
+
+ if (--data->ref == 0)
+ IDirectFBDataBuffer_Memory_Destruct( thiz );
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Memory_Flush( IDirectFBDataBuffer *thiz )
+{
+ return DFB_UNSUPPORTED;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Memory_Finish( IDirectFBDataBuffer *thiz )
+{
+ return DFB_UNSUPPORTED;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Memory_SeekTo( IDirectFBDataBuffer *thiz,
+ unsigned int offset )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_Memory)
+
+ if (offset >= data->length)
+ return DFB_INVARG;
+
+ data->pos = offset;
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Memory_GetPosition( IDirectFBDataBuffer *thiz,
+ unsigned int *offset )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_Memory)
+
+ if (!offset)
+ return DFB_INVARG;
+
+ *offset = data->pos;
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Memory_GetLength( IDirectFBDataBuffer *thiz,
+ unsigned int *length )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_Memory)
+
+ if (!length)
+ return DFB_INVARG;
+
+ *length = data->length;
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Memory_WaitForData( IDirectFBDataBuffer *thiz,
+ unsigned int length )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_Memory)
+
+ if (data->pos + length > data->length)
+ return DFB_EOF;
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Memory_WaitForDataWithTimeout( IDirectFBDataBuffer *thiz,
+ unsigned int length,
+ unsigned int seconds,
+ unsigned int milli_seconds )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_Memory)
+
+ if (data->pos + length > data->length)
+ return DFB_EOF;
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Memory_GetData( IDirectFBDataBuffer *thiz,
+ unsigned int length,
+ void *data_buffer,
+ unsigned int *read_out )
+{
+ unsigned int size;
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_Memory)
+
+ if (!data_buffer || !length)
+ return DFB_INVARG;
+
+ if (data->pos >= data->length)
+ return DFB_EOF;
+
+ size = MIN( length, data->length - data->pos );
+
+ direct_memcpy( data_buffer, data->buffer + data->pos, size );
+
+ data->pos += size;
+
+ if (read_out)
+ *read_out = size;
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Memory_PeekData( IDirectFBDataBuffer *thiz,
+ unsigned int length,
+ int offset,
+ void *data_buffer,
+ unsigned int *read_out )
+{
+ unsigned int size;
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_Memory)
+
+ if (!data_buffer || !length)
+ return DFB_INVARG;
+
+ if (data->pos + offset >= data->length)
+ return DFB_EOF;
+
+ size = MIN( length, data->length - data->pos - offset );
+
+ direct_memcpy( data_buffer, data->buffer + data->pos + offset, size );
+
+ if (read_out)
+ *read_out = size;
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Memory_HasData( IDirectFBDataBuffer *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_Memory)
+
+ if (data->pos >= data->length)
+ return DFB_EOF;
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Memory_PutData( IDirectFBDataBuffer *thiz,
+ const void *data_buffer,
+ unsigned int length )
+{
+ return DFB_UNSUPPORTED;
+}
+
+DFBResult
+IDirectFBDataBuffer_Memory_Construct( IDirectFBDataBuffer *thiz,
+ const void *data_buffer,
+ unsigned int length,
+ CoreDFB *core )
+{
+ DFBResult ret;
+
+ DIRECT_ALLOCATE_INTERFACE_DATA(thiz, IDirectFBDataBuffer_Memory)
+
+ ret = IDirectFBDataBuffer_Construct( thiz, NULL, core );
+ if (ret)
+ return ret;
+
+ data->buffer = data_buffer;
+ data->length = length;
+
+ data->base.is_memory = true;
+
+ thiz->Release = IDirectFBDataBuffer_Memory_Release;
+ thiz->Flush = IDirectFBDataBuffer_Memory_Flush;
+ thiz->Finish = IDirectFBDataBuffer_Memory_Finish;
+ thiz->SeekTo = IDirectFBDataBuffer_Memory_SeekTo;
+ thiz->GetPosition = IDirectFBDataBuffer_Memory_GetPosition;
+ thiz->GetLength = IDirectFBDataBuffer_Memory_GetLength;
+ thiz->WaitForData = IDirectFBDataBuffer_Memory_WaitForData;
+ thiz->WaitForDataWithTimeout = IDirectFBDataBuffer_Memory_WaitForDataWithTimeout;
+ thiz->GetData = IDirectFBDataBuffer_Memory_GetData;
+ thiz->PeekData = IDirectFBDataBuffer_Memory_PeekData;
+ thiz->HasData = IDirectFBDataBuffer_Memory_HasData;
+ thiz->PutData = IDirectFBDataBuffer_Memory_PutData;
+
+ return DFB_OK;
+}
+
diff --git a/Source/DirectFB/src/media/idirectfbdatabuffer_streamed.c b/Source/DirectFB/src/media/idirectfbdatabuffer_streamed.c
new file mode 100755
index 0000000..5ce1168
--- /dev/null
+++ b/Source/DirectFB/src/media/idirectfbdatabuffer_streamed.c
@@ -0,0 +1,529 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <string.h>
+#include <errno.h>
+
+#include <sys/time.h>
+
+#include <pthread.h>
+
+#include <fusion/reactor.h>
+#include <direct/list.h>
+#include <fusion/lock.h>
+
+#include <directfb.h>
+
+#include <core/coredefs.h>
+#include <core/coretypes.h>
+
+#include <direct/interface.h>
+#include <direct/mem.h>
+#include <direct/memcpy.h>
+#include <direct/util.h>
+
+#include <media/idirectfbdatabuffer.h>
+
+typedef struct {
+ DirectLink link;
+
+ void *data; /* actual data hold */
+ unsigned int length; /* length of chunk */
+
+ unsigned int done; /* number of bytes already consumed */
+} DataChunk;
+
+static DataChunk *
+create_chunk( const void *data, int length );
+
+static void
+destroy_chunk( DataChunk *chunk );
+
+/*
+ * private data struct of IDirectFBDataBuffer_Streamed
+ */
+typedef struct {
+ IDirectFBDataBuffer_data base;
+
+ DirectLink *chunks; /* data chunks */
+
+ unsigned int length; /* total length of all chunks */
+
+ bool finished; /* whether Finish() has been called */
+
+ pthread_mutex_t chunks_mutex; /* mutex lock for accessing
+ the chunk list */
+
+ pthread_cond_t wait_condition; /* condition used for idle
+ wait in WaitForEvent() */
+} IDirectFBDataBuffer_Streamed_data;
+
+static void
+DestroyAllChunks( IDirectFBDataBuffer_Streamed_data *data );
+
+static void
+ReadChunkData( IDirectFBDataBuffer_Streamed_data *data,
+ void *buffer,
+ unsigned int offset,
+ unsigned int length,
+ bool flush );
+
+
+static void
+IDirectFBDataBuffer_Streamed_Destruct( IDirectFBDataBuffer *thiz )
+{
+ IDirectFBDataBuffer_Streamed_data *data =
+ (IDirectFBDataBuffer_Streamed_data*) thiz->priv;
+
+ pthread_cond_destroy( &data->wait_condition );
+ pthread_mutex_destroy( &data->chunks_mutex );
+
+ IDirectFBDataBuffer_Destruct( thiz );
+}
+
+static DirectResult
+IDirectFBDataBuffer_Streamed_Release( IDirectFBDataBuffer *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer)
+
+ if (--data->ref == 0)
+ IDirectFBDataBuffer_Streamed_Destruct( thiz );
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Streamed_Flush( IDirectFBDataBuffer *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_Streamed)
+
+ pthread_mutex_lock( &data->chunks_mutex );
+
+ DestroyAllChunks( data );
+
+ pthread_mutex_unlock( &data->chunks_mutex );
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Streamed_Finish( IDirectFBDataBuffer *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_Streamed)
+
+ if (!data->finished) {
+ data->finished = true;
+
+ pthread_mutex_lock( &data->chunks_mutex );
+ pthread_cond_broadcast( &data->wait_condition );
+ pthread_mutex_unlock( &data->chunks_mutex );
+ }
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Streamed_SeekTo( IDirectFBDataBuffer *thiz,
+ unsigned int offset )
+{
+ return DFB_UNSUPPORTED;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Streamed_GetPosition( IDirectFBDataBuffer *thiz,
+ unsigned int *offset )
+{
+ return DFB_UNSUPPORTED;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Streamed_GetLength( IDirectFBDataBuffer *thiz,
+ unsigned int *length )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_Streamed)
+
+ /* Check arguments. */
+ if (!length)
+ return DFB_INVARG;
+
+ /* Return total length of all chunks. */
+ *length = data->length;
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Streamed_WaitForData( IDirectFBDataBuffer *thiz,
+ unsigned int length )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_Streamed)
+
+ if (data->finished && !data->chunks)
+ return DFB_EOF;
+
+ pthread_mutex_lock( &data->chunks_mutex );
+
+ while (data->length < length && !data->finished)
+ pthread_cond_wait( &data->wait_condition, &data->chunks_mutex );
+
+ pthread_mutex_unlock( &data->chunks_mutex );
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Streamed_WaitForDataWithTimeout( IDirectFBDataBuffer *thiz,
+ unsigned int length,
+ unsigned int seconds,
+ unsigned int milli_seconds )
+{
+ struct timespec timeout;
+ DFBResult ret = DFB_OK;
+ bool locked = false;
+ long int nano_seconds = milli_seconds * 1000000;
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_Streamed)
+
+ if (data->finished && !data->chunks)
+ return DFB_EOF;
+
+ if (pthread_mutex_trylock( &data->chunks_mutex ) == 0) {
+ if (data->length >= length) {
+ pthread_mutex_unlock( &data->chunks_mutex );
+
+ return DFB_OK;
+ }
+
+ locked = true;
+ }
+
+ direct_util_get_monotonic_pthread_timeout(&timeout, seconds, nano_seconds);
+
+ if (!locked)
+ pthread_mutex_lock( &data->chunks_mutex );
+
+ while (data->length < length && !data->finished) {
+ if (pthread_cond_timedwait( &data->wait_condition,
+ &data->chunks_mutex,
+ &timeout ) == ETIMEDOUT)
+ {
+ ret = DFB_TIMEOUT;
+ break;
+ }
+ }
+
+ pthread_mutex_unlock( &data->chunks_mutex );
+
+ return ret;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Streamed_GetData( IDirectFBDataBuffer *thiz,
+ unsigned int length,
+ void *data_buffer,
+ unsigned int *read_out )
+{
+ unsigned int len;
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_Streamed)
+
+ if (!data_buffer || !length)
+ return DFB_INVARG;
+
+ pthread_mutex_lock( &data->chunks_mutex );
+
+ if (!data->chunks) {
+ pthread_mutex_unlock( &data->chunks_mutex );
+ return data->finished ? DFB_EOF : DFB_BUFFEREMPTY;
+ }
+
+ /* Calculate maximum number of bytes to be read. */
+ len = MIN( length, data->length );
+
+ /* Read data from chunks (destructive). */
+ ReadChunkData( data, data_buffer, 0, len, true );
+
+ /* Decrease total number of bytes. */
+ data->length -= len;
+
+ /* Return number of bytes read. */
+ if (read_out)
+ *read_out = len;
+
+ pthread_mutex_unlock( &data->chunks_mutex );
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Streamed_PeekData( IDirectFBDataBuffer *thiz,
+ unsigned int length,
+ int offset,
+ void *data_buffer,
+ unsigned int *read_out )
+{
+ unsigned int len;
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_Streamed)
+
+ if (!data_buffer || !length || offset < 0)
+ return DFB_INVARG;
+
+ pthread_mutex_lock( &data->chunks_mutex );
+
+ if (!data->chunks || (unsigned int) offset >= data->length) {
+ pthread_mutex_unlock( &data->chunks_mutex );
+ return data->finished ? DFB_EOF : DFB_BUFFEREMPTY;
+ }
+
+ /* Calculate maximum number of bytes to be read. */
+ len = MIN( length, data->length - offset );
+
+ /* Read data from chunks (non-destructive). */
+ ReadChunkData( data, data_buffer, offset, len, false );
+
+ /* Return number of bytes read. */
+ if (read_out)
+ *read_out = len;
+
+ pthread_mutex_unlock( &data->chunks_mutex );
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Streamed_HasData( IDirectFBDataBuffer *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_Streamed)
+
+ /* If there's no chunk there's no data. */
+ if (!data->chunks)
+ return data->finished ? DFB_EOF : DFB_BUFFEREMPTY;
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBDataBuffer_Streamed_PutData( IDirectFBDataBuffer *thiz,
+ const void *data_buffer,
+ unsigned int length )
+{
+ DataChunk *chunk;
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBDataBuffer_Streamed)
+
+ /* Check arguments. */
+ if (!data_buffer || !length)
+ return DFB_INVARG;
+
+ /* Fail if Finish() has been called. */
+ if (data->finished)
+ return DFB_UNSUPPORTED;
+
+ /* Create a chunk containing a copy of the provided data. */
+ chunk = create_chunk( data_buffer, length );
+ if (!chunk)
+ return DFB_NOSYSTEMMEMORY;
+
+ pthread_mutex_lock( &data->chunks_mutex );
+
+ /* Append new chunk. */
+ direct_list_append( &data->chunks, &chunk->link );
+
+ /* Increase total length. */
+ data->length += length;
+
+ pthread_cond_broadcast( &data->wait_condition );
+
+ pthread_mutex_unlock( &data->chunks_mutex );
+
+ return DFB_OK;
+}
+
+DFBResult
+IDirectFBDataBuffer_Streamed_Construct( IDirectFBDataBuffer *thiz,
+ CoreDFB *core )
+{
+ DFBResult ret;
+
+ DIRECT_ALLOCATE_INTERFACE_DATA(thiz, IDirectFBDataBuffer_Streamed)
+
+ ret = IDirectFBDataBuffer_Construct( thiz, NULL, core );
+ if (ret)
+ return ret;
+
+ direct_util_recursive_pthread_mutex_init( &data->chunks_mutex );
+ direct_util_monotonic_pthread_cond_init( &data->wait_condition );
+
+ thiz->Release = IDirectFBDataBuffer_Streamed_Release;
+ thiz->Flush = IDirectFBDataBuffer_Streamed_Flush;
+ thiz->Finish = IDirectFBDataBuffer_Streamed_Finish;
+ thiz->SeekTo = IDirectFBDataBuffer_Streamed_SeekTo;
+ thiz->GetPosition = IDirectFBDataBuffer_Streamed_GetPosition;
+ thiz->GetLength = IDirectFBDataBuffer_Streamed_GetLength;
+ thiz->WaitForData = IDirectFBDataBuffer_Streamed_WaitForData;
+ thiz->WaitForDataWithTimeout = IDirectFBDataBuffer_Streamed_WaitForDataWithTimeout;
+ thiz->GetData = IDirectFBDataBuffer_Streamed_GetData;
+ thiz->PeekData = IDirectFBDataBuffer_Streamed_PeekData;
+ thiz->HasData = IDirectFBDataBuffer_Streamed_HasData;
+ thiz->PutData = IDirectFBDataBuffer_Streamed_PutData;
+
+ return DFB_OK;
+}
+
+/******************************************************************************/
+
+static void
+DestroyAllChunks( IDirectFBDataBuffer_Streamed_data *data )
+{
+ DirectLink *l, *n;
+
+ D_ASSERT( data != NULL );
+
+ /* Loop through list. */
+ direct_list_foreach_safe (l, n, data->chunks) {
+ /* Deallocate chunk. */
+ destroy_chunk( (DataChunk*) l );
+ }
+
+ /* Clear lists. */
+ data->chunks = NULL;
+}
+
+static void
+ReadChunkData( IDirectFBDataBuffer_Streamed_data *data,
+ void *buffer,
+ unsigned int offset,
+ unsigned int length,
+ bool flush )
+{
+ DirectLink *l, *n;
+
+ D_ASSERT( data != NULL );
+ D_ASSERT( buffer != NULL );
+
+ /* Loop through links. */
+ direct_list_foreach_safe (l, n, data->chunks) {
+ unsigned int len;
+ unsigned int off = 0;
+ DataChunk *chunk = (DataChunk*) l;
+
+ /* Is there data to be skipped? */
+ if (offset) {
+ /* Calculate number of bytes to be skipped from this chunk. */
+ off = MIN( offset, chunk->length - chunk->done );
+
+ /* Decrease number of bytes to skipped. */
+ offset -= off;
+ }
+
+ /* Calculate number of bytes to be read from this chunk. */
+ len = MIN( length, chunk->length - chunk->done - off );
+
+ /* Can we read from this chunk? */
+ if (len) {
+ /* Copy as many bytes as possible. */
+ direct_memcpy( buffer, chunk->data + chunk->done + off, len );
+
+ /* Increase write pointer. */
+ buffer += len;
+
+ /* Decrease number of bytes to read. */
+ length -= len;
+ }
+
+ /* Destructive read? */
+ if (flush) {
+ /* Increase number of consumed bytes. */
+ chunk->done += len + off;
+
+ /* Completely consumed? */
+ if (chunk->done == chunk->length) {
+ /* Remove the chunk from the list. */
+ direct_list_remove( &data->chunks, l );
+
+ /* Deallocate chunk. */
+ destroy_chunk( chunk );
+ }
+ }
+ }
+
+ D_ASSERT( length == 0 );
+ D_ASSERT( offset == 0 );
+}
+
+/******************************************************************************/
+
+static DataChunk *
+create_chunk( const void *data, int length )
+{
+ DataChunk *chunk;
+
+ D_ASSERT( data != NULL );
+ D_ASSERT( length > 0 );
+
+ /* Allocate chunk information. */
+ chunk = D_CALLOC( 1, sizeof(DataChunk) );
+ if (!chunk)
+ return NULL;
+
+ /* Allocate chunk data. */
+ chunk->data = D_MALLOC( length );
+ if (!chunk->data) {
+ D_FREE( chunk );
+ return NULL;
+ }
+
+ /* Fill chunk data. */
+ direct_memcpy( chunk->data, data, length );
+
+ /* Remember chunk length. */
+ chunk->length = length;
+
+ return chunk;
+}
+
+static void
+destroy_chunk( DataChunk *chunk )
+{
+ D_ASSERT( chunk != NULL );
+ D_ASSERT( chunk->data != NULL );
+
+ /* Deallocate chunk data. */
+ D_FREE( chunk->data );
+
+ /* Deallocate chunk information. */
+ D_FREE( chunk );
+}
+
diff --git a/Source/DirectFB/src/media/idirectfbfont.c b/Source/DirectFB/src/media/idirectfbfont.c
new file mode 100755
index 0000000..4ce0946
--- /dev/null
+++ b/Source/DirectFB/src/media/idirectfbfont.c
@@ -0,0 +1,965 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <math.h>
+
+#include <sys/fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+
+#include "directfb.h"
+
+#include "core/coretypes.h"
+
+#include "core/fonts.h"
+
+#include <direct/interface.h>
+#include <direct/mem.h>
+#include <direct/tree.h>
+#include <direct/utf8.h>
+
+#include <media/idirectfbfont.h>
+#include <media/idirectfbdatabuffer.h>
+
+#include "misc/util.h"
+
+
+D_DEBUG_DOMAIN( Font, "IDirectFBFont", "DirectFB Font Interface" );
+
+/**********************************************************************************************************************/
+
+void
+IDirectFBFont_Destruct( IDirectFBFont *thiz )
+{
+ IDirectFBFont_data *data = (IDirectFBFont_data*)thiz->priv;
+
+ D_DEBUG_AT( Font, "%s( %p )\n", __FUNCTION__, thiz );
+
+ dfb_font_destroy (data->font);
+
+ /* release memory, if any */
+ if (data->content) {
+ if (data->content_mapped)
+ munmap( data->content, data->content_size );
+ else
+ D_FREE( data->content );
+ }
+
+ DIRECT_DEALLOCATE_INTERFACE( thiz );
+}
+
+/**********************************************************************************************************************/
+
+/*
+ * increments reference count of font
+ */
+static DirectResult
+IDirectFBFont_AddRef( IDirectFBFont *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBFont)
+
+ D_DEBUG_AT( Font, "%s( %p )\n", __FUNCTION__, thiz );
+
+ data->ref++;
+
+ return DFB_OK;
+}
+
+/*
+ * decrements reference count, destructs interface data if reference count is 0
+ */
+static DirectResult
+IDirectFBFont_Release( IDirectFBFont *thiz )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBFont)
+
+ D_DEBUG_AT( Font, "%s( %p )\n", __FUNCTION__, thiz );
+
+ if (--data->ref == 0)
+ IDirectFBFont_Destruct( thiz );
+
+ return DFB_OK;
+}
+
+/*
+ * Get the distance from the baseline to the top.
+ */
+static DFBResult
+IDirectFBFont_GetAscender( IDirectFBFont *thiz, int *ascender )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBFont)
+
+ D_DEBUG_AT( Font, "%s( %p )\n", __FUNCTION__, thiz );
+
+ if (!ascender)
+ return DFB_INVARG;
+
+ *ascender = data->font->ascender;
+
+ return DFB_OK;
+}
+
+/*
+ * Get the distance from the baseline to the bottom.
+ * This is a negative value!
+ */
+static DFBResult
+IDirectFBFont_GetDescender( IDirectFBFont *thiz, int *descender )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBFont)
+
+ D_DEBUG_AT( Font, "%s( %p )\n", __FUNCTION__, thiz );
+
+ if (!descender)
+ return DFB_INVARG;
+
+ *descender = data->font->descender;
+
+ return DFB_OK;
+}
+
+/*
+ * Get the height of this font.
+ */
+static DFBResult
+IDirectFBFont_GetHeight( IDirectFBFont *thiz, int *height )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBFont)
+
+ D_DEBUG_AT( Font, "%s( %p )\n", __FUNCTION__, thiz );
+
+ if (!height)
+ return DFB_INVARG;
+
+ *height = data->font->height;
+
+ return DFB_OK;
+}
+
+/*
+ * Get the line spacing vector of this font.
+ */
+static DFBResult
+IDirectFBFont_GetLineSpacingVector( IDirectFBFont *thiz, int *xspacing, int *yspacing )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBFont)
+
+ D_DEBUG_AT( Font, "%s( %p )\n", __FUNCTION__, thiz );
+
+ if (!xspacing && !yspacing)
+ return DFB_INVARG;
+
+ if (xspacing) {
+ *xspacing = - data->font->height * data->font->up_unit_x;
+ }
+
+ if (yspacing) {
+ *yspacing = - data->font->height * data->font->up_unit_y;
+ }
+
+ return DFB_OK;
+}
+
+/*
+ * Get the maximum character width.
+ */
+static DFBResult
+IDirectFBFont_GetMaxAdvance( IDirectFBFont *thiz, int *maxadvance )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBFont)
+
+ D_DEBUG_AT( Font, "%s( %p )\n", __FUNCTION__, thiz );
+
+ if (!maxadvance)
+ return DFB_INVARG;
+
+ *maxadvance = data->font->maxadvance;
+
+ return DFB_OK;
+}
+
+/*
+ * Get the kerning to apply between two glyphs.
+ */
+static DFBResult
+IDirectFBFont_GetKerning( IDirectFBFont *thiz,
+ unsigned int prev, unsigned int current,
+ int *kern_x, int *kern_y)
+{
+ DFBResult ret;
+ CoreFont *font;
+ int x = 0, y = 0;
+ unsigned int prev_index, current_index;
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBFont)
+
+ D_DEBUG_AT( Font, "%s( %p )\n", __FUNCTION__, thiz );
+
+ if (!kern_x && !kern_y)
+ return DFB_INVARG;
+
+ font = data->font;
+
+ dfb_font_lock( font );
+
+ if (font->GetKerning) {
+ ret = dfb_font_decode_character( font, data->encoding, prev, &prev_index );
+ if (ret)
+ goto error;
+
+ ret = dfb_font_decode_character( font, data->encoding, current, &current_index );
+ if (ret)
+ goto error;
+
+ ret = font->GetKerning (font, prev_index, current_index, &x, &y);
+ if (ret)
+ goto error;
+ }
+
+ dfb_font_unlock( font );
+
+ if (kern_x)
+ *kern_x = x;
+ if (kern_y)
+ *kern_y = y;
+
+ return DFB_OK;
+
+
+error:
+ dfb_font_unlock( font );
+
+ return ret;
+}
+
+/*
+ * Get the logical and ink extents of the specified string.
+ */
+static DFBResult
+IDirectFBFont_GetStringExtents( IDirectFBFont *thiz,
+ const char *text, int bytes,
+ DFBRectangle *logical_rect,
+ DFBRectangle *ink_rect )
+{
+ DFBResult ret;
+ CoreFont *font;
+ int xbaseline = 0;
+ int ybaseline = 0;
+
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBFont)
+
+ D_DEBUG_AT( Font, "%s( %p )\n", __FUNCTION__, thiz );
+
+
+ if (!text)
+ return DFB_INVARG;
+
+ if (!logical_rect && !ink_rect)
+ return DFB_INVARG;
+
+ if (bytes < 0)
+ bytes = strlen (text);
+
+ if (ink_rect)
+ memset (ink_rect, 0, sizeof (DFBRectangle));
+
+ font = data->font;
+
+ dfb_font_lock( font );
+
+ if (bytes > 0) {
+ int i, num;
+ unsigned int prev = 0;
+ unsigned int indices[bytes];
+
+ /* Decode string to character indices. */
+ ret = dfb_font_decode_text( font, data->encoding, text, bytes, indices, &num );
+ if (ret) {
+ dfb_font_unlock( font );
+ return ret;
+ }
+
+ for (i=0; i<num; i++) {
+ unsigned int current = indices[i];
+ CoreGlyphData *glyph;
+
+ if (dfb_font_get_glyph_data( font, current, 0, &glyph ) == DFB_OK) { // FIXME: support font layers
+ int kx, ky = 0;
+
+ if (prev && font->GetKerning &&
+ font->GetKerning( font, prev, current, &kx, &ky ) == DFB_OK) {
+ xbaseline += kx;
+ ybaseline += ky;
+ }
+
+ if (ink_rect) {
+ DFBRectangle glyph_rect = { xbaseline + glyph->left,
+ ybaseline + glyph->top,
+ glyph->width, glyph->height};
+ dfb_rectangle_union (ink_rect, &glyph_rect);
+ }
+
+ xbaseline += glyph->xadvance;
+ ybaseline += glyph->yadvance;
+ }
+
+ prev = current;
+ }
+ }
+
+ if (logical_rect) {
+ // We already have the text baseline vector in (xbaseline,ybaseline).
+ // Now find the ascender and descender vectors:
+ int xascender = font->ascender * font->up_unit_x;
+ int yascender = font->ascender * font->up_unit_y;
+ int xdescender = font->descender * font->up_unit_x;
+ int ydescender = font->descender * font->up_unit_y;
+
+ // Now find top/bottom left/right points relative to the text:
+ int top_left_x = xascender;
+ int top_left_y = yascender;
+ int bottom_left_x = xdescender;
+ int bottom_left_y = ydescender;
+ int top_right_x = top_left_x + xbaseline;
+ int top_right_y = top_left_y + ybaseline;
+ int bottom_right_x = bottom_left_x + xbaseline;
+ int bottom_right_y = bottom_left_y + ybaseline;
+
+ // The logical rectangle is the bounding-box of these points:
+#define MIN4(a,b,c,d) (MIN(MIN((a),(b)),MIN((c),(d))))
+#define MAX4(a,b,c,d) (MAX(MAX((a),(b)),MAX((c),(d))))
+ logical_rect->x = MIN4(top_left_x, bottom_left_x, top_right_x, bottom_right_x);
+ logical_rect->y = MIN4(top_left_y, bottom_left_y, top_right_y, bottom_right_y);
+ logical_rect->w = MAX4(top_left_x, bottom_left_x, top_right_x, bottom_right_x) - logical_rect->x;
+ logical_rect->h = MAX4(top_left_y, bottom_left_y, top_right_y, bottom_right_y) - logical_rect->y;
+ }
+
+ if (ink_rect) {
+ if (ink_rect->w < 0) { /* PBE FIXME what is this doing? */
+ ink_rect->x += ink_rect->w;
+ ink_rect->w = -ink_rect->w;
+ }
+ ink_rect->x += font->ascender * font->up_unit_x;
+ ink_rect->y += font->ascender * font->up_unit_y;
+ }
+
+ dfb_font_unlock( font );
+
+ return DFB_OK;
+}
+
+/*
+ * Get the logical width of the specified string.
+ */
+static DFBResult
+IDirectFBFont_GetStringWidth( IDirectFBFont *thiz,
+ const char *text,
+ int bytes,
+ int *ret_width )
+{
+ DFBResult ret;
+ int xsize = 0;
+ int ysize = 0;
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBFont)
+
+ D_DEBUG_AT( Font, "%s( %p )\n", __FUNCTION__, thiz );
+
+ if (!text || !ret_width)
+ return DFB_INVARG;
+
+ if (bytes < 0)
+ bytes = strlen (text);
+
+ if (bytes > 0) {
+ int i, num, kx, ky;
+ unsigned int prev = 0;
+ unsigned int indices[bytes];
+ CoreFont *font = data->font;
+
+ dfb_font_lock( font );
+
+ /* Decode string to character indices. */
+ ret = dfb_font_decode_text( font, data->encoding, text, bytes, indices, &num );
+ if (ret) {
+ dfb_font_unlock( font );
+ return ret;
+ }
+
+ /* Calculate string width. */
+ for (i=0; i<num; i++) {
+ unsigned int current = indices[i];
+ CoreGlyphData *glyph;
+
+ if (dfb_font_get_glyph_data( font, current, 0, &glyph ) == DFB_OK) { // FIXME: support font layers
+ xsize += glyph->xadvance;
+ ysize += glyph->yadvance;
+
+ if (prev && font->GetKerning &&
+ font->GetKerning( font, prev, current, &kx, &ky ) == DFB_OK) {
+ xsize += kx;
+ ysize += ky;
+ }
+ }
+
+ prev = current;
+ }
+
+ dfb_font_unlock( font );
+ }
+
+ if (!ysize) {
+ *ret_width = xsize;
+ }
+ else if (!xsize) {
+ *ret_width = ysize;
+ }
+ else {
+ *ret_width = sqrt(xsize*xsize + ysize*ysize);
+ }
+
+ return DFB_OK;
+}
+
+/*
+ * Get the extents of the specified glyph.
+ */
+static DFBResult
+IDirectFBFont_GetGlyphExtents( IDirectFBFont *thiz,
+ unsigned int character,
+ DFBRectangle *rect,
+ int *advance )
+{
+ DFBResult ret;
+ CoreFont *font;
+ CoreGlyphData *glyph;
+ unsigned int index;
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBFont)
+
+ D_DEBUG_AT( Font, "%s( %p )\n", __FUNCTION__, thiz );
+
+ if (!rect && !advance)
+ return DFB_INVARG;
+
+ font = data->font;
+
+ dfb_font_lock( font );
+
+ ret = dfb_font_decode_character( font, data->encoding, character, &index );
+ if (ret) {
+ dfb_font_unlock( font );
+ return ret;
+ }
+
+ if (dfb_font_get_glyph_data (font, index, 0, &glyph) != DFB_OK) { // FIXME: support font layers
+ if (rect)
+ rect->x = rect->y = rect->w = rect->h = 0;
+
+ if (advance)
+ *advance = 0;
+ }
+ else {
+ if (rect) {
+ rect->x = glyph->left;
+ rect->y = glyph->top - font->ascender;
+ rect->w = glyph->width;
+ rect->h = glyph->height;
+ }
+
+ if (advance)
+ *advance = glyph->xadvance;
+ }
+
+ dfb_font_unlock( font );
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBFont_GetStringBreak( IDirectFBFont *thiz,
+ const char *text,
+ int bytes,
+ int max_width,
+ int *ret_width,
+ int *ret_str_length,
+ const char **ret_next_line)
+{
+ DFBResult ret;
+ CoreFont *font;
+ const u8 *string;
+ const u8 *end;
+ CoreGlyphData *glyph;
+ int kern_x;
+ int kern_y;
+ int length = 0;
+ int xsize = 0;
+ int ysize = 0;
+ int width = 0;
+ unichar current;
+ unsigned int index;
+ unsigned int prev = 0;
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBFont)
+
+ if (!text || !ret_next_line || !ret_str_length || !ret_width)
+ return DFB_INVARG;
+
+ /* FIXME: Try to change the font module API *slightly* to support this. */
+ if (data->encoding != DTEID_UTF8)
+ return DFB_UNSUPPORTED;
+
+ if (bytes < 0)
+ bytes = strlen (text);
+
+ if (!bytes) {
+ *ret_next_line = NULL;
+ *ret_str_length = 0;
+ *ret_width = 0;
+
+ return DFB_OK;
+ }
+
+ font = data->font;
+ string = (const u8*) text;
+ end = string + bytes;
+ *ret_next_line = NULL;
+
+ dfb_font_lock( font );
+
+ do {
+ *ret_width = width;
+ length ++;
+
+ current = DIRECT_UTF8_GET_CHAR( string );
+
+ string += DIRECT_UTF8_SKIP( string[0] );
+
+ if (current == ' ' || current == 0x0a) {
+ *ret_next_line = (const char*) string;
+ *ret_str_length = length;
+ *ret_width = width;
+ }
+
+ ret = dfb_font_decode_character( font, data->encoding, current, &index );
+ if (ret)
+ continue;
+
+ ret = dfb_font_get_glyph_data( font, index, 0, &glyph ); // FIXME: support font layers
+ if (ret)
+ continue;
+
+ xsize += glyph->xadvance;
+ ysize += glyph->yadvance;
+
+ if (prev && font->GetKerning && font->GetKerning( font, prev, index, &kern_x, &kern_y) == DFB_OK) {
+ xsize += kern_x;
+ ysize += kern_y;
+ }
+
+ if (!ysize) {
+ width = xsize;
+ }
+ else if (!xsize) {
+ width = ysize;
+ }
+ else {
+ width = sqrt(xsize*xsize + ysize*ysize);
+ }
+
+ prev = index;
+ } while (width < max_width && string < end && current != 0x0a);
+
+ dfb_font_unlock( font );
+
+ if (width<max_width && string >= end) {
+ *ret_next_line = NULL;
+ *ret_str_length = length;
+ *ret_width = width;
+
+ return DFB_OK;
+ }
+
+ if (*ret_next_line == NULL) {
+ if (length == 1) {
+ *ret_str_length = length;
+ *ret_next_line = (const char*) string;
+ *ret_width = width;
+ } else {
+ *ret_str_length = length-1;
+ *ret_next_line = (const char*) string-1;
+ /* ret_width already set in the loop */
+ }
+ }
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBFont_SetEncoding( IDirectFBFont *thiz,
+ DFBTextEncodingID encoding )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBFont)
+
+ D_DEBUG_AT( Font, "%s( %p, %d )\n", __FUNCTION__, thiz, encoding );
+
+ if (encoding > data->font->last_encoding)
+ return DFB_IDNOTFOUND;
+
+ data->encoding = encoding;
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBFont_EnumEncodings( IDirectFBFont *thiz,
+ DFBTextEncodingCallback callback,
+ void *context )
+{
+ int i;
+ CoreFont *font;
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBFont)
+
+ if (!callback)
+ return DFB_INVARG;
+
+ D_DEBUG_AT( Font, "%s( %p, %p, %p )\n", __FUNCTION__, thiz, callback, context );
+
+ font = data->font;
+
+ if (callback( DTEID_UTF8, "UTF8", context ) == DFENUM_OK) {
+ for (i=DTEID_OTHER; i<=font->last_encoding; i++) {
+ if (callback( i, font->encodings[i]->name, context ) != DFENUM_OK)
+ break;
+ }
+ }
+
+ return DFB_OK;
+}
+
+static DFBResult
+IDirectFBFont_FindEncoding( IDirectFBFont *thiz,
+ const char *name,
+ DFBTextEncodingID *ret_id )
+{
+ int i;
+ CoreFont *font;
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBFont)
+
+ if (!name || !ret_id)
+ return DFB_INVARG;
+
+ D_DEBUG_AT( Font, "%s( %p, '%s', %p )\n", __FUNCTION__, thiz, name, ret_id );
+
+ if (!strcasecmp( name, "UTF8" )) {
+ *ret_id = DTEID_UTF8;
+ return DFB_OK;
+ }
+
+ font = data->font;
+
+ for (i=DTEID_OTHER; i<=font->last_encoding; i++) {
+ if (!strcasecmp( name, font->encodings[i]->name )) {
+ *ret_id = i;
+ return DFB_OK;
+ }
+ }
+
+ return DFB_IDNOTFOUND;
+}
+
+/*
+ * Get the extents of the specified glyph.
+ */
+static DFBResult
+IDirectFBFont_GetGlyphExtentsXY( IDirectFBFont *thiz,
+ unsigned int character,
+ DFBRectangle *rect,
+ int *xadvance,
+ int *yadvance )
+{
+ DFBResult ret;
+ CoreFont *font;
+ CoreGlyphData *glyph;
+ unsigned int index;
+
+ DIRECT_INTERFACE_GET_DATA(IDirectFBFont)
+
+ D_DEBUG_AT( Font, "%s( %p )\n", __FUNCTION__, thiz );
+
+ if (!rect && !xadvance && !yadvance)
+ return DFB_INVARG;
+
+ font = data->font;
+
+ dfb_font_lock( font );
+
+ ret = dfb_font_decode_character( font, data->encoding, character, &index );
+ if (ret) {
+ dfb_font_unlock( font );
+ return ret;
+ }
+
+ if (dfb_font_get_glyph_data (font, index, 0, &glyph) != DFB_OK) { // FIXME: support font layers
+ if (rect)
+ rect->x = rect->y = rect->w = rect->h = 0;
+
+ if (xadvance)
+ *xadvance = 0;
+
+ if (yadvance)
+ *yadvance = 0;
+ }
+ else {
+ if (rect) {
+ rect->x = glyph->left + font->ascender * font->up_unit_x;
+ rect->y = glyph->top + font->ascender * font->up_unit_y;
+ rect->w = glyph->width;
+ rect->h = glyph->height;
+ }
+
+ if (xadvance)
+ *xadvance = glyph->xadvance;
+
+ if (yadvance)
+ *yadvance = glyph->yadvance;
+ }
+
+ dfb_font_unlock( font );
+
+ return DFB_OK;
+}
+
+/*
+ * Get the description of the font.
+ */
+static DFBResult
+IDirectFBFont_GetDescription( IDirectFBFont *thiz,
+ DFBFontDescription *ret_description )
+{
+ DIRECT_INTERFACE_GET_DATA(IDirectFBFont)
+
+ D_DEBUG_AT( Font, "%s( %p )\n", __FUNCTION__, thiz );
+
+ if (!ret_description)
+ return DFB_INVARG;
+
+ *ret_description = data->font->description;
+
+ return DFB_OK;
+}
+
+/**********************************************************************************************************************/
+
+DFBResult
+IDirectFBFont_Construct( IDirectFBFont *thiz, CoreFont *font )
+{
+ DIRECT_ALLOCATE_INTERFACE_DATA(thiz, IDirectFBFont)
+
+ data->ref = 1;
+ data->font = font;
+
+ thiz->AddRef = IDirectFBFont_AddRef;
+ thiz->Release = IDirectFBFont_Release;
+ thiz->GetAscender = IDirectFBFont_GetAscender;
+ thiz->GetDescender = IDirectFBFont_GetDescender;
+ thiz->GetHeight = IDirectFBFont_GetHeight;
+ thiz->GetMaxAdvance = IDirectFBFont_GetMaxAdvance;
+ thiz->GetKerning = IDirectFBFont_GetKerning;
+ thiz->GetStringWidth = IDirectFBFont_GetStringWidth;
+ thiz->GetStringExtents = IDirectFBFont_GetStringExtents;
+ thiz->GetGlyphExtents = IDirectFBFont_GetGlyphExtents;
+ thiz->GetStringBreak = IDirectFBFont_GetStringBreak;
+ thiz->SetEncoding = IDirectFBFont_SetEncoding;
+ thiz->EnumEncodings = IDirectFBFont_EnumEncodings;
+ thiz->FindEncoding = IDirectFBFont_FindEncoding;
+ thiz->GetLineSpacingVector = IDirectFBFont_GetLineSpacingVector;
+ thiz->GetGlyphExtentsXY = IDirectFBFont_GetGlyphExtentsXY;
+ thiz->GetDescription = IDirectFBFont_GetDescription;
+
+ return DFB_OK;
+}
+
+static DFBResult
+try_map_file( IDirectFBDataBuffer_data *buffer_data,
+ IDirectFBFont_ProbeContext *ctx )
+{
+ /* try to map the "file" content first */
+ if (!access( buffer_data->filename, O_RDONLY )) {
+ int fd;
+ struct stat st;
+
+ fd = open( buffer_data->filename, O_RDONLY );
+ if (fd < 0) {
+ D_PERROR( "IDirectFBFont: Could not open '%s'\n", buffer_data->filename );
+ return DFB_IO;
+ }
+
+ if (fstat( fd, &st )) {
+ D_PERROR( "IDirectFBFont: Could not stat '%s'\n", buffer_data->filename );
+ close( fd );
+ return DFB_IO;
+ }
+
+ ctx->content = mmap( NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0 );
+ if (ctx->content == MAP_FAILED) {
+ D_PERROR( "IDirectFBFont: Could not mmap '%s'\n", buffer_data->filename );
+ close( fd );
+ return DFB_IO;
+ }
+
+ ctx->content_size = st.st_size;
+ ctx->content_mapped = true;
+
+ close( fd );
+
+ return DFB_OK;
+ }
+
+ return DFB_UNSUPPORTED;
+}
+
+static void
+unmap_or_free( IDirectFBFont_ProbeContext *ctx )
+{
+ if (ctx->content) {
+ if (ctx->content_mapped)
+ munmap( ctx->content, ctx->content_size );
+ else
+ D_FREE( ctx->content );
+ }
+}
+
+DFBResult
+IDirectFBFont_CreateFromBuffer( IDirectFBDataBuffer *buffer,
+ CoreDFB *core,
+ const DFBFontDescription *desc,
+ IDirectFBFont **interface )
+{
+ DFBResult ret;
+ DirectInterfaceFuncs *funcs = NULL;
+ IDirectFBDataBuffer_data *buffer_data;
+ IDirectFBFont *ifont;
+ IDirectFBFont_ProbeContext ctx = {0};
+
+ /* Get the private information of the data buffer. */
+ buffer_data = (IDirectFBDataBuffer_data*) buffer->priv;
+ if (!buffer_data)
+ return DFB_DEAD;
+
+ /* Provide a fallback for image providers without data buffer support. */
+ ctx.filename = buffer_data->filename;
+
+ /* try to map the "file" content first */
+ if (try_map_file( buffer_data, &ctx ) != DFB_OK) {
+ /* try to load the "file" content from the buffer */
+
+ /* we need to be able to seek (this implies non-streamed,
+ so we also know the size) so we can reuse the buffer */
+ if (buffer->SeekTo( buffer, 0 ) == DFB_OK) {
+ unsigned int size, got;
+
+ /* get the "file" length */
+ buffer->GetLength( buffer, &size );
+
+ ctx.content = D_MALLOC( size );
+ if (!ctx.content)
+ return DR_NOLOCALMEMORY;
+
+ ctx.content_size = 0;
+
+ while (ctx.content_size < size) {
+ unsigned int get = size - ctx.content_size;
+
+ if (get > 8192)
+ get = 8192;
+
+ ret = buffer->WaitForData( buffer, get );
+ if (ret) {
+ D_DERROR( ret, "%s: WaitForData failed!\n", __FUNCTION__ );
+ break;
+ }
+
+ ret = buffer->GetData( buffer, get, ctx.content + ctx.content_size, &got );
+ if (ret) {
+ D_DERROR( ret, "%s: GetData failed!\n", __FUNCTION__ );
+ break;
+ }
+
+ if (!got)
+ break;
+
+ ctx.content_size += got;
+ }
+
+ if (ctx.content_size != size) {
+ D_ERROR( "%s: Got size %u differs from supposed %u!\n", __FUNCTION__, ctx.content_size, size );
+ D_FREE( ctx.content );
+ return DFB_FAILURE;
+ }
+ }
+ }
+
+ /* Find a suitable implementation. */
+ ret = DirectGetInterface( &funcs, "IDirectFBFont", NULL, DirectProbeInterface, &ctx );
+ if (ret) {
+ unmap_or_free( &ctx );
+ return ret;
+ }
+
+ DIRECT_ALLOCATE_INTERFACE( ifont, IDirectFBFont );
+
+ /* Construct the interface. */
+ ret = funcs->Construct( ifont, core, &ctx, desc );
+ if (ret) {
+ unmap_or_free( &ctx );
+ return ret;
+ }
+
+ /* store pointer for deletion at destroy */
+ {
+ IDirectFBFont_data *data = (IDirectFBFont_data*)(ifont->priv);
+ data->content = ctx.content;
+ data->content_size = ctx.content_size;
+ data->content_mapped = ctx.content_mapped;
+ }
+
+ *interface = ifont;
+
+ return DFB_OK;
+}
+
diff --git a/Source/DirectFB/src/media/idirectfbfont.h b/Source/DirectFB/src/media/idirectfbfont.h
new file mode 100755
index 0000000..85bdb0c
--- /dev/null
+++ b/Source/DirectFB/src/media/idirectfbfont.h
@@ -0,0 +1,82 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __IDIRECTFBFONT_H__
+#define __IDIRECTFBFONT_H__
+
+#include <directfb.h>
+
+#include <core/coretypes.h>
+
+/*
+ * probing context
+ */
+typedef struct {
+ /* Only set if databuffer is created from file.
+ deprecated - use memory location below. */
+ const char *filename;
+
+ /* if !=NULL, pointer to the file content */
+ unsigned char *content;
+ unsigned int content_size;
+ bool content_mapped;
+} IDirectFBFont_ProbeContext;
+
+DFBResult
+IDirectFBFont_CreateFromBuffer( IDirectFBDataBuffer *buffer,
+ CoreDFB *core,
+ const DFBFontDescription *desc,
+ IDirectFBFont **interface );
+
+/**********************************************************************************************************************/
+
+/*
+ * private data struct of IDirectFBFont
+ * used by implementors of IDirectFBFont
+ */
+typedef struct {
+ int ref; /* reference counter */
+ CoreFont *font; /* pointer to core font */
+ unsigned char *content; /* possible allocation, free at intf. close */
+ unsigned int content_size;
+ bool content_mapped;
+
+ DFBTextEncodingID encoding; /* text encoding */
+} IDirectFBFont_data;
+
+/*
+ * common code to construct the interface (internal usage only)
+ */
+DFBResult IDirectFBFont_Construct( IDirectFBFont *thiz, CoreFont *font );
+
+/*
+ * deinitialize font and its surfaces
+ */
+void IDirectFBFont_Destruct( IDirectFBFont *thiz );
+
+#endif
diff --git a/Source/DirectFB/src/media/idirectfbimageprovider.c b/Source/DirectFB/src/media/idirectfbimageprovider.c
new file mode 100755
index 0000000..f54319c
--- /dev/null
+++ b/Source/DirectFB/src/media/idirectfbimageprovider.c
@@ -0,0 +1,167 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+
+#include <stddef.h>
+#include <string.h>
+
+#include <directfb.h>
+
+#include <core/core.h>
+
+#include <direct/interface.h>
+#include <direct/mem.h>
+
+#include <media/idirectfbimageprovider.h>
+#include <media/idirectfbdatabuffer.h>
+
+
+static DirectResult
+IDirectFBImageProvider_AddRef( IDirectFBImageProvider *thiz )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DirectResult
+IDirectFBImageProvider_Release( IDirectFBImageProvider *thiz )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBImageProvider_GetSurfaceDescription( IDirectFBImageProvider *thiz,
+ DFBSurfaceDescription *ret_dsc )
+{
+ if (!ret_dsc)
+ return DFB_INVARG;
+
+ ret_dsc->flags = DSDESC_NONE;
+
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBImageProvider_GetImageDescription( IDirectFBImageProvider *thiz,
+ DFBImageDescription *ret_dsc )
+{
+ if (!ret_dsc)
+ return DFB_INVARG;
+
+ ret_dsc->caps = DICAPS_NONE;
+
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBImageProvider_RenderTo( IDirectFBImageProvider *thiz,
+ IDirectFBSurface *destination,
+ const DFBRectangle *destination_rect )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBImageProvider_SetRenderCallback( IDirectFBImageProvider *thiz,
+ DIRenderCallback callback,
+ void *callback_data )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBImageProvider_WriteBack( IDirectFBImageProvider *thiz,
+ IDirectFBSurface *surface,
+ const DFBRectangle *src_rect,
+ const char *filename )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static void
+IDirectFBImageProvider_Construct( IDirectFBImageProvider *thiz )
+{
+ thiz->AddRef = IDirectFBImageProvider_AddRef;
+ thiz->Release = IDirectFBImageProvider_Release;
+ thiz->GetSurfaceDescription = IDirectFBImageProvider_GetSurfaceDescription;
+ thiz->GetImageDescription = IDirectFBImageProvider_GetImageDescription;
+ thiz->RenderTo = IDirectFBImageProvider_RenderTo;
+ thiz->SetRenderCallback = IDirectFBImageProvider_SetRenderCallback;
+ thiz->WriteBack = IDirectFBImageProvider_WriteBack;
+}
+
+DFBResult
+IDirectFBImageProvider_CreateFromBuffer( IDirectFBDataBuffer *buffer,
+ CoreDFB *core,
+ IDirectFBImageProvider **interface )
+{
+ DFBResult ret;
+ DirectInterfaceFuncs *funcs = NULL;
+ IDirectFBDataBuffer_data *buffer_data;
+ IDirectFBImageProvider *imageprovider;
+ IDirectFBImageProvider_ProbeContext ctx;
+
+ /* Get the private information of the data buffer. */
+ buffer_data = (IDirectFBDataBuffer_data*) buffer->priv;
+ if (!buffer_data)
+ return DFB_DEAD;
+
+ /* Clear for safety, especially header data. */
+ memset( &ctx, 0, sizeof(ctx) );
+
+ /* Provide a fallback for image providers without data buffer support. */
+ ctx.filename = buffer_data->filename;
+
+ /* Wait until 32 bytes are available. */
+ ret = buffer->WaitForData( buffer, 32 );
+ if (ret)
+ return ret;
+
+ /* Read the first 32 bytes. */
+ buffer->PeekData( buffer, 32, 0, ctx.header, NULL );
+
+ /* Find a suitable implementation. */
+ ret = DirectGetInterface( &funcs, "IDirectFBImageProvider", NULL, DirectProbeInterface, &ctx );
+ if (ret)
+ return ret;
+
+ DIRECT_ALLOCATE_INTERFACE( imageprovider, IDirectFBImageProvider );
+
+ /* Initialize interface pointers. */
+ IDirectFBImageProvider_Construct( imageprovider );
+
+ /* Construct the interface. */
+ ret = funcs->Construct( imageprovider, buffer, core );
+ if (ret)
+ return ret;
+
+ *interface = imageprovider;
+
+ return DFB_OK;
+}
+
diff --git a/Source/DirectFB/src/media/idirectfbimageprovider.h b/Source/DirectFB/src/media/idirectfbimageprovider.h
new file mode 100755
index 0000000..afbd613
--- /dev/null
+++ b/Source/DirectFB/src/media/idirectfbimageprovider.h
@@ -0,0 +1,48 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __IDIRECTFBIMAGEPROVIDER_H__
+#define __IDIRECTFBIMAGEPROVIDER_H__
+
+#include <core/coretypes.h>
+
+/*
+ * probing context
+ */
+typedef struct {
+ unsigned char header[32];
+
+ const char *filename; /* Only set if databuffer is created from file. */
+} IDirectFBImageProvider_ProbeContext;
+
+DFBResult
+IDirectFBImageProvider_CreateFromBuffer( IDirectFBDataBuffer *buffer,
+ CoreDFB *core,
+ IDirectFBImageProvider **interface );
+
+#endif
diff --git a/Source/DirectFB/src/media/idirectfbvideoprovider.c b/Source/DirectFB/src/media/idirectfbvideoprovider.c
new file mode 100755
index 0000000..fcea1ba
--- /dev/null
+++ b/Source/DirectFB/src/media/idirectfbvideoprovider.c
@@ -0,0 +1,387 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+
+#include <stddef.h>
+#include <string.h>
+
+#include <directfb.h>
+
+#include <direct/interface.h>
+#include <direct/mem.h>
+
+#include <media/idirectfbvideoprovider.h>
+#include <media/idirectfbdatabuffer.h>
+
+
+static DirectResult
+IDirectFBVideoProvider_AddRef( IDirectFBVideoProvider *thiz )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DirectResult
+IDirectFBVideoProvider_Release( IDirectFBVideoProvider *thiz )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_GetCapabilities( IDirectFBVideoProvider *thiz,
+ DFBVideoProviderCapabilities *ret_caps )
+{
+ if (!ret_caps)
+ return DFB_INVARG;
+
+ *ret_caps = 0;
+
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_GetSurfaceDescription( IDirectFBVideoProvider *thiz,
+ DFBSurfaceDescription *ret_dsc )
+{
+ if (!ret_dsc)
+ return DFB_INVARG;
+
+ ret_dsc->flags = DSDESC_NONE;
+
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_GetStreamDescription( IDirectFBVideoProvider *thiz,
+ DFBStreamDescription *ret_dsc )
+{
+ if (!ret_dsc)
+ return DFB_INVARG;
+
+ memset( ret_dsc, 0, sizeof(DFBStreamDescription) );
+
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_GetBufferOccupancy( IDirectFBVideoProvider *thiz,
+ DFBBufferOccupancy *ret_occ )
+{
+ if (!ret_occ)
+ return DFB_INVARG;
+
+ memset( ret_occ, 0, sizeof(DFBBufferOccupancy) );
+
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_GetBufferThresholds( IDirectFBVideoProvider *thiz,
+ DFBBufferThresholds *ret_thresh )
+{
+ if (!ret_thresh)
+ return DFB_INVARG;
+
+ memset( ret_thresh, 0, sizeof(DFBBufferThresholds) );
+
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_SetBufferThresholds( IDirectFBVideoProvider *thiz,
+ DFBBufferThresholds thresh )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_PlayTo( IDirectFBVideoProvider *thiz,
+ IDirectFBSurface *destination,
+ const DFBRectangle *destination_rect,
+ DVFrameCallback callback,
+ void *ctx )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_Stop( IDirectFBVideoProvider *thiz )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_GetStatus( IDirectFBVideoProvider *thiz,
+ DFBVideoProviderStatus *ret_status )
+{
+ if (!ret_status)
+ return DFB_INVARG;
+
+ *ret_status = DVSTATE_UNKNOWN;
+
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_SeekTo( IDirectFBVideoProvider *thiz,
+ double seconds )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_GetPos( IDirectFBVideoProvider *thiz,
+ double *ret_seconds )
+{
+ if (!ret_seconds)
+ return DFB_INVARG;
+
+ *ret_seconds = 0.0;
+
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_GetLength( IDirectFBVideoProvider *thiz,
+ double *ret_seconds )
+{
+ if (!ret_seconds)
+ return DFB_INVARG;
+
+ *ret_seconds = 0.0;
+
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_GetColorAdjustment( IDirectFBVideoProvider *thiz,
+ DFBColorAdjustment *ret_adj )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_SetColorAdjustment( IDirectFBVideoProvider *thiz,
+ const DFBColorAdjustment *adj )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_SendEvent( IDirectFBVideoProvider *thiz,
+ const DFBEvent *event )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_SetPlaybackFlags( IDirectFBVideoProvider *thiz,
+ DFBVideoProviderPlaybackFlags flags )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_SetSpeed( IDirectFBVideoProvider *thiz,
+ double multiplier )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_GetSpeed( IDirectFBVideoProvider *thiz,
+ double *ret_multiplier )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_SetVolume( IDirectFBVideoProvider *thiz,
+ float level )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_GetVolume( IDirectFBVideoProvider *thiz,
+ float *ret_level )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_SetStreamAttributes(IDirectFBVideoProvider *thiz,
+ DFBStreamAttributes attr)
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_SetAudioOutputs(IDirectFBVideoProvider *thiz,
+ DFBVideoProviderAudioUnits* audioUnits)
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_GetAudioOutputs(IDirectFBVideoProvider *thiz,
+ DFBVideoProviderAudioUnits* audioUnits)
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_SetAudioDelay( IDirectFBVideoProvider *thiz,
+ long delay )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_CreateEventBuffer( IDirectFBVideoProvider *thiz,
+ IDirectFBEventBuffer **buffer )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_AttachEventBuffer( IDirectFBVideoProvider *thiz,
+ IDirectFBEventBuffer *buffer )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_EnableEvents(IDirectFBVideoProvider *thiz,
+ DFBVideoProviderEventType mask )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_DisableEvents(IDirectFBVideoProvider *thiz,
+ DFBVideoProviderEventType mask )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult
+IDirectFBVideoProvider_DetachEventBuffer( IDirectFBVideoProvider *thiz,
+ IDirectFBEventBuffer *buffer )
+{
+ return DFB_UNIMPLEMENTED;
+}
+
+static void
+IDirectFBVideoProvider_Construct( IDirectFBVideoProvider *thiz )
+{
+ thiz->AddRef = IDirectFBVideoProvider_AddRef;
+ thiz->Release = IDirectFBVideoProvider_Release;
+ thiz->GetCapabilities = IDirectFBVideoProvider_GetCapabilities;
+ thiz->GetSurfaceDescription = IDirectFBVideoProvider_GetSurfaceDescription;
+ thiz->GetStreamDescription = IDirectFBVideoProvider_GetStreamDescription;
+ thiz->GetBufferOccupancy = IDirectFBVideoProvider_GetBufferOccupancy;
+ thiz->SetBufferThresholds = IDirectFBVideoProvider_SetBufferThresholds;
+ thiz->GetBufferThresholds = IDirectFBVideoProvider_GetBufferThresholds;
+ thiz->PlayTo = IDirectFBVideoProvider_PlayTo;
+ thiz->Stop = IDirectFBVideoProvider_Stop;
+ thiz->GetStatus = IDirectFBVideoProvider_GetStatus;
+ thiz->SeekTo = IDirectFBVideoProvider_SeekTo;
+ thiz->GetPos = IDirectFBVideoProvider_GetPos;
+ thiz->GetLength = IDirectFBVideoProvider_GetLength;
+ thiz->GetColorAdjustment = IDirectFBVideoProvider_GetColorAdjustment;
+ thiz->SetColorAdjustment = IDirectFBVideoProvider_SetColorAdjustment;
+ thiz->SendEvent = IDirectFBVideoProvider_SendEvent;
+ thiz->SetPlaybackFlags = IDirectFBVideoProvider_SetPlaybackFlags;
+ thiz->SetSpeed = IDirectFBVideoProvider_SetSpeed;
+ thiz->GetSpeed = IDirectFBVideoProvider_GetSpeed;
+ thiz->SetVolume = IDirectFBVideoProvider_SetVolume;
+ thiz->GetVolume = IDirectFBVideoProvider_GetVolume;
+ thiz->SetStreamAttributes = IDirectFBVideoProvider_SetStreamAttributes;
+ thiz->SetAudioOutputs = IDirectFBVideoProvider_SetAudioOutputs;
+ thiz->GetAudioOutputs = IDirectFBVideoProvider_GetAudioOutputs;
+ thiz->CreateEventBuffer = IDirectFBVideoProvider_CreateEventBuffer;
+ thiz->AttachEventBuffer = IDirectFBVideoProvider_AttachEventBuffer;
+ thiz->EnableEvents = IDirectFBVideoProvider_EnableEvents;
+ thiz->DisableEvents = IDirectFBVideoProvider_DisableEvents;
+ thiz->DetachEventBuffer = IDirectFBVideoProvider_DetachEventBuffer;
+ thiz->SetAudioDelay = IDirectFBVideoProvider_SetAudioDelay;
+}
+
+
+DFBResult
+IDirectFBVideoProvider_CreateFromBuffer( IDirectFBDataBuffer *buffer,
+ CoreDFB *core,
+ IDirectFBVideoProvider **interface )
+{
+ DFBResult ret;
+ DirectInterfaceFuncs *funcs = NULL;
+ IDirectFBDataBuffer_data *buffer_data;
+ IDirectFBVideoProvider *videoprovider;
+ IDirectFBVideoProvider_ProbeContext ctx;
+
+ /* Get the private information of the data buffer. */
+ buffer_data = (IDirectFBDataBuffer_data*) buffer->priv;
+ if (!buffer_data)
+ return DFB_DEAD;
+
+ /* Provide a fallback for video providers without data buffer support. */
+ ctx.filename = buffer_data->filename;
+ ctx.buffer = buffer;
+
+ /* Wait until 64 bytes are available. */
+ ret = buffer->WaitForData( buffer, sizeof(ctx.header) );
+ if (ret)
+ return ret;
+
+ /* Clear context header. */
+ memset( ctx.header, 0, sizeof(ctx.header) );
+
+ /* Read the first 64 bytes. */
+ buffer->PeekData( buffer, sizeof(ctx.header), 0, ctx.header, NULL );
+
+ /* Find a suitable implementation. */
+ ret = DirectGetInterface( &funcs, "IDirectFBVideoProvider", NULL, DirectProbeInterface, &ctx );
+ if (ret)
+ return ret;
+
+ DIRECT_ALLOCATE_INTERFACE( videoprovider, IDirectFBVideoProvider );
+
+ /* Initialize interface pointers. */
+ IDirectFBVideoProvider_Construct( videoprovider );
+
+ /* Construct the interface. */
+ ret = funcs->Construct( videoprovider, buffer, core );
+ if (ret)
+ return ret;
+
+ *interface = videoprovider;
+
+ return DFB_OK;
+}
+
diff --git a/Source/DirectFB/src/media/idirectfbvideoprovider.h b/Source/DirectFB/src/media/idirectfbvideoprovider.h
new file mode 100755
index 0000000..24e9ea1
--- /dev/null
+++ b/Source/DirectFB/src/media/idirectfbvideoprovider.h
@@ -0,0 +1,54 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __IDIRECTFBVIDEOPROVIDER_H__
+#define __IDIRECTFBVIDEOPROVIDER_H__
+
+#include <core/coretypes.h>
+
+/*
+ * probing context
+ */
+typedef struct {
+ unsigned char header[64];
+
+ /* Only set if databuffer is created from file. */
+ const char *filename;
+
+ /* Usefull if provider needs more data for probing. */
+ IDirectFBDataBuffer *buffer;
+} IDirectFBVideoProvider_ProbeContext;
+
+
+DFBResult
+IDirectFBVideoProvider_CreateFromBuffer( IDirectFBDataBuffer *buffer,
+ CoreDFB *core,
+ IDirectFBVideoProvider **interface );
+
+#endif
+