Hello..
I've been quite buisy the last weeks, but I've put together patches to get a
videoprovider for directfb using Xine.
I've got two patches one for the latest xine cvs:
cd xine-lib;cat patch-xine-lib | patch -p1
and one for latest directfb cvs:
cd DirectFB;cat patch-directfb | patch -p1

first install the xine stuff, then directfb

$ df_video video.mpg

HOWEVER!!! (BIG)
It doesn't work, I'm stuck with a problem that I can't figure out.
if you try the code you'll see at the beginning of the output there is:
datatype: 0 <--- printed from xine's directfb videoutput plugin
<a line>
gotten: 2 <--- printed from idirectfbvideoprovider_xine.c

they should have the same value.

the problem is I'm not able to pass IDirectFBVideoProvider_Xine_data *data
trough xine_load_video_output_plugin(..., (void *) data);

xine_load_video_output_plugin dlopens xine-lib/src/video_out/video_out_directfb.c (the 
shared object) and passes data on as void*
However somewhere something goes wrong since I can't access the
IDirectFBVideoProvider_Xine_data *data from video_out_directfb.c

patches are attached.

I hope anyone can point out the problem to me :)
Thanks for any help!

Regards Hallvar Helleseth
diff -Nur -x CVS -x .* DirectFB/configure.in DirectFB.xine/configure.in
--- DirectFB/configure.in       Mon Dec 10 17:49:55 2001
+++ DirectFB.xine/configure.in  Mon Dec 10 17:53:56 2001
@@ -301,6 +301,26 @@
 
   AM_CONDITIONAL(AVIFILE_PROVIDER, test x$AVIFILE = xyes)
 
