[vlc-commits] Mac windowless: fix video output under Safari 5, which doesn' t support NPN_PluginThreadAsyncCall

Felix Paul Kühne git at videolan.org
Mon Feb 10 15:35:57 CET 2014


npapi-vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Mon Feb 10 15:34:59 2014 +0100| [b39c0884e03aadf9a1a6a77c139d5fd6102003b3] | committer: Felix Paul Kühne

Mac windowless: fix video output under Safari 5, which doesn't support NPN_PluginThreadAsyncCall

> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=b39c0884e03aadf9a1a6a77c139d5fd6102003b3
---

 npapi/vlcplugin_mac.h       |    2 +-
 npapi/vlcplugin_mac.mm      |    2 +-
 npapi/vlcwindowless_mac.cpp |   31 ++++++++++++++++++++++++++++++-
 npapi/vlcwindowless_mac.h   |    8 +++++++-
 4 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/npapi/vlcplugin_mac.h b/npapi/vlcplugin_mac.h
index 3e848f0..d103c27 100644
--- a/npapi/vlcplugin_mac.h
+++ b/npapi/vlcplugin_mac.h
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * vlcplugin_mac.h: a VLC plugin for Mozilla (Mac interface)
  *****************************************************************************
- * Copyright (C) 2011-2013 VLC authors and VideoLAN
+ * Copyright (C) 2011-2014 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Felix Paul Kühne <fkuehne # videolan # org>
diff --git a/npapi/vlcplugin_mac.mm b/npapi/vlcplugin_mac.mm
index e89067f..f94a375 100644
--- a/npapi/vlcplugin_mac.mm
+++ b/npapi/vlcplugin_mac.mm
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * vlcplugin_mac.cpp: a VLC plugin for Mozilla (Mac interface)
  *****************************************************************************
- * Copyright (C) 2011-2013 VLC Authors and VideoLAN
+ * Copyright (C) 2011-2014 VLC Authors and VideoLAN
  * $Id$
  *
  * Authors: Felix Paul Kühne <fkuehne # videolan # org>
diff --git a/npapi/vlcwindowless_mac.cpp b/npapi/vlcwindowless_mac.cpp
index 93c2772..2d0c226 100644
--- a/npapi/vlcwindowless_mac.cpp
+++ b/npapi/vlcwindowless_mac.cpp
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * vlcwindowless_mac.cpp: VLC NPAPI windowless plugin for Mac
  *****************************************************************************
- * Copyright (C) 2012-2013 VLC Authors and VideoLAN
+ * Copyright (C) 2012-2014 VLC Authors and VideoLAN
  * $Id$
  *
  * Authors: Felix Paul Kühne <fkuehne # videolan # org>
@@ -30,6 +30,12 @@ VlcWindowlessMac::VlcWindowlessMac(NPP instance, NPuint16_t mode) :
     VlcWindowlessBase(instance, mode)
 {
     colorspace = CGColorSpaceCreateDeviceRGB();
+
+    const char *userAgent = NPN_UserAgent(this->getBrowser());
+    if (strstr(userAgent, "Safari") && strstr(userAgent, "Version/5")) {
+        legacy_drawing_mode = true;
+        fprintf(stderr, "Safari 5 detected, using legacy drawing mode\n");
+    }
 }
 
 VlcWindowlessMac::~VlcWindowlessMac()
@@ -249,3 +255,26 @@ bool VlcWindowlessMac::handle_event(void *event)
 
     return VlcPluginBase::handle_event(event);
 }
+
+void VlcWindowlessMac::video_display_cb(void * /*picture*/)
+{
+    if (p_browser) {
+        if (!legacy_drawing_mode)
+            NPN_PluginThreadAsyncCall(p_browser,
+                                      VlcWindowlessBase::invalidate_window_proxy,
+                                      this);
+        else
+            invalidate_window();
+    }
+}
+
+void VlcWindowlessMac::set_player_window() {
+    libvlc_video_set_format_callbacks(getMD(),
+                                      video_format_proxy,
+                                      video_cleanup_proxy);
+    libvlc_video_set_callbacks(getMD(),
+                               video_lock_proxy,
+                               video_unlock_proxy,
+                               video_display_proxy,
+                               this);
+}
diff --git a/npapi/vlcwindowless_mac.h b/npapi/vlcwindowless_mac.h
index 401fcc8..93646eb 100644
--- a/npapi/vlcwindowless_mac.h
+++ b/npapi/vlcwindowless_mac.h
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * vlcwindowsless_mac.h: VLC NPAPI windowless plugin for Mac
  *****************************************************************************
- * Copyright (C) 2012-2013 VLC Authors and VideoLAN
+ * Copyright (C) 2012-2014 VLC Authors and VideoLAN
  * $Id$
  *
  * Authors: Felix Paul Kühne <fkuehne # videolan # org>
@@ -34,6 +34,11 @@ public:
 
     bool handle_event(void *event);
     NPError get_root_layer(void *value);
+    void video_display_cb(void *picture);
+    void set_player_window();
+
+    static void video_display_proxy(void *opaque, void *picture)
+    { reinterpret_cast<VlcWindowlessMac*>(opaque)->video_display_cb(picture); }
 
 protected:
     void drawNoPlayback(CGContextRef cgContext);
@@ -43,6 +48,7 @@ private:
     CGImageRef lastFrame;
     int cached_width;
     int cached_height;
+    bool legacy_drawing_mode;
 };
 
 #endif /* __VLCWINDOWLESS_MAC_H__ */



More information about the vlc-commits mailing list