Gnash  0.8.10
plugin.h
Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00003 //   Free Software Foundation, Inc
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 #ifndef GNASH_AOS4_PLUGIN_H
00020 #define GNASH_AOS4_PLUGIN_H
00021  
00022 #include <string>
00023 #include "pluginbase.h"
00024 
00025 #include "prinit.h"
00026 #include "prlock.h"
00027 #include "prcvar.h"
00028 #include "prerr.h"
00029 #include "prerror.h"
00030 #include "prthread.h"
00031 
00032 #include "log.h"
00033 #include "rc.h"
00034 #include "Player.h"
00035 #include "URL.h"
00036 #include "sound_handler.h"
00037 #include "Renderer.h"
00038 #include "Renderer_agg.h"
00039 #include "MovieClip.h"
00040 #include "movie_definition.h"
00041 #include "movie_root.h"
00042 #include "SystemClock.h"
00043 #include "VM.h"
00044 
00045 class nsPluginInstance : public nsPluginInstanceBase
00046 {
00047 public:
00048     nsPluginInstance(nsPluginCreateData*);
00049     virtual ~nsPluginInstance();
00050 
00051     // We are required to implement these three methods.
00052     NPBool init(NPWindow* aWindow);
00053     void shut(void);
00054     NPBool isInitialized(void) { return _initialized; }
00055 
00056     NPError NewStream(NPMIMEType type, NPStream *stream, NPBool seekable,
00057             uint16_t *stype);
00058     NPError DestroyStream(NPStream *stream, NPError reason);
00059     int32 Write(NPStream *stream, int32 offset, int32 len, void *buffer);
00060 
00061     // locals
00062     typedef std::map<std::string, std::string> VariableMap;
00063     const char* getVersion();
00064     void threadMain(void);
00065 
00066     struct Window *getWindow() { return _window; }
00067     int getWidth() { return _width; };
00068     int getHeight() { return _height; };
00069     int getRowStride() { return _rowstride; }
00070     APTR getMemDC() { return _hMemDC; } //was HDC
00071     struct BitMap * getBitmap() { return _bmp; }
00072     unsigned char* getMemAddr() { return _memaddr; }
00073     size_t getMemSize() { return _rowstride * _height; }
00074     void notify_mouse_state(int x, int y, int buttons)
00075     {
00076         mouse_x = x;
00077         mouse_y = y;
00078         if (buttons >= 0) {
00079             mouse_buttons = buttons;
00080         }
00081     }
00082 
00083 private:
00084     NPP         _instance;
00085     struct Window *_window;
00086     NPBool      _initialized;
00087     NPBool      _shutdown;
00088     ULONG       _oldWndProc;
00089 
00090     NPStream*   _stream;
00091     std::string _url;
00092     VariableMap _flashVars;
00093     PRThread*   _thread;
00094     uint32_t    _x;
00095     uint32_t    _y;
00096     uint32_t    _width;
00097     uint32_t    _height;
00098     uint32_t    _rowstride;
00099     APTR        _hMemDC; //was HDC
00100     APTR                _bmpInfo; //was BITMAPINFO
00101     struct BitMap *_bmp;
00102     unsigned char* _memaddr;
00103 
00104     //std::auto_ptr<gnash::media::sound_handler> _sound_handler;
00105     gnash::Renderer* _Renderer;
00106 
00107     // Mouse state.
00108     int mouse_x;
00109     int mouse_y;
00110     int mouse_buttons;
00111 
00112     static void FSCommand_callback(gnash::MovieClip* movie, const std::string& command, const std::string& args);
00113 };
00114  
00115 #endif // __PLUGIN_H__