[vlc-devel] [RFC v2 1/8] vout display: add an API to handle surface rendering through a callback
Steve Lhomme
robux4 at ycbcr.xyz
Thu May 2 15:28:44 CEST 2019
The callbacks will be used by D3D but could also be used by other rendering
engines.
---
include/vlc_vout_display.h | 72 ++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index bdae03881c..3126138459 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -455,5 +455,77 @@ VLC_API void vout_display_PlacePicture(vout_display_place_t *place, const video_
void vout_display_TranslateMouseState(vout_display_t *vd, vlc_mouse_t *video,
const vlc_mouse_t *window);
+/*** rendering to external surfaces ***/
+typedef struct
+{
+ bool hardware_decoding; /** set if D3D11_CREATE_DEVICE_VIDEO_SUPPORT is needed */
+} vlc_video_surface_device_cfg_t;
+
+typedef struct
+{
+ void *device_context; /** ID3D11DeviceContext* for D3D11, IDirect3DDevice9* for D3D9 */
+} vlc_video_surface_device_setup_t;
+
+typedef struct
+{
+ unsigned width, height;
+} vlc_video_surface_cfg_t;
+
+typedef struct
+{
+ intptr_t surface_format; /* DXGI_FORMAT for D3D11, D3DFORMAT for D3D9 */
+} video_surface_output_cfg_t;
+
+typedef enum
+{
+ VLC_VIDEO_SURFACE_DEVICE_SETUP,
+ VLC_VIDEO_SURFACE_DEVICE_CLEANUP,
+ VLC_VIDEO_SURFACE_UPDATE_OUTPUT,
+ VLC_VIDEO_SURFACE_SWAP,
+ VLC_VIDEO_SURFACE_START_RENDERING,
+ VLC_VIDEO_SURFACE_FINISHED_RENDERING,
+} vlc_video_surface_control_t;
+
+typedef int (*vlc_video_surface_control)(void* opaque,
+ vlc_video_surface_control_t control,
+ const void *input,
+ void *output);
+
+static inline void *vlc_video_surface_setup(void *opaque, vlc_video_surface_control ctrl, bool hardware_decoding)
+{
+ vlc_video_surface_device_cfg_t cfg = { .hardware_decoding = hardware_decoding };
+ vlc_video_surface_device_setup_t result = { .device_context = NULL };
+ if (ctrl(opaque, VLC_VIDEO_SURFACE_DEVICE_SETUP, &cfg, &result) != 0)
+ return NULL;
+ return result.device_context;
+}
+
+static inline void vlc_video_surface_cleanup(void *opaque, vlc_video_surface_control ctrl)
+{
+ ctrl(opaque, VLC_VIDEO_SURFACE_DEVICE_CLEANUP, 0, NULL);
+}
+
+static inline bool vlc_video_surface_update_output(void *opaque, vlc_video_surface_control ctrl,
+ const vlc_video_surface_cfg_t *cfg,
+ video_surface_output_cfg_t *out)
+{
+ return ctrl(opaque, VLC_VIDEO_SURFACE_UPDATE_OUTPUT, cfg, out) == 0;
+}
+
+static inline void vlc_video_surface_swap(void *opaque, vlc_video_surface_control ctrl)
+{
+ ctrl(opaque, VLC_VIDEO_SURFACE_SWAP, 0, NULL);
+}
+
+static inline bool vlc_video_surface_start_rendering(void *opaque, vlc_video_surface_control ctrl)
+{
+ return ctrl(opaque, VLC_VIDEO_SURFACE_START_RENDERING, 0, NULL) == 0;
+}
+
+static inline void vlc_video_surface_finished_rendering(void *opaque, vlc_video_surface_control ctrl)
+{
+ ctrl(opaque, VLC_VIDEO_SURFACE_FINISHED_RENDERING, 0, NULL);
+}
+
/** @} */
#endif /* VLC_VOUT_DISPLAY_H */
--
2.17.1
More information about the vlc-devel
mailing list