[vlc-commits] [Git][videolan/vlc][master] 2 commits: vout: update the display fit dynamically

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Apr 15 05:48:29 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
dfdc613d by Steve Lhomme at 2024-04-15T05:27:09+00:00
vout: update the display fit dynamically

- - - - -
ffd9f613 by Steve Lhomme at 2024-04-15T05:27:09+00:00
libvlc: add API to get/set the video fit mode

- - - - -


5 changed files:

- include/vlc/libvlc_media_player.h
- lib/libvlc.sym
- lib/media_player.c
- lib/video.c
- src/video_output/vout_intf.c


Changes:

=====================================
include/vlc/libvlc_media_player.h
=====================================
@@ -147,6 +147,17 @@ typedef enum libvlc_position_t {
     libvlc_position_bottom_right
 } libvlc_position_t;
 
+/**
+ * Enumeration of values used to set the video fitting inside the display area.
+ */
+typedef enum libvlc_video_fit_mode_t {
+    libvlc_video_fit_none,    /**< Explicit zoom set by \ref libvlc_video_set_scale */
+    libvlc_video_fit_smaller, /**< Fit inside / to smallest display dimension */
+    libvlc_video_fit_larger,  /**< Fit outside / to largest display dimension */
+    libvlc_video_fit_width,   /**< Fit to display width */
+    libvlc_video_fit_height,  /**< Fit to display height */
+} libvlc_video_fit_mode_t;
+
 /**
  * Enumeration of teletext keys than can be passed via
  * libvlc_video_set_teletext()
@@ -1881,6 +1892,23 @@ LIBVLC_API char *libvlc_video_get_aspect_ratio( libvlc_media_player_t *p_mi );
  */
 LIBVLC_API void libvlc_video_set_aspect_ratio( libvlc_media_player_t *p_mi, const char *psz_aspect );
 
+/**
+ * Get current video display fit mode.
+ *
+ * \param p_mi the media player
+ * \return the video display fit mode.
+ */
+LIBVLC_API libvlc_video_fit_mode_t libvlc_video_get_display_fit( libvlc_media_player_t *p_mi );
+
+/**
+ * Set new video display fit.
+ *
+ * \param p_mi the media player
+ * \param fit new display fit mode
+ * \note Invalid fit mode are ignored.
+ */
+LIBVLC_API void libvlc_video_set_display_fit( libvlc_media_player_t *p_mi, libvlc_video_fit_mode_t fit );
+
 /**
  * Create a video viewpoint structure.
  *


=====================================
lib/libvlc.sym
=====================================
@@ -251,6 +251,8 @@ libvlc_video_set_callbacks
 libvlc_video_set_crop_ratio
 libvlc_video_set_crop_window
 libvlc_video_set_crop_border
+libvlc_video_get_display_fit
+libvlc_video_set_display_fit
 libvlc_video_set_deinterlace
 libvlc_video_set_format
 libvlc_video_set_format_callbacks


=====================================
lib/media_player.c
=====================================
@@ -689,6 +689,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
 
     var_Create (mp, "fullscreen", VLC_VAR_BOOL);
     var_Create (mp, "autoscale", VLC_VAR_BOOL | VLC_VAR_DOINHERIT);
+    var_Create (mp, "fit", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
     var_Create (mp, "zoom", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT);
     var_Create (mp, "aspect-ratio", VLC_VAR_STRING);
     var_Create (mp, "crop", VLC_VAR_STRING);


=====================================
lib/video.c
=====================================
@@ -252,6 +252,28 @@ void libvlc_video_set_aspect_ratio( libvlc_media_player_t *p_mi,
     free (pp_vouts);
 }
 
+libvlc_video_fit_mode_t libvlc_video_get_display_fit( libvlc_media_player_t *p_mi )
+{
+    return var_GetInteger (p_mi, "fit");
+}
+
+void libvlc_video_set_display_fit( libvlc_media_player_t *p_mi, libvlc_video_fit_mode_t fit )
+{
+    var_SetInteger (p_mi, "fit", fit);
+
+    size_t n;
+    vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
+    for (size_t i = 0; i < n; i++)
+    {
+        vout_thread_t *p_vout = pp_vouts[i];
+
+        var_SetInteger (p_vout, "fit", fit);
+        vout_Release(p_vout);
+    }
+    free (pp_vouts);
+}
+
+
 libvlc_video_viewpoint_t *libvlc_video_new_viewpoint(void)
 {
     libvlc_video_viewpoint_t *p_vp = malloc(sizeof *p_vp);


=====================================
src/video_output/vout_intf.c
=====================================
@@ -58,6 +58,8 @@ static int AspectCallback( vlc_object_t *, char const *,
                            vlc_value_t, vlc_value_t, void * );
 static int AutoScaleCallback( vlc_object_t *, char const *,
                               vlc_value_t, vlc_value_t, void * );
+static int FitCallback( vlc_object_t *, char const *,
+                        vlc_value_t, vlc_value_t, void * );
 static int ZoomCallback( vlc_object_t *, char const *,
                          vlc_value_t, vlc_value_t, void * );
 static int AboveCallback( vlc_object_t *, char const *,
@@ -307,6 +309,7 @@ void vout_CreateVars( vout_thread_t *p_vout )
 void vout_IntfInit( vout_thread_t *p_vout )
 {
     var_AddCallback( p_vout, "autoscale", AutoScaleCallback, NULL );
+    var_AddCallback( p_vout, "fit", FitCallback, NULL );
     var_AddCallback( p_vout, "zoom", ZoomCallback, NULL );
     var_AddCallback( p_vout, "crop-left", CropBorderCallback, NULL );
     var_AddCallback( p_vout, "crop-top", CropBorderCallback, NULL );
@@ -358,6 +361,7 @@ void vout_IntfDeinit(vlc_object_t *obj)
     var_DelCallback(obj, "crop-top", CropBorderCallback, NULL);
     var_DelCallback(obj, "crop-left", CropBorderCallback, NULL);
     var_DelCallback(obj, "zoom", ZoomCallback, NULL);
+    var_DelCallback(obj, "fit", FitCallback, NULL);
     var_DelCallback(obj, "autoscale", AutoScaleCallback, NULL);
 }
 
@@ -574,6 +578,17 @@ static int AutoScaleCallback( vlc_object_t *obj, char const *name,
     return VLC_SUCCESS;
 }
 
+static int FitCallback( vlc_object_t *obj, char const *name,
+                        vlc_value_t prev, vlc_value_t cur, void *data )
+{
+    vout_thread_t *p_vout = (vout_thread_t *)obj;
+    enum vlc_video_fitting fit = cur.i_int;
+
+    (void) name; (void) prev; (void) data;
+    vout_ChangeDisplayFitting(p_vout, fit);
+    return VLC_SUCCESS;
+}
+
 static int ZoomCallback( vlc_object_t *obj, char const *name,
                          vlc_value_t prev, vlc_value_t cur, void *data )
 {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/dface0a07e0b74cddbabd2de64c54848bb93e784...ffd9f613a74b2e0e039f9508044d0911cdc4dfaf

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/dface0a07e0b74cddbabd2de64c54848bb93e784...ffd9f613a74b2e0e039f9508044d0911cdc4dfaf
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list