[vlc-devel] [PATCH] libvlc: handle the report size callback in the wextern window module

Steve Lhomme robux4 at ycbcr.xyz
Tue Jun 11 16:11:31 CEST 2019


On 2019-06-09 10:41, Rémi Denis-Courmont wrote:
> Le perjantaina 7. kesäkuuta 2019, 11.15.44 EEST Steve Lhomme a écrit :
>> This way it can work for all modules that render externally. And the code is
>> generic. It also makes more sense to handle the window size in the window
>> module.
>> ---
>>   doc/libvlc/d3d11_player.cpp             | 30 +++++------
>>   doc/libvlc/d3d9_player.c                | 29 ++++++-----
>>   include/vlc/libvlc_media_player.h       | 27 +++++++---
>>   lib/media_player.c                      |  3 ++
>>   modules/video_output/wextern.c          | 66 +++++++++++++++++++++----
>>   modules/video_output/win32/direct3d11.c |  9 ----
>>   modules/video_output/win32/direct3d9.c  |  3 --
>>   7 files changed, 110 insertions(+), 57 deletions(-)
> 
>> diff --git a/include/vlc/libvlc_media_player.h
>> b/include/vlc/libvlc_media_player.h index c1529fdecc..2920605ae4 100644
>> --- a/include/vlc/libvlc_media_player.h
>> +++ b/include/vlc/libvlc_media_player.h
>> @@ -655,6 +647,23 @@ typedef bool( *libvlc_video_direct3d_device_setup_cb )(
>> void **opaque, */
>>   typedef void( *libvlc_video_direct3d_device_cleanup_cb )( void *opaque );
>>
>> +/** Set the callback to call when the host app resizes the rendering area.
>> + *
>> + * This allows text rendering and aspect ratio to be handled properly when
>> the host
>> + * rendering size changes.
>> + *
>> + * It may be called before the \ref libvlc_video_direct3d_device_setup_cb
>> callback.
>> + *
>> + * \param opaque private pointer set on the opaque parameter of @a
>> libvlc_video_direct3d_device_setup_cb() [IN]
>> + * \param report_size_change
>> callback to use when the size changes. [IN]
>> + *        The callback is
>> valid until another call to \ref libvlc_video_direct3d_set_resize_cb
>> + *
>>      is done. This may be called from any thread.
>> + * \param report_opaque private pointer to pass to the \ref
>> report_size_change callback. [IN]
>> + */
>> +typedef void( *libvlc_video_direct3d_set_resize_cb )( void *opaque,
>> +                                                      void
>> (*report_size_change)(void *report_opaque, unsigned width, unsigned
>> height), +                                                      void
>> *report_opaque ); +
>>   typedef struct
>>   {
>>       unsigned width;                        /** rendering video width in
>> pixel */
> 
> Passing a callback to a callback assumes that the host application only ever
> wants to change the size when LibVLC wants to. I don't think we can generally
> make that assumption.

The callback called by the host is not changed, nor the moment it can be 
called or its validity (before cleanup is called).

The only thing that changes is when the host is given this callback+opaque.

This patch could be split in 2:
- moving the callback set to the host outside of the setup callback
- call the resize callback of the host from wextern rather than each 
module individually.

> AFAICT, we need a regular (not callback) LibVLC function that specifies the
> window, the resolution - which means we need to be able to track window
> instances.

In an ideal world, yes. But that's not what we have now nor likely in 
4.0. It seems quite tricky to do IMO.

> Also, this assumes that changing the size can be done asynchronously. In
> general, that's not true. For instance, X11 works that way. But Wayland needs
> to wait until the size change has been seen by the display before it
> acknowledges a size change. Some other backends may have even stronger
> constraints.
> 
> -- 
> レミ・デニ-クールモン
> http://www.remlab.net/
> 
> 
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
> 


More information about the vlc-devel mailing list