gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, master, updated. f409f53702411781fe1a


From: Andrea Palmatè
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. f409f53702411781fe1ad9dbdd6d0e61163a653d
Date: Sat, 16 Oct 2010 13:14:05 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  f409f53702411781fe1ad9dbdd6d0e61163a653d (commit)
      from  360d6ba0ad265bdaee5ec11b10273628b9d6fd2c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=f409f53702411781fe1ad9dbdd6d0e61163a653d


commit f409f53702411781fe1ad9dbdd6d0e61163a653d
Author: Andrea Palmatè <address@hidden>
Date:   Sat Oct 16 15:13:17 2010 +0200

    Add plugin support for AmigaOS4. Note that currently the plugin is broken 
on OS4

diff --git a/plugin/aos4/.DS_Store b/plugin/aos4/.DS_Store
new file mode 100644
index 0000000..5008ddf
Binary files /dev/null and b/plugin/aos4/.DS_Store differ
diff --git a/plugin/aos4/Makefile.am b/plugin/aos4/Makefile.am
new file mode 100644
index 0000000..bdae047
--- /dev/null
+++ b/plugin/aos4/Makefile.am
@@ -0,0 +1,87 @@
+## Process this file with automake to generate Makefile.in
+# 
+#   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 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
+
+AUTOMAKE_OPTIONS = 
+
+if NPAPI
+if AMIGAOS4
+
+AM_CPPFLAGS = \
+       -I$(top_srcdir)/libbase \
+       -I$(top_srcdir)/libmedia \
+       -I$(top_srcdir)/libsound \
+       -I$(top_srcdir)/libmedia/ffmpeg \
+       -I$(top_srcdir)/librender \
+       -I$(top_srcdir)/libcore \
+       -I$(top_srcdir)/libcore/parser \
+       -I$(top_srcdir)/libcore/vm \
+       -I$(top_srcdir)/libcore/swf \
+       -I$(top_srcdir)/gui \
+       -I$(top_srcdir)/plugin/npapi/mozilla-sdk \
+       -I$(top_srcdir)/plugin/npapi/mozilla-sdk/include \
+       -I$(top_srcdir)/plugin/npapi \
+       $(AGG_CFLAGS) \
+       $(BOOST_CFLAGS) \
+       $(FFMPEG_CFLAGS) \
+       $(SDL_CFLAGS) \
+       $(NULL)
+
+AM_LDFLAGS = \
+       $(top_builddir)/libbase/libgnashbase.la \
+       $(top_builddir)/libmedia/libgnashmedia.la \
+       $(top_builddir)/libsound/libgnashsound.la \
+       $(top_builddir)/librender/libgnashrender.la \
+       $(top_builddir)/libcore/libgnashcore.la \
+       $(top_builddir)/plugin/mozilla-sdk/np_entry.lo \
+       $(top_builddir)/plugin/mozilla-sdk/npn_gate.lo \
+       $(top_builddir)/plugin/mozilla-sdk/npp_gate.lo \
+       $(AGG_LIBS) \
+       $(BOOST_LIBS) \
+       $(CURL_LIBS) \
+       $(EXPAT_LIBS) \
+       $(FFMPEG_LIBS) \
+       $(JPEG_LIBS) \
+       $(PNG_LIBS) \
+       $(SDL_LIBS) \
+       $(NSPR_LIBS) \
+       $(NULL)
+
+plugindir = $(bindir)
+
+plugin_LTLIBRARIES = libnpgnash.la
+
+libnpgnash_la_SOURCES = plugin.cpp
+libnpgnash_la_LDFLAGS = -shared -no-undefined -version-info 0:0:0 \
+       -o libnpgnash.so 
+
+install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
+       @echo "Nothing to install here now."
+       @echo "Use \"make install-plugin\" to install the npgnash plugin to 
$(bindir)."
+
+install-plugin install-plugins: $(plugin_LTLIBRARIES)
+       test -d $(bindir) || $(mkinstalldirs) $(bindir)
+       $(INSTALL_PROGRAM) libnpgnash.so $(bindir)
+
+uninstall-plugin uninstall-plugins: 
+       $(RM) -f $(bindir)/libnpgnash.so
+
+endif # AMIGAOS4
+endif # NPAPI
+
+force:
+
+.PHONY : install-plugins install-plugin uninstall-plugin uninstall-plugins
diff --git a/plugin/aos4/plugin.cpp b/plugin/aos4/plugin.cpp
new file mode 100644
index 0000000..89cb460
--- /dev/null
+++ b/plugin/aos4/plugin.cpp
@@ -0,0 +1,645 @@
+// plugin.cpp:  Windows "win32" flash player Mozilla plugin, for Gnash.
+// 
+//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 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
+//
+
+#ifdef HAVE_CONFIG_H
+#include "gnashconfig.h"
+#endif
+
+#include <proto/intuition.h>
+#include <proto/Picasso96API.h>
+#include <proto/exec.h>
+#include <cstdlib>
+
+#define FLASH_MAJOR_VERSION "9"
+#define FLASH_MINOR_VERSION "0"
+#define FLASH_REV_NUMBER "82"
+
+#define MIME_TYPES_HANDLED "application/x-shockwave-flash"
+// The name must be this value to get flash movies that check the
+// plugin version to load.
+#define PLUGIN_NAME "Shockwave Flash"
+#define MIME_TYPES_DESCRIPTION MIME_TYPES_HANDLED":swf:"PLUGIN_NAME
+
+// Some javascript plugin detectors use the description
+// to decide the flash version to display. They expect the
+// form (major version).(minor version) r(revision).
+// e.g. "8.0 r99."
+#ifndef FLASH_MAJOR_VERSION
+#define FLASH_MAJOR_VERSION DEFAULT_FLASH_MAJOR_VERSION
+#endif
+#ifndef FLASH_MINOR_VERSION
+#define FLASH_MINOR_VERSION DEFAULT_FLASH_MINOR_VERSION
+#endif
+#ifndef FLASH_REV_NUMBER
+#define FLASH_REV_NUMBER DEFAULT_FLASH_REV_NUMBER
+#endif
+#define FLASH_VERSION FLASH_MAJOR_VERSION"."\
+    FLASH_MINOR_VERSION" r"FLASH_REV_NUMBER"."
+
+#define PLUGIN_DESCRIPTION \
+  "Shockwave Flash "FLASH_VERSION" Gnash "VERSION", the GNU SWF Player. \
+  Copyright &copy; 2006, 2007, 2008 \
+  <a href=\"http://www.fsf.org\";>Free Software Foundation</a>, Inc.<br> \
+  Gnash comes with NO WARRANTY, to the extent permitted by law. \
+  You may redistribute copies of Gnash under the terms of the \
+  <a href=\"http://www.gnu.org/licenses/gpl.html\";>GNU General Public \
+  License</a>. For more information about Gnash, see <a \
+  href=\"http://www.gnu.org/software/gnash/\";> \
+  http://www.gnu.org/software/gnash</a>. \
+  Compatible Shockwave Flash "FLASH_VERSION
+
+#include <cstdarg>
+#include <boost/cstdint.hpp>
+#include <fstream>
+
+#include "plugin.h"
+
+static int module_initialized = FALSE;
+static PRLock* playerLock = NULL;
+static int instances = 0;
+
+char* NPP_GetMIMEDescription(void);
+static void playerThread(void *arg);
+//static LRESULT CALLBACK PluginWinProc(HWND, UINT, WPARAM, LPARAM);
+
+#define DBG(x, ...) __DBG(x, ## __VA_ARGS__)
+inline void
+__DBG(const char *fmt, ...)
+{
+    char buf[1024];
+    va_list ap;
+    
+    va_start(ap, fmt);
+    vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
+    va_end(ap);
+    printf(buf);
+}
+
+// general initialization and shutdown
+
+NPError
+NS_PluginInitialize(void)
+{
+    DBG("NS_PluginInitialize\n");
+    if (!playerLock) {
+        playerLock = PR_NewLock();
+    }
+    module_initialized = TRUE;
+    return NPERR_NO_ERROR;
+}
+ 
+void
+NS_PluginShutdown(void)
+{
+    DBG("NS_PluginShutdown\n");
+    if (!module_initialized) return;
+    if (playerLock) {
+               PR_DestroyLock(playerLock);
+               playerLock = NULL;
+    }
+}
+
+/// \brief Return the MIME Type description for this plugin.
+char*
+NPP_GetMIMEDescription(void)
+{
+    if (!module_initialized) return NULL;
+    return MIME_TYPES_HANDLED;
+}
+
+#if 0
+/// \brief Retrieve values from the plugin for the Browser
+///
+/// This C++ function is called by the browser to get certain
+/// information is needs from the plugin. This information is the
+/// plugin name, a description, etc...
+///
+/// This is actually not used on Win32 (XP_WIN), only on Unix (XP_UNIX).
+NPError
+NS_PluginGetValue(NPPVariable aVariable, void *aValue)
+{
+    NPError err = NPERR_NO_ERROR;
+
+    if (!module_initialized) return NPERR_NO_ERROR;
+    DBG("aVariable = %d\n", aVariable);
+    switch (aVariable) {
+        case NPPVpluginNameString:
+            *static_cast<char **> (aValue) = PLUGIN_NAME;
+            break;
+
+        // This becomes the description field you see below the opening
+        // text when you type about:plugins and in
+        // navigator.plugins["Shockwave Flash"].description, used in
+        // many flash version detection scripts.
+        case NPPVpluginDescriptionString:
+            *static_cast<const char **>(aValue) = PLUGIN_DESCRIPTION;
+            break;
+
+        case NPPVpluginNeedsXEmbed:
+#ifdef HAVE_GTK2
+            *static_cast<PRBool *>(aValue) = PR_TRUE;
+#else
+            *static_cast<PRBool *>(aValue) = PR_FALSE;
+#endif
+            break;
+
+        case NPPVpluginTimerInterval:
+
+        case NPPVpluginKeepLibraryInMemory:
+
+        default:
+            err = NPERR_INVALID_PARAM;
+            break;
+    }
+    return err;
+}
+#endif
+
+// construction and destruction of our plugin instance object
+
+nsPluginInstanceBase*
+NS_NewPluginInstance(nsPluginCreateData* aCreateDataStruct)
+{
+    DBG("NS_NewPluginInstance\n");
+    if (!module_initialized) return NULL;
+    if (instances > 0) {
+        return NULL;
+    }
+    instances++; // N.B. This is a threading race condition. FIXME.
+    if (!playerLock) {
+        playerLock = PR_NewLock();
+    }
+    if (!aCreateDataStruct) {
+        return NULL;
+    }
+    return new nsPluginInstance(aCreateDataStruct);
+}
+ 
+void
+NS_DestroyPluginInstance(nsPluginInstanceBase* aPlugin)
+{
+    DBG("NS_DestroyPluginInstance\n");
+    if (!module_initialized) return;
+    if (aPlugin) {
+        delete (nsPluginInstance *) aPlugin;
+    }
+    if (playerLock) {
+               PR_DestroyLock(playerLock);
+               playerLock = NULL;
+    }
+    instances--;
+}
+ 
+// nsPluginInstance class implementation
+
+/// \brief Constructor
+nsPluginInstance::nsPluginInstance(nsPluginCreateData* data) :
+    nsPluginInstanceBase(),
+    _instance(data->instance),
+    _window(NULL),
+    _initialized(FALSE),
+    _shutdown(FALSE),
+    _stream(NULL),
+    _url(""),
+    _thread(NULL),
+    _width(0),
+    _height(0),
+    _rowstride(0),
+    _hMemDC(NULL),
+    _bmp(NULL),
+    _memaddr(NULL),
+    mouse_x(0),
+    mouse_y(0),
+    mouse_buttons(0),
+    _oldWndProc(NULL)
+{
+    DBG("nsPluginInstance::nsPluginInstance\n");
+}
+ 
+/// \brief Destructor
+nsPluginInstance::~nsPluginInstance()
+{
+    DBG("nsPluginInstance::~nsPluginInstance\n");
+    if (_memaddr) {
+        // Deleting _bmp should free this memory.
+        _memaddr = NULL;
+    }
+    if (_hMemDC) {
+        //DeleteObject(_hMemDC);
+        IExec->FreeVec(_hMemDC);
+        _hMemDC = NULL;
+    }
+    if (_bmp) {
+        //DeleteObject(_bmp);
+        IP96->p96FreeBitMap(_bmp);
+        _bmp = NULL;
+    }
+}
+ 
+NPBool
+nsPluginInstance::init(NPWindow* aWindow)
+{
+    DBG("nsPluginInstance::init\n");
+
+    if (!aWindow) {
+        DBG("aWindow == NULL\n");
+        return FALSE;
+    }
+
+    _x = aWindow->x;
+    _y = aWindow->y;
+    _width = aWindow->width;
+    _height = aWindow->height; 
+    _window = (struct Window *) aWindow->window;
+    // Windows DIB row stride is always a multiple of 4 bytes.
+    _rowstride = /* 24 bits */ 3 * _width;
+    _rowstride += _rowstride % 4;
+
+       /*
+    memset(&_bmpInfo, 0, sizeof(BITMAPINFOHEADER));
+    _bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+    _bmpInfo.bmiHeader.biWidth = _width; 
+    // Negative height means first row comes first in memory.
+    _bmpInfo.bmiHeader.biHeight = -1 * _height; 
+    _bmpInfo.bmiHeader.biPlanes = 1; 
+    _bmpInfo.bmiHeader.biBitCount = 24; 
+    _bmpInfo.bmiHeader.biCompression = BI_RGB; 
+    _bmpInfo.bmiHeader.biSizeImage = 0; 
+    _bmpInfo.bmiHeader.biXPelsPerMeter = 0; 
+    _bmpInfo.bmiHeader.biYPelsPerMeter = 0; 
+    _bmpInfo.bmiHeader.biClrUsed = 0; 
+    _bmpInfo.bmiHeader.biClrImportant = 0; 
+
+    HDC hDC = GetDC(_window);
+    _hMemDC = CreateCompatibleDC(hDC);
+    _bmp = CreateDIBSection(_hMemDC, &_bmpInfo,
+            DIB_RGB_COLORS, (void **) &_memaddr, 0, 0);
+    SelectObject(_hMemDC, _bmp);
+    */
+
+       _bmp = IP96->p96AllocBitMap(_width, _height, 24, BMF_MINPLANES | 
BMF_DISPLAYABLE,((struct Window *)aWindow)->RPort->BitMap, (RGBFTYPE)0);
+    DBG("aWindow->type: %s (%u)\n", 
+            (aWindow->type == NPWindowTypeWindow) ? "NPWindowTypeWindow" :
+            (aWindow->type == NPWindowTypeDrawable) ? "NPWindowTypeDrawable" :
+            "unknown",
+            aWindow->type);
+
+    // subclass window so we can intercept window messages and
+    // do our drawing to it
+    //_oldWndProc = SubclassWindow(_window, (WNDPROC) PluginWinProc);
+ 
+    // associate window with our nsPluginInstance object so we can access 
+    // it in the window procedure
+    //SetWindowLong(_window, GWL_USERDATA, (LONG) this);
+
+    _initialized = TRUE;
+    return TRUE;
+}
+
+void
+nsPluginInstance::shut(void)
+{
+    DBG("nsPluginInstance::shut\n");
+
+    DBG("Acquiring playerLock mutex for shutdown.\n");
+    PR_Lock(playerLock);
+    _shutdown = TRUE;
+    DBG("Releasing playerLock mutex for shutdown.\n");
+    PR_Unlock(playerLock);
+
+    if (_thread) {
+        DBG("Waiting for thread to terminate.\n");
+        PR_JoinThread(_thread);
+        _thread = NULL; 
+    }
+
+    // subclass it back
+    //SubclassWindow(_window, _oldWndProc);
+
+    _initialized = FALSE;
+}
+
+NPError
+nsPluginInstance::NewStream(NPMIMEType type, NPStream *stream,
+        NPBool seekable, boost::uint16_t *stype)
+{
+    DBG("nsPluginInstance::NewStream\n");
+    DBG("stream->url: %s\n", stream->url);
+
+    if (!_stream) {
+        _stream = stream;
+        _url = stream->url;
+#if 0
+        if (seekable) {
+            *stype = NP_SEEK;
+        }
+#endif
+    }
+
+    return NPERR_NO_ERROR;
+}
+
+NPError
+nsPluginInstance::DestroyStream(NPStream *stream, NPError reason)
+{
+    DBG("nsPluginInstance::DestroyStream\n");
+    DBG("stream->url: %s\n", stream->url);
+
+    // N.B. We can only support one Gnash VM/thread right now. 
+    if (!_thread) {
+        _thread = PR_CreateThread(PR_USER_THREAD, playerThread, this,
+                PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);
+    }
+
+    return NPERR_NO_ERROR;
+}
+
+int32
+nsPluginInstance::Write(NPStream *stream, int32 offset, int32 len,
+        void *buffer)
+{
+    DBG("nsPluginInstance::Write\n");
+    DBG("stream->url: %s, offset: %ld, len: %ld\n",
+            stream->url, offset, len);
+}
+
+static void
+playerThread(void *arg)
+{
+    nsPluginInstance *plugin = (nsPluginInstance *) arg;
+
+    plugin->threadMain();
+}
+
+void
+nsPluginInstance::threadMain(void)
+{
+    DBG("nsPluginInstance::threadMain started\n");
+    DBG("URL: %s\n", _url.c_str());
+
+       PR_Lock(playerLock);
+
+    // Initialize Gnash core library.
+    DBG("Gnash core initialized.\n");
+ 
+    // Init logfile.
+    gnash::RcInitFile& rcinit = gnash::RcInitFile::getDefaultInstance();
+    std::string logfilename = std::string("T:npgnash.log");
+    rcinit.setDebugLog(logfilename);
+    gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
+    dbglogfile.setWriteDisk(true);
+    dbglogfile.setVerbosity(GNASH_DEBUG_LEVEL);
+    DBG("Gnash logging initialized: %s\n", logfilename.c_str());
+
+    // Init sound.
+    //_sound_handler.reset(gnash::sound::create_sound_handler_sdl());
+    //gnash::set_sound_handler(_sound_handler.get());
+    DBG("Gnash sound initialized.\n");
+
+    // Init GUI.
+    int old_mouse_x = 0, old_mouse_y = 0, old_mouse_buttons = 0;
+    _render_handler =
+        (gnash::render_handler *) gnash::create_render_handler_agg("BGR24");
+    // _memaddr = (unsigned char *) malloc(getMemSize());
+    static_cast<gnash::render_handler_agg_base 
*>(_render_handler)->init_buffer(
+            getMemAddr(), getMemSize(), _width, _height, _rowstride);
+    gnash::set_render_handler(_render_handler);
+    DBG("Gnash GUI initialized: %ux%u\n", _width, _height);
+
+    gnash::URL url(_url);
+
+    VariableMap vars;
+    gnash::URL::parse_querystring(url.querystring(), vars);
+    for (VariableMap::iterator i = vars.begin(), ie = vars.end(); i != ie; 
i++) {
+        _flashVars[i->first] = i->second;
+    }
+
+    gnash::set_base_url(url);
+
+    gnash::movie_definition* md = NULL;
+    try {
+        md = gnash::createMovie(url, _url.c_str(), false);
+    } catch (const gnash::GnashException& err) {
+        md = NULL;
+    }
+    if (!md) {
+        /*
+         * N.B. Can't use the goto here, as C++ complains about "jump to
+         * label 'done' from here crosses initialization of ..." a bunch
+         * of things.  Sigh.  So, instead, I duplicate the cleanup code
+         * here.  TODO: Remove this duplication.
+         */
+        // goto done;
+
+        PR_Unlock(playerLock);
+
+        DBG("Clean up Gnash.\n");
+        //gnash::clear();
+
+        DBG("nsPluginInstance::threadMain exiting\n");
+        return;
+    }
+    DBG("Movie created: %s\n", _url.c_str());
+
+    int movie_width = static_cast<int>(md->get_width_pixels());
+    int movie_height = static_cast<int>(md->get_height_pixels());
+    float movie_fps = md->get_frame_rate();
+    DBG("Movie dimensions: %ux%u (%.2f fps)\n",
+            movie_width, movie_height, movie_fps);
+
+    gnash::SystemClock clock; // use system clock here...
+    gnash::movie_root& root = gnash::VM::init(*md, clock).getRoot();
+    DBG("Gnash VM initialized.\n");
+    
+    // Register this plugin as listener for FsCommands from the core
+    // (movie_root)
+#if 0
+    /* Commenting out for now as registerFSCommandCallback() has changed. */
+    root.registerFSCommandCallback(FSCommand_callback);
+#endif
+    
+    // Register a static function to handle ActionScript events such
+    // as Mouse.hide, Stage.align etc.
+    // root.registerEventCallback(&staticEventHandlingFunction);
+
+    md->completeLoad();
+    DBG("Movie loaded.\n");
+
+    std::auto_ptr<gnash::Movie> mr(md->createMovie());
+    mr->setVariables(_flashVars);
+    root.setRootMovie(mr.release());
+    //root.set_display_viewport(0, 0, _width, _height);
+    root.set_background_alpha(1.0f);
+    gnash::Movie* mi = root.getRootMovie();
+    DBG("Movie instance created.\n");
+
+    //ShowWindow(_window, SW_SHOW);
+       IIntuition->ShowWindow(_window,NULL);
+       
+    for (;;) {
+        // DBG("Inside main thread loop.\n");
+
+        if (_shutdown) {
+            DBG("Main thread shutting down.\n");
+            break;
+        }
+
+        size_t cur_frame = mi->get_current_frame();
+        // DBG("Got current frame number: %d.\n", cur_frame);
+        size_t tot_frames = mi->get_frame_count();
+        // DBG("Got total frame count: %d.\n", tot_frames);
+
+        // DBG("Advancing one frame.\n");
+        root.advance();
+        // DBG("Going to next frame.\n");
+        root.goto_frame(cur_frame + 1);
+        // DBG("Ensuring frame is loaded.\n");
+        //root.get_movie_definition()->ensure_frame_loaded(tot_frames);
+        // DBG("Setting play state to PLAY.\n");
+        root.set_play_state(gnash::MovieClip::PLAYSTATE_PLAY);
+
+        if (old_mouse_x != mouse_x || old_mouse_y != mouse_y) {
+            old_mouse_x = mouse_x;
+            old_mouse_y = mouse_y;
+            //root.notify_mouse_moved(mouse_x, mouse_y);
+        }
+        if (old_mouse_buttons != mouse_buttons) {
+            old_mouse_buttons = mouse_buttons;
+            int mask = 1;
+            //root.notify_mouse_clicked(mouse_buttons > 0, mask);
+        }
+
+        root.display();
+
+#if 0
+        RECT rt;
+        GetClientRect(_window, &rt);
+        InvalidateRect(_window, &rt, FALSE);
+
+        InvalidatedRanges ranges;
+        ranges.setSnapFactor(1.3f);
+        ranges.setSingleMode(false);
+        root.add_invalidated_bounds(ranges, false);
+        ranges.growBy(40.0f);
+        ranges.combine_ranges();
+
+        if (!ranges.isNull()) {
+            InvalidateRect(_window, &rt, FALSE);
+        }
+
+        root.display();
+#endif
+
+        // DBG("Unlocking playerLock mutex.\n");
+        PR_Unlock(playerLock);
+        // DBG("Sleeping.\n");
+        PR_Sleep(PR_INTERVAL_MIN);
+        // DBG("Acquiring playerLock mutex.\n");
+        PR_Lock(playerLock);
+    }
+
+done:
+       PR_Unlock(playerLock);
+
+    DBG("Clean up Gnash.\n");
+
+    /*
+     * N.B.  As per server/impl.cpp:clear(), all of Gnash's threads aren't
+     * guaranteed to be terminated by this, yet.  Therefore, when Firefox
+     * unloads npgnash.dll after calling NS_PluginShutdown(), and there are
+     * still Gnash threads running, they will try and access memory that was
+     * freed as part of the unloading of npgnash.dll, resulting in a process
+     * abend.
+     */
+
+    //gnash::clear();
+
+    DBG("nsPluginInstance::threadMain exiting\n");
+}
+
+const char*
+nsPluginInstance::getVersion()
+{
+    return NPN_UserAgent(_instance);
+}
+
+void
+nsPluginInstance::FSCommand_callback(gnash::MovieClip* movie, const 
std::string& command, const std::string& args)
+// For handling notification callbacks from ActionScript.
+{
+    gnash::log_debug(_("FSCommand_callback(%p): %s %s"), (void*) movie, 
command, args);
+}
+
+/*
+static LRESULT CALLBACK
+PluginWinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+    // get our plugin instance object
+    nsPluginInstance *plugin =
+        (nsPluginInstance *) GetWindowLong(hWnd, GWL_USERDATA);
+
+    if (plugin) {
+        switch (msg) {
+            case WM_PAINT:
+            {
+                if (plugin->getMemAddr() == NULL) {
+                    break;
+                }
+
+                PAINTSTRUCT ps;
+                HDC hDC = BeginPaint(hWnd, &ps);
+
+                RECT rt;
+                GetClientRect(hWnd, &rt);
+                int w = rt.right - rt.left;
+                int h = rt.bottom - rt.top;
+
+                BitBlt(hDC, rt.left, rt.top, w, h,
+                        plugin->getMemDC(), 0, 0, SRCCOPY);
+
+                EndPaint(hWnd, &ps);
+                return 0L;
+            }
+            case WM_MOUSEMOVE:
+            {
+                int x = GET_X_LPARAM(lParam); 
+                int y = GET_Y_LPARAM(lParam); 
+
+                plugin->notify_mouse_state(x, y, -1);
+                break;
+            }
+            case WM_LBUTTONDOWN:
+            case WM_LBUTTONUP:
+            {
+                int x = GET_X_LPARAM(lParam); 
+                int y = GET_Y_LPARAM(lParam); 
+                int buttons = (msg == WM_LBUTTONDOWN) ? 1 : 0;
+
+                plugin->notify_mouse_state(x, y, buttons);
+                break;
+            }
+            default:
+//                dbglogfile << "msg " << msg << endl;
+                break;
+        }
+    }
+    return DefWindowProc(hWnd, msg, wParam, lParam);
+}
+*/
diff --git a/plugin/aos4/plugin.h b/plugin/aos4/plugin.h
new file mode 100644
index 0000000..f10a0aa
--- /dev/null
+++ b/plugin/aos4/plugin.h
@@ -0,0 +1,116 @@
+// 
+//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 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 __PLUGIN_H__
+#define __PLUGIN_H__
+ 
+#include <string>
+#include "pluginbase.h"
+
+#include "prinit.h"
+#include "prlock.h"
+#include "prcvar.h"
+#include "prerr.h"
+#include "prerror.h"
+#include "prthread.h"
+
+#include "gnash.h"
+#include "log.h"
+#include "rc.h"
+#include "Player.h"
+#include "URL.h"
+#include "sound_handler.h"
+#include "Renderer.h"
+#include "Renderer_agg.h"
+#include "MovieClip.h"
+#include "movie_definition.h"
+#include "movie_root.h"
+#include "SystemClock.h"
+#include "VM.h"
+
+class nsPluginInstance : public nsPluginInstanceBase
+{
+public:
+    nsPluginInstance(nsPluginCreateData*);
+    virtual ~nsPluginInstance();
+
+    // We are required to implement these three methods.
+    NPBool init(NPWindow* aWindow);
+    void shut(void);
+    NPBool isInitialized(void) { return _initialized; }
+
+    NPError NewStream(NPMIMEType type, NPStream *stream, NPBool seekable,
+            uint16_t *stype);
+    NPError DestroyStream(NPStream *stream, NPError reason);
+    int32 Write(NPStream *stream, int32 offset, int32 len, void *buffer);
+
+    // locals
+    typedef std::map<std::string, std::string> VariableMap;
+    const char* getVersion();
+    void threadMain(void);
+
+    struct Window *getWindow() { return _window; }
+    int getWidth() { return _width; };
+    int getHeight() { return _height; };
+    int getRowStride() { return _rowstride; }
+    APTR getMemDC() { return _hMemDC; } //was HDC
+    struct BitMap * getBitmap() { return _bmp; }
+    unsigned char* getMemAddr() { return _memaddr; }
+    size_t getMemSize() { return _rowstride * _height; }
+    void notify_mouse_state(int x, int y, int buttons)
+    {
+        mouse_x = x;
+        mouse_y = y;
+        if (buttons >= 0) {
+            mouse_buttons = buttons;
+        }
+    }
+
+private:
+    NPP         _instance;
+    struct Window *_window;
+    NPBool      _initialized;
+    NPBool      _shutdown;
+    ULONG       _oldWndProc;
+
+    NPStream*   _stream;
+    std::string _url;
+    VariableMap _flashVars;
+    PRThread*   _thread;
+    uint32_t    _x;
+    uint32_t    _y;
+    uint32_t    _width;
+    uint32_t    _height;
+    uint32_t    _rowstride;
+    APTR        _hMemDC; //was HDC
+    APTR               _bmpInfo; //was BITMAPINFO
+    struct BitMap *_bmp;
+    unsigned char* _memaddr;
+
+    //std::auto_ptr<gnash::media::sound_handler> _sound_handler;
+    gnash::Renderer* _Renderer;
+
+    // Mouse state.
+    int mouse_x;
+    int mouse_y;
+    int mouse_buttons;
+
+    static void FSCommand_callback(gnash::MovieClip* movie, const std::string& 
command, const std::string& args);
+};
+ 
+#endif // __PLUGIN_H__

-----------------------------------------------------------------------

Summary of changes:
 plugin/aos4/.DS_Store              |  Bin 0 -> 6148 bytes
 plugin/{win32 => aos4}/Makefile.am |   30 +++++++-----------
 plugin/{win32 => aos4}/plugin.cpp  |   59 +++++++++++++++++++----------------
 plugin/{win32 => aos4}/plugin.h    |   18 +++++-----
 4 files changed, 53 insertions(+), 54 deletions(-)
 create mode 100644 plugin/aos4/.DS_Store
 copy plugin/{win32 => aos4}/Makefile.am (76%)
 copy plugin/{win32 => aos4}/plugin.cpp (93%)
 copy plugin/{win32 => aos4}/plugin.h (89%)


hooks/post-receive
-- 
Gnash



reply via email to

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