[vlc-commits] macosx/player controller: expose subtitles FPS

Felix Paul Kühne git at videolan.org
Sun Mar 24 19:10:46 CET 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sun Mar 24 18:59:35 2019 +0100| [c23839de0240ebec339e64f774cef2b09fa08bf4] | committer: Felix Paul Kühne

macosx/player controller: expose subtitles FPS

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c23839de0240ebec339e64f774cef2b09fa08bf4
---

 modules/gui/macosx/playlist/VLCPlayerController.h | 13 +++++++++++
 modules/gui/macosx/playlist/VLCPlayerController.m | 27 ++++++++++++++++++++++-
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/modules/gui/macosx/playlist/VLCPlayerController.h b/modules/gui/macosx/playlist/VLCPlayerController.h
index 06b5d65a33..aac55005be 100644
--- a/modules/gui/macosx/playlist/VLCPlayerController.h
+++ b/modules/gui/macosx/playlist/VLCPlayerController.h
@@ -129,6 +129,12 @@ extern NSString *VLCPlayerAudioDelayChanged;
 extern NSString *VLCPlayerSubtitlesDelayChanged;
 
 /**
+ * Listen to VLCPlayerSubtitlesFPSChanged to be notified if the subtitles FPS of the current media changes
+ * @note the affected player object will be the object of the notification
+ */
+extern NSString *VLCPlayerSubtitlesFPSChanged;
+
+/**
  * Listen to VLCPlayerRecordingChanged to be notified if the recording state of the current media changes
  * @note the affected player object will be the object of the notification
  */
@@ -480,6 +486,13 @@ extern NSString *VLCPlayerMuteChanged;
 @property (readwrite, nonatomic) vlc_tick_t subtitlesDelay;
 
 /**
+ * the subtitles fps to correct mismatch between video and text
+ * the default value shall be 1.0
+ * @note listen to VLCPlayerSubtitlesFPSChanged to be notified about changes to this property
+ */
+ at property (readwrite, nonatomic) float subtitlesFPS;
+
+/**
  * a scale factor for text based subtitles, range 10 - 500, default 100
  * @warning this does not have any effect on bitmapped subtitles
  */
diff --git a/modules/gui/macosx/playlist/VLCPlayerController.m b/modules/gui/macosx/playlist/VLCPlayerController.m
index 8931ffa645..5d899b7805 100644
--- a/modules/gui/macosx/playlist/VLCPlayerController.m
+++ b/modules/gui/macosx/playlist/VLCPlayerController.m
@@ -48,6 +48,7 @@ NSString *VLCPlayerTeletextPageChanged = @"VLCPlayerTeletextPageChanged";
 NSString *VLCPlayerTeletextTransparencyChanged = @"VLCPlayerTeletextTransparencyChanged";
 NSString *VLCPlayerAudioDelayChanged = @"VLCPlayerAudioDelayChanged";
 NSString *VLCPlayerSubtitlesDelayChanged = @"VLCPlayerSubtitlesDelayChanged";
+NSString *VLCPlayerSubtitlesFPSChanged = @"VLCPlayerSubtitlesFPSChanged";
 NSString *VLCPlayerSubtitleTextScalingFactorChanged = @"VLCPlayerSubtitleTextScalingFactorChanged";
 NSString *VLCPlayerRecordingChanged = @"VLCPlayerRecordingChanged";
 NSString *VLCPlayerRendererChanged = @"VLCPlayerRendererChanged";
@@ -95,6 +96,7 @@ NSString *VLCPlayerMuteChanged = @"VLCPlayerMuteChanged";
 - (void)audioDelayChanged:(vlc_tick_t)audioDelay;
 - (void)rendererChanged:(vlc_renderer_item_t *)newRendererItem;
 - (void)subtitlesDelayChanged:(vlc_tick_t)subtitlesDelay;
+- (void)subtitlesFPSChanged:(float)subtitlesFPS;
 - (void)recordingChanged:(BOOL)recording;
 - (void)inputStatsUpdated:(VLCInputStats *)inputStats;
 - (void)stopActionChanged:(enum vlc_player_media_stopped_action)stoppedAction;
@@ -263,6 +265,15 @@ static void cb_player_subtitle_delay_changed(vlc_player_t *p_player, vlc_tick_t
     });
 }
 
+static void cb_player_associated_subs_fps_changed(vlc_player_t *p_player, float subs_fps, void *p_data)
+{
+    VLC_UNUSED(p_player);
+    dispatch_async(dispatch_get_main_queue(), ^{
+        VLCPlayerController *playerController = (__bridge VLCPlayerController *)p_data;
+        [playerController subtitlesFPSChanged:subs_fps];
+    });
+}
+
 static void cb_player_renderer_changed(vlc_player_t *p_player,
                                        vlc_renderer_item_t *p_new_renderer,
                                        void *p_data)
@@ -375,7 +386,7 @@ static const struct vlc_player_cbs player_callbacks = {
     cb_player_teletext_transparency_changed,
     cb_player_audio_delay_changed,
     cb_player_subtitle_delay_changed,
-    NULL, //cb_player_associated_subs_fps_changed,
+    cb_player_associated_subs_fps_changed,
     cb_player_renderer_changed,
     cb_player_record_changed,
     NULL, //cb_player_signal_changed,
@@ -1044,6 +1055,20 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = {
     vlc_player_Unlock(_p_player);
 }
 
+- (void)subtitlesFPSChanged:(float)subtitlesFPS
+{
+    _subtitlesFPS = subtitlesFPS;
+    [_defaultNotificationCenter postNotificationName:VLCPlayerSubtitlesFPSChanged
+                                              object:self];
+}
+
+- (void)setSubtitlesFPS:(float)subtitlesFPS
+{
+    vlc_player_Lock(_p_player);
+    vlc_player_SetAssociatedSubsFPS(_p_player, subtitlesFPS);
+    vlc_player_Unlock(_p_player);
+}
+
 - (unsigned int)subtitleTextScalingFactor
 {
     unsigned int ret = 100;



More information about the vlc-commits mailing list