Commit 3212a8f4 authored by James Bates's avatar James Bates Committed by Jean-Baptiste Kempf

npapi-vlc: Fix Mac OS X build

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 501e348c
......@@ -14,3 +14,6 @@ libtool
Makefile
Makefile.in
stamp-*
extras/macosx/Info.plist
npapi/VLC Plugin*
npapi/npvlc.rsrc
......@@ -145,7 +145,9 @@ glibc run-time.])
dnl
dnl libraries checks
AC_PATH_XTRA
PKG_CHECK_MODULES([LIBVLC], [libvlc >= 1.1.0])
PKG_CHECK_MODULES([LIBVLC], [libvlc >= 1.1.0], [
LIBVLC_PREFIX=`pkg-config --variable=prefix libvlc`
AC_SUBST(LIBVLC_PREFIX)])
dnl
......
This diff is collapsed.
......@@ -104,26 +104,22 @@ else
lib_LTLIBRARIES = npvlc.la
AM_CPPFLAGS += -I. -I$(top_builddir) -c \
-F/System/Library/Frameworks/CoreFoundation.framework \
-I/Developer/Headers/FlatCarbon -fno-common -fpascal-strings \
-Wmost -Wno-four-char-constants -Wno-unknown-pragmas \
-DXP_UNIX -DXP_MACOSX=1 \
-DNO_X11=1 -DUSE_SYSTEM_CONSOLE=1 -pipe -fmessage-length=0
SOURCES_support = support/npmac.cpp
SOURCES_support = support/npmac.cpp \
vlcplugin_mac.cpp \
vlcplugin_mac.h
libvlcplugin_la_LDFLAGS += \
-bundle -Wl,-read_only_relocs -Wl,suppress \
-Wl,-headerpad_max_install_names \
-Wl,-framework,Carbon -Wl,-framework,System \
-shrext $(LIBEXT)
-shrext .dylib
noinst_DATA = npvlc.rsrc VLC\ Plugin.plugin
MOSTLYCLEANFILES += npvlc.rsrc
noinst_DATA = VLC\ Plugin.plugin
CLEANFILES += VLC\ Plugin.plugin
npvlc.rsrc: vlc.r
/Developer/Tools/Rez -useDF /Developer/Headers/FlatCarbon/Types.r $< -o $@
#
# Plugin uses shared libraries that are located relatively through @executable_path,
# which unfortunately references the path of the App using the Plugin, rather than the
......@@ -140,13 +136,12 @@ define FIXEXECPATH
}' | sh -x
endef
VLC\ Plugin.plugin: npvlc.rsrc $(lib_LTLIBRARIES)
VLC\ Plugin.plugin: $(lib_LTLIBRARIES)
rm -Rf "$@"
$(INSTALL) -d "VLC-Plugin.plugin/Contents/MacOS/lib"
$(INSTALL) -d "VLC-Plugin.plugin/Contents/Resources"
ACTION="release-makefile" PRODUCT="VLC-Plugin.plugin" src_dir=$(srcdir) build_dir=$(top_builddir) sh "$(top_srcdir)/project/macosx/framework/Pre-Compile.sh"
$(INSTALL) npvlc.rsrc "VLC-Plugin.plugin/Contents/Resources/VLC Plugin.rsrc"
$(INSTALL) "$(top_builddir)/extras/package/macosx/plugin/Info.plist" "VLC-Plugin.plugin/Contents/Info.plist"
ACTION="release-makefile" PRODUCT="VLC-Plugin.plugin" libvlc_dir=$(LIBVLC_PREFIX) src_dir=$(srcdir) build_dir=$(top_builddir) sh "$(top_srcdir)/extras/macosx/build-package.sh"
$(INSTALL) "$(top_builddir)/extras/macosx/Info.plist" "VLC-Plugin.plugin/Contents/Info.plist"
mv "VLC-Plugin.plugin" "VLC Plugin.plugin"
find "VLC Plugin.plugin" -type d -exec chmod ugo+rx '{}' \;
find "VLC Plugin.plugin" -type f -exec chmod ugo+r '{}' \;
......
......@@ -27,14 +27,7 @@
#include "config.h"
#include <string.h>
#include <Processes.h>
#include <Gestalt.h>
#include <CodeFragments.h>
#include <Timer.h>
#include <Resources.h>
#include <ToolUtils.h>
#include <stddef.h>
#define XP_MACOSX 1
#undef TARGET_RT_MAC_CFM
......@@ -665,8 +658,43 @@ void Private_Shutdown(void)
NPError Private_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved)
{
EnterCodeResource();
NPError ret = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
PLUGINDEBUGSTR("\pNew;g;");
/*
* We should negotiate and setup uniform event & drawing models, so the 32- and 64-bit plugins behave
* identically
*/
NPBool supportsCoreGraphics = FALSE;
NPError err = NPN_GetValue(instance, NPNVsupportsCoreGraphicsBool, &supportsCoreGraphics);
if (err != NPERR_NO_ERROR || !supportsCoreGraphics) {
PLUGINDEBUGSTR("\pNew: browser doesn't support CoreGraphics drawing model;g;");
return NPERR_INCOMPATIBLE_VERSION_ERROR;
}
err = NPN_SetValue(instance, NPPVpluginDrawingModel, (void*)NPDrawingModelCoreGraphics);
if (err != NPERR_NO_ERROR) {
PLUGINDEBUGSTR("\pNew: couldn't activate CoreGraphics drawing model;g;");
return NPERR_INCOMPATIBLE_VERSION_ERROR;
}
NPBool supportsCocoaEvents = FALSE;
err = NPN_GetValue(instance, NPNVsupportsCocoaBool, &supportsCocoaEvents);
if (err != NPERR_NO_ERROR || !supportsCocoaEvents) {
PLUGINDEBUGSTR("\pNew: browser doesn't support Cocoa event model;g;");
return NPERR_INCOMPATIBLE_VERSION_ERROR;
}
err = NPN_SetValue(instance, NPPVpluginEventModel, (void*)NPEventModelCocoa);
if (err != NPERR_NO_ERROR) {
PLUGINDEBUGSTR("\pNew: couldn't activate Cocoa event model;g;");
return NPERR_INCOMPATIBLE_VERSION_ERROR;
}
NPError ret = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
ExitCodeResource();
return ret;
}
......@@ -903,6 +931,9 @@ typedef int main_return_t;
typedef NPError mainReturnType;
#endif
typedef void (* NP_LOADDS NPP_ShutdownProcPtr)(void);
#if (((NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR) < 20)
typedef NPP_ShutdownUPP unloadupp_t;
#else
......@@ -1102,8 +1133,11 @@ NPError NP_Initialize(NPNetscapeFuncs* nsTable)
/* validate input parameters */
if( NULL == nsTable )
if( NULL == nsTable ) {
PLUGINDEBUGSTR("\pNP_Initialize error: NPERR_INVALID_FUNCTABLE_ERROR: table is null");
return NPERR_INVALID_FUNCTABLE_ERROR;
}
/*
* Check the major version passed in Netscape's function table.
......@@ -1114,11 +1148,20 @@ NPError NP_Initialize(NPNetscapeFuncs* nsTable)
*
*/
if ((nsTable->version >> 8) > NP_VERSION_MAJOR)
if ((nsTable->version >> 8) > NP_VERSION_MAJOR) {
PLUGINDEBUGSTR("\pNP_Initialize error: NPERR_INCOMPATIBLE_VERSION_ERROR");
return NPERR_INCOMPATIBLE_VERSION_ERROR;
}
if (nsTable->size < sizeof(NPNetscapeFuncs))
// We use all functions of the nsTable up to and including setexception. We therefore check that
// reaches at least till that function.
if (nsTable->size < (offsetof(NPNetscapeFuncs, setexception) + sizeof(NPN_SetExceptionProcPtr))) {
PLUGINDEBUGSTR("\pNP_Initialize error: NPERR_INVALID_FUNCTABLE_ERROR: table too small");
return NPERR_INVALID_FUNCTABLE_ERROR;
}
int navMinorVers = nsTable->version & 0xFF;
......
......@@ -15,7 +15,7 @@
#elif defined(XP_WIN)
# include "vlcplugin_win.h"
typedef VlcPluginWin VlcPlugin;
#elif defined(XP_MAC)
#elif defined(XP_MACOSX)
# include "vlcplugin_mac.h"
typedef VlcPluginMac VlcPlugin;
#endif
......
......@@ -402,8 +402,7 @@ NPError VlcPluginBase::init(int argc, char* const argn[], char* const argv[])
/* locate VLC module path */
#ifdef XP_MACOSX
ppsz_argv[ppsz_argc++] = "--plugin-path=/Library/Internet\\ Plug-Ins/VLC\\ Plugin.plugin/Contents/MacOS/plugins";
ppsz_argv[ppsz_argc++] = "--vout=minimal_macosx";
ppsz_argv[ppsz_argc++] = "--vout=vout_macosx";
#elif defined(XP_WIN)
HKEY h_key;
DWORD i_type, i_data = MAX_PATH + 1;
......
......@@ -26,6 +26,8 @@
#include "vlcplugin_mac.h"
#include <npapi.h>
VlcPluginMac::VlcPluginMac(NPP instance, NPuint16_t mode) :
VlcPluginBase(instance, mode)
{
......@@ -44,21 +46,21 @@ void VlcPluginMac::toggle_fullscreen()
{
if (!get_options().get_enable_fs()) return;
if (playlist_isplaying())
libvlc_toggle_fullscreen(libvlc_media_player);
libvlc_toggle_fullscreen(getMD());
}
void VlcPluginMac::set_fullscreen(int yes)
{
if (!get_options().get_enable_fs()) return;
if (playlist_isplaying())
libvlc_set_fullscreen(libvlc_media_player, yes);
libvlc_set_fullscreen(getMD(), yes);
}
int VlcPluginMac::get_fullscreen()
{
int r = 0;
if (playlist_isplaying())
r = libvlc_get_fullscreen(libvlc_media_player);
r = libvlc_get_fullscreen(getMD());
return r;
}
......@@ -76,8 +78,8 @@ bool VlcPluginMac::resize_windows()
* relative to GrafPort window origin is set relative to document,
* which of little use for drawing
*/
view.top = ((NP_Port*) (npwindow.window))->porty;
view.left = ((NP_Port*) (npwindow.window))->portx;
view.top = 0; // ((NP_Port*) (npwindow.window))->porty;
view.left = 0; // ((NP_Port*) (npwindow.window))->portx;
view.bottom = npwindow.height+view.top;
view.right = npwindow.width+view.left;
......@@ -96,5 +98,5 @@ bool VlcPluginMac::resize_windows()
bool VlcPluginMac::destroy_windows()
{
window.window = NULL;
npwindow.window = NULL;
}
......@@ -29,8 +29,6 @@
#include "vlcplugin_base.h"
#include <Quickdraw.h>
class VlcPluginMac : public VlcPluginBase
{
public:
......
......@@ -138,7 +138,8 @@ int16_t NPP_HandleEvent( NPP instance, void * event )
return false;
}
#ifndef __x86_64__
// FIXME: implement Cocoa event model, by porting this legacy code:
/*
EventRecord *myEvent = (EventRecord*)event;
switch( myEvent->what )
......@@ -149,7 +150,7 @@ int16_t NPP_HandleEvent( NPP instance, void * event )
{
if( (myEvent->when - lastMouseUp) < GetDblTime() )
{
/* double click */
// double click
p_plugin->toggle_fullscreen();
}
return true;
......@@ -188,12 +189,12 @@ int16_t NPP_HandleEvent( NPP instance, void * event )
if( ! hasVout )
{
/* draw the text from get_bg_text() */
// draw the text from get_bg_text()
ForeColor(blackColor);
PenMode( patCopy );
/* seems that firefox forgets to set the following
* on occasion (reload) */
// seems that firefox forgets to set the following
// on occasion (reload)
SetOrigin(((NP_Port *)npwindow.window)->portx,
((NP_Port *)npwindow.window)->porty);
......@@ -230,7 +231,7 @@ int16_t NPP_HandleEvent( NPP instance, void * event )
default:
;
}
#endif // __x86_64__
*/
return false;
}
#endif /* XP_MACOSX */
......@@ -342,8 +343,10 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
/* retrieve current window */
NPWindow& curr_window = p_plugin->getWindow();
if (window && window->window) {
if (window/* && window->window */) {
::DebugStr((const unsigned char*)"vlcshell: received window object from browser");
if (!curr_window.window) {
::DebugStr((const unsigned char*)"vlcshell: no current window");
/* we've just been created */
p_plugin->setWindow(*window);
p_plugin->create_windows();
......@@ -373,11 +376,13 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
p_plugin->update_controls();
} else {
if (window->window == curr_window.window) {
::DebugStr((const unsigned char*)"Already have current window, and new window is the same");
/* resize / move notification */
p_plugin->setWindow(*window);
p_plugin->resize_windows();
} else {
/* plugin parent window was changed, notify plugin about it */
::DebugStr((const unsigned char*)"Already have current window, but new window is different");
p_plugin->destroy_windows();
p_plugin->setWindow(*window);
p_plugin->create_windows();
......@@ -387,12 +392,12 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
} else {
/* NOTE: on Windows, Opera does not call NPP_SetWindow
* on window destruction. */
::DebugStr((const unsigned char*)"vlcshell: received no window object from browser");
if (curr_window.window) {
/* we've been destroyed */
p_plugin->destroy_windows();
}
}
return NPERR_NO_ERROR;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment