I'm working on a standalone daemon executable that needs to load an existing third party NPAPI plugin on a host machine. What I want to do is render the generated views from the plugin to a texture/surface.
It needs to work on both Mac and Windows, but since I'm a heavy Mac user, I decided to build the Mac version first. We don't have the source code for this plugin - it's something an external vendor supplied us with - so it's a black box implementation.
On the web, the plugin works in a very similar way to flash. You embed an area in a webpage linked to a certain mimetype (i.e application/flash) and that loads the plugin, which in turn will instruct the plugin to load a certain file (think an SWF) and then render it.
What I'm doing right now is:
1. Open the library (Bundle) and extract NP_Initialize etc.
2. Call NP_Initialize -> returns the object with NPP function pointers etc
3. Call NPP_New (this calls a set of NPP functions) -> ultimately returns NPERR_NO_ERROR.
Since NPERR_NO_ERROR is the expected response, I'm assuming these three steps were completed successfully.
During NPP_New, the plugin requests both the Cocoa Event model and the Core Animation (or alternatively, Core Graphics, if I return false for Core Animation) rendering mode.
Then I call:
4. NPP_SetWindow
5. Once the window is set, I load an online file with CURL, and call NPP_NewStream/WriteReady/Write and DestroyStream.
From what I could find in the NPAPI documentation, the NewStream/WriteStream/etc functions basically load a file into memory of the plugin, so it can be rendered.
The plugin supports both Core Animation and Core Graphics in a browser, and works fine in browsers that support NPAPI plugins.
Once I've done all of the above, I attempt to render to a texture, but I keep getting false responses back from NPP_Event function calls with a CGContextRef when in Core Graphics mode. When running in Core Animation mode, I render the texture to a bitmap using renderInContext but the entire image stays blank/transparent.
It's a long shot, but does anyone have any ideas?