[vlc-commits] macosx/player controller: expose aout and vout threads

Felix Paul Kühne git at videolan.org
Mon Mar 11 11:14:23 CET 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Mon Mar 11 10:30:27 2019 +0100| [a2a239fd4d73a2df5e433664d9dfe31693a11daf] | committer: Felix Paul Kühne

macosx/player controller: expose aout and vout threads

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

 modules/gui/macosx/playlist/VLCPlayerController.h | 35 +++++++++++
 modules/gui/macosx/playlist/VLCPlayerController.m | 72 ++++++++++++++++++++++-
 2 files changed, 106 insertions(+), 1 deletion(-)

diff --git a/modules/gui/macosx/playlist/VLCPlayerController.h b/modules/gui/macosx/playlist/VLCPlayerController.h
index 62e7c84313..e44f76ec79 100644
--- a/modules/gui/macosx/playlist/VLCPlayerController.h
+++ b/modules/gui/macosx/playlist/VLCPlayerController.h
@@ -149,6 +149,12 @@ extern NSString *VLCPlayerStatisticsUpdated;
 extern NSString *VLCPlayerFullscreenChanged;
 
 /**
+ * Listen to VLCPlayerListOfVideoOutputThreadsChanged to be notified when a video output thread was added or removed
+ * @note the affected player object will be the object of the notification
+ */
+extern NSString *VLCPlayerListOfVideoOutputThreadsChanged;
+
+/**
  * Listen to VLCPlayerWallpaperModeChanged to be notified whether the fullscreen state of the video output changes
  * @note the affected player object will be the object of the notification
  */
@@ -494,6 +500,28 @@ extern NSString *VLCPlayerMuteChanged;
 #pragma mark - video output properties
 
 /**
+ * the main video output thread
+ * @warning the returned vout_thread_t * must be released with vout_Release().
+ * @note listen to VLCPlayerListOfVideoOutputThreadsChanged to be notified about changes
+ * @return the current video output thread or NULL if there is none
+ */
+ at property (readonly, nullable) vout_thread_t *mainVideoOutputThread;
+
+/**
+ * the video output embedded in the current key window
+ * @warning the returned vout_thread_t * must be released with vout_Release().
+ * @return the current video output thread for the key window or the main video output thread or NULL if there is none
+ */
+ at property (readonly, nullable) vout_thread_t *videoOutputThreadForKeyWindow;
+
+/**
+ * an array holding all current video output threads
+ * @warning the returned vout_thread_t * instances must be individually released with vout_Release().
+ * @note listen to VLCPlayerListOfVideoOutputThreadsChanged to be notified about changes
+ */
+ at property (readonly, nullable, copy) NSArray<NSValue *> *allVideoOutputThreads;
+
+/**
  * indicates whether video is displayed in fullscreen or shall to
  * @note listen to VLCPlayerFullscreenChanged to be notified about changes to this property
  */
@@ -545,6 +573,13 @@ extern NSString *VLCPlayerMuteChanged;
  */
 - (void)toggleMute;
 
+/**
+ * the main audio output thread
+ * @warning the returned vout_thread_t * must be released with aout_Release().
+ * @return the current audio output instance or NULL if there is none
+ */
+ at property (readonly, nullable) audio_output_t *mainAudioOutput;
+
 @end
 
 @interface VLCInputStats : NSObject
diff --git a/modules/gui/macosx/playlist/VLCPlayerController.m b/modules/gui/macosx/playlist/VLCPlayerController.m
index 81e484d1a4..b19e1f4cbf 100644
--- a/modules/gui/macosx/playlist/VLCPlayerController.m
+++ b/modules/gui/macosx/playlist/VLCPlayerController.m
@@ -26,6 +26,7 @@
 #import "os-integration/VLCRemoteControlService.h"
 #import "os-integration/iTunes.h"
 #import "os-integration/Spotify.h"
+#import "windows/video/VLCVoutView.h"
 
 #import <MediaPlayer/MediaPlayer.h>
 
@@ -53,6 +54,7 @@ NSString *VLCPlayerInputStats = @"VLCPlayerInputStats";
 NSString *VLCPlayerStatisticsUpdated = @"VLCPlayerStatisticsUpdated";
 NSString *VLCPlayerFullscreenChanged = @"VLCPlayerFullscreenChanged";
 NSString *VLCPlayerWallpaperModeChanged = @"VLCPlayerWallpaperModeChanged";
