Commit dd21c7cf authored by Felix Paul Kühne's avatar Felix Paul Kühne

media discover: completely drop delegation protocol, turn available discoverers array into a stub

parent 2cb98b15
......@@ -31,29 +31,6 @@
@class VLCMediaList;
@class VLCMediaDiscoverer;
/**
* VLCMediaDiscovererDelegate
*/
@protocol VLCMediaDiscovererDelegate <NSObject>
@optional
/**
* delegate method triggered when a discoverer was started
*
* \param the discoverer that was started
*/
- (void)discovererStarted:(VLCMediaDiscoverer *)theDiscoverer;
/**
* delegate method triggered when a discoverer was stopped
*
* \param the discoverer that was stopped
*/
- (void)discovererStopped:(VLCMediaDiscoverer *)theDiscoverer;
@end
/**
* VLCMediaDiscoverer
*/
......@@ -63,16 +40,9 @@
@property (nonatomic, readonly) VLCLibrary *libraryInstance;
/**
* delegate property to listen to start/stop events
*/
@property (weak, readwrite) id<VLCMediaDiscovererDelegate> delegate;
/**
* Maintains a list of available media discoverers. This list is populated as new media
* discoverers are created.
* \return A list of available media discoverers.
* \return returns an empty array, will be removed in subsequent releases
*/
+ (NSArray *)availableMediaDiscoverer;
+ (NSArray *)availableMediaDiscoverer __attribute__((deprecated));
/* Initializers */
/**
......
......@@ -41,53 +41,14 @@
VLCLibrary *_privateLibrary;
}
/**
* libvlc told us that the discoverer is actually running
*/
- (void)_mediaDiscovererStarted;
/**
* libvlc told us that the discoverer stopped running
*/
- (void)_mediaDiscovererEnded;
@end
static NSArray *availableMediaDiscoverer = nil; // Global list of media discoverers
/* libvlc event callback */
static void HandleMediaDiscovererStarted(const libvlc_event_t *event, void *self)
{
@autoreleasepool {
[[VLCEventManager sharedManager] callOnMainThreadObject:(__bridge id)(self)
withMethod:@selector(_mediaDiscovererStarted)
withArgumentAsObject:@(event->type)];
}
}
static void HandleMediaDiscovererEnded(const libvlc_event_t *event, void *self)
{
@autoreleasepool {
[[VLCEventManager sharedManager] callOnMainThreadObject:(__bridge id)(self)
withMethod:@selector(_mediaDiscovererEnded)
withArgumentAsObject:@(event->type)];
}
}
@implementation VLCMediaDiscoverer
@synthesize libraryInstance = _privateLibrary;
+ (NSArray *)availableMediaDiscoverer
{
if (!availableMediaDiscoverer) {
availableMediaDiscoverer = @[[[VLCMediaDiscoverer alloc] initWithName:@"sap"],
[[VLCMediaDiscoverer alloc] initWithName:@"upnp"],
[[VLCMediaDiscoverer alloc] initWithName:@"freebox"],
[[VLCMediaDiscoverer alloc] initWithName:@"video_dir"]];
}
return availableMediaDiscoverer;
return @[];
}
- (instancetype)initWithName:(NSString *)aServiceName
......@@ -106,12 +67,6 @@ static void HandleMediaDiscovererEnded(const libvlc_event_t *event, void *self)
VKLog(@"media discovery initialization failed, maybe no such module?");
return NULL;
}
libvlc_event_manager_t *em = libvlc_media_discoverer_event_manager(_mdis);
if (em) {
libvlc_event_attach(em, libvlc_MediaDiscovererStarted, HandleMediaDiscovererStarted, (__bridge void *)(self));
libvlc_event_attach(em, libvlc_MediaDiscovererEnded, HandleMediaDiscovererEnded, (__bridge void *)(self));
}
}
return self;
}
......@@ -123,12 +78,6 @@ static void HandleMediaDiscovererEnded(const libvlc_event_t *event, void *self)
[[VLCEventManager sharedManager] cancelCallToObject:self];
libvlc_event_manager_t *em = libvlc_media_discoverer_event_manager(_mdis);
if (em) {
libvlc_event_detach(em, libvlc_MediaDiscovererStarted, HandleMediaDiscovererStarted, (__bridge void *)(self));
libvlc_event_detach(em, libvlc_MediaDiscovererEnded, HandleMediaDiscovererEnded, (__bridge void *)(self));
}
libvlc_media_discoverer_release(_mdis);
libvlc_release(_privateLibrary.instance);
......@@ -137,8 +86,11 @@ static void HandleMediaDiscovererEnded(const libvlc_event_t *event, void *self)
- (int)startDiscoverer
{
int returnValue = libvlc_media_discoverer_start(_mdis);
if (returnValue == -1)
if (returnValue == -1) {
VKLog(@"media discovery start failed");
_running = NO;
return returnValue;
}
_running = libvlc_media_discoverer_is_running(_mdis);
......@@ -185,27 +137,4 @@ static void HandleMediaDiscovererEnded(const libvlc_event_t *event, void *self)
return _running;
}
- (void)_mediaDiscovererStarted
{
[self willChangeValueForKey:@"running"];
_running = YES;
[self didChangeValueForKey:@"running"];
if (self.delegate) {
if ([self.delegate respondsToSelector:@selector(discovererStarted:)])
[self.delegate discovererStarted:self];
}
}
- (void)_mediaDiscovererEnded
{
[self willChangeValueForKey:@"running"];
_running = NO;
[self didChangeValueForKey:@"running"];
if (self.delegate) {
if ([self.delegate respondsToSelector:@selector(discovererStopped:)])
[self.delegate discovererStopped:self];
}
}
@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