vlc | branch: master | Marvin Scholz <epira...@gmail.com> | Thu Jun 16 23:54:18 
2016 +0200| [6f2093a7e443b06b6fd13346eddb1fff6c7f0e7b] | committer: Felix Paul 
Kühne

macosx: Add Renderer Dialog

This adds a dialog to choose a renderer discovered with VLCRendererDiscovery, 
this allows for example to render to Chromecast in the future.

Additionally edited the Makefile for the new classes to be compiled.

Signed-off-by: Felix Paul Kühne <fkue...@videolan.org>

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

 modules/gui/macosx/Makefile.am         |    5 +-
 modules/gui/macosx/VLCRendererDialog.h |   35 ++++++++
 modules/gui/macosx/VLCRendererDialog.m |  155 ++++++++++++++++++++++++++++++++
 3 files changed, 194 insertions(+), 1 deletion(-)

diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am
index 1210d47..787f1cb 100644
--- a/modules/gui/macosx/Makefile.am
+++ b/modules/gui/macosx/Makefile.am
@@ -81,4 +81,7 @@ libmacosx_plugin_la_SOURCES = \
        VLCHUDButtonCell.h VLCHUDButtonCell.m \
        VLCHUDCheckboxCell.h VLCHUDCheckboxCell.m \
        VLCHUDRadiobuttonCell.h VLCHUDRadiobuttonCell.m \
-       VLCHUDTextFieldCell.h VLCHUDTextFieldCell.m
+       VLCHUDTextFieldCell.h VLCHUDTextFieldCell.m \
+       VLCRendererDiscovery.h VLCRendererDiscovery.m \
+       VLCRendererItem.h VLCRendererItem.m \
+       VLCRendererDialog.h VLCRendererDialog.m
diff --git a/modules/gui/macosx/VLCRendererDialog.h 
b/modules/gui/macosx/VLCRendererDialog.h
new file mode 100644
index 0000000..4999294
--- /dev/null
+++ b/modules/gui/macosx/VLCRendererDialog.h
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * VLCRendererDialog.h: View controller class for the renderer dialog
+ *****************************************************************************
+ * Copyright (C) 2016 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Marvin Scholz <epirat07 at gmail dot com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, 
USA.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+#import "VLCRendererItem.h"
+#import "VLCRendererDiscovery.h"
+
+@interface VLCRendererDialog : NSWindowController 
<VLCRendererDiscoveryDelegate, NSWindowDelegate>
+
+@property NSMutableArray<VLCRendererItem*> *rendererItems;
+
+- (IBAction)selectRenderer:(id)sender;
+
+@end
diff --git a/modules/gui/macosx/VLCRendererDialog.m 
b/modules/gui/macosx/VLCRendererDialog.m
new file mode 100644
index 0000000..f2f2d16
--- /dev/null
+++ b/modules/gui/macosx/VLCRendererDialog.m
@@ -0,0 +1,155 @@
+/*****************************************************************************
+ * VLCRendererDialog.m: View controller class for the renderer dialog
+ *****************************************************************************
+ * Copyright (C) 2016 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Marvin Scholz <epirat07 at gmail dot com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, 
USA.
+ *****************************************************************************/
+
+#import "VLCRendererDialog.h"
+
+#import "VLCRendererItem.h"
+#import "intf.h"
+
+#include <vlc_renderer_discovery.h>
+
+
+@interface VLCRendererDialog ()
+{
+    IBOutlet NSTableView *tableView;
+    IBOutlet NSArrayController *arrayController;
+
+    NSMutableArray<VLCRendererDiscovery*> *renderer_discoveries;
+
+    intf_thread_t          *p_intf;
+    vlc_renderer_discovery *p_rd;
+}
+@end
+
+@implementation VLCRendererDialog
+
+- (id)init
+{
+    self = [super initWithWindowNibName:@"VLCRendererDialog"];
+    if (self) {
+        _rendererItems = [[NSMutableArray alloc] init];
+        renderer_discoveries = [[NSMutableArray alloc] initWithCapacity:1];
+        p_intf = getIntf();
+    }
+    return self;
+}
+
+- (void)dealloc
+{
+    [self stopRendererDiscoveries];
+    [self clearRendererDiscoveries];
+}
+
+- (void)windowDidLoad
+{
+    [super windowDidLoad];
+    [self.window setDelegate:self];
+    [self.window setTitle:_NS("Renderer selection")];
+
+    [self loadRendererDiscoveries];
+}
+
+- (void)windowWillClose:(NSNotification *)notification
+{
+    // Stop all renderer discoveries here!
+    [self stopRendererDiscoveries];
+}
+
+- (void)showWindow:(id)sender
+{
+    // Start all renderer discoveries here!
+    [self startRendererDiscoveries];
+    return [super showWindow:sender];
+}
+
+- (void)loadRendererDiscoveries
+{
+    playlist_t *playlist = pl_Get(p_intf);
+
+    // Service Discovery subnodes
+    char **ppsz_longnames;
+    char **ppsz_names;
+
+    if (vlc_rd_get_names(playlist, &ppsz_names, &ppsz_longnames) != 
VLC_SUCCESS) {
+        return;
+    }
+    char **ppsz_name = ppsz_names;
+    char **ppsz_longname = ppsz_longnames;
+
+    for( ; *ppsz_name; ppsz_name++, ppsz_longname++) {
+        VLCRendererDiscovery *dc = [[VLCRendererDiscovery alloc] 
initWithName:*ppsz_name andLongname:*ppsz_longname];
+        [dc setDelegate:self];
+        [dc startDiscovery];
+        [renderer_discoveries addObject:dc];
+    }
+    free(ppsz_names);
+    free(ppsz_longnames);
+}
+
+- (void)clearRendererDiscoveries
+{
+    [renderer_discoveries removeAllObjects];
+}
+
+- (void)startRendererDiscoveries
+{
+    for (VLCRendererDiscovery *dc in renderer_discoveries) {
+        [dc startDiscovery];
+    }
+}
+
+- (void)stopRendererDiscoveries
+{
+    for (VLCRendererDiscovery *dc in renderer_discoveries) {
+        [dc stopDiscovery];
+    }
+}
+
+- (IBAction)selectRenderer:(id)sender
+{
+    playlist_t *playlist = pl_Get(p_intf);
+    VLCRendererItem* item = [arrayController.selectedObjects firstObject];
+    if (item) {
+        [item setSoutForPlaylist:playlist];
+    } else {
+        [self unsetSoutForPlaylist:playlist];
+    }
+}
+
+- (void)unsetSoutForPlaylist:(playlist_t*)playlist
+{
+    var_SetString(playlist, "sout", "");
+}
+
+#pragma mark VLCRendererDiscoveryDelegate methods
+- (void)addedRendererItem:(VLCRendererItem *)item from:(VLCRendererDiscovery 
*)sender
+{
+    [arrayController addObject:item];
+}
+
+- (void)removedRendererItem:(VLCRendererItem *)item from:(VLCRendererDiscovery 
*)sender
+{
+    [arrayController removeObject:item];
+}
+
+@end

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to