+NSString *VLCPlayerListOfVideoOutputThreadsChanged = @"VLCPlayerListOfVideoOutputThreadsChanged";
 NSString *VLCPlayerVolumeChanged = @"VLCPlayerVolumeChanged";
 NSString *VLCPlayerMuteChanged = @"VLCPlayerMuteChanged";
 
@@ -95,6 +97,7 @@ NSString *VLCPlayerMuteChanged = @"VLCPlayerMuteChanged";
 - (void)inputStatsUpdated:(VLCInputStats *)inputStats;
 - (void)stopActionChanged:(enum vlc_player_media_stopped_action)stoppedAction;
 - (void)metaDataChangedForInput:(input_item_t *)inputItem;
+- (void)voutListUpdated;
 
 /* video */
 - (void)fullscreenChanged:(BOOL)isFullscreen;
@@ -324,6 +327,19 @@ static void cb_player_item_meta_changed(vlc_player_t *p_player,
     });
 }
 
+static void cb_player_vout_list_changed(vlc_player_t *p_player,
+                                        enum vlc_player_list_action action,
+                                        vout_thread_t *p_vout,
+                                        void *p_data)
+{
+    VLC_UNUSED(p_player);
+    VLC_UNUSED(p_vout);
+    dispatch_async(dispatch_get_main_queue(), ^{
+        VLCPlayerController *playerController = (__bridge VLCPlayerController *)p_data;
+        [playerController voutListUpdated];
+    });
+}
+
 static const struct vlc_player_cbs player_callbacks = {
     cb_player_current_media_changed,
     cb_player_state_changed,
@@ -356,7 +372,7 @@ static const struct vlc_player_cbs player_callbacks = {
     cb_player_item_meta_changed,
     NULL, //cb_player_item_epg_changed,
     NULL, //cb_player_subitems_changed,
-    NULL, //cb_player_vout_list_changed,
+    cb_player_vout_list_changed,
 };
 
 #pragma mark - video specific callback implementations
@@ -1101,6 +1117,55 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = {
     vlc_player_vout_Snapshot(_p_player);
 }
 
+- (void)voutListUpdated
+{
+    [_defaultNotificationCenter postNotificationName:VLCPlayerListOfVideoOutputThreadsChanged
+                                              object:self];
+}
+
+- (vout_thread_t *)mainVideoOutputThread
+{
+    return vlc_player_vout_Hold(_p_player);
+}
+
+- (vout_thread_t *)videoOutputThreadForKeyWindow
+{
+    vout_thread_t *p_vout = nil;
+
+    id currentWindow = [NSApp keyWindow];
+    if ([currentWindow respondsToSelector:@selector(videoView)]) {
+        VLCVoutView *videoView = [currentWindow videoView];
+        if (videoView) {
+            p_vout = [videoView voutThread];
+        }
+    }
+
+    if (!p_vout)
+        p_vout = [self mainVideoOutputThread];
+
+    return p_vout;
+}
+
+- (NSArray<NSValue *> *)allVideoOutputThreads
+{
+    size_t numberOfVoutThreads = 0;
+    vout_thread_t **pp_vouts = vlc_player_vout_HoldAll(_p_player, &numberOfVoutThreads);
+    if (numberOfVoutThreads == 0) {
+        return nil;
+    }
+
+    NSMutableArray<NSValue *> *vouts = [NSMutableArray arrayWithCapacity:numberOfVoutThreads];
+
+    for (size_t i = 0; i < numberOfVoutThreads; ++i)
+    {
+        assert(pp_vouts[i]);
+        [vouts addObject:[NSValue valueWithPointer:pp_vouts[i]]];
+    }
+
+    free(pp_vouts);
+    return vouts;
+}
+
 #pragma mark - audio specific delegation
 
 - (void)volumeChanged:(float)volume
@@ -1142,6 +1207,11 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = {
     vlc_player_aout_Mute(_p_player, !_mute);
 }
 
+- (audio_output_t *)mainAudioOutput
+{
+    return vlc_player_aout_Hold(_p_player);
+}
+
 @end
 
 @implementation VLCInputStats



More information about the vlc-commits mailing list