+dnl Test for Xine
+XINE=no
+  AC_ARG_ENABLE(xine, [  --enable-xine        build Xine video provider
+  [default=auto]], enable_xine="$enableval", enable_xine=yes)
+
+  if test x$enable_xine = xyes; then
+       AC_PATH_PROG(XINE_CONFIG, xine-config, no)
+       if test x$XINE_CONFIG = xno; then
+         AC_MSG_WARN(["*** xine-config not found -- Xine video provider will not
+         be built."])
+       else
+         AC_PROG_CXX
+         XINE=yes
+         XINE_CFLAGS=`xine-config --cflags`
+         XINE_LIBS=`xine-config --libs`
+       fi
+  fi
+  
+  AM_CONDITIONAL(XINE_PROVIDER, test x$XINE = xyes)
+  
 
 dnl Test for libflash
   FLASH=no
@@ -443,6 +463,8 @@
 AC_SUBST(AVIFILE_PROVIDER)
 AC_SUBST(AVIFILE_CFLAGS)
 AC_SUBST(AVIFILE_LIBS)
+AC_SUBST(XINE_CFLAGS)
+AC_SUBST(XINE_LIBS)
 AC_SUBST(LIBMPEG3_LIBS)
 AC_SUBST(LIBFLASH)
 AC_SUBST(GFX_ATI)
@@ -516,6 +538,7 @@
   AviFile             $AVIFILE
   libmpeg3            $MPEG3
   Flash               $FLASH
+  Xine                $XINE
   Video4Linux         yes
 
 Building Font implementations:
diff -Nur -x CVS -x .* DirectFB/interfaces/IDirectFBVideoProvider/Makefile.am 
DirectFB.xine/interfaces/IDirectFBVideoProvider/Makefile.am
--- DirectFB/interfaces/IDirectFBVideoProvider/Makefile.am      Mon Dec 10 17:49:56 
2001
+++ DirectFB.xine/interfaces/IDirectFBVideoProvider/Makefile.am Mon Dec 10 18:11:02 
+2001
@@ -8,7 +8,11 @@
 else
 AVIFILE_PROVIDER_LTLIB =
 endif
-
+if XINE_PROVIDER
+XINE_PROVIDER_LTLIB = libidirectfbvideoprovider_xine.la
+else
+XINE_PROVIDER_LTLIB =
+endif
 
 ## This is a hack around fucking libtool to link libmpeg3.a into our shared object.
 
@@ -52,12 +56,21 @@
 CFLAGS = $(DFB_CFLAGS)
 CXXFLAGS = $(DFB_CXXFLAGS) $(AVIFILE_CFLAGS)
 
+internalincludedir = $(INTERNALINCLUDEDIR)
+
+internalinclude_HEADERS = xine_provider.h
 
 idirectfbvideoprovider_LTLIBRARIES = \
        libidirectfbvideoprovider_v4l.la        \
        $(AVIFILE_PROVIDER_LTLIB)               \
-       $(FLASH_PROVIDER_LTLIB)
+       $(FLASH_PROVIDER_LTLIB)                 \
+       $(XINE_PROVIDER_LTLIB)
+
+libidirectfbvideoprovider_xine_la_SOURCES = idirectfbvideoprovider_xine.c
+
+libidirectfbvideoprovider_xine_la_LIBADD = $(XINE_LIBS)
 
+libidirectfbvideoprovider_xine_la_LDFLAGS = -avoid-version -module -disable-static
 
 libidirectfbvideoprovider_avifile_la_SOURCES = idirectfbvideoprovider_avifile.cpp
 
diff -Nur -x CVS -x .* 
DirectFB/interfaces/IDirectFBVideoProvider/idirectfbvideoprovider_xine.c 
DirectFB.xine/interfaces/IDirectFBVideoProvider/idirectfbvideoprovider_xine.c
--- DirectFB/interfaces/IDirectFBVideoProvider/idirectfbvideoprovider_xine.c    Thu 
Jan  1 01:00:00 1970
+++ DirectFB.xine/interfaces/IDirectFBVideoProvider/idirectfbvideoprovider_xine.c      
+ Mon Dec 10 17:38:19 2001
@@ -0,0 +1,495 @@
+/*
+   (c) Copyright 2001  Kim JeongHoe <[EMAIL PROTECTED]> and Hallvar I guess..
+   All rights reserved.
+
+   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 <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <malloc.h>
+
+#include <pthread.h>
+
+#include <directfb.h>
+#include <directfb_internals.h>
+
+#include <misc/util.h>
+#include <misc/mem.h>
+
+#include <core/coredefs.h>
+#include <core/coretypes.h>
+
+#include <core/layers.h>
+#include <core/state.h>
+#include <core/surfaces.h>
+#include <core/gfxcard.h>
+
+#include <display/idirectfbsurface.h>
+
+//#include <xine.h>
+#include <xine/xine_internal.h>
+//#include "utils.h"
+#include <xine/xineutils.h>
+
+#include "xine_provider.h"
+
+static void
+IDirectFBVideoProvider_Xine_Destruct( IDirectFBVideoProvider *thiz )
+{
+    IDirectFBVideoProvider_Xine_data *data;
+
+    data = (IDirectFBVideoProvider_Xine_data*)thiz->priv;
+
+    thiz->Stop( thiz );
+
+    surface_destroy( data->source );
+    
+    DFBFREE( thiz->priv );
+    thiz->priv = NULL;
+
+#ifndef DFB_DEBUG
+    DFBFREE( thiz );
+#endif
+}
+
+static DFBResult
+IDirectFBVideoProvider_Xine_AddRef( IDirectFBVideoProvider *thiz )
+{
+    INTERFACE_GET_DATA (IDirectFBVideoProvider_Xine)
+
+    data->ref++;
+
+    return DFB_OK;
+}
+
+
+static DFBResult
+IDirectFBVideoProvider_Xine_Release( IDirectFBVideoProvider *thiz )
+{
+    INTERFACE_GET_DATA (IDirectFBVideoProvider_Xine)
+
+    if (--data->ref == 0) {
+        IDirectFBVideoProvider_Xine_Destruct( thiz );
+    }
+
+    return DFB_OK;
+}
+
+static DFBResult 
+IDirectFBVideoProvider_Xine_GetCapabilities(
+                                           IDirectFBVideoProvider       *thiz,
+                                           DFBVideoProviderCapabilities *caps )
+{
+     INTERFACE_GET_DATA (IDirectFBVideoProvider_Xine)
+
+     if (!caps)
+          return DFB_INVARG;
+
+     *caps = DVCAPS_BASIC | DVCAPS_SCALE | DVCAPS_SEEK;
+
+     return DFB_OK;
+}
+
+static DFBResult
+IDirectFBVideoProvider_Xine_GetSurfaceDescription(
+    IDirectFBVideoProvider *thiz, DFBSurfaceDescription  *desc )
+{
+    INTERFACE_GET_DATA (IDirectFBVideoProvider_Xine)
+
+    if (!desc)
+        return DFB_INVARG;
+
+    desc->flags  = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT;
+    desc->width  = 300;
+    desc->height = 300;
+    desc->pixelformat = layers->shared->surface->format;
+
+    return DFB_OK;
+}
+
+
+static void*
+MpegThread( void *ctx )
+{
+    IDirectFBVideoProvider_Xine_data *data =
+        (IDirectFBVideoProvider_Xine_data*) ctx;
+    struct timeval start, after;
+    long frame_delay;
+    long delay = -1;
+    double rate;
+    DFBRectangle rect, drect, srect;
+    int drop = 0;
+    long frame;
+    long frames;
+
+    rect.x = 0;
+    rect.y = 0;
+    rect.w = 300;
+    rect.h = 300;
+
+       data->d = 542;
+       xine_play(data->xine, "/home/hallvar/test.mpg",0,0);
+               
+       
+    while ( 1 ) {
+        pthread_testcancel();
+/*
+        drect = data->dest_rect;
+        if (drect.w != rect.w  ||  drect.h != rect.h)
+               {
+            gfxcard_stretchblit( &rect, &drect, &data->state );
+               }
+        else {
+            srect = rect;
+            gfxcard_blit( &srect, drect.x, drect.y, &data->state );
+        }
+
+        if (data->callback)
+            data->callback (data->ctx);
+                       */
+    }
+       
+    return NULL;
+}
+
+
+static DFBResult
+IDirectFBVideoProvider_Xine_PlayTo( IDirectFBVideoProvider *thiz,
+                                        IDirectFBSurface       *destination,
+                                        DFBRectangle           *dstrect,
+                                        DVFrameCallback         callback,
+                                        void                   *ctx )
+{
+    DFBRectangle            rect;
+    IDirectFBSurface_data  *dst_data;
+
+    INTERFACE_GET_DATA (IDirectFBVideoProvider_Xine)
+
+    if (!destination)
+        return DFB_INVARG;
+
+    dst_data = (IDirectFBSurface_data*)destination->priv;
+
+    if (!dst_data)
+        return DFB_DEAD;
+
+        /* build the destination rectangle */
+    if (dstrect) {
+        if (dstrect->w < 1  ||  dstrect->h < 1)
+            return DFB_INVARG;
+
+        rect = *dstrect;
+
+        rect.x += dst_data->area.wanted.x;
+        rect.y += dst_data->area.wanted.y;
+    }
+    else
+        rect = dst_data->area.wanted;
+
+        /* save for later blitting operation */
+    data->dest_rect = rect;
+
+        /* build the clip rectangle */
+    if (!rectangle_intersect( &rect, &dst_data->area.current ))
+        return DFB_INVARG;
+
+        /* put the destination clip into the state */
+    data->state.clip.x1 = rect.x;
+    data->state.clip.y1 = rect.y;
+    data->state.clip.x2 = rect.x + rect.w - 1;
+    data->state.clip.y2 = rect.y + rect.h - 1;
+    data->state.destination = dst_data->surface;
+    data->state.modified = (StateModificationFlags)
+        (data->state.modified | SMF_CLIP | SMF_DESTINATION);
+
+    if (data->destination) {
+        data->destination->Release( data->destination );
+        data->destination = NULL;     /* FIXME: remove listener */
+    }
+     
+    destination->AddRef( destination );
+    data->destination = destination;   /* FIXME: install listener */
+
+    data->callback = callback;
+    data->ctx = ctx;
+
+       data->dstsurface = dst_data->surface;
+
+       surfacemanager_lock(data->dstsurface->manager);
+       surfacemanager_assure_video(data->dstsurface->manager, 
+data->dstsurface->back_buffer);
+       surfacemanager_unlock(data->dstsurface->manager);
+
+    if (data->thread == -1)
+        pthread_create( &data->thread, NULL, MpegThread, data );
+    
+     
+    return DFB_OK;
+}
+
+
+static DFBResult
+IDirectFBVideoProvider_Xine_Stop( IDirectFBVideoProvider *thiz )
+{
+    IDirectFBVideoProvider_Xine_data *data;
+
+    if (!thiz)
+        return DFB_INVARG;
+
+    data = (IDirectFBVideoProvider_Xine_data*)thiz->priv;
+
+    if (!data)
+        return DFB_DEAD;
+
+    if (data->thread != -1)
+    {
+        pthread_cancel( data->thread );
+        pthread_join( data->thread, NULL );
+        data->thread = -1;
+    }
+       
+     
+    if (data->destination) {
+        data->destination->Release( data->destination );
+        data->destination = NULL;     /* FIXME: remove listener */
+    }
+
+    return DFB_OK;
+}
+
+
+static DFBResult IDirectFBVideoProvider_Xine_SeekTo(
+                                              IDirectFBVideoProvider *thiz,
+                                              double                  seconds )
+{
+    IDirectFBVideoProvider_Xine_data *data;
+    double rate;
+
+    if (!thiz)
+        return DFB_INVARG;
+
+    data = (IDirectFBVideoProvider_Xine_data*)thiz->priv;
+
+    if (!data)
+        return DFB_DEAD;
+/*
+    rate = mpeg3_frame_rate( data->stream, 0 );
+    mpeg3_set_frame( data->stream, (long) (seconds * rate), 0 );
+*/
+    return DFB_OK;
+}
+
+
+static DFBResult IDirectFBVideoProvider_Xine_GetPos(
+                                              IDirectFBVideoProvider *thiz,
+                                              double                 *seconds )
+{
+    IDirectFBVideoProvider_Xine_data *data;
+    double rate;
+
+    if (!thiz)
+        return DFB_INVARG;
+
+    data = (IDirectFBVideoProvider_Xine_data*)thiz->priv;
+
+    if (!data)
+        return DFB_DEAD;
+/*
+    rate = mpeg3_frame_rate( data->stream, 0 );
+    *seconds = mpeg3_get_frame( data->stream, 0 ) / rate;
+*/
+    return DFB_OK;
+}
+
+
+static DFBResult IDirectFBVideoProvider_Xine_GetLength(
+                                              IDirectFBVideoProvider *thiz,
+                                              double                 *seconds )
+{
+    IDirectFBVideoProvider_Xine_data *data;
+    double rate;
+    long frames;
+
+    if (!thiz)
+        return DFB_INVARG;
+
+    data = (IDirectFBVideoProvider_Xine_data*)thiz->priv;
+
+    if (!data)
+        return DFB_DEAD;
+
+       /*
+    frames = mpeg3_video_frames( data->stream, 0 );
+    if (frames <= 1)
+         return DFB_UNSUPPORTED;
+    
+    rate = mpeg3_frame_rate( data->stream, 0 );
+    *seconds = frames / rate;
+    */
+    return DFB_OK;
+}
+
+static DFBResult IDirectFBVideoProvider_Xine_GetColorAdjustment(
+                                                  IDirectFBVideoProvider *thiz,
+                                                  DFBColorAdjustment     *adj )
+{
+    IDirectFBVideoProvider_Xine_data *data;
+
+    if (!thiz || !adj)
+        return DFB_INVARG;
+
+    data = (IDirectFBVideoProvider_Xine_data*)thiz->priv;
+
+    if (!data)
+        return DFB_DEAD;
+
+    return DFB_UNIMPLEMENTED;
+}
+
+static DFBResult IDirectFBVideoProvider_Xine_SetColorAdjustment(
+                                                  IDirectFBVideoProvider *thiz,
+                                                  DFBColorAdjustment     *adj )
+{
+    IDirectFBVideoProvider_Xine_data *data;
+
+    if (!thiz || !adj)
+        return DFB_INVARG;
+
+    data = (IDirectFBVideoProvider_Xine_data*)thiz->priv;
+
+    if (!data)
+        return DFB_DEAD;
+
+    return DFB_UNIMPLEMENTED;
+}
+
+
+/* exported symbols */
+
+const char *get_type()
+{
+     return "IDirectFBVideoProvider";
+}
+
+const char *get_implementation()
+{
+     return "Xine";
+}
+
+DFBResult Probe( const char *filename )
+{
+   return DFB_OK;
+}
+
+DFBResult Construct( IDirectFBVideoProvider *thiz, const char *filename )
+{
+    IDirectFBVideoProvider_Xine_data *data;
+    int height, width;
+       char          *audio_driver_id = NULL;
+       int            audio_channel   = 0;
+       int            demux_strategy  = DEMUX_DEFAULT_STRATEGY;
+
+
+    data = (IDirectFBVideoProvider_Xine_data *)
+         DFBCALLOC( 1, sizeof(IDirectFBVideoProvider_Xine_data) );
+  /*
+      data = (IDirectFBVideoProvider_Xine_data *) 
+malloc(sizeof(IDirectFBVideoProvider_Xine_data));
+
+         data->d = 2;
+       data->vo_driver = xine_load_video_output_plugin(NULL, "directfb", 
+VISUAL_TYPE_DIRECTFB, (void *) data);
+       */
+    thiz->priv = data;
+
+    data->ref = 1;
+       
+    data->state.source   = data->source;
+    data->state.modified = SMF_ALL;
+
+    data->thread = -1;
+
+    thiz->AddRef    = IDirectFBVideoProvider_Xine_AddRef;
+    thiz->Release   = IDirectFBVideoProvider_Xine_Release;
+    thiz->GetCapabilities = IDirectFBVideoProvider_Xine_GetCapabilities;
+    thiz->GetSurfaceDescription =
+         IDirectFBVideoProvider_Xine_GetSurfaceDescription;
+    thiz->PlayTo    = IDirectFBVideoProvider_Xine_PlayTo;
+    thiz->Stop      = IDirectFBVideoProvider_Xine_Stop;
+    thiz->SeekTo    = IDirectFBVideoProvider_Xine_SeekTo;
+    thiz->GetPos    = IDirectFBVideoProvider_Xine_GetPos;
+    thiz->GetLength = IDirectFBVideoProvider_Xine_GetLength;
+    thiz->GetColorAdjustment =
+         IDirectFBVideoProvider_Xine_GetColorAdjustment;
+    thiz->SetColorAdjustment =
+         IDirectFBVideoProvider_Xine_SetColorAdjustment;
+
+ 
+       if(!xine_check_version(0, 9, 6))
+          return DFB_INIT;
+
+
+       char *configfile;
+       {
+          char *homedir;
+          homedir = strdup(xine_get_homedir());
+          configfile = (char *) xine_xmalloc(strlen(homedir) + 8 + 1);
+          sprintf (configfile, "%s/.xinerc", homedir);
+       }
+       data->config = config_file_init (configfile);
+       
+       /*
+       width = 300;
+       height = 300;
+    surface_create( width, height, DSPF_RGB16, CSP_SYSTEMONLY,
+                    DSCAPS_SYSTEMONLY, &(data->source));
+*/
+       data->d = 2;
+       //DataType *b;
+       //b = (DataType *)malloc(sizeof(DataType));
+       //b->d = 2343;
+       vo_driver_t *vo_driver;
+       vo_driver = xine_load_video_output_plugin(data->config, "directfb", 
+VISUAL_TYPE_DIRECTFB, (void *) data);
+       printf("gotten: %i\n", data->d);
+
+       if(!vo_driver)
+       {
+          printf("video driver directfb failed\n");
+          return DFB_INIT;
+       }
+
+       audio_driver_id = "oss";
+       
+       data->ao_driver = xine_load_audio_output_plugin(data->config,
+                                            audio_driver_id);
+       if(!data->ao_driver)
+       {
+          printf("audio driver oss failed\n");
+       }
+       
+       data->xine = xine_init (vo_driver, data->ao_driver, data->config);
+
+       if(!data->xine)
+       {
+          printf("xine_init() failed.\n");
+          return DFB_INIT;
+       }
+
+       xine_select_audio_channel (data->xine, audio_channel);
+       
+   return DFB_OK;
+}
diff -Nur -x CVS -x .* DirectFB/interfaces/IDirectFBVideoProvider/xine_provider.h 
DirectFB.xine/interfaces/IDirectFBVideoProvider/xine_provider.h
--- DirectFB/interfaces/IDirectFBVideoProvider/xine_provider.h  Thu Jan  1 01:00:00 
1970
+++ DirectFB.xine/interfaces/IDirectFBVideoProvider/xine_provider.h     Sun Nov 25 
+19:48:46 2001
@@ -0,0 +1,38 @@
+/*
+#include <directfb.h>
+#include <directfb_internals.h>
+
+#include <misc/util.h>
+#include <misc/mem.h>
+
+#include <core/coredefs.h>
+#include <core/coretypes.h>
+
+#include <core/layers.h>
+#include <core/state.h>
+#include <core/surfaces.h>
+#include <core/gfxcard.h>
+
+#include <display/idirectfbsurface.h>
+*/
+typedef struct _xineviddata {
+    int               ref;
+       
+       xine_t                   *xine;
+       int              ignore_status;
+       config_values_t  *config;
+       ao_driver_t      *ao_driver;
+       vo_driver_t              *vo_driver;
+
+    pthread_t        thread;
+
+    IDirectFBSurface *destination;
+    DFBRectangle     dest_rect;
+    DVFrameCallback  callback;
+    void             *ctx;
+
+    CardState        state;
+    CoreSurface      *source;
+       CoreSurface              *dstsurface;
+       int d;
+} IDirectFBVideoProvider_Xine_data;
diff -Nur -x CVS -x .* DirectFB/src/interface.c DirectFB.xine/src/interface.c
--- DirectFB/src/interface.c    Mon Dec 10 17:49:56 2001
+++ DirectFB.xine/src/interface.c       Mon Dec 10 17:56:54 2001
@@ -114,7 +114,7 @@
                     continue;
           }
 
