[vlc-devel] [PATCH 2/9] libvlc: add a callback to notify the host when the rendering starts/ends

Steve Lhomme robux4 at ycbcr.xyz
Fri Jan 18 16:32:13 CET 2019


This is going to be necessary for Direct3D rendering as we will need to share
the rendering context on both sides.
---
 doc/libvlc/sdl_opengl_player.cpp  |  1 +
 include/vlc/libvlc_media_player.h | 22 ++++++++++++++++++++++
 lib/media_player.c                |  6 ++++++
 3 files changed, 29 insertions(+)

diff --git a/doc/libvlc/sdl_opengl_player.cpp b/doc/libvlc/sdl_opengl_player.cpp
index dabc430bdd..901adafbe2 100644
--- a/doc/libvlc/sdl_opengl_player.cpp
+++ b/doc/libvlc/sdl_opengl_player.cpp
@@ -82,6 +82,7 @@ public:
         libvlc_video_set_output_callbacks(m_mp, libvlc_video_engine_opengl,
             setup, cleanup, resize, swap,
             make_current, get_proc_address,
+            NULL, NULL,
             this);
 
         // Play the video
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index ecaa8f54e1..715972ccdf 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -478,6 +478,24 @@ typedef bool (*libvlc_video_makeCurrent_cb)(void* opaque, bool enter);
  */
 typedef void* (*libvlc_video_getProcAddress_cb)(void* opaque, const char* fct_name);
 
+/**
+ * Callback prototype called to tell the host the rendering is about to start.
+ *
+ * \param opaque private pointer passed in the @a libvlc_video_engine_callbacks_t [IN]
+ * \return true on success
+ * \version LibVLC 4.0.0 or later
+ */
+typedef bool (*libvlc_video_start_render_cb)(void* opaque);
+
+
+/**
+ * Callback prototype called to tell the host the rendering has ended.
+ *
+ * \param opaque private pointer passed in the @a libvlc_video_engine_callbacks_t [IN]
+ * \version LibVLC 4.0.0 or later
+ */
+typedef void (*libvlc_video_end_render_cb)(void* opaque);
+
 /**
  * Enumeration of the Video engine to be used on output.
  * can be passed to @a libvlc_video_set_output_callbacks
@@ -503,6 +521,8 @@ typedef enum libvlc_video_engine_t {
  * \param swap_cb callback called after rendering a video frame (cannot be NULL)
  * \param makeCurrent_cb callback called to enter/leave the opengl context (cannot be NULL for \ref libvlc_video_engine_opengl and for \ref libvlc_video_engine_gles2)
  * \param getProcAddress_cb opengl function loading callback (cannot be NULL for \ref libvlc_video_engine_opengl and for \ref libvlc_video_engine_gles2)
+ * \param startRender_cb callback called when the rendering is starting
+ * \param endRender_cb callback called when the rendering is finished
  * \param opaque private pointer passed to callbacks
  * \libvlc_return_bool
  * \version LibVLC 4.0.0 or later
@@ -516,6 +536,8 @@ int libvlc_video_set_output_callbacks( libvlc_media_player_t *mp,
                                         libvlc_video_swap_cb swap_cb,
                                         libvlc_video_makeCurrent_cb makeCurrent_cb,
                                         libvlc_video_getProcAddress_cb getProcAddress_cb,
+                                        libvlc_video_start_render_cb startRender_cb,
+                                        libvlc_video_end_render_cb endRender_cb,
                                         void* opaque );
 
 /**
diff --git a/lib/media_player.c b/lib/media_player.c
index 4079efd4b0..4264484aa3 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -646,6 +646,8 @@ libvlc_media_player_new( libvlc_instance_t *instance )
     var_Create( mp, "vout-cb-swap", VLC_VAR_ADDRESS );
     var_Create( mp, "vout-cb-get-proc-address", VLC_VAR_ADDRESS );
     var_Create( mp, "vout-cb-make-current", VLC_VAR_ADDRESS );
+    var_Create( mp, "vout-cb-start-render", VLC_VAR_ADDRESS );
+    var_Create( mp, "vout-cb-end-render", VLC_VAR_ADDRESS );
 
     var_Create (mp, "avcodec-hw", VLC_VAR_STRING);
     var_Create (mp, "drawable-xid", VLC_VAR_INTEGER);
@@ -1168,6 +1170,8 @@ int libvlc_video_set_output_callbacks( libvlc_media_player_t *mp,
                                         libvlc_video_swap_cb swap_cb,
                                         libvlc_video_makeCurrent_cb makeCurrent_cb,
                                         libvlc_video_getProcAddress_cb getProcAddress_cb,
+                                        libvlc_video_start_render_cb startRender_cb,
+                                        libvlc_video_end_render_cb endRender_cb,
                                         void* opaque )
 {
 #ifdef __ANDROID__
@@ -1197,6 +1201,8 @@ int libvlc_video_set_output_callbacks( libvlc_media_player_t *mp,
     var_SetAddress( mp, "vout-cb-swap", swap_cb );
     var_SetAddress( mp, "vout-cb-get-proc-address", getProcAddress_cb );
     var_SetAddress( mp, "vout-cb-make-current", makeCurrent_cb );
+    var_SetAddress( mp, "vout-cb-start-render", startRender_cb );
+    var_SetAddress( mp, "vout-cb-end-render", endRender_cb );
     return 1;
 }
 
-- 
2.17.1



More information about the vlc-devel mailing list