vlc | branch: master | Felix Paul Kühne <fe...@feepk.net> | Sun Jun 30 11:33:42 2019 +0200| [91a29caca83526a97cae648d1c008b97629ce3c3] | committer: Felix Paul Kühne
macosx/input item: implement parsing > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=91a29caca83526a97cae648d1c008b97629ce3c3 --- modules/gui/macosx/library/VLCInputItem.h | 8 ++++ modules/gui/macosx/library/VLCInputItem.m | 75 +++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/modules/gui/macosx/library/VLCInputItem.h b/modules/gui/macosx/library/VLCInputItem.h index 8554dd793e..a9e9690a9d 100644 --- a/modules/gui/macosx/library/VLCInputItem.h +++ b/modules/gui/macosx/library/VLCInputItem.h @@ -28,6 +28,10 @@ NS_ASSUME_NONNULL_BEGIN +extern NSString *VLCInputItemParsingSucceeded; +extern NSString *VLCInputItemParsingFailed; +extern NSString *VLCInputItemSubtreeAdded; + @interface VLCInputItem : NSObject - (instancetype)initWithInputItem:(struct input_item_t *)p_inputItem; @@ -37,6 +41,10 @@ NS_ASSUME_NONNULL_BEGIN @property (readonly) NSString *MRL; @property (readonly) vlc_tick_t duration; @property (readonly) enum input_item_type_e inputType; +@property (readonly) struct input_item_node_t *subTree; + +- (void)parseInputItem; +- (void)cancelParsing; @end diff --git a/modules/gui/macosx/library/VLCInputItem.m b/modules/gui/macosx/library/VLCInputItem.m index b20f4ead45..394114cef4 100644 --- a/modules/gui/macosx/library/VLCInputItem.m +++ b/modules/gui/macosx/library/VLCInputItem.m @@ -22,8 +22,47 @@ #import "VLCInputItem.h" +#import "main/VLCMain.h" #import "extensions/NSString+Helpers.h" +NSString *VLCInputItemParsingSucceeded = @"VLCInputItemParsingSucceeded"; +NSString *VLCInputItemParsingFailed = @"VLCInputItemParsingFailed"; +NSString *VLCInputItemSubtreeAdded = @"VLCInputItemSubtreeAdded"; + +@interface VLCInputItem() +{ + input_item_parser_id_t *_p_parserID; +} + +- (void)parsingEnded:(int)status; +- (void)subTreeAdded:(input_item_node_t *)p_node; + +@end + +static void cb_parsing_ended(input_item_t *p_item, int status, void *p_data) +{ + VLC_UNUSED(p_item); + dispatch_async(dispatch_get_main_queue(), ^{ + VLCInputItem *inputItem = (__bridge VLCInputItem *)p_data; + [inputItem parsingEnded:status]; + }); +} + +static void cb_subtree_added(input_item_t *p_item, input_item_node_t *p_node, void *p_data) +{ + VLC_UNUSED(p_item); + dispatch_async(dispatch_get_main_queue(), ^{ + VLCInputItem *inputItem = (__bridge VLCInputItem *)p_data; + [inputItem subTreeAdded:p_node]; + }); +} + +static const struct input_item_parser_cbs_t parserCallbacks = +{ + cb_parsing_ended, + cb_subtree_added, +}; + @implementation VLCInputItem - (instancetype)initWithInputItem:(struct input_item_t *)p_inputItem @@ -38,6 +77,9 @@ - (void)dealloc { + if (_p_parserID) { + input_item_parser_id_Release(_p_parserID); + } input_item_Release(_vlcInputItem); } @@ -73,6 +115,39 @@ return ITEM_TYPE_UNKNOWN; } +- (void)parseInputItem +{ + _p_parserID = input_item_Parse(_vlcInputItem, + (vlc_object_t *)getIntf(), + &parserCallbacks, + (__bridge void *) self); +} + +- (void)cancelParsing +{ + if (_p_parserID) { + input_item_parser_id_Interrupt(_p_parserID); + } +} + +- (void)parsingEnded:(int)status +{ + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + if (status) { + [notificationCenter postNotificationName:VLCInputItemParsingSucceeded object:self]; + } else { + [notificationCenter postNotificationName:VLCInputItemParsingFailed object:self]; + } + input_item_parser_id_Release(_p_parserID); + _p_parserID = NULL; +} + +- (void)subTreeAdded:(input_item_node_t *)p_node +{ + _subTree = p_node; + [[NSNotificationCenter defaultCenter] postNotificationName:VLCInputItemSubtreeAdded object:self]; +} + @end @interface VLCInputNode() _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits