gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog pythonmodule/Makefile.am python...


From: Benjamin Wolsey
Subject: [Gnash-commit] gnash ChangeLog pythonmodule/Makefile.am python...
Date: Thu, 10 Jan 2008 00:36:24 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Benjamin Wolsey <bwy>   08/01/10 00:36:24

Modified files:
        .              : ChangeLog 
        pythonmodule   : Makefile.am gnashPythonExample.py 
                         gnashpython.cpp gnashpython.h pyGnash.cpp 
        server         : movie_root.cpp 

Log message:
                * server/movie_root.cpp: use get() method of smart pointer
                  fix a broken build (at least with boost 1.33).
                * pythonmodule/*: General fix up.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5358&r2=1.5359
http://cvs.savannah.gnu.org/viewcvs/gnash/pythonmodule/Makefile.am?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/pythonmodule/gnashPythonExample.py?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/pythonmodule/gnashpython.cpp?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/pythonmodule/gnashpython.h?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/pythonmodule/pyGnash.cpp?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.146&r2=1.147

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5358
retrieving revision 1.5359
diff -u -b -r1.5358 -r1.5359
--- ChangeLog   9 Jan 2008 20:06:01 -0000       1.5358
+++ ChangeLog   10 Jan 2008 00:36:23 -0000      1.5359
@@ -1,3 +1,9 @@
+2008-01-10 Benjamin Wolsey <address@hidden>
+
+       * server/movie_root.cpp: use get() method of smart pointer
+         fix a broken build (at least with boost 1.33).
+       * pythonmodule/*: General fix up.
+
 2008-01-09 Benjamin Wolsey <address@hidden>
 
        * pythonmodule/gnashpython.{h,cpp}: new pythonwrapper::GnashPlayer

Index: pythonmodule/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/pythonmodule/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- pythonmodule/Makefile.am    9 Jan 2008 20:06:02 -0000       1.1
+++ pythonmodule/Makefile.am    10 Jan 2008 00:36:24 -0000      1.2
@@ -37,11 +37,8 @@
        $(CURL_LIBS) \
        $(LIBXML_LIBS) \
        $(INCLTDL) \
-       $(LIRC_LIBS) \
-       $(MYSQL_LIBS) \
        $(BOOST_LIBS) \
        $(PTHREAD_LIBS) \
-       $(BOOSTPYTHON_LIBS) \
        $(NULL)
                
 libgnashpython_la_CPPFLAGS = -I.. \

Index: pythonmodule/gnashPythonExample.py
===================================================================
RCS file: /sources/gnash/gnash/pythonmodule/gnashPythonExample.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- pythonmodule/gnashPythonExample.py  9 Jan 2008 20:06:02 -0000       1.1
+++ pythonmodule/gnashPythonExample.py  10 Jan 2008 00:36:24 -0000      1.2
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 #
-# gnash.py: An example python script demonstrating Gnash python bindings.
+# gnashPythonExample.py: An python script demonstrating Gnash bindings.
 # 
 #   Copyright (C) 2008 Free Software Foundation, Inc.
 # 
@@ -28,25 +28,29 @@
 # Gnash from python, but also to extract information (and eventually
 # thumbnails) from SWF files.
 #
+# Do not rely on this interface remaining stable!
+#
 # 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
+import sys
 
 # 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")
+player.setBaseURL("../../testsuite/movies.all/gravity.swf")
 
 # Then instruct Gnash to load the movie from the URL:
-if player.createMovieDefinition():
+if player.loadMovie():
     print "Movie successfully created."
 else:
-    print "Load failed."
+    print "Load of movie failed."
+    sys.exit()
 
 # At this stage, you can query movie properties like so:
 print "The frame rate of this movie is " + str(player.swfFrameRate()) + " FPS."
@@ -60,19 +64,28 @@
 # The third stage completes initialization.
 if player.initVM():
     print "VM initialized."
-#else:
-#  print "VM initialization failed."
+else:
+    print "VM initialization failed."
+    sys.exit()
+
 
 print "Loaded " +  str(player.swfBytesLoaded()) + " of " + 
str(player.swfBytesTotal()) + " bytes reported."
 
+# This initializes the named renderer. "Cairo", "OpenGL" and various
+# AGG types are possible. Asking for a non-existent renderer results
+# in a runtime exception.
 if player.addRenderer("AGG_RGB565"):
-    print "Renderer added.";
+    print "Renderer added."
 
-# You are now able to advance the movie.
+# Once the movie is loaded, you can advance to the next frame of the movie.
+# This may not be the directly following frame, or even a different one at all.
+# You do not need to add a renderer to advance through the movie.
 print "We start at frame " + str(player.currentFrame()) + "."
 
+# Advance 10 times.
 for i in range(0,10):
     player.advance()
+    print player.currentFrame()
 
 print "After 10 advances we are at frame " + str(player.currentFrame()) + " 
(You don't necessarily move to the next frame when you advance)."
 

Index: pythonmodule/gnashpython.cpp
===================================================================
RCS file: /sources/gnash/gnash/pythonmodule/gnashpython.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- pythonmodule/gnashpython.cpp        9 Jan 2008 20:06:02 -0000       1.1
+++ pythonmodule/gnashpython.cpp        10 Jan 2008 00:36:24 -0000      1.2
@@ -17,7 +17,6 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-
 #include "GnashException.h"
 #include "URL.h"
 #include "noseek_fd_adapter.h"
@@ -25,25 +24,21 @@
 #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 "gnash.h"
+#include "VM.h"
 #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 <memory>
 
 #include "gnashpython.h"
-#include "sound_handler.h"
+
+#define REQUIRE_MOVIE_LOADED if (!_movieDef) throw GnashException("No Movie 
Loaded!")
+#define REQUIRE_VM_STARTED if (!_movieDef || !_movieRoot) throw 
GnashException("VM not started!")
 
 namespace gnash {
 
@@ -51,6 +46,14 @@
 
 
 GnashPlayer::GnashPlayer()
+       :
+    _movieDef(NULL),
+    _movieRoot(NULL),
+    _movieInstance(NULL),
+    _handler(NULL),
+    _url(""),
+    _forceRedraw(false),
+    _fp(NULL)
 {
     init();
 }
@@ -59,14 +62,24 @@
 {
 }
 
+// Initialize the core libs. If this gets called twice:
+// f = gnash.Player()
+// g = gnash.Player()
+// we fail an assertion because the player can only handle
+// one movie at once.
+// TODO: Find way of checking whether gnashInit() has been called
+// Better TODO: Get Gnash to handle more than one movie.
 void
 GnashPlayer::init() {
     gnash::gnashInit();
 }
 
+// Set our _url member and pass this to the core.
 void
 GnashPlayer::setBaseURL(std::string url)
 {
+
+    // Don't allow empty urls
     if (url == "" || _url != "") return;
 
     _url = url;
@@ -77,9 +90,11 @@
     gnash::set_base_url( (gnash::URL)_url );
 }
 
+// TODO: Read in movies from a python file object.
 bool
 GnashPlayer::createMovieDefinition()
 {
+    if (_movieDef) return false;
 
     // Fail if base URL not set
     if (_url == "") return false;
@@ -120,37 +135,42 @@
     _movieDef->completeLoad();
     _movieDef->ensure_frame_loaded(getSWFFrameCount());
     
+    if (_fp) {
     fclose (_fp);
+    }
 
+    // I don't know why it's done like this.
     auto_ptr<movie_instance> mi (_movieDef->create_movie_instance());
 
-    // Set _movie before calling ::render
+    // Setup Movie Instance.
     _movieInstance = mi.get();
 
-    // Finally, place the root movie on the stage ...
+    // Put the instance on stage.
     _movieRoot->setRootMovie( mi.release() ); 
    
     return true; 
 }
 
+// Whether the movie can be resized or not
 void
 GnashPlayer::allowRescale(bool allow)
 {
-    if (!_movieRoot || !_movieDef) return;
+    REQUIRE_VM_STARTED;
     _movieRoot->allowRescaling(allow);
 }
 
+// Move Gnash's sense of time along manually
 void
 GnashPlayer::advanceClock(unsigned long ms)
 {
-    if (!_movieRoot || !_movieDef) return;
+    REQUIRE_VM_STARTED;
     _manualClock.advance(ms);
 }
 
 void
 GnashPlayer::advance() {
 
-    if (!_movieRoot || !_movieDef) return;
+    REQUIRE_VM_STARTED;
 
     float fps = getSWFFrameRate();
     unsigned long clockAdvance = long(1000/fps);
@@ -159,86 +179,101 @@
     _movieRoot->advance();
 }
 
+// Send a key event to the movie. This is matched to
+// gnash::key::code. You could even use this to 
+// implement a UI in python.
 void
 GnashPlayer::pressKey(int code)
 {
-    if (!_movieRoot) return;   
+    REQUIRE_VM_STARTED;        
     _movieRoot->notify_key_event((gnash::key::code)code, true);
 }
 
+// Start the movie from the beginning.
 void
 GnashPlayer::restart()
 {
-    if (!_movieDef || !_movieRoot) return;
+    REQUIRE_VM_STARTED;
     _movieRoot->getRootMovie()->restart();
 }
 
-
+// The number of bytes already loaded.
 int
 GnashPlayer::getSWFBytesLoaded() const
 {
-    if (!_movieDef) return 0;
+    REQUIRE_MOVIE_LOADED;
     return _movieDef->get_bytes_loaded();
 }
 
+// The number of frames reported in the movie headers.
 int
 GnashPlayer::getSWFFrameCount() const
 {
-    if (!_movieDef) return 0;
+    REQUIRE_MOVIE_LOADED;
     return _movieDef->get_frame_count();
 }
 
+// The URL of the stream.
 std::string
 GnashPlayer::getSWFURL() const
 {
-    if (!_movieDef) return "";
+    REQUIRE_MOVIE_LOADED;
     return _movieDef->get_url();
 }
 
+// The length in bytes reported in the movie headers.
 int
 GnashPlayer::getSWFBytesTotal() const
 {
-    if (!_movieDef) return 0;
+    REQUIRE_MOVIE_LOADED;
     return _movieDef->get_bytes_total();
 }
 
+// The version of the root movie.
 int
 GnashPlayer::getSWFVersion() const
 {
-    if (!_movieDef) return 0;
+    REQUIRE_MOVIE_LOADED;
     return _movieDef->get_version();
 }
 
+// The width of the movie.
 float
 GnashPlayer::getSWFWidth() const
 {
-    if (!_movieDef) return 0;
+    REQUIRE_MOVIE_LOADED;
     return _movieDef->get_width_pixels();
 }
 
+// The height of the movie.
 float
 GnashPlayer::getSWFHeight() const
 {
-    if (!_movieDef) return 0;
+    REQUIRE_MOVIE_LOADED;
     return _movieDef->get_height_pixels();
 }
 
+// The movie's frame rate.
 float
 GnashPlayer::getSWFFrameRate() const
 {
-    if (!_movieDef) return 0;
+    REQUIRE_MOVIE_LOADED;
     return _movieDef->get_frame_rate();
 }
 
+// The current position in the movie.
 int
 GnashPlayer::getCurrentFrame() const
 {
-    if (!_movieDef || !_movieRoot) return 0;
+    REQUIRE_VM_STARTED;
     return _movieRoot->getRootMovie()->get_current_frame();
 }
 
-// Rendering stuff
+//
+//    Renderer functions
+//
 
+// Initialize the named rendererm throwing exception  
 bool
 GnashPlayer::initRenderer(const std::string& r)
 {
@@ -260,16 +295,35 @@
     }
 #endif
 
-    if (_handler) {
-       return addRenderer(_handler); // False if it fails
+    if (!_handler) {
+        // If the handler doesn't exist or can't be opened, throw
+        // exception
+        throw GnashException("Cannot create that renderer");
     }
     else {
+        // Try adding handler, return result
+        return addRenderer(_handler);
+    }
+   
+    // Shouldn't get to here...
+    return false;
+}
+
+// Test and set the render handler, returning false if anything
+// goes wrong.
+bool
+GnashPlayer::addRenderer(gnash::render_handler* handler)
+{
+    if (!handler->initTestBuffer(getSWFWidth(), getSWFHeight())) {
         return false;
     }
     
+    gnash::set_render_handler(handler);
+       
     return true;
 }
 
+// Render the frame
 void
 GnashPlayer::render()
 {
@@ -294,25 +348,14 @@
        
 }
 
-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
+//
+// Wrapper class for characters (doesn't work)
+//
 
 GnashCharacter*
 GnashPlayer::getCharacterById(int id)
 {
-    if (!_movieDef || !_movieRoot) return NULL;
+    REQUIRE_VM_STARTED;
 
     gnash::character* c = _movieRoot->getRootMovie()->get_character(id);
     
@@ -326,7 +369,7 @@
 GnashCharacter*
 GnashPlayer::getTopmostMouseEntity()
 {
-    if (!_movieDef || !_movieRoot) return NULL;
+    REQUIRE_VM_STARTED;
 
     gnash::character* c = _movieRoot->getActiveEntityUnderPointer();
     
@@ -344,6 +387,8 @@
 }
 
 GnashCharacter::GnashCharacter()
+    :
+    _character(NULL)
 {
 }
 

Index: pythonmodule/gnashpython.h
===================================================================
RCS file: /sources/gnash/gnash/pythonmodule/gnashpython.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- pythonmodule/gnashpython.h  9 Jan 2008 20:06:02 -0000       1.1
+++ pythonmodule/gnashpython.h  10 Jan 2008 00:36:24 -0000      1.2
@@ -16,25 +16,22 @@
 // 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
+#ifndef GNASHPYTHON_H
+#define GNASHPYTHON_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 "render_handler.h"
 #include "movie_instance.h" 
 #include "character.h"
 
-#include <memory> // for auto_ptr
 #include <string> 
 
+// Boost 1.33 seems to dislike auto_ptrs in the class
+// declaration. Perhaps I'm not handling them correctly, perhaps
+// it's better in 1.34.
 
 // Forward declarations
 namespace gnash {
@@ -46,7 +43,6 @@
 }
 }
 
-
 namespace gnash {
 
 namespace pythonwrapper {

Index: pythonmodule/pyGnash.cpp
===================================================================
RCS file: /sources/gnash/gnash/pythonmodule/pyGnash.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- pythonmodule/pyGnash.cpp    9 Jan 2008 20:06:02 -0000       1.1
+++ pythonmodule/pyGnash.cpp    10 Jan 2008 00:36:24 -0000      1.2
@@ -20,6 +20,9 @@
 #include <boost/python.hpp>
 #include "gnashpython.h"
 
+// Warning! These Python bindings are not mature. They are unlikely to 
+// stay as they are. Do not rely on this interface!
+
 using namespace boost::python;
 
 namespace gnash {
@@ -28,7 +31,7 @@
   class_<pythonwrapper::GnashPlayer>("Player", "Allows direct control of a 
Gnash player.")
 
     .def("setBaseURL", &pythonwrapper::GnashPlayer::setBaseURL)  
-    .def("createMovieDefinition", 
&pythonwrapper::GnashPlayer::createMovieDefinition)
+    .def("loadMovie", &pythonwrapper::GnashPlayer::createMovieDefinition)
     .def("initVM", &pythonwrapper::GnashPlayer::initVM)
 
     .def("addRenderer", &pythonwrapper::GnashPlayer::initRenderer)
@@ -49,8 +52,8 @@
     .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.")
+       "Length of the loaded movie in bytes as reported in the headers."
+       )
     .def("swfBytesLoaded", &pythonwrapper::GnashPlayer::getSWFBytesLoaded,
        "The number of bytes of the movie that have been loaded")
 
@@ -60,7 +63,8 @@
                return_value_policy<manage_new_object>())
     ;
 
-  class_<pythonwrapper::GnashCharacter>("Character", "A character from the 
movie.")
+  class_<pythonwrapper::GnashCharacter>("Character", "A character from the 
movie."
+                                                       "This class doesn't 
work")
     ;
 
 }

Index: server/movie_root.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.cpp,v
retrieving revision 1.146
retrieving revision 1.147
diff -u -b -r1.146 -r1.147
--- server/movie_root.cpp       9 Jan 2008 17:52:17 -0000       1.146
+++ server/movie_root.cpp       10 Jan 2008 00:36:24 -0000      1.147
@@ -190,7 +190,7 @@
                // don't leak overloaded levels
 
                LevelMovie lm = it->second;
-               if ( lm == _rootMovie.get() )
+               if ( lm.get() == _rootMovie.get() )
                {
                        // NOTE: this is not enough to trigger
                        //       an application reset. Was tested




reply via email to

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