Commit 3cc9fc3f authored by Soomin Lee's avatar Soomin Lee Committed by Carola Nitz

Renderer API integration

Signed-off-by: 's avatarCarola Nitz <nitz.carola@googlemail.com>
(cherry picked from commit 399f6d26)
parent fbd08913
/*****************************************************************************
* VLCRendererItem+Init.h
*****************************************************************************
* Copyright © 2018 VLC authors, VideoLAN
* Copyright © 2018 Videolabs
*
* Authors: Soomin Lee<bubu@mikan.io>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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 "VLCRendererItem.h"
/**
* VLCRendererItem internal category in order to hide the C part to the users
*/
@interface VLCRendererItem (Internal)
/**
* Initializer method to create an VLCRendererItem with an libvlc_renderer_item_t *
*
* \param renderer item
* \note This initializer is not meant to be used externally
* \return An instance of `VLCRendererItem`, can be nil
*/
- (instancetype _Nullable)initWithCItem:(libvlc_renderer_item_t * _Nonnull)item;
/**
* Returns the C renderer item
* \return Renderer item
*/
- (libvlc_renderer_item_t * _Nonnull)rendererItem;
@end
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#import <MobileVLCKit/VLCMediaThumbnailer.h> #import <MobileVLCKit/VLCMediaThumbnailer.h>
#import <MobileVLCKit/VLCDialogProvider.h> #import <MobileVLCKit/VLCDialogProvider.h>
#import <MobileVLCKit/VLCTime.h> #import <MobileVLCKit/VLCTime.h>
#import <MobileVLCKit/VLCRendererDiscoverer.h>
#import <MobileVLCKit/VLCRendererItem.h>
@class VLCMedia; @class VLCMedia;
@class VLCMediaLibrary; @class VLCMediaLibrary;
...@@ -42,3 +44,6 @@ ...@@ -42,3 +44,6 @@
@class VLCMediaListPlayer; @class VLCMediaListPlayer;
@class VLCMediaPlayer; @class VLCMediaPlayer;
@class VLCDialogProvider; @class VLCDialogProvider;
@class VLCRendererDiscoverer;
@class VLCRendererDiscovererDescription;
@class VLCRendererItem;
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#endif #endif
@class VLCLibrary; @class VLCLibrary;
@class VLCRendererItem;
/* Notification Messages */ /* Notification Messages */
extern NSString *const VLCMediaPlayerTimeChanged; extern NSString *const VLCMediaPlayerTimeChanged;
...@@ -820,4 +821,17 @@ extern NSString *const VLCTitleDescriptionIsMenu; ...@@ -820,4 +821,17 @@ extern NSString *const VLCTitleDescriptionIsMenu;
@property (NS_NONATOMIC_IOSONLY, readonly) UIImage *lastSnapshot; @property (NS_NONATOMIC_IOSONLY, readonly) UIImage *lastSnapshot;
#endif #endif
#pragma mark -
#pragma mark Renderer
/**
* Sets a `VLCRendererItem` to the current media player
* \param item `VLCRendererItem` discovered by `VLCRendererDiscoverer`
* \return `YES` if successful, `NO` otherwise
* \note Must be called before the first call of `play` to take effect
* \see VLCRendererDiscoverer
* \see VLCRendererItem
*/
- (BOOL)setRendererItem:(VLCRendererItem *)item;
@end @end
/*****************************************************************************
* VLCRendererDiscoverer.h
*****************************************************************************
* Copyright © 2018 VLC authors, VideoLAN
* Copyright © 2018 Videolabs
*
* Authors: Soomin Lee<bubu@mikan.io>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*****************************************************************************/
@class VLCRendererItem;
@class VLCRendererDiscoverer;
/**
* Renderer Discoverer delegate protocol
* Allows to be notified upon discovery/changes of an renderer item
*/
@protocol VLCRendererDiscovererDelegate <NSObject>
- (void)rendererDiscovererItemAdded:(VLCRendererDiscoverer * _Nonnull)rendererDiscoverer
item:(VLCRendererItem * _Nonnull)item;
- (void)rendererDiscovererItemDeleted:(VLCRendererDiscoverer * _Nonnull)rendererDiscoverer
item:(VLCRendererItem * _Nonnull)item;
@end
/**
* Renderer Discoverer description
*/
@interface VLCRendererDiscovererDescription : NSObject
/**
* Name of the renderer discoverer
*/
@property (nonatomic, readonly, copy) NSString * _Nonnull name;
/**
* Long name of the renderer discoverer
*/
@property (nonatomic, readonly, copy) NSString * _Nonnull longName;
/**
* Instanciates an object that holds information about a renderer discoverer
* \param name Name of the renderer discoverer
* \param longName Long name of the renderer discoverer
* \return A new `VLCRendererDiscovererDescription` object, only if there were no errors
*/
- (instancetype _Nonnull)initWithName:(NSString * _Nonnull)name longName:(NSString *_Nonnull)longName;
@end
/**
* Renderer Discoverer
*/
@interface VLCRendererDiscoverer : NSObject
/**
* Receiver's delegate
*/
@property (nonatomic, weak) id <VLCRendererDiscovererDelegate> _Nullable delegate;
- (instancetype _Nullable)init NS_UNAVAILABLE;
/**
* Instanciates a `VLCRendererDiscoverer`
* \param name Name of the renderer discoverer
* \return A new `VLCRendererDiscoverer` object, only if there were no errors
*/
- (instancetype _Nullable)initWithName:(NSString * _Nonnull)name;
/**
* Start the renderer discoverer
* \return `YES` if successful, `NO` otherwise
*/
- (BOOL)start;
/**
* Stops the renderer discoverer
* \note This cannot fail
*/
- (void)stop;
/**
* Returns an `NSArray` of `VLCRendererDiscovererDescription`
* \note Call this method to retreive information in order to instanciate a `
* `VLCRendererDiscoverer`
* \return An `NSArray` of `VLCRendererDiscovererDescription`
*/
+ (NSArray<VLCRendererDiscovererDescription *> * _Nullable)list;
@end
/*****************************************************************************
* VLCRendererItem.h
*****************************************************************************
* Copyright © 2018 VLC authors, VideoLAN
* Copyright © 2018 Videolabs
*
* Authors: Soomin Lee<bubu@mikan.io>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*****************************************************************************/
typedef NS_OPTIONS(NSInteger, VLCRendererPlay) {
/** The renderer can render audio */
VLCRendererPlaysAudio = 1 << 0,
/** The renderer can render video */
VLCRendererPlaysVideo = 1 << 1
};
/**
* Renderer Item
*/
@interface VLCRendererItem : NSObject
/**
* Name of the renderer item
*/
@property (nonatomic, readonly, copy) NSString * _Nonnull name;
/**
* For now, the type can only be "chromecast" ("upnp", "airplay" may come later)
*/
@property (nonatomic, readonly, copy) NSString * _Nonnull type;
/**
* IconURI of the renderer item
*/
@property (nonatomic, readonly, copy) NSString * _Nonnull iconURI;
/**
* Flags of the renderer item
*/
@property (nonatomic, readonly, assign) int flags;
/**
* \note Unavailable, handled by `VLCRendererDicoverer`
* \see VLCRendererDiscoverer
*/
- (instancetype _Nullable)init NS_UNAVAILABLE;
@end
...@@ -174,6 +174,10 @@ ...@@ -174,6 +174,10 @@
7DFDF4E91C9AF25600BA86A6 /* VLCiOSLegacyDialogProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7D803EC41C8F2AEF00864A9C /* VLCiOSLegacyDialogProvider.h */; settings = {ATTRIBUTES = (Private, ); }; }; 7DFDF4E91C9AF25600BA86A6 /* VLCiOSLegacyDialogProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7D803EC41C8F2AEF00864A9C /* VLCiOSLegacyDialogProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
7DFDF4EA1C9AF25600BA86A6 /* VLCCustomDialogProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7D34F5551C909DF6008A39F0 /* VLCCustomDialogProvider.h */; settings = {ATTRIBUTES = (Private, ); }; }; 7DFDF4EA1C9AF25600BA86A6 /* VLCCustomDialogProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7D34F5551C909DF6008A39F0 /* VLCCustomDialogProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
7DFDF4EB1C9AF27A00BA86A6 /* VLCDialogProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7D803EB71C8F21EF00864A9C /* VLCDialogProvider.h */; settings = {ATTRIBUTES = (Public, ); }; }; 7DFDF4EB1C9AF27A00BA86A6 /* VLCDialogProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7D803EB71C8F21EF00864A9C /* VLCDialogProvider.h */; settings = {ATTRIBUTES = (Public, ); }; };
8D2CE649203DCC48004BB7F6 /* VLCRendererDiscoverer.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D2CE648203DCC48004BB7F6 /* VLCRendererDiscoverer.m */; };
8D2CE650203EEA47004BB7F6 /* VLCRendererItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D2CE64F203EEA47004BB7F6 /* VLCRendererItem.m */; };
8D826AE1203F3CC500536EF7 /* VLCRendererDiscoverer.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 8D2CE647203DCC48004BB7F6 /* VLCRendererDiscoverer.h */; };
8D826AE2203F3CC500536EF7 /* VLCRendererItem.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 8D2CE64E203EEA47004BB7F6 /* VLCRendererItem.h */; };
AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; }; AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
...@@ -184,6 +188,8 @@ ...@@ -184,6 +188,8 @@
dstPath = MobileVLCKit; dstPath = MobileVLCKit;
dstSubfolderSpec = 16; dstSubfolderSpec = 16;
files = ( files = (
8D826AE1203F3CC500536EF7 /* VLCRendererDiscoverer.h in Copy Headers */,
8D826AE2203F3CC500536EF7 /* VLCRendererItem.h in Copy Headers */,
7D6695301CB5574C00F79C08 /* VLCDialogProvider.h in Copy Headers */, 7D6695301CB5574C00F79C08 /* VLCDialogProvider.h in Copy Headers */,
7A5ECB9E11DE975A00F66AF3 /* MobileVLCKit.h in Copy Headers */, 7A5ECB9E11DE975A00F66AF3 /* MobileVLCKit.h in Copy Headers */,
4B09CED21BC463B100695566 /* VLCAudio.h in Copy Headers */, 4B09CED21BC463B100695566 /* VLCAudio.h in Copy Headers */,
...@@ -368,6 +374,11 @@ ...@@ -368,6 +374,11 @@
7DEBDAE8203C56D5000A7D2F /* libvlc_vlm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = libvlc_vlm.h; path = libvlc/vlc/include/vlc/libvlc_vlm.h; sourceTree = "<group>"; }; 7DEBDAE8203C56D5000A7D2F /* libvlc_vlm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = libvlc_vlm.h; path = libvlc/vlc/include/vlc/libvlc_vlm.h; sourceTree = "<group>"; };
7DEBDAE9203C56D5000A7D2F /* libvlc_events.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = libvlc_events.h; path = libvlc/vlc/include/vlc/libvlc_events.h; sourceTree = "<group>"; }; 7DEBDAE9203C56D5000A7D2F /* libvlc_events.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = libvlc_events.h; path = libvlc/vlc/include/vlc/libvlc_events.h; sourceTree = "<group>"; };
7DEBDAEA203C56D5000A7D2F /* libvlc_media_discoverer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = libvlc_media_discoverer.h; path = libvlc/vlc/include/vlc/libvlc_media_discoverer.h; sourceTree = "<group>"; }; 7DEBDAEA203C56D5000A7D2F /* libvlc_media_discoverer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = libvlc_media_discoverer.h; path = libvlc/vlc/include/vlc/libvlc_media_discoverer.h; sourceTree = "<group>"; };
8D2CE647203DCC48004BB7F6 /* VLCRendererDiscoverer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = VLCRendererDiscoverer.h; path = Headers/Public/VLCRendererDiscoverer.h; sourceTree = "<group>"; };
8D2CE648203DCC48004BB7F6 /* VLCRendererDiscoverer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = VLCRendererDiscoverer.m; path = Sources/VLCRendererDiscoverer.m; sourceTree = "<group>"; };
8D2CE64E203EEA47004BB7F6 /* VLCRendererItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = VLCRendererItem.h; path = Headers/Public/VLCRendererItem.h; sourceTree = "<group>"; };
8D2CE64F203EEA47004BB7F6 /* VLCRendererItem.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = VLCRendererItem.m; path = Sources/VLCRendererItem.m; sourceTree = "<group>"; };
8D2CE653203F206F004BB7F6 /* VLCRendererItem+Init.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "VLCRendererItem+Init.h"; path = "Headers/Internal/VLCRendererItem+Init.h"; sourceTree = "<group>"; };
AA747D9E0F9514B9006C5449 /* MobilePrefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MobilePrefix.pch; path = Headers/PCH/MobilePrefix.pch; sourceTree = SOURCE_ROOT; }; AA747D9E0F9514B9006C5449 /* MobilePrefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MobilePrefix.pch; path = Headers/PCH/MobilePrefix.pch; sourceTree = SOURCE_ROOT; };
AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
D2AAC07E0554694100DB518D /* libMobileVLCKit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMobileVLCKit.a; sourceTree = BUILT_PRODUCTS_DIR; }; D2AAC07E0554694100DB518D /* libMobileVLCKit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMobileVLCKit.a; sourceTree = BUILT_PRODUCTS_DIR; };
...@@ -526,6 +537,7 @@ ...@@ -526,6 +537,7 @@
7A5ECAC911DE8F7300F66AF3 /* VLCTime.m */, 7A5ECAC911DE8F7300F66AF3 /* VLCTime.m */,
7D34F5571C909E13008A39F0 /* Dialogs */, 7D34F5571C909E13008A39F0 /* Dialogs */,
7DB683D31C996187000C70BE /* VLCHelperCode.m */, 7DB683D31C996187000C70BE /* VLCHelperCode.m */,
8D826AE0203F3CA700536EF7 /* Renderer */,
); );
name = Sources; name = Sources;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -555,6 +567,8 @@ ...@@ -555,6 +567,8 @@
6360B0E311E7F0D300EAD790 /* VLCMediaDiscoverer.h */, 6360B0E311E7F0D300EAD790 /* VLCMediaDiscoverer.h */,
7D803EB71C8F21EF00864A9C /* VLCDialogProvider.h */, 7D803EB71C8F21EF00864A9C /* VLCDialogProvider.h */,
7A5ECAD811DE8FAB00F66AF3 /* VLCTime.h */, 7A5ECAD811DE8FAB00F66AF3 /* VLCTime.h */,
8D2CE647203DCC48004BB7F6 /* VLCRendererDiscoverer.h */,
8D2CE64E203EEA47004BB7F6 /* VLCRendererItem.h */,
7DEBDADE203C56BC000A7D2F /* libvlc */, 7DEBDADE203C56BC000A7D2F /* libvlc */,
); );
name = Headers; name = Headers;
...@@ -571,6 +585,7 @@ ...@@ -571,6 +585,7 @@
7D803EC41C8F2AEF00864A9C /* VLCiOSLegacyDialogProvider.h */, 7D803EC41C8F2AEF00864A9C /* VLCiOSLegacyDialogProvider.h */,
7D34F5551C909DF6008A39F0 /* VLCCustomDialogProvider.h */, 7D34F5551C909DF6008A39F0 /* VLCCustomDialogProvider.h */,
7DB683D91C9961BA000C70BE /* VLCHelperCode.h */, 7DB683D91C9961BA000C70BE /* VLCHelperCode.h */,
8D2CE653203F206F004BB7F6 /* VLCRendererItem+Init.h */,
); );
name = Internal; name = Internal;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -655,6 +670,15 @@ ...@@ -655,6 +670,15 @@
name = libvlc; name = libvlc;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
8D826AE0203F3CA700536EF7 /* Renderer */ = {
isa = PBXGroup;
children = (
8D2CE648203DCC48004BB7F6 /* VLCRendererDiscoverer.m */,
8D2CE64F203EEA47004BB7F6 /* VLCRendererItem.m */,
);
name = Renderer;
sourceTree = "<group>";
};
/* End PBXGroup section */ /* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */ /* Begin PBXHeadersBuildPhase section */
...@@ -949,6 +973,7 @@ ...@@ -949,6 +973,7 @@
7A5ECACB11DE8F7300F66AF3 /* VLCEventManager.m in Sources */, 7A5ECACB11DE8F7300F66AF3 /* VLCEventManager.m in Sources */,
7D5F800A185B72EB00C2CD75 /* VLCMediaListPlayer.m in Sources */, 7D5F800A185B72EB00C2CD75 /* VLCMediaListPlayer.m in Sources */,
7D803EC61C8F2AF900864A9C /* VLCiOSLegacyDialogProvider.m in Sources */, 7D803EC61C8F2AF900864A9C /* VLCiOSLegacyDialogProvider.m in Sources */,
8D2CE649203DCC48004BB7F6 /* VLCRendererDiscoverer.m in Sources */,
7A5ECACC11DE8F7300F66AF3 /* VLCLibrary.m in Sources */, 7A5ECACC11DE8F7300F66AF3 /* VLCLibrary.m in Sources */,
7A5ECACD11DE8F7300F66AF3 /* VLCMedia.m in Sources */, 7A5ECACD11DE8F7300F66AF3 /* VLCMedia.m in Sources */,
7D803EC91C8F2B0900864A9C /* VLCDialogProvider.m in Sources */, 7D803EC91C8F2B0900864A9C /* VLCDialogProvider.m in Sources */,
...@@ -960,6 +985,7 @@ ...@@ -960,6 +985,7 @@
7D34F5521C909DDF008A39F0 /* VLCCustomDialogProvider.m in Sources */, 7D34F5521C909DDF008A39F0 /* VLCCustomDialogProvider.m in Sources */,
4B49C5FC1BC3D7870052D40C /* VLCAudio.m in Sources */, 4B49C5FC1BC3D7870052D40C /* VLCAudio.m in Sources */,
636E975811EBC67A002FE8A9 /* VLCMediaThumbnailer.m in Sources */, 636E975811EBC67A002FE8A9 /* VLCMediaThumbnailer.m in Sources */,
8D2CE650203EEA47004BB7F6 /* VLCRendererItem.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#import "VLCMediaPlayer.h" #import "VLCMediaPlayer.h"
#import "VLCEventManager.h" #import "VLCEventManager.h"
#import "VLCLibVLCBridging.h" #import "VLCLibVLCBridging.h"
#import "VLCRendererItem+Init.h"
#if !TARGET_OS_IPHONE #if !TARGET_OS_IPHONE
# import "VLCVideoView.h" # import "VLCVideoView.h"
#endif #endif
...@@ -1279,6 +1280,15 @@ static void HandleMediaPlayerSnapshot(const libvlc_event_t * event, void * self) ...@@ -1279,6 +1280,15 @@ static void HandleMediaPlayerSnapshot(const libvlc_event_t * event, void * self)
{ {
return _playerInstance; return _playerInstance;
} }
#pragma mark -
#pragma mark - Renderer
- (BOOL)setRendererItem:(VLCRendererItem *)item
{
return libvlc_media_player_set_renderer(_playerInstance, item.rendererItem) == 0;
}
@end @end
@implementation VLCMediaPlayer (Private) @implementation VLCMediaPlayer (Private)
......
/*****************************************************************************
* VLCRendererDiscoverer.m
*****************************************************************************
* Copyright © 2018 VLC authors, VideoLAN
* Copyright © 2018 Videolabs
*
* Authors: Soomin Lee<bubu@mikan.io>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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 "VLCRendererDiscoverer.h"
#import "VLCLibrary.h"
#import "VLCEventManager.h"
#import "VLCRendererItem+Init.h"
@interface VLCRendererDiscoverer()
{
libvlc_renderer_discoverer_t *_rendererDiscoverer;
}
@end
#pragma mark - LibVLC event callbacks
static void HandleRendererDiscovererItemAdded(const libvlc_event_t *event, void *self)
{
@autoreleasepool {
[[VLCEventManager sharedManager] callOnMainThreadObject:(__bridge id)(self)
withMethod:@selector(itemAdded:)
withArgumentAsObject:[[VLCRendererItem alloc] initWithCItem:
event->u.renderer_discoverer_item_added.item]];
}
}
static void HandleRendererDiscovererItemDeleted(const libvlc_event_t *event, void *self)
{
@autoreleasepool {
[[VLCEventManager sharedManager] callOnMainThreadObject:(__bridge id)(self)
withMethod:@selector(itemDeleted:)
withArgumentAsObject:[[VLCRendererItem alloc] initWithCItem:
event->u.renderer_discoverer_item_deleted.item]];
}
}
#pragma mark - VLCRendererDiscovererDescription
@implementation VLCRendererDiscovererDescription
- (instancetype)initWithName:(NSString *)name longName:(NSString *)longName
{
self = [super init];
if (self) {
NSAssert(!name, @"VLCRendererDiscovererDescription: name is NULL");
_name = name;
NSAssert(!longName, @"VLCRendererDiscovererDescription: longName is NULL");
_longName = longName;
}
return self;
}
@end
#pragma mark - VLCRendererDiscoverer
@implementation VLCRendererDiscoverer
- (instancetype)initWithName:(NSString *)name
{
self = [super init];
if (self) {
_rendererDiscoverer = libvlc_renderer_discoverer_new([VLCLibrary sharedLibrary].instance, [name UTF8String]);
if (!_rendererDiscoverer) {
NSAssert(_rendererDiscoverer, @"Failed to create renderer with name %@", name);
return nil;
}
libvlc_event_manager_t *p_em = libvlc_renderer_discoverer_event_manager(_rendererDiscoverer);
if (p_em) {
libvlc_event_attach(p_em, libvlc_RendererDiscovererItemAdded,
HandleRendererDiscovererItemAdded, (__bridge void *)(self));
libvlc_event_attach(p_em, libvlc_RendererDiscovererItemDeleted,
HandleRendererDiscovererItemDeleted, (__bridge void *)(self));
}
}
return self;
}
- (BOOL)start
{
return libvlc_renderer_discoverer_start(_rendererDiscoverer) == 0;
}
- (void)stop
{
libvlc_renderer_discoverer_stop(_rendererDiscoverer);
}
- (void)dealloc
{
libvlc_event_manager_t *p_em = libvlc_renderer_discoverer_event_manager(_rendererDiscoverer);
if (p_em) {
libvlc_event_detach(p_em, libvlc_RendererDiscovererItemAdded,
HandleRendererDiscovererItemAdded, (__bridge void *)(self));
libvlc_event_detach(p_em, libvlc_RendererDiscovererItemDeleted,
HandleRendererDiscovererItemDeleted, (__bridge void *)(self));
}
if (_rendererDiscoverer) {
libvlc_renderer_discoverer_release(_rendererDiscoverer);
}
}
+ (NSArray<VLCRendererDiscovererDescription *> *)list
{
size_t i_nb_services = 0;
libvlc_rd_description_t **pp_services = NULL;
i_nb_services = libvlc_renderer_discoverer_list_get([VLCLibrary sharedLibrary].instance, &pp_services);
if (i_nb_services == 0) {
return NULL;
}
NSMutableArray *list;
for (size_t i = 0; i < i_nb_services; ++i) {
[list addObject:[[VLCRendererDiscovererDescription alloc] initWithName:[NSString stringWithUTF8String:pp_services[i]->psz_name]
longName:[NSString stringWithUTF8String:pp_services[i]->psz_longname]]];
}
if (pp_services) {
libvlc_renderer_discoverer_list_release(pp_services, i_nb_services);
}
return [list copy];
}
#pragma mark - Handling libvlc event callbacks
- (void)itemAdded:(VLCRendererItem *)item
{
if ([_delegate respondsToSelector:@selector(rendererDiscovererItemAdded:)]) {
[_delegate rendererDiscovererItemAdded:self item:item];
}
}
- (void)itemDeleted:(VLCRendererItem *)item
{
if ([_delegate respondsToSelector:@selector(rendererDiscovererItemDeleted:)]) {
[_delegate rendererDiscovererItemDeleted:self item:item];
}
}
@end
/*****************************************************************************
* VLCRendererItem.m
*****************************************************************************
* Copyright © 2018 VLC authors, VideoLAN
* Copyright © 2018 Videolabs
*
* Authors: Soomin Lee<bubu@mikan.io>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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 "VLCRendererItem+Init.h"
@interface VLCRendererItem()
{
libvlc_renderer_item_t *_item;
}
@end
@implementation VLCRendererItem
- (void)dealloc
{
if (_item) {
libvlc_renderer_item_release(_item);
}
}
@end
@implementation VLCRendererItem (Internal)
- (instancetype)initWithCItem:(libvlc_renderer_item_t *)item
{
self = [super init];
if (self) {
if (!item) {
NSAssert(!item, @"Renderer item is NULL");
return nil;
}
_item = libvlc_renderer_item_hold(item);
_name = [NSString stringWithUTF8String:libvlc_renderer_item_name(_item)];
NSAssert(!_name, @"VLCRendererItem: name is NULL");
_type = [NSString stringWithUTF8String:libvlc_renderer_item_type(_item)];
NSAssert(!_type, @"VLCRendererItem: type is NULL");
_iconURI = [NSString stringWithUTF8String:libvlc_renderer_item_icon_uri(_item)];
NSAssert(!_iconURI, @"VLCRendererItem: iconURI is NULL");
_flags = libvlc_renderer_item_flags(_item);
}
return self;
}
- (libvlc_renderer_item_t *)rendererItem
{
return _item;
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment