gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog configure.ac Makefile.am python...


From: Benjamin Wolsey
Subject: [Gnash-commit] gnash ChangeLog configure.ac Makefile.am python...
Date: Wed, 09 Jan 2008 20:06:02 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Benjamin Wolsey <bwy>   08/01/09 20:06:02

Modified files:
        .              : ChangeLog configure.ac Makefile.am 
Added files:
        pythonmodule   : Makefile.am gnashPythonExample.py 
                         gnashpython.cpp gnashpython.h pyGnash.cpp 

Log message:
                * pythonmodule/gnashpython.{h,cpp}: new 
pythonwrapper::GnashPlayer
                  class for providing Python bindings.
                * pythonmodule/pyGnash.cpp: the python module with interface to
                  gnash core libs.
                * pythonmodule/gnashPythonExample.py: example script as a 
substitute
                  for proper documentation.
                * configure.ac, Makefile.am, pythonmodule/Makefile.am: add new
                  directories; it's not built by default, neither are there 
macros
                  in configure.ac yet. To build, change 
ENABLE_GNASH_PYTHON_MODULE
                  manually and specify the python headers/libs in 
pythonmodule/Makefile.am.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5357&r2=1.5358
http://cvs.savannah.gnu.org/viewcvs/gnash/configure.ac?cvsroot=gnash&r1=1.468&r2=1.469
http://cvs.savannah.gnu.org/viewcvs/gnash/Makefile.am?cvsroot=gnash&r1=1.99&r2=1.100
http://cvs.savannah.gnu.org/viewcvs/gnash/pythonmodule/Makefile.am?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/pythonmodule/gnashPythonExample.py?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/pythonmodule/gnashpython.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/pythonmodule/gnashpython.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/pythonmodule/pyGnash.cpp?cvsroot=gnash&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5357
retrieving revision 1.5358
diff -u -b -r1.5357 -r1.5358
--- ChangeLog   9 Jan 2008 17:52:16 -0000       1.5357
+++ ChangeLog   9 Jan 2008 20:06:01 -0000       1.5358
@@ -1,3 +1,16 @@
+2008-01-09 Benjamin Wolsey <address@hidden>
+
+       * pythonmodule/gnashpython.{h,cpp}: new pythonwrapper::GnashPlayer
+         class for providing Python bindings.
+       * pythonmodule/pyGnash.cpp: the python module with interface to
+         gnash core libs.
+       * pythonmodule/gnashPythonExample.py: example script as a substitute
+         for proper documentation.
+       * configure.ac, Makefile.am, pythonmodule/Makefile.am: add new
+         directories; it's not built by default, neither are there macros
+         in configure.ac yet. To build, change ENABLE_GNASH_PYTHON_MODULE
+         manually and specify the python headers/libs in 
pythonmodule/Makefile.am.
+
 2008-01-09 Sandro Santilli <address@hidden>
 
        * server/movie_root.cpp (findCharacterByTarget): start from

Index: configure.ac
===================================================================
RCS file: /sources/gnash/gnash/configure.ac,v
retrieving revision 1.468
retrieving revision 1.469
diff -u -b -r1.468 -r1.469
--- configure.ac        4 Jan 2008 13:35:11 -0000       1.468
+++ configure.ac        9 Jan 2008 20:06:01 -0000       1.469
@@ -15,7 +15,7 @@
 dnl  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 dnl  
 
-dnl $Id: configure.ac,v 1.468 2008/01/04 13:35:11 strk Exp $
+dnl $Id: configure.ac,v 1.469 2008/01/09 20:06:01 bwy Exp $
 
 AC_PREREQ(2.50)
 AC_INIT(gnash, cvs)
@@ -881,6 +881,8 @@
 PKG_PROG_PKG_CONFIG
 
 AC_PATH_PROG(PYTHON, python, ,[${pathlist}])
+AM_CONDITIONAL([ENABLE_GNASH_PYTHON_MODULE], 0)
+
 
 dnl Look for scratchbox
 sbox=no
@@ -1848,6 +1850,7 @@
 doc/C/Makefile
 doc/C/asspec/Makefile
 doc/Doxyfile
+pythonmodule/Makefile
 testsuite/Makefile
 testsuite/libbase/Makefile
 testsuite/libgeometry/Makefile

Index: Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/Makefile.am,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -b -r1.99 -r1.100
--- Makefile.am 4 Jan 2008 23:57:10 -0000       1.99
+++ Makefile.am 9 Jan 2008 20:06:01 -0000       1.100
@@ -15,7 +15,7 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 # 
 
-# $Id: Makefile.am,v 1.99 2008/01/04 23:57:10 strk Exp $
+# $Id: Makefile.am,v 1.100 2008/01/09 20:06:01 bwy Exp $
 
 ## Process this file with automake to produce Makefile.in
 AUTOMAKE_OPTIONS = 1.6.0
@@ -48,6 +48,7 @@
        utilities \
        gui \
        plugin \
+       pythonmodule \
        testsuite \
        po \
        $(NULL)

Index: pythonmodule/Makefile.am
===================================================================
RCS file: pythonmodule/Makefile.am
diff -N pythonmodule/Makefile.am
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ pythonmodule/Makefile.am    9 Jan 2008 20:06:02 -0000       1.1
@@ -0,0 +1,116 @@
+## Process this file with automake to generate Makefile.in
+# 
+#   Copyright (C) 2008 Free Software Foundation, Inc.
+# 
+# This program 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 3 of the License, or
+# (at your option) any later version.
+# 
+# This program 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+if ENABLE_GNASH_PYTHON_MODULE
+
+AUTOMAKE_OPTIONS = 
+
+pkglib_LTLIBRARIES = libgnashpython.la gnash.la
+
+EXTRA_DIST = gnashPythonExample.py
+
+BOOSTPYTHON_LIBS = -lboost_python 
+BOOSTPYTHON_CFLAGS = -I/usr/include/python2.5
+
+libgnashpython_la_SOURCES = \
+       gnashpython.cpp \
+       $(NULL)
+
+libgnashpython_la_LDFLAGS = \
+       $(GLIB_LIBS) \
+       $(LIBLTDL) \
+       $(FFMPEG_LIBS) \
+       $(CURL_LIBS) \
+       $(LIBXML_LIBS) \
+       $(INCLTDL) \
+       $(LIRC_LIBS) \
+       $(MYSQL_LIBS) \
+       $(BOOST_LIBS) \
+       $(PTHREAD_LIBS) \
+       $(BOOSTPYTHON_LIBS) \
+       $(NULL)
+               
+libgnashpython_la_CPPFLAGS = -I.. \
+        -I$(top_srcdir) \
+        -I$(top_srcdir)/server \
+        -I$(top_srcdir)/server/parser \
+        -I$(top_srcdir)/server/vm \
+       -I$(top_srcdir)/libltdl \
+        -I$(top_srcdir)/libbase \
+        -I$(top_srcdir)/backend \
+        -I$(top_srcdir)/libgeometry \
+               -I$(top_srcdir)/libmedia \
+               -I$(top_srcdir)/libmedia/sdl \
+               -I$(top_srcdir)/libmedia/gst \
+       -DLOCALEDIR=\"$(localedir)\" \
+       $(BOOSTPYTHON_CFLAGS) \
+        $(LIBXML_CFLAGS) \
+        $(DMALLOC_CFLAGS) \
+       $(LIRC_CFLAGS) \
+       $(BOOST_CFLAGS) \
+        $(PTHREAD_CFLAGS) \
+       $(NULL)
+
+gnash_la_SOURCES = \
+       pyGnash.cpp
+       $(NULL)
+
+gnash_la_LDFLAGS = \
+       $(GLIB_LIBS) \
+       $(LIBLTDL) \
+       $(BOOSTPYTHON_LIBS) \
+       $(NULL)
+
+gnash_la_LDFLAGS += -module -lgnashpython
+
+gnash_la_CPPFLAGS = -I.. \
+        -I$(top_srcdir) \
+        -I$(top_srcdir)/server \
+        -I$(top_srcdir)/server/parser \
+        -I$(top_srcdir)/server/vm \
+       -I$(top_srcdir)/libltdl \
+        -I$(top_srcdir)/libbase \
+        -I$(top_srcdir)/backend \
+        -I$(top_srcdir)/libgeometry \
+               -I$(top_srcdir)/libmedia \
+               -I$(top_srcdir)/libmedia/sdl \
+               -I$(top_srcdir)/libmedia/gst \
+       -DLOCALEDIR=\"$(localedir)\" \
+       -DBOOST_PYTHON_DYNAMIC_LIB \
+       $(BOOSTPYTHON_CFLAGS) \
+        $(LIBXML_CFLAGS) \
+        $(DMALLOC_CFLAGS) \
+       $(LIRC_CFLAGS) \
+       $(BOOST_CFLAGS) \
+       $(NULL)
+
+libgnashpython_la_LIBADD = $(top_builddir)/server/libgnashserver.la \
+       $(RENDERER_LIBS) \
+       $(GNASH_LIBS)
+
+noinst_HEADERS = \
+       gnashpython.h
+
+# Rebuild with GCC 4.x Mudflap support
+mudflap:
+       @echo "Rebuilding with GCC Mudflap support"
+       $(MAKE) CXXFLAGS="$(CXXFLAGS) -fmudflap" LDFLAGS="$(LDFLAGS) -lmudflap"
+
+clean-hook:
+       -rm -f core.* $(CLEANFILES)
+
+endif

Index: pythonmodule/gnashPythonExample.py
===================================================================
RCS file: pythonmodule/gnashPythonExample.py
diff -N pythonmodule/gnashPythonExample.py
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ pythonmodule/gnashPythonExample.py  9 Jan 2008 20:06:02 -0000       1.1
@@ -0,0 +1,92 @@
+#!/usr/bin/python
+#
+# gnash.py: An example python script demonstrating Gnash python bindings.
+# 
+#   Copyright (C) 2008 Free Software Foundation, Inc.
+# 
+# This program 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 3 of the License, or
+# (at your option) any later version.
+# 
+# This program 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+#
+#
+# The Gnash python bindings are loosely based on functions in 
+# testsuite/MovieTester.h
+#
+# They are designed to allow quick setup of the Gnash player while
+# catering for different purposes. The module can be used to test
+# Gnash from python, but also to extract information (and eventually
+# thumbnails) from SWF files.
+#
+# The greatest limitation at present is the single movie: calling
+# obj = gnash.Player() more than once results in an assertion
+# failure as we try to initGnash() twice.
+
+# The lovely gnash module is named:
+import gnash
+
+# Functions are accessed through the Player() class
+player = gnash.Player()
+
+# The initialization of the player is split into three stages. First,
+# set the base URL:
+player.setBaseURL("/home/benjamin/Download/SWF/SWF6/u2_has.swf")
+
+# Then instruct Gnash to load the movie from the URL:
+if player.createMovieDefinition():
+    print "Movie successfully created."
+else:
+    print "Load failed."
+
+# At this stage, you can query movie properties like so:
+print "The frame rate of this movie is " + str(player.swfFrameRate()) + " FPS."
+print "It has " + str(player.swfFrameCount()) + " frames altogether."
+print "Loaded " +  str(player.swfBytesLoaded()) + " of " + 
str(player.swfBytesTotal()) + "reported bytes."
+print "It is version " + str(player.swfVersion()) +"."
+print "It is " + str(player.swfWidth()) + "x" + str(player.swfWidth()) + " 
pixels."
+print "URL: " + player.swfURL() + "."
+
+
+# The third stage completes initialization.
+if player.initVM():
+    print "VM initialized."
+#else:
+#  print "VM initialization failed."
+
+print "Loaded " +  str(player.swfBytesLoaded()) + " of " + 
str(player.swfBytesTotal()) + " bytes reported."
+
+if player.addRenderer("AGG_RGB565"):
+    print "Renderer added.";
+
+# You are now able to advance the movie.
+print "We start at frame " + str(player.currentFrame()) + "."
+
+for i in range(0,10):
+    player.advance()
+
+print "After 10 advances we are at frame " + str(player.currentFrame()) + " 
(You don't necessarily move to the next frame when you advance)."
+
+# Render like this (don't expect to see anything...)
+player.render()
+
+# You can also make time pass in an instant:
+player.advanceClock(199)
+
+# or press a key
+player.pressKey(65)
+
+
+
+
+
+

Index: pythonmodule/gnashpython.cpp
===================================================================
RCS file: pythonmodule/gnashpython.cpp
diff -N pythonmodule/gnashpython.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ pythonmodule/gnashpython.cpp        9 Jan 2008 20:06:02 -0000       1.1
@@ -0,0 +1,355 @@
+// gnashpython.cpp: python bindings to Gnash
+// 
+//   Copyright (C) 2008 Free Software Foundation, Inc.
+// 
+// This program 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 3 of the License, or
+// (at your option) any later version.
+// 
+// This program 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+
+#include "GnashException.h"
+#include "URL.h"
+#include "noseek_fd_adapter.h"
+#include "movie_definition.h"
+#include "movie_instance.h"
+#include "movie_root.h"
+#include "sprite_instance.h"
+#include "as_environment.h"
+#include "gnash.h" // for create_movie and create_library_movie and for 
gnash::key namespace
+#include "VM.h" // for initialization
+#include "sound_handler.h" // for creating the "test" sound handlers
+#include "render.h" // for get_render_handler
+#include "types.h" // for rgba class
+#include "render.h"
+#include "render_handler.h"
+#include "render_handler_agg.h"
+#include "SystemClock.h"
+#include "impl.h"
+
+#include <cstdio>
+#include <string>
+#include <memory> // for auto_ptr
+#include <boost/shared_ptr.hpp>
+
+#include "gnashpython.h"
+#include "sound_handler.h"
+
+namespace gnash {
+
+namespace pythonwrapper {
+
+
+GnashPlayer::GnashPlayer()
+{
+    init();
+}
+
+GnashPlayer::~GnashPlayer()
+{
+}
+
+void
+GnashPlayer::init() {
+    gnash::gnashInit();
+}
+
+void
+GnashPlayer::setBaseURL(std::string url)
+{
+    if (url == "" || _url != "") return;
+
+    _url = url;
+
+    // Pass the base URL to the core libs. We can only do this
+    // once! Checking if it's been set when it hasn't trigger
+    // an assertion failure...
+    gnash::set_base_url( (gnash::URL)_url );
+}
+
+bool
+GnashPlayer::createMovieDefinition()
+{
+
+    // Fail if base URL not set
+    if (_url == "") return false;
+
+    _fp = fopen(_url.c_str(), "rb");
+    
+    if (!_fp) return false;
+
+    std::auto_ptr<tu_file> in(noseek_fd_adapter::make_stream(fileno(_fp)));
+      
+    _movieDef = gnash::create_movie(in, _url, false);
+    
+    if (!_movieDef) {
+        // Something didn't work
+        fclose(_fp);
+       return false;
+    }
+    
+    return true;
+}
+
+bool
+GnashPlayer::initVM()
+{
+
+    // If movie definition hasn't already been created, try to create it,
+    // fail if that doesn't work either.
+    if (!_movieDef && !createMovieDefinition()) return false;
+
+    // Initialize the VM with a manual clock
+    _movieRoot = &(gnash::VM::init(*_movieDef, _manualClock).getRoot());
+
+    if (!_movieRoot) {
+        // Something didn't work
+        return false;
+    }
+    
+    _movieDef->completeLoad();
+    _movieDef->ensure_frame_loaded(getSWFFrameCount());
+    
+    fclose (_fp);
+
+    auto_ptr<movie_instance> mi (_movieDef->create_movie_instance());
+
+    // Set _movie before calling ::render
+    _movieInstance = mi.get();
+
+    // Finally, place the root movie on the stage ...
+    _movieRoot->setRootMovie( mi.release() ); 
+   
+    return true; 
+}
+
+void
+GnashPlayer::allowRescale(bool allow)
+{
+    if (!_movieRoot || !_movieDef) return;
+    _movieRoot->allowRescaling(allow);
+}
+
+void
+GnashPlayer::advanceClock(unsigned long ms)
+{
+    if (!_movieRoot || !_movieDef) return;
+    _manualClock.advance(ms);
+}
+
+void
+GnashPlayer::advance() {
+
+    if (!_movieRoot || !_movieDef) return;
+
+    float fps = getSWFFrameRate();
+    unsigned long clockAdvance = long(1000/fps);
+    advanceClock(clockAdvance);
+
+    _movieRoot->advance();
+}
+
+void
+GnashPlayer::pressKey(int code)
+{
+    if (!_movieRoot) return;   
+    _movieRoot->notify_key_event((gnash::key::code)code, true);
+}
+
+void
+GnashPlayer::restart()
+{
+    if (!_movieDef || !_movieRoot) return;
+    _movieRoot->getRootMovie()->restart();
+}
+
+
+int
+GnashPlayer::getSWFBytesLoaded() const
+{
+    if (!_movieDef) return 0;
+    return _movieDef->get_bytes_loaded();
+}
+
+int
+GnashPlayer::getSWFFrameCount() const
+{
+    if (!_movieDef) return 0;
+    return _movieDef->get_frame_count();
+}
+
+std::string
+GnashPlayer::getSWFURL() const
+{
+    if (!_movieDef) return "";
+    return _movieDef->get_url();
+}
+
+int
+GnashPlayer::getSWFBytesTotal() const
+{
+    if (!_movieDef) return 0;
+    return _movieDef->get_bytes_total();
+}
+
+int
+GnashPlayer::getSWFVersion() const
+{
+    if (!_movieDef) return 0;
+    return _movieDef->get_version();
+}
+
+float
+GnashPlayer::getSWFWidth() const
+{
+    if (!_movieDef) return 0;
+    return _movieDef->get_width_pixels();
+}
+
+float
+GnashPlayer::getSWFHeight() const
+{
+    if (!_movieDef) return 0;
+    return _movieDef->get_height_pixels();
+}
+
+float
+GnashPlayer::getSWFFrameRate() const
+{
+    if (!_movieDef) return 0;
+    return _movieDef->get_frame_rate();
+}
+
+int
+GnashPlayer::getCurrentFrame() const
+{
+    if (!_movieDef || !_movieRoot) return 0;
+    return _movieRoot->getRootMovie()->get_current_frame();
+}
+
+// Rendering stuff
+
+bool
+GnashPlayer::initRenderer(const std::string& r)
+{
+    if (_handler) return false;
+
+#ifdef RENDERER_AGG
+    if (r.substr(0,4) == "AGG_") {
+        _handler = gnash::create_render_handler_agg(r.substr(4).c_str());
+    }
+#endif
+#ifdef RENDERER_CAIRO
+    else if (r == "Cairo") {
+        _handler = (gnash::renderer::cairo::create_handler(); 
+    }
+#endif 
+#ifdef RENDERER_OPENGL
+    else if (r == "OpenGL") {
+        _handler = gnash::create_render_handler_ogl(false);
+    }
+#endif
+
+    if (_handler) {
+       return addRenderer(_handler); // False if it fails
+    }
+    else {
+        return false;
+    }
+    
+    return true;
+}
+
+void
+GnashPlayer::render()
+{
+
+    if (!_handler) return;
+
+    _invalidatedBounds.setNull();
+
+    _movieRoot->add_invalidated_bounds(_invalidatedBounds, false);
+
+    // Force full redraw by using a WORLD invalidated ranges
+    gnash::InvalidatedRanges ranges = _invalidatedBounds; 
+    if ( _forceRedraw ) {
+        ranges.setWorld(); // set to world if asked a full redraw
+        _forceRedraw = false; // reset to no forced redraw
+    }
+    
+    gnash::set_render_handler(_handler);
+
+    _handler->set_invalidated_regions(ranges);
+    _movieRoot->display();
+       
+}
+
+bool
+GnashPlayer::addRenderer(gnash::render_handler* handler)
+{
+    if (!handler->initTestBuffer(getSWFWidth(), getSWFHeight())) {
+        cout << "Failed to init renderer, but the renderer was okay" << "\n";
+        return false;
+    }
+
+    gnash::set_render_handler(handler);
+       
+    return true;
+}
+
+// Gnash Character
+
+GnashCharacter*
+GnashPlayer::getCharacterById(int id)
+{
+    if (!_movieDef || !_movieRoot) return NULL;
+
+    gnash::character* c = _movieRoot->getRootMovie()->get_character(id);
+    
+    if (!c) return NULL;
+    
+    GnashCharacter* chr(new GnashCharacter(c));
+
+    return chr;
+}
+
+GnashCharacter*
+GnashPlayer::getTopmostMouseEntity()
+{
+    if (!_movieDef || !_movieRoot) return NULL;
+
+    gnash::character* c = _movieRoot->getActiveEntityUnderPointer();
+    
+    if (!c) return NULL;
+    
+    GnashCharacter* chr(new GnashCharacter(c));
+
+    return chr;
+}
+
+GnashCharacter::GnashCharacter(gnash::character* c)
+    :
+    _character(c)
+{
+}
+
+GnashCharacter::GnashCharacter()
+{
+}
+
+GnashCharacter::~GnashCharacter()
+{
+}
+
+} // end pythonwrapper
+} // end gnash

Index: pythonmodule/gnashpython.h
===================================================================
RCS file: pythonmodule/gnashpython.h
diff -N pythonmodule/gnashpython.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ pythonmodule/gnashpython.h  9 Jan 2008 20:06:02 -0000       1.1
@@ -0,0 +1,132 @@
+// gnashpython.h: headers for the python bindings to Gnash
+// 
+//   Copyright (C) 2008 Free Software Foundation, Inc.
+// 
+// This program 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 3 of the License, or
+// (at your option) any later version.
+// 
+// This program 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+#ifndef GNASH_PYTHON_H
+#define GNASH_PYTHON_H
+
+#include <string>
+#include "gnash.h"
+#include "ManualClock.h"
+#include "movie_root.h"
+#include "movie_definition.h"
+
+#include "Range2d.h"
+#include "sound_handler.h" // for creating the "test" sound handlers
+#include "types.h" // for rgba class
+#include "render_handler.h" // for dtor visibility by auto_ptr
+#include "movie_instance.h" 
+#include "character.h"
+
+#include <memory> // for auto_ptr
+#include <string> 
+
+
+// Forward declarations
+namespace gnash {
+namespace pythonwrapper {
+
+    class GnashCharacter;
+    class GnashPlayer;
+
+}
+}
+
+
+namespace gnash {
+
+namespace pythonwrapper {
+
+class GnashPlayer
+{
+
+public:
+
+    GnashPlayer();
+    ~GnashPlayer();
+
+    // Movie creation
+    bool createMovieDefinition();
+    bool initVM();
+    void setBaseURL(std::string url);
+    
+    bool initRenderer(const std::string& r);
+    bool addRenderer(gnash::render_handler* handler);
+
+    // Movie information
+    float getSWFFrameRate() const;
+    int getSWFFrameCount() const;
+    int getSWFVersion() const;
+    float getSWFWidth() const;
+    float getSWFHeight() const;
+    int getSWFBytesTotal() const;
+    int getSWFBytesLoaded() const;
+    std::string getSWFURL() const;
+    
+    int getCurrentFrame() const;
+    
+    // Sprites
+    
+    GnashCharacter* getCharacterById(int id);    
+    GnashCharacter* getTopmostMouseEntity();
+
+    // Interaction
+    void advanceClock(unsigned long ms);
+    void advance();
+    void pressKey(int code);
+    void allowRescale(bool allow);
+    void render();
+    void restart();
+    
+private:
+    void init();
+
+    gnash::movie_definition* _movieDef;
+    gnash::movie_root* _movieRoot;
+    gnash::movie_instance* _movieInstance;
+    gnash::ManualClock _manualClock;
+
+    gnash::render_handler* _handler;
+
+    // The base URL of the movie;
+    std::string _url;
+    bool _forceRedraw;
+    gnash::InvalidatedRanges _invalidatedBounds;
+
+    // File to open (a bit primitive...)    
+    FILE* _fp;
+};
+
+class GnashCharacter
+{
+public:
+    GnashCharacter();
+    GnashCharacter(gnash::character* c);
+    ~GnashCharacter();
+
+    const std::string name() { return _character->get_name(); }
+    const float ratio() { return _character->get_ratio(); }
+    
+private:
+    gnash::character*  _character;
+    
+};
+
+}
+}
+// end namespace pythonwrapper
+#endif

Index: pythonmodule/pyGnash.cpp
===================================================================
RCS file: pythonmodule/pyGnash.cpp
diff -N pythonmodule/pyGnash.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ pythonmodule/pyGnash.cpp    9 Jan 2008 20:06:02 -0000       1.1
@@ -0,0 +1,68 @@
+// pyGnash.cpp: The python module interface to Gnash
+//
+//   Copyright (C) 2008 Free Software Foundation, Inc.
+// 
+// This program 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 3 of the License, or
+// (at your option) any later version.
+// 
+// This program 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+//
+#include <boost/python.hpp>
+#include "gnashpython.h"
+
+using namespace boost::python;
+
+namespace gnash {
+
+BOOST_PYTHON_MODULE(gnash) {
+  class_<pythonwrapper::GnashPlayer>("Player", "Allows direct control of a 
Gnash player.")
+
+    .def("setBaseURL", &pythonwrapper::GnashPlayer::setBaseURL)  
+    .def("createMovieDefinition", 
&pythonwrapper::GnashPlayer::createMovieDefinition)
+    .def("initVM", &pythonwrapper::GnashPlayer::initVM)
+
+    .def("addRenderer", &pythonwrapper::GnashPlayer::initRenderer)
+
+    .def("currentFrame", &pythonwrapper::GnashPlayer::getCurrentFrame)
+
+    .def("advanceClock", &pythonwrapper::GnashPlayer::advanceClock)
+    .def("advance", &pythonwrapper::GnashPlayer::advance)
+    .def("restart", &pythonwrapper::GnashPlayer::restart)
+    .def("pressKey", &pythonwrapper::GnashPlayer::pressKey)
+    .def("allowRescale", &pythonwrapper::GnashPlayer::allowRescale)
+    .def("render", &pythonwrapper::GnashPlayer::render)
+        
+    .def("swfFrameRate", &pythonwrapper::GnashPlayer::getSWFFrameRate)
+    .def("swfFrameCount", &pythonwrapper::GnashPlayer::getSWFFrameCount)
+    .def("swfVersion", &pythonwrapper::GnashPlayer::getSWFVersion)
+    .def("swfWidth", &pythonwrapper::GnashPlayer::getSWFWidth)
+    .def("swfHeight", &pythonwrapper::GnashPlayer::getSWFHeight)
+    .def("swfURL", &pythonwrapper::GnashPlayer::getSWFURL)
+    .def("swfBytesTotal", &pythonwrapper::GnashPlayer::getSWFBytesTotal,
+       "Reported length of the movie in bytes. "
+       "There is no guarantee that this is accurate.")
+    .def("swfBytesLoaded", &pythonwrapper::GnashPlayer::getSWFBytesLoaded,
+       "The number of bytes of the movie that have been loaded")
+
+    .def("getCharacterById", &pythonwrapper::GnashPlayer::getCharacterById,
+               return_value_policy<manage_new_object>())
+    .def("getTopmostMouseEntity", 
&pythonwrapper::GnashPlayer::getTopmostMouseEntity,
+               return_value_policy<manage_new_object>())
+    ;
+
+  class_<pythonwrapper::GnashCharacter>("Character", "A character from the 
movie.")
+    ;
+
+}
+
+} // end namespace gnash




reply via email to

[Prev in Thread] Current Thread [Next in Thread]