? simple
? examples/MediaPlayer/build
? examples/MediaPlayer/build.properties
? examples/MediaPlayer/build.properties.sample
? test/build
M examples/MediaPlayer/JMPlayer.java
M examples/MediaPlayer/build.xml
M examples/MediaPlayer/samples/test.html
M mozilla/nppluglet.cpp
M mozilla/nppluglet.h


git-svn-id: svn://10.0.0.236/trunk@213989 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
edburns%acm.org
2006-10-23 05:18:19 +00:00
parent 968f64f58b
commit e144e050f9
6 changed files with 154 additions and 25 deletions

View File

@@ -44,6 +44,8 @@
#include "nsIServiceManager.h"
#include "nsIMemory.h"
#include "nsISupportsUtils.h" // this is where some useful macros defined
#include "ns4xPluginStreamListener.h"
#include "nsIPluginStreamInfo.h"
#include "nsServiceManagerUtils.h"
@@ -214,30 +216,16 @@ NPBool nsPluginInstance::init(NPWindow* aWindow)
return mInitialized;
}
rv = mPluglet->Initialize(peer);
#if defined(XP_MAC) || defined(XP_MACOSX)
#elif defined(XP_WIN) || defined(XP_OS2)
pluginWindow.window = (nsPluginPort *) aWindow->window;
#elif defined(XP_UNIX) && defined(MOZ_X11)
#else
#endif
pluginWindow.x = aWindow->x;
pluginWindow.y = aWindow->y;
pluginWindow.width = aWindow->width;
pluginWindow.height = aWindow->height;
pluginWindow.clipRect.top = aWindow->clipRect.top;
pluginWindow.clipRect.left = aWindow->clipRect.left;
pluginWindow.clipRect.bottom = aWindow->clipRect.bottom;
pluginWindow.clipRect.right = aWindow->clipRect.right;
#if defined(XP_UNIX) && !defined(XP_MACOSX)
pluginWindow.ws_info = aWindow->ws_info;
#endif
pluginWindow.type = aWindow->type == NPWindowTypeWindow ?
nsPluginWindowType_Window : nsPluginWindowType_Drawable;
rv = mPluglet->SetWindow(&pluginWindow);
if (NS_SUCCEEDED(rv)) {
rv = mPluglet->Start();
rv = this->CopyNPWindowToNsPluginWindow(aWindow, &pluginWindow);
if (NS_SUCCEEDED(rv)) {
mInitialized = PR_TRUE;
rv = mPluglet->Start();
if (NS_SUCCEEDED(rv)) {
rv = mPluglet->SetWindow(&pluginWindow);
if (NS_SUCCEEDED(rv)) {
mInitialized = PR_TRUE;
}
}
}
}
@@ -258,6 +246,90 @@ NPBool nsPluginInstance::isInitialized()
return mInitialized;
}
NPError nsPluginInstance::SetWindow(NPWindow* pNPWindow)
{
nsresult rv = NS_ERROR_FAILURE;
nsPluginWindow pluginWindow;
if (!this->isInitialized()) {
return rv;
}
rv = this->CopyNPWindowToNsPluginWindow(pNPWindow, &pluginWindow);
if (NS_SUCCEEDED(rv)) {
rv = mPluglet->SetWindow(&pluginWindow);
}
return (NPError) rv;
}
NPError nsPluginInstance::NewStream(NPMIMEType type, NPStream* stream,
NPBool seekable, uint16* stype)
{
nsresult rv = NS_ERROR_FAILURE;
if (!this->isInitialized()) {
return rv;
}
nsCOMPtr<nsIPluginStreamListener> listener = nsnull;
rv = mPluglet->NewStream(getter_AddRefs(listener));
if (NS_SUCCEEDED(rv)) {
ns4xPluginStreamListener * hostListener =
(ns4xPluginStreamListener *) stream->ndata;
if (hostListener) {
nsCOMPtr<nsIPluginStreamInfo> hostStreamInfo =
hostListener->mStreamInfo;
if (hostStreamInfo) {
rv = listener->OnStartBinding(hostStreamInfo);
if (NS_SUCCEEDED(rv)) {
stream->pdata = (void *) listener.get();
nsCOMPtr<nsISupports> toCast =
do_QueryInterface(listener);
nsISupports *toAddRef = (nsISupports *) toCast.get();
NS_ADDREF(toAddRef);
}
}
}
}
return rv;
}
NPError nsPluginInstance::DestroyStream(NPStream *stream, NPError reason)
{
nsresult rv = NS_ERROR_FAILURE;
if (!this->isInitialized()) {
return rv;
}
nsCOMPtr<nsIPluginStreamListener> listener =
(nsIPluginStreamListener *) stream->pdata;
nsCOMPtr<nsISupports> toCast = do_QueryInterface(listener);
nsISupports *toRelease = (nsISupports *) toCast.get();
NS_RELEASE(toRelease);
listener = nsnull;
stream->pdata = nsnull;
return NS_OK;
}
int32 nsPluginInstance::WriteReady(NPStream *stream) {
int32 result = 65536;
return result;
}
int32 nsPluginInstance::Write(NPStream *stream, int32 offset,
int32 len, void *buffer)
{
int32 result = len;
nsCOMPtr<nsIPluginStreamListener> listener =
(nsIPluginStreamListener *) stream->pdata;
return result;
}
NS_IMETHODIMP nsPluginInstance::HasPlugletForMimeType(const char *aMimeType,
PRBool *outResult)
{
@@ -288,6 +360,39 @@ NS_IMETHODIMP nsPluginInstance::HasPlugletForMimeType(const char *aMimeType,
return rv;
}
nsresult nsPluginInstance::CopyNPWindowToNsPluginWindow(NPWindow *aWindow,
nsPluginWindow *pluginWindow)
{
nsresult rv = NS_ERROR_NULL_POINTER;
if (nsnull == aWindow || nsnull == pluginWindow) {
return rv;
}
#if defined(XP_MAC) || defined(XP_MACOSX)
#elif defined(XP_WIN) || defined(XP_OS2)
pluginWindow->window = (nsPluginPort *) aWindow->window;
#elif defined(XP_UNIX) && defined(MOZ_X11)
#else
#endif
pluginWindow->x = aWindow->x;
pluginWindow->y = aWindow->y;
pluginWindow->width = aWindow->width;
pluginWindow->height = aWindow->height;
pluginWindow->clipRect.top = aWindow->clipRect.top;
pluginWindow->clipRect.left = aWindow->clipRect.left;
pluginWindow->clipRect.bottom = aWindow->clipRect.bottom;
pluginWindow->clipRect.right = aWindow->clipRect.right;
#if defined(XP_UNIX) && !defined(XP_MACOSX)
pluginWindow->ws_info = aWindow->ws_info;
#endif
pluginWindow->type = aWindow->type == NPWindowTypeWindow ?
nsPluginWindowType_Window : nsPluginWindowType_Drawable;
rv = NS_OK;
return rv;
}
// ==============================

View File

@@ -53,6 +53,15 @@ public:
void shut();
NPBool isInitialized();
NPError SetWindow(NPWindow* pNPWindow);
NPError NewStream(NPMIMEType type, NPStream* stream,
NPBool seekable, uint16* stype);
NPError DestroyStream(NPStream *stream, NPError reason);
int32 WriteReady(NPStream *stream);
int32 Write(NPStream *stream, int32 offset, int32 len, void *buffer);
// we need to provide implementation of this method as it will be
// used by Mozilla to retrive the scriptable peer
// and couple of other things on Unix
@@ -70,6 +79,9 @@ private:
nsScriptablePeer * mScriptablePeer;
nsPluginCreateData mCreateDataStruct;
nsresult CopyNPWindowToNsPluginWindow(NPWindow *npWindow,
nsPluginWindow *nsWindow);
public:
char mString[128];
};