wiki:FlashResearch
Last modified 15 years ago Last modified on 04/14/10 09:55:28

Needed libraries to integrate flash

See #2329

  • Swfdec - is a library for decoding and rendering Flash animations. Sophie user will be able only to play flash videos. An interactions should be revised in future revisions.
  • Cairo - is a software library used to provide a vector graphics-based, device-independent API for software developers. It is designed to provide primitives for 2-dimensional drawing across a number of different backends.

Main idea of this task is not to explain why these two libraries (swfdec for flash, and cairo for rendering) were chosen for the implementation, but if it would be possible to implement flash capability in Sophie 2.0 in a reasonable time - few weeks. While I was researching the swfdec and cairo capabilities, I found out that both libraries have many dependencies (some of them are only needed for win32 build):

  • libiconv - library for convertion from one character encoding to another through Unicode conversion. - The libiconv library and its header files are under LGPL.
  • libbz2 - high-quality block-sorting file compressor library. - bzip2-1.0 is distributed under a BSD-style license.
  • libfontconfig-1 - generic font configuration library (shared library). - fontconfig is distributed under a permissive free software licence.
  • libfreetype6 - high-quality software font engine (runtime library). - FreeType License / GNU General Public License.
  • libgcrypt11 - a general purpose cryptographic library based on the code from GnuPG. - GNU General Public License.
  • libgio-2.0-0 - provides a virtual file system (VFS) API. - LGPL v2.1.
  • libglib-2.0-0 - a cross-platform software utility library. - LGPL v2.1 or later.
    • libgmodule-2.0-0 - LGPL v2.1.
    • libgobject-2.0-0 - LGPL v2.1.
    • libgthread-2.0-0 - LGPL v2.1.
  • liboil - a library of simple functions that are optimized for various CPUs.- BSD.
  • libpango - a library for laying out and rendering of text. - LGPL.
    • libpangocairo - LGPL.
    • libpangoft2-1.0-0 - LGPL.
    • libpangowin32-1.0-0 - LGPL.
  • libpixman - pixel-manipulation library for X and cairo. - MIT (X11).
  • libpng12-0 - official PNG reference library which supports almost all PNG features. - zlib License (permissive).
  • libxml2 - XML C parser and toolkit. - MIT (X11).
  • msvcrt - a module containing standard C library functions such as printf, memcpy, and cos. It is a part of the Microsoft C Runtime Library. - Freeware.
  • msvcrt20 - a module containing standard C library functions such as printf, memcpy, and cos. It is a part of the Microsoft C Runtime Library. - Freeware.
  • msvcrt40 - a module containing standard C library functions such as printf, memcpy, and cos. It is a part of the Microsoft C Runtime Library. - Freeware.
  • pthreadGC2 - a module\r for POSIX threads - Uknown.
  • zlib1 - a compression library. - zlib License (permissive).

I came at conclusion that there are so many dependecies, and mainly because glib library cannot be linked staticly, our native application/program cannot be build staticly. So, that is one disadvantage. But, this dependencies can be easily fixed (I tried this, and made successful build of cairo and swfdec under linux64). As my first impressions were, it came out that that task of implementing flash isn't that hard in algorithms and programming part (as was the case in the other natives), but in building the libraries. Here are the conclusions I made about the builds under different platforms:

  • Linux (32bit and 64bit) - I already made necessary builds and made executable native for linux64, so I guess, with high certainty, it wont be a problem either in linux32.
  • Mac (32bit intel) - I talked to the developer that made first attempt of implementing flash capabilities, and it came out that it is the same case like the linux - with the mac's package manager all the dipendencies can be fixed.
  • Windows (32bit) - My biggest concern was about windows because of the so many dependencies, and it is quite difficult to find the adequate libraries for the build. But, from the previous attempts, there are almost all needed libraries (in form of .dlls for win). There was even a successful build of the libraries and the native application itself. So, again, with high certainty, I can say that, the native application can be build under windows32.

Another problem with the code of the native application itself, was the fact that it was producing big memory leaks. As I was looking the code I came out with several "suspects" :)

  • in the method getFrame() in flash_player.h every time getFrame() is called, a CairoHandler is created (it has several fields containing) and there are several memcpy(...) which maybe are not needed, because ever frame, every time is copied twice.
    		CairoHandler cairoHandler(width, height);
            outputToCairoHandler(&cairoHandler);
    
            char *result = new char[(width * height + 2) * sizeof (int) ];
    
            memcpy(result, &width, sizeof (int));
            memcpy(result + sizeof (int), &height, sizeof (int));
            memcpy(result + 2 * sizeof (int), cairoHandler.getData(), width * height
                    * sizeof (int));
    
            return result;
    

Apart of that, swfdec and cairo have very useful and clean APIs (as isn't the case with ffmpeg), so the code of the native application is quite clean and readable , so I dont suspect that there will be major difficulties around the APIs, that is if we ever build the libraries :). So, at the end, my opinion is that it is worth trying to develop the native. One developer for about 2-2,5 weeks, probably should be enough as a resource of this task.