[vlc-devel] [PATCH] lib: add libvlc_video_set_spu_text_scale API

Mark Lee mark.lee at capricasoftware.co.uk
Mon Apr 20 14:01:40 CEST 2020


---
 include/vlc/libvlc_media_player.h | 19 +++++++++++++++++++
 lib/libvlc.sym                    |  1 +
 lib/video.c                       | 11 +++++++++++
 3 files changed, 31 insertions(+)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 5e0255a10a..a6f5fbf8e5 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -1544,6 +1544,25 @@ LIBVLC_API int libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu );
  */
 LIBVLC_API int64_t libvlc_video_get_spu_delay( libvlc_media_player_t *p_mi );
 
+/**
+ * Set the subtitle text scale.
+ *
+ * The scale factor is expressed as a percentage of the default size, where
+ * 1.0 represents 100 percent.
+ *
+ * A value of 0.5 would result in text half the normal size, and a value of 2.0
+ * would result in text twice the normal size.
+ *
+ * The minimum acceptable value for the scale factor is 0.1.
+ *
+ * The maximum is 5.0 (five times normal size).
+ *
+ * \param p_mi media player
+ * \param f_scale scale factor in the range [0.1;5.0] (default: 1.0)
+ * \version LibVLC 4.0.0 or later
+ */
+LIBVLC_API void libvlc_video_set_spu_text_scale( libvlc_media_player_t *p_mi, float f_scale );
+
 /**
  * Set the subtitle delay. This affects the timing of when the subtitle will
  * be displayed. Positive values result in subtitles being displayed later,
diff --git a/lib/libvlc.sym b/lib/libvlc.sym
index 67e4dcf748..5623ec87d5 100644
--- a/lib/libvlc.sym
+++ b/lib/libvlc.sym
@@ -248,6 +248,7 @@ libvlc_video_set_mouse_input
 libvlc_video_set_scale
 libvlc_video_set_spu
 libvlc_video_set_spu_delay
+libvlc_video_set_spu_text_scale
 libvlc_video_set_teletext
 libvlc_video_set_track
 libvlc_video_take_snapshot
diff --git a/lib/video.c b/lib/video.c
index 6f8e6d7f59..85519fb904 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -362,6 +362,17 @@ int libvlc_video_set_spu_delay( libvlc_media_player_t *p_mi,
     return 0;
 }
 
+void libvlc_video_set_spu_text_scale( libvlc_media_player_t *p_mi,
+                                      float f_scale )
+{
+    vlc_player_t *player = p_mi->player;
+    vlc_player_Lock(player);
+
+    vlc_player_SetSubtitleTextScale(player, lroundf(f_scale * 100.f));
+
+    vlc_player_Unlock(player);
+}
+
 static void libvlc_video_set_crop(libvlc_media_player_t *mp,
                                   const char *geometry)
 {
-- 
2.17.1



More information about the vlc-devel mailing list