-          handle = dlopen( buf, RTLD_LAZY );
+          handle = dlopen( buf, RTLD_LAZY | RTLD_GLOBAL);
           if (handle) {
                char *(*get)() = NULL;
diff -Nur -x CVS -x .* xine-lib/configure.in xine-lib.directfb/configure.in
--- xine-lib/configure.in       Mon Dec 10 17:47:27 2001
+++ xine-lib.directfb/configure.in      Mon Dec 10 00:22:12 2001
@@ -268,6 +268,12 @@
 AM_PATH_AALIB(1.2,, AC_MSG_RESULT([*** All of AALIB dependent parts will be disabled 
***]))
 AM_CONDITIONAL(HAVE_AA, test x$no_aalib != "xyes")
 
+dnl
+dnl Checks for DirectFB library
+dnl
+AM_PATH_DIRECTFB(0.9.7,, AC_MSG_RESULT(*** All of DIRECTFB dependent parts will be 
+disabled ***))
+AM_CONDITIONAL(HAVE_DIRECTFB, test x$no_directfb != "xyes")
+
 
 dnl
 dnl Check for divx4
@@ -709,6 +715,8 @@
 AC_SUBST(XINE_SKINDIR)
 AC_SUBST(XINE_FONTDIR)
 
+UT_LIBS="$(top_srcdir)/xine-utils/.libs/libxineutils.so"
+AC_SUBST(UT_LIBS)
 
 dnl Where scripts will/should be installed.
 eval XINE_SCRIPTPATH="${datadir}/xine/scripts"
@@ -868,6 +876,9 @@
   fi
   echo "   - dxr3"
 fi
+if test x$no_directfb != "xyes";then
+  echo "   - directfb (For use with video provider"
+fi
 echo ""
 
 dnl Audio plugins
@@ -938,3 +949,5 @@
   echo "   - cda"
 fi
 echo "---"
+
+
diff -Nur -x CVS -x .* xine-lib/cvscompile.sh xine-lib.directfb/cvscompile.sh
--- xine-lib/cvscompile.sh      Mon Dec 10 17:47:27 2001
+++ xine-lib.directfb/cvscompile.sh     Mon Dec 10 18:21:24 2001
@@ -13,7 +13,7 @@
 srcdir=`dirname $0`
 test -z "$srcdir" && srcdir=.
 
-m4_files="_xine.m4 alsa.m4 arts.m4 esd.m4 aa.m4 irixal.m4 ogg.m4 vorbis.m4"
+m4_files="_xine.m4 alsa.m4 arts.m4 esd.m4 aa.m4 irixal.m4 ogg.m4 vorbis.m4 
+directfb.m4"
 if test -d $srcdir/m4; then
     rm -f acinclude.m4
     for m4f in $m4_files; do
diff -Nur -x CVS -x .* xine-lib/m4/directfb.m4 xine-lib.directfb/m4/directfb.m4
--- xine-lib/m4/directfb.m4     Thu Jan  1 01:00:00 1970
+++ xine-lib.directfb/m4/directfb.m4    Sat Nov 24 00:56:13 2001
@@ -0,0 +1,58 @@
+dnl -------------------- DIRECTFB -------------------------
+AC_DEFUN(AM_PATH_DIRECTFB,
+[dnl 
+dnl
+AC_ARG_WITH(directfblib-prefix,
+    [  --with-directfb-prefix=PFX Prefix where DIRECTFB is installed (optional)],
+            aalib_config_prefix="$withval", aalib_config_prefix="")
+
+  if test x$directfb_config_prefix != x ; then
+     directfb_config_args="$directfb_config_args --prefix=$directfb_config_prefix"
+     if test x${DIRECTFB_CONFIG+set} != xset ; then
+        AALIB_CONFIG=$directfb_config_prefix/bin/directfb-config
+     fi
+  fi
+
+  min_directfb_version=ifelse([$1], ,0.9.7,$1)
+
+  if test ! -x "$DIRECTFB_CONFIG"; then
+    DIRECTFB_CONFIG=""
+  fi
+  AC_PATH_PROG(DIRECTFB_CONFIG, directfb-config, no)
+  
+  AC_MSG_CHECKING(for DIRECTFB version >= $min_directfb_version)
+  no_directfb=""
+  DIRECTFB_CFLAGS=`$DIRECTFB_CONFIG $directfb_config_args --cflags`
+  DIRECTFB_CFLAGS="$DIRECTFB_CFLAGS -I`$DIRECTFB_CONFIG 
+--prefix`/include/directfb-internal"
+  DIRECTFB_LIBS=`$DIRECTFB_CONFIG $directfb_config_args --libs`
+  directfb_config_major_version=`$DIRECTFB_CONFIG $directfb_config_args \
+    --version | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
+  directfb_config_minor_version=`$DIRECTFB_CONFIG $directfb_config_args \
+    --version | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
+  directfb_config_sub_version=`$DIRECTFB_CONFIG $directfb_config_args \
+    --version | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
+  
+  ac_save_CFLAGS="$CFLAGS"
+  ac_save_LIBS="$LIBS"
+  CFLAGS="$CFLAGS $DIRECTFB_CFLAGS"
+  LIBS="$DIRECTFB_LIBS $LIBS"
+
+  if test "x$no_directfb" = x; then
+    AC_MSG_RESULT(yes)
+    ifelse([$2], , :, [$2])     
+  else
+    AC_MSG_RESULT(no)
+    if test "$DIRECTFB_CONFIG" ; then
+      echo "*** The directfb-config program installed by DIRECTFB could not be found"
+      echo "*** If DIRECTFB was installed in PREFIX, make sure PREFIX/bin is in"
+      echo "*** your path, or use --with-directfb-prefix to set the prefix"
+      echo "*** where DIRECTFB is installed."
+    fi
+    ifelse([$3], , :, [$3])
+  fi
+  UT_LIBS="${top_srcdir}/xine-utils/.libs/libxineutils.so"
+  AC_SUBST(DIRECTFB_CFLAGS)
+  AC_SUBST(DIRECTFB_LIBS)
+  AC_SUBST(UT_LIBS)
+  AC_LANG_RESTORE()
+])
diff -Nur -x CVS -x .* xine-lib/src/video_out/Makefile.am 
xine-lib.directfb/src/video_out/Makefile.am
--- xine-lib/src/video_out/Makefile.am  Mon Dec 10 17:46:44 2001
+++ xine-lib.directfb/src/video_out/Makefile.am Mon Dec 10 17:42:30 2001
@@ -1,4 +1,4 @@
-CFLAGS = @GLOBAL_CFLAGS@ @X_CFLAGS@ @LIBMPEG2_CFLAGS@ -DXINE_COMPILE
+CFLAGS =  @DIRECTFB_CFLAGS@ @GLOBAL_CFLAGS@ @X_CFLAGS@ @LIBMPEG2_CFLAGS@ 
+-DXINE_COMPILE
 DEBUG_CFLAGS = @DEBUG_CFLAGS@ @X_CFLAGS@ @LIBMPEG2_CFLAGS@ -DXINE_COMPILE
 
 LIBTOOL = $(SHELL) $(top_builddir)/libtool-nofpic
@@ -16,6 +16,9 @@
 if HAVE_AA
 aa_module = xineplug_vo_out_aa.la
 endif
+if HAVE_DIRECTFB
+directfb_module = xineplug_vo_out_directfb.la
+endif
 
 ##
 # IMPORTANT:
@@ -23,7 +26,7 @@
 # All of xine video out plugins should be named like the 
 # scheme "xineplug_vo_out_"
 #
-lib_LTLIBRARIES = $(xv_module) $(syncfb_module) $(xshm_module) $(aa_module)
+lib_LTLIBRARIES = $(xv_module) $(syncfb_module) $(xshm_module) $(aa_module) 
+$(directfb_module)
 
 xineplug_vo_out_xv_la_SOURCES = deinterlace.c alphablend.c video_out_xv.c
 xineplug_vo_out_xv_la_LIBADD =  $(XV_LIB) $(X_LIBS) -lXext
@@ -40,6 +43,11 @@
 xineplug_vo_out_aa_la_SOURCES =  video_out_aa.c
 xineplug_vo_out_aa_la_LIBADD = $(AALIB_LIBS)
 xineplug_vo_out_aa_la_LDFLAGS = -avoid-version -module
+
+xineplug_vo_out_directfb_la_SOURCES =  video_out_directfb.c
+xineplug_vo_out_directfb_la_LIBADD = $(DIRECTFB_LIBS)
+xineplug_vo_out_directfb_la_LDFLAGS = -avoid-version -module
+
 
 noinst_HEADERS = yuv2rgb.h video_out_syncfb.h alphablend.h deinterlace.h
 
diff -Nur -x CVS -x .* xine-lib/src/video_out/video_out_directfb.c 
xine-lib.directfb/src/video_out/video_out_directfb.c
--- xine-lib/src/video_out/video_out_directfb.c Thu Jan  1 01:00:00 1970
+++ xine-lib.directfb/src/video_out/video_out_directfb.c        Mon Dec 10 17:38:14 
+2001
@@ -0,0 +1,335 @@
+/* 
+ * Copyright (C) 2000-2001 the xine project
+ * 
+ * This file is part of xine, a unix video player.
+ * 
+ * xine is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * xine is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
+ *
+ * $Id: video_out_aa.c,v 1.13 2001/10/03 15:14:03 jkeil Exp $
+ *
+ * video_out_aa.c, ascii-art output plugin for xine
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <string.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+
+#include <directfb.h>
+#include <directfb_internals.h>
+
+#include <misc/util.h>
+#include <misc/mem.h>
+
+#include <core/coredefs.h>
+#include <core/coretypes.h>
+#include <core/state.h>
+
+#include <core/surfaces.h>
+
+//#include <display/idirectfbsurface.h>
+
+
+#include "video_out.h"
+#include "xine_internal.h"
+#include "utils.h"
+
+#include <xine_provider.h>
+
+/*
+ * global variables
+ */
+
+typedef struct directfb_frame_s {
+
+  vo_frame_t    vo_frame;
+
+  int           width, height;
+  uint8_t      *mem[3];
+
+  int           ratio_code;
+
+  int           format;
+
+} directfb_frame_t;
+
+typedef struct {
+
+  vo_driver_t        vo_driver;
+
+  config_values_t   *config;
+
+  int                user_ratio;
+
+  IDirectFBVideoProvider_Xine_data       *context;
+} directfb_driver_t;
+
+
+/*
+ * our video driver
+ */
+
+static uint32_t directfb_get_capabilities (vo_driver_t *this) {
+  return VO_CAP_YUY2 | VO_CAP_RGB;
+}
+
+static void *malloc_aligned (size_t alignment, size_t size, void **mem) {
+  char *aligned;
+
+  aligned = malloc (size+alignment);
+  *mem = aligned;
+
+  while ((int) aligned % alignment)
+    aligned++;
+
+  return aligned;
+}
+
+static void directfb_dispose_frame (vo_frame_t *vo_img) {
+  directfb_frame_t *frame = (directfb_frame_t *)vo_img;
+  
+  if (frame->mem[0])
+    free (frame->mem[0]);
+  if (frame->mem[1])
+    free (frame->mem[1]);
+  if (frame->mem[2])
+    free (frame->mem[2]);
+
+  free (frame);
+}
+
+static void directfb_frame_field (vo_frame_t *vo_img, int which_field) {
+  /* nothing to be done here */
+}
+
+
+static vo_frame_t *directfb_alloc_frame(vo_driver_t *this) {
+  directfb_frame_t *frame;
+
+  frame = (directfb_frame_t *) malloc (sizeof (directfb_frame_t));
+  memset (frame, 0, sizeof (directfb_frame_t));
+
+  frame->vo_frame.copy = NULL;
+  frame->vo_frame.field = directfb_frame_field;
+  frame->vo_frame.dispose = directfb_dispose_frame;
+
+  return (vo_frame_t*) frame;
+}
+
+static void directfb_update_frame_format (vo_driver_t *this, vo_frame_t *img,
+                                   uint32_t width, uint32_t height, 
+                                   int ratio_code, int format, int flags) {
+
+  int image_size;
+
+  directfb_frame_t *frame = (directfb_frame_t *) img;
+
+  /* printf ("aa_update_format...\n"); */
+
+  if ((frame->width != width) || (frame->height != height) 
+      || (frame->format != format)) {
+
+    if (frame->mem[0]) {
+      free (frame->mem[0]);
+      frame->mem[0] = NULL;
+    }
+    if (frame->mem[1]) {
+      free (frame->mem[1]);
+      frame->mem[1] = NULL;
+    }
+      
+    if (frame->mem[2]) {
+      free (frame->mem[2]);
+      frame->mem[2] = NULL;
+    }
+
+    frame->width  = width;
+    frame->height = height;
+    frame->format = format;
+
+
+    if (format == IMGFMT_YV12) {
+      image_size = width * height;
+      frame->vo_frame.base[0] = malloc_aligned(16,image_size, (void**) 
+&frame->mem[0]);
+      frame->vo_frame.base[1] = malloc_aligned(16,image_size/4, (void**) 
+&frame->mem[1]);
+      frame->vo_frame.base[2] = malloc_aligned(16,image_size/4, (void**) 
+&frame->mem[2]);
+
+      // printf ("allocated yuv memory for %d x %d image\n", width, height);
+
+    } else if (format == IMGFMT_YUY2) {
+      image_size = width * 2 * height;
+      frame->vo_frame.base[0] = malloc_aligned(16,image_size, (void**) 
+&frame->mem[0]);
+    } else {
+      printf ("alert! unsupported image format %04x\n", format);
+      exit (1);
+    }
+
+    frame->ratio_code = ratio_code;
+
+  }
+
+  /* printf ("aa_update_format done\n"); */
+}
+
+static void directfb_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) {
+  int x,y;
+  double x_fact, y_fact; /* ratio between aa's and frame's width/height */
+
+  uint8_t *img;
+  uint8_t *src_image;
+ IDirectFBVideoProvider_Xine_data *data; 
+
+  directfb_driver_t *this = (directfb_driver_t*) this_gen;
+  directfb_frame_t *frame = (directfb_frame_t *) frame_gen;
+  data = (IDirectFBVideoProvider_Xine_data *) this->context;
+
+  x_fact = (double) frame->width / (double) 300;
+  y_fact = (double) frame->height / (double) 300;
+
+  src_image = frame->vo_frame.base[0];
+  printf("gfxcard 0\n");
+  //void *d = surface->back_buffer->video.offset;
+  //printf("offset: %i\n", (int) data->dstsurface->back_buffer->video.offset);
+  printf("d: %i\n", data->d);
+  //img = (uint8_t *)surface->back_buffer->video.offset;
+  printf("gfxcard 0a\n");
+  //img = (uint8_t *)gfxcard_memory_physical(surface->back_buffer->video.offset);
+  printf("gfxcard 1\n");
+  //img = directfb_image(this->context); /* pointer to the beginning of the output */
+
+  /*
+  fprintf(stderr,
+         "aalib sez: width: %d, height: %d\n",
+         aa_imgwidth (this->context),
+         aa_imgheight (this->context));
+  */
+
+  if (frame->format == IMGFMT_YV12) {
+    for (y = 0; y<300; y++) {
+      for (x = 0; x<300; x++) {
+      
+       *img++ = src_image[((int)((double) x * x_fact) +
+                           frame->width * (int)((double) y * y_fact))];
+      
+      }
+    }
+  } else {
+    for (y = 0; y<300; y++) {
+      for (x = 0; x<300; x++) {
+      
+       *img++ = src_image[((int)((double) x * x_fact) * 2 +
+                           frame->width * 2 * (int)((double) y * y_fact))];
+      
+      }
+    }
+  }
+
+  frame->vo_frame.displayed (&frame->vo_frame);
+
+  /*
+  aa_fastrender(this->context, 0, 0, 
+               directfb_imgwidth (this->context), 
+               directfb_imgheight (this->context));
+
+  aa_flush (this->context);
+*/
+}
+
+static int directfb_get_property (vo_driver_t *this_gen, int property) {
+  directfb_driver_t *this = (directfb_driver_t*) this_gen;
+  
+  if ( property == VO_PROP_ASPECT_RATIO) {
+    return this->user_ratio ;
+  } else {
+    printf ("video_out_xshm: tried to get unsupported property %d\n", property);
+  }
+
+  return 0;
+}
+
+static int directfb_set_property (vo_driver_t *this_gen, 
+                           int property, int value) {
+  directfb_driver_t *this = (directfb_driver_t*) this_gen;
+
+  if ( property == VO_PROP_ASPECT_RATIO) {
+    if (value>=NUM_ASPECT_RATIOS)
+      value = ASPECT_AUTO;
+    this->user_ratio = value;
+
+  } else {
+    printf ("video_out_xshm: tried to set unsupported property %d\n", property);
+  }
+
+  return value;
+}
+
+static void directfb_get_property_min_max (vo_driver_t *this_gen, 
+                                    int property, int *min, int *max) {
+  *min = 0;
+  *max = 0;
+}
+
+static void directfb_exit (vo_driver_t *this_gen) {
+}
+
+
+vo_driver_t *init_video_out_plugin (config_values_t *config, void *visual_gen) {
+  directfb_driver_t          *this;
+
+  this = (directfb_driver_t*) xine_xmalloc (sizeof (directfb_driver_t));
+
+  //this->context = (IDirectFBVideoProvider_Xine_data *) visual_gen;
+  //printf("dcontext: %i\n", this->context->d);
+  IDirectFBVideoProvider_Xine_data *b;
+  b = (IDirectFBVideoProvider_Xine_data *) visual_gen;
+  printf("dataype: %i\n", b->d);
+
+  this->config = config;
+
+  this->vo_driver.get_capabilities     = directfb_get_capabilities;
+  this->vo_driver.alloc_frame          = directfb_alloc_frame ;
+  this->vo_driver.update_frame_format  = directfb_update_frame_format;
+  this->vo_driver.display_frame        = directfb_display_frame;
+  this->vo_driver.get_property         = directfb_get_property;
+  this->vo_driver.set_property         = directfb_set_property;
+  this->vo_driver.get_property_min_max = directfb_get_property_min_max;
+  this->vo_driver.gui_data_exchange    = NULL;
+  this->vo_driver.exit                 = directfb_exit;
+
+  return (vo_driver_t*) this;
+}    
+
+static vo_info_t vo_info_directfb = {
+  2,
+  "directfb",
+  "xine video output plugin using the DirectFB library",
+  VISUAL_TYPE_DIRECTFB,
+  10
+};
+
+vo_info_t *get_video_out_plugin_info() {
+  return &vo_info_directfb;
+}
diff -Nur -x CVS -x .* xine-lib/src/xine-engine/xine_internal.h 
xine-lib.directfb/src/xine-engine/xine_internal.h
--- xine-lib/src/xine-engine/xine_internal.h    Mon Dec 10 17:47:27 2001
+++ xine-lib.directfb/src/xine-engine/xine_internal.h   Mon Dec 10 16:35:46 2001
@@ -493,6 +493,7 @@
 #define VISUAL_TYPE_AA    2
 #define VISUAL_TYPE_FB    3
 #define VISUAL_TYPE_GTK   4
+#define VISUAL_TYPE_DIRECTFB 5
 
 /*
  * list_video_output_plugins

Reply via email to