[vlc-commits] npapi: windowless: Use vlcpp lambdas to avoid callback proxy

Hugo Beauzée-Luyssen git at videolan.org
Tue Apr 21 10:15:58 CEST 2015


npapi-vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Fri Mar 27 12:10:32 2015 +0100| [b65eb81eb16b59213cf934b75bbac3c0eadb37f3] | committer: Hugo Beauzée-Luyssen

npapi: windowless: Use vlcpp lambdas to avoid callback proxy

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

 npapi/vlcwindowless_base.cpp |   25 +++++++++++++++++--------
 npapi/vlcwindowless_base.h   |   16 ----------------
 2 files changed, 17 insertions(+), 24 deletions(-)

diff --git a/npapi/vlcwindowless_base.cpp b/npapi/vlcwindowless_base.cpp
index 35a33e8..ed6250a 100644
--- a/npapi/vlcwindowless_base.cpp
+++ b/npapi/vlcwindowless_base.cpp
@@ -103,13 +103,22 @@ void VlcWindowlessBase::video_display_cb(void * /*picture*/)
 }
 
 void VlcWindowlessBase::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);
+    getMD().setVideoFormatCallbacks([this](char *chroma, unsigned *width,
+                                    unsigned *height, unsigned *pitches, unsigned *lines) {
+        return video_format_cb( chroma, width, height, pitches, lines );
+    },
+    [this] {
+        video_cleanup_cb();
+    });
+
+    getMD().setVideoCallbacks([this](void** planes) {
+        return video_lock_cb( planes );
+    },
+    [this]( void* picture, void* const* planes ) {
+        video_unlock_cb( picture, planes );
+    },
+    [this](void* picture) {
+        video_display_cb( picture );
+    });
 }
 
diff --git a/npapi/vlcwindowless_base.h b/npapi/vlcwindowless_base.h
index 53535c0..359041a 100644
--- a/npapi/vlcwindowless_base.h
+++ b/npapi/vlcwindowless_base.h
@@ -46,15 +46,6 @@ public:
     VlcWindowlessBase(NPP, NPuint16_t);
 
     //for libvlc_video_set_format_callbacks
-    static unsigned video_format_proxy(void **opaque, char *chroma,
-                                       unsigned *width, unsigned *height,
-                                       unsigned *pitches, unsigned *lines)
-        { return reinterpret_cast<VlcWindowlessBase*>(*opaque)->video_format_cb(chroma,
-                                                                  width, height,
-                                                                  pitches, lines); }
-    static void video_cleanup_proxy(void *opaque)
-        { reinterpret_cast<VlcWindowlessBase*>(opaque)->video_cleanup_cb(); };
-
     unsigned video_format_cb(char *chroma,
                              unsigned *width, unsigned *height,
                              unsigned *pitches, unsigned *lines);
@@ -62,13 +53,6 @@ public:
     //end (for libvlc_video_set_format_callbacks)
 
     //for libvlc_video_set_callbacks
-    static void* video_lock_proxy(void *opaque, void **planes)
-        { return reinterpret_cast<VlcWindowlessBase*>(opaque)->video_lock_cb(planes); }
-    static void video_unlock_proxy(void *opaque, void *picture, void *const *planes)
-        { reinterpret_cast<VlcWindowlessBase*>(opaque)->video_unlock_cb(picture, planes); }
-    static void video_display_proxy(void *opaque, void *picture)
-        { reinterpret_cast<VlcWindowlessBase*>(opaque)->video_display_cb(picture); }
-
     void* video_lock_cb(void **planes);
     void video_unlock_cb(void *picture, void *const *planes);
     void video_display_cb(void *picture);



More information about the vlc-commits mailing list