[vlc-devel] [PATCH 8/8] libvlc: use a callback to select the plane to render to

Steve Lhomme robux4 at ycbcr.xyz
Mon May 6 15:01:37 CEST 2019


We can now render to NV12/P010 externally. Only supported by D3D11 rendering.
---
 include/vlc/libvlc_media_player.h | 17 +++++++++++++++++
 include/vlc_vout_display.h        |  6 ++++++
 lib/media_player.c                |  3 +++
 3 files changed, 26 insertions(+)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 51561c3281..a350120905 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -736,6 +736,22 @@ typedef struct
  */
 typedef bool( *libvlc_video_surface_start_rendering_cb )( void *opaque, bool enter, const libvlc_video_surface_hdr10_metadata_t *hdr10 );
 
+/** Tell the host the rendering for the given plane is about to start
+ *
+ * \param opaque private pointer passed to the @a libvlc_video_surface_set_callbacks() [IN]
+ * \param plane number of the rendering plane to select
+ * \return true on success
+ * \version LibVLC 4.0.0 or later
+ *
+ * \note This is only used with \ref libvlc_video_rendering_direct3d11.
+ *
+ * The host should call OMSetRenderTargets for Direct3D11.
+ *
+ * The number of planes depend on the DXGI_FORMAT returned during the
+ * \ref LIBVLC_VIDEO_UPDATE_OUTPUT call. It's usually one plane except for
+ * semi-planar formats like DXGI_FORMAT_NV12 or DXGI_FORMAT_P010.
+ */
+typedef bool( *libvlc_video_surface_select_plane_cb )( void *opaque, size_t plane );
 
 /**
  * Set callbacks and data to render decoded video to a custom Direct3D output
@@ -758,6 +774,7 @@ int libvlc_video_surface_set_callbacks( libvlc_media_player_t *mp,
                                         libvlc_video_surface_update_output_cb update_output_cb,
                                         libvlc_video_swap_cb swap_cb,
                                         libvlc_video_surface_start_rendering_cb makeCurrent_cb,
+                                        libvlc_video_surface_select_plane_cb select_plane_cb,
                                         void* opaque );
 
 /**
diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 1f8f9fa713..38fd74b21b 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -497,11 +497,17 @@ typedef struct
     video_transfer_func_t   transfer;
 } video_surface_output_cfg_t; /* must match libvlc_video_output_cfg_t */
 
+typedef struct
+{
+    size_t plane;
+} vlc_video_surface_plane_t; /* must match libvlc_video_surface_plane_t */
+
 typedef bool( *vlc_video_surface_device_setup_cb )( void *opaque, const vlc_video_surface_device_cfg_t *cfg, vlc_video_surface_device_setup_t *out );
 typedef void( *vlc_video_surface_device_cleanup_cb )( void *opaque );
 typedef bool( *vlc_video_surface_update_output_cb )( void *opaque, const vlc_video_surface_cfg_t *cfg, video_surface_output_cfg_t *output );
 typedef void( *vlc_video_swap_cb )( void* opaque );
 typedef bool( *vlc_video_surface_start_rendering_cb )( void *opaque, bool enter, const vlc_video_surface_hdr10_metadata_t *hdr10 );
+typedef bool( *vlc_video_surface_select_plane_cb )( void *opaque, size_t plane );
 
 /** @} */
 #endif /* VLC_VOUT_DISPLAY_H */
diff --git a/lib/media_player.c b/lib/media_player.c
index 3e05d52fd9..42f7c11d59 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -646,6 +646,7 @@ 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-select-plane", VLC_VAR_ADDRESS );
 
     var_Create (mp, "avcodec-hw", VLC_VAR_STRING);
     var_Create (mp, "drawable-xid", VLC_VAR_INTEGER);
@@ -1212,6 +1213,7 @@ int libvlc_video_surface_set_callbacks( libvlc_media_player_t *mp,
                                         libvlc_video_surface_update_output_cb update_output_cb,
                                         libvlc_video_swap_cb swap_cb,
                                         libvlc_video_surface_start_rendering_cb makeCurrent_cb,
+                                        libvlc_video_surface_select_plane_cb select_plane_cb,
                                         void* opaque )
 {
     var_SetString( mp, "window", "host_window");
@@ -1235,6 +1237,7 @@ int libvlc_video_surface_set_callbacks( libvlc_media_player_t *mp,
     var_SetAddress( mp, "vout-cb-update-output", update_output_cb );
     var_SetAddress( mp, "vout-cb-swap", swap_cb );
     var_SetAddress( mp, "vout-cb-make-current", makeCurrent_cb );
+    var_SetAddress( mp, "vout-cb-select-plane", select_plane_cb );
     return 1;
 }
 
-- 
2.17.1



More information about the vlc-devel mailing list