OSS Flash Player

= OSS Flash player on DirectFB =

Introduction
This wiki explains how to cross-compile an OSS Flash player for DirectFB. The most remarkable efforts regarding this type of software are Swfdec and Gnash. At the moment, this wiki describes Swfdec and some of its optionals, Gnash will be added soon.

Proprietary Flash players, such as Adobe Flash, are not considered.

This documentation is still a work in progress, some steps of this procedure are not nice. Any help, suggestions and corrections are welcome.

Swfdec
Swfdec is a decoder/renderer for Macromedia Flash animations.

From the Swfdec official site:

"Swfdec is the library for decoding and rendering Flash animations. It is still in heavy development. The intended audience are developers or people using it for pretested Flash animations (think embedded here). If you use it on unknown content, expect it to have issues and don't be surprised if it crashes. If you encounter such a crash however, make sure to file a bug immediately."

Although this Wiki was written with embedded systems in mind, this procedure should work on an i386 architecture using the host compiler and removing the --host and --build flags.

Supported Architectures
This procedure should work on any architecture in which DirectFB and GTK+- are installed.

It has been reported to work successfully in the following architectures/processors:

- SH (STMicroelectronics ST40)

Requirements
The OSS Flash layer Swfdec: swfdec-0.5.2

The software stack for making Swfdec work is the following:

Swfdec |           v           GTK+ |           V         DirectFB

Swfdec should run on all GDK backends (such as FB and X), but we're focused on DirectFB only.

This procedure assumes you already have DirectFB and GTK+ installed.

For installing GTK+ on DirectFB you can check these wikis:

Buiding GTK on DirectFB HOWTO

or

GTK on DirectFB for Embedded Systems

Optional libraries

Swfdec can use several libraries, such as HTTP libraries and MPEG audio decoders. Some of these libraries are described in this wiki:

libsoup-2.2.96

libsoup contains an HTTP library implementation in C:

libmad-0.15.1b

libmad is a high-quality MPEG audio decoder capable of 24-bit output:

liboil-0.3.11

liboil is a library of simple functions that are generally loops implementing simple algorithms. This functions are optimized for various CPUs.

ALSA [ToDo]

libjpeg [ToDo]

Environment configuration
Start yourself off by opening a new terminal and setting up the following variables:

$ export PREFIX=/opt/gtkdfb

Building options
If you're not building any of this options you can skip this section. However, without some of this functions you won't have audio or support for some images/video formats, etc.

libmad

Package: libmad-0.15.1b

Configure, compile and install: $ GLIB_CFLAGS="-I$PREFIX/usr/local/include/glib-2.0 -I$PREFIX/usr/local/lib/glib-2.0/include" \ GLIB_LIBS="-L$PREFIX/usr/local/lib -lglib-2.0" \ ./configure --build=i386-linux --host=sh4-linux --prefix=$PREFIX/usr/local \ --disable-ssl --disable-glibtest

$ make $ make install

libsoup

Package: libsoup-2.2.96

Configure, compile and install: $ ./configure --build=i386-linux --host=sh4-linux --prefix=$PREFIX/usr/local \ --enable-speed --disable-debugging

$ make $ make install

ALSA [ToDo]

libmad [ToDo]

libjpeg [ToDo]

Building Swfdec
This configure assumes that you already have liboil, libsoup, libmad and ALSA installed. If you don't, remove those options from the configure.

Configure: $ CC=sh4-linux-gcc CXX=sh4-linux-g++ LD=sh4-linux-ld \ GLIB_CFLAGS="-I$PREFIX/usr/local/include/glib-2.0 -I$PREFIX/usr/local/lib/glib-2.0/include" \ GLIB_LIBS="-L$PREFIX/usr/local/lib -lglib-2.0" \ GTK_CFLAGS="-I$PREFIX/usr/local/include/gtk-2.0 -I$PREFIX/usr/local/lib/gtk-2.0/include \ -I$PREFIX/usr/local/include/atk-1.0 -I$PREFIX/usr/local/include/cairo \  -I$PREFIX/usr/local/include/pango-1.0 -I$PREFIX/usr/local/include/glib-2.0 \  -I$PREFIX/usr/local/lib/glib-2.0/include -I$PREFIX/usr/local/include/freetype2 \  -I$PREFIX/usr/local/include/libpng12" \ GTK_LIBS="-L$PREFIX/usr/local/lib -lgtk-directfb-2.0 -lgdk-directfb-2.0 -latk-1.0 -lgdk_pixbuf-2.0 \ -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 \  -ldirectfb -ldirect -lfusion" \ PANGO_CFLAGS="-I$PREFIX/usr/local/include/pango-1.0" \ PANGO_LIBS="-L$PREFIX/usr/local/lib -lpango-1.0" \ CAIRO_CFLAGS="-I$PREFIX/usr/local/include/cairo" \ CAIRO_LIBS="-L$PREFIX/usr/local/lib -lcairo" \ GTHREAD_CFLAGS="-pthread -I$PREFIX/usr/local/include/glib-2.0 \ -I$PREFIX/usr/local/lib/glib-2.0/include" \ GTHREAD_LIBS="-pthread -L$PREFIX/usr/local/lib -lgthread-2.0 -lrt -lglib-2.0" \ LIBOIL_CFLAGS="-I$PREFIX/usr/local/include/liboil-0.3" \ LIBOIL_LIBS="-L$PREFIX/usr/local/lib -loil-0.3" \ HTTP_CFLAGS="-I$PREFIX/usr/local/include/libsoup-2.2" \ HTTP_LIBS="-L$PREFIX/usr/local/lib -lsoup-2.2" \ ALSA_CFLAGS="-I$PREFIX/include" \ ALSA_LIBS="-L$PREFIX/lib -lalsaplayer" \ MAD_LIBS="-L$PREFIX/usr/local/lib -lmad" \ ./configure \ --build=i386-linux \ --host=sh4-linux \ --prefix=$PREFIX/usr/local \ --enable-gtk \ --enable-mad \ --disable-ffmpeg \ --disable-gstreamer \ --with-audio=alsa \ --without-x

We had some problems with libtool, so we solved them adding the LIBTOOL and LIBTOOL_PREFIX variables to the configure. Don't worry about this if you don't have problems with your libtools: LIBTOOL=/opt/STM/STLinux-2.3ear/host/bin/libtool LIBTOOL_PREFIX_BASE=$PREFIX

Compile: $ make

If you are cross-compiling, the previous make will NOT work. It will give you an error saying that it cannot execute the file compute-strings. This is obvious since we are generating executables for another architecture, but the Makefile want to execute them in the host.

Edit the file libswfdec/Makefile:

Comment the following line. swfdec_as_strings.h: swfdec_as_strings.c compute-strings && cp xgen-sas \ && rm -f xgen-sas
 * 1)       ./compute-strings >> xgen-sas \

The previous line contains instructions that must be performed in the target (instead of the host) before keep going with the compilation. Here are the steps: Host> Copy the file compute-strings to the target (via NFS or FTP) Target> Execute it: $ ./compute-strings >> xgen-sas Target> Copy the generated file xgen-sas back to the target with the name swfdec_as_strings.h in the same folder where the file compute-strings was.

Edit the file libswfdec-gtk/Makefile:

Add to the SWFDEC_LIBS variable the following: -ldirectfb -ldirect -lfusion

Edit the file player/Makefile:

Add at the end of the SWFDEC_GTK_LIBS variable the following: /opt/gtkdfb/usr/lib/libasound.so

Compile again: $ make

Again, we had some problems with libtool, so we solved them this way. Don't worry about this if you don't have problems with your libtools. $ LIBTOOL_PREFIX_BASE=$PREFIX LD=sh4-linux-ld LIBTOOL=/opt/STM/STLinux-2.3ear/host/bin/libtool \ gmake $ cp libswfdec-gtk/libswfdec-gtk-0.5.la libswfdec-gtk/.libs/libswfdec-gtk-0.5.lai $ LIBTOOL_PREFIX_BASE=$PREFIX LD=sh4-linux-ld LIBTOOL=/opt/STM/STLinux-2.3ear/host/bin/libtool \ gmake install

That’s it. Any help, suggestions and corrections are welcome.