Commit 9f38aeb6 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx/media source: expose preparsing of media within a tree

parent c50c777d
......@@ -32,6 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithInputItem:(struct input_item_t *)p_inputItem;
@property (readonly) struct input_item_t *vlcInputItem;
@property (readonly) NSString *name;
@property (readonly) NSString *MRL;
@property (readonly) vlc_tick_t duration;
......
......@@ -24,57 +24,51 @@
#import "extensions/NSString+Helpers.h"
@interface VLCInputItem()
{
struct input_item_t *_p_inputItem;
}
@end
@implementation VLCInputItem
- (instancetype)initWithInputItem:(struct input_item_t *)p_inputItem
{
self = [super init];
if (self && p_inputItem != NULL) {
_p_inputItem = p_inputItem;
input_item_Hold(_p_inputItem);
_vlcInputItem = p_inputItem;
input_item_Hold(_vlcInputItem);
}
return self;
}
- (void)dealloc
{
input_item_Release(_p_inputItem);
input_item_Release(_vlcInputItem);
}
- (NSString *)name
{
if (_p_inputItem) {
return toNSStr(_p_inputItem->psz_name);
if (_vlcInputItem) {
return toNSStr(_vlcInputItem->psz_name);
}
return @"";
}
- (NSString *)MRL
{
if (_p_inputItem) {
return toNSStr(_p_inputItem->psz_uri);
if (_vlcInputItem) {
return toNSStr(_vlcInputItem->psz_uri);
}
return @"";
}
- (vlc_tick_t)duration
{
if (_p_inputItem) {
return _p_inputItem->i_duration;
if (_vlcInputItem) {
return _vlcInputItem->i_duration;
}
return -1;
}
- (enum input_item_type_e)inputType
{
if (_p_inputItem) {
return _p_inputItem->i_type;
if (_vlcInputItem) {
return _vlcInputItem->i_type;
}
return ITEM_TYPE_UNKNOWN;
}
......
......@@ -24,6 +24,7 @@
#import <vlc_media_source.h>
@class VLCInputItem;
@class VLCInputNode;
NS_ASSUME_NONNULL_BEGIN
......@@ -34,7 +35,9 @@ extern NSString *VLCMediaSourceChildrenRemoved;
@interface VLCMediaSource : NSObject
- (instancetype)initWithMediaSource:(vlc_media_source_t *)p_mediaSource;
- (instancetype)initWithMediaSource:(vlc_media_source_t *)p_mediaSource andLibVLCInstance:(libvlc_int_t *)p_libvlcInstance;
- (void)preparseInputItemWithinTree:(VLCInputItem *)inputItem;
@property (readonly) NSString *mediaSourceDescription;
@property (readonly) VLCInputNode *rootNode;
......
......@@ -28,6 +28,7 @@
@interface VLCMediaSource ()
{
libvlc_int_t *_p_libvlcInstance;
vlc_media_source_t *_p_mediaSource;
vlc_media_tree_listener_id *_p_treeListenerID;
}
......@@ -79,10 +80,11 @@ static const struct vlc_media_tree_callbacks treeCallbacks = {
@implementation VLCMediaSource
- (instancetype)initWithMediaSource:(vlc_media_source_t *)p_mediaSource
- (instancetype)initWithMediaSource:(vlc_media_source_t *)p_mediaSource andLibVLCInstance:(libvlc_int_t *)p_libvlcInstance
{
self = [super init];
if (self && p_mediaSource != NULL) {
_p_libvlcInstance = p_libvlcInstance;
_p_mediaSource = p_mediaSource;
vlc_media_source_Hold(_p_mediaSource);
_p_treeListenerID = vlc_media_tree_AddListener(_p_mediaSource->tree,
......@@ -104,6 +106,11 @@ static const struct vlc_media_tree_callbacks treeCallbacks = {
}
}
- (void)preparseInputItemWithinTree:(VLCInputItem *)inputItem
{
vlc_media_tree_Preparse(_p_mediaSource->tree, _p_libvlcInstance, inputItem.vlcInputItem);
}
- (NSString *)mediaSourceDescription
{
if (_p_mediaSource != NULL) {
......
......@@ -52,7 +52,7 @@
continue;
}
VLCMediaSource *mediaSource = [[VLCMediaSource alloc] initWithMediaSource:p_mediaSource];
VLCMediaSource *mediaSource = [[VLCMediaSource alloc] initWithMediaSource:p_mediaSource andLibVLCInstance:p_libvlcInstance];
[mutableArray addObject:mediaSource];
}
......
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