Commit 592c1efc authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

macosx/framework: Get rid of VLCMediaListAspect, and remove a bunch of exception.

parent cb9e605b
......@@ -23,7 +23,6 @@
*****************************************************************************/
#import "VLCLibrary.h"
#import "VLCMediaListAspect.h"
#import "VLCStreamOutput.h"
#import "VLCMediaPlayer.h"
......@@ -129,34 +128,6 @@ extern void __catch_exception( void * e, const char * function, const char * fil
@property (readonly) void * instance;
@end
/**
* Bridges functionality between VLCMediaListAspect and libvlc.
*/
@interface VLCMediaListAspect (VLCLibVLCBridging)
/* Factories */
/**
* Manufactures a new media list aspect object with libvlc media list view instance.
* \return Newly created media list aspect using specified libvlc media list view.
*/
+ (id)mediaListAspectWithLibVLCMediaListView:(libvlc_media_list_view_t *)p_new_mlv;
/**
* Manufactures a new media list aspect object with libvlc media list view instance.
* \return Newly created media list aspect using specified libvlc media list view.
*/
+ (id)mediaListAspectWithLibVLCMediaListView:(libvlc_media_list_view_t *)p_new_mlv andMediaList:(VLCMediaList*)mediaList;
/* Initializers */
/**
* Initializes a new media list aspect object with libvlc media list view instance.
* \return Newly created media list aspect using specified libvlc media list view.
*/
- (id)initWithLibVLCMediaListView:(libvlc_media_list_view_t *)p_new_mlv andMediaList:(VLCMediaList*)mediaList;
/* Properties */
@property (readonly) libvlc_media_list_view_t * libVLCMediaListView; //< Libvlc pointer to media list view instance.
@end
/**
* Bridges functionality between VLCLibrary and VLCAudio.
*/
......
......@@ -31,7 +31,6 @@
#import <VLCKit/VLCMediaLibrary.h>
#import <VLCKit/VLCMediaList.h>
#import <VLCKit/VLCMediaListPlayer.h>
#import <VLCKit/VLCMediaListAspect.h>
#import <VLCKit/VLCMediaDiscoverer.h>
#import <VLCKit/VLCMediaPlayer.h>
#import <VLCKit/VLCTime.h>
......
......@@ -30,7 +30,6 @@ extern NSString * VLCMediaListItemDeleted;
@class VLCMedia;
@class VLCMediaList;
@class VLCMediaListAspect;
/**
* TODO: Documentation VLCMediaListDelegate
......@@ -56,9 +55,6 @@ extern NSString * VLCMediaListItemDeleted;
id <VLCMediaListDelegate,NSObject> delegate; //< Delegate object
/* We need that private copy because of Cocoa Bindings, that need to be working on first thread */
NSMutableArray * cachedMedia; //< Private copy of media objects.
VLCMediaListAspect * flatAspect; //< TODO: Documentation VLCMediaList.flatAspect
VLCMediaListAspect * hierarchicalAspect; //< TODO: Documentation VLCMediaList.hierarchicalAspect
VLCMediaListAspect * hierarchicalNodeAspect; //< TODO: Documentation VLCMediaList.hierarchicalNodeAspect
}
/* Operations */
......@@ -113,19 +109,4 @@ extern NSString * VLCMediaListItemDeleted;
*/
@property (readonly) BOOL isReadOnly;
/* Media list aspect */
/**
* TODO: Documentation VLCMediaList.hierarchicalAspect
*/
@property (readonly) VLCMediaListAspect * hierarchicalAspect;
/**
* TODO: Documentation VLCMediaList.hierarchicalNodeAspect
*/
@property (readonly) VLCMediaListAspect * hierarchicalNodeAspect;
/**
* TODO: Documentation VLCMediaList.flatAspect
*/
@property (readonly) VLCMediaListAspect * flatAspect;
@end
/*****************************************************************************
* VLCMediaLisAspect.h: VLCKit.framework VLCMediaLisAspect header
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
*
* 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 "VLCMediaList.h"
@class VLCMedia;
@class VLCMediaList;
@interface VLCMediaListAspectNode : NSObject
{
VLCMedia * media;
VLCMediaListAspect * children;
}
@property (retain) VLCMedia * media;
@property (retain) VLCMediaListAspect * children;
- (BOOL)isLeaf;
@end
@interface VLCMediaListAspect : NSObject
{
void * p_mlv; //< Internal instance of media list view
NSMutableArray * cachedNode;
VLCMediaList * parentMediaList;
BOOL ownHisMediaList;
}
- (VLCMedia *)mediaAtIndex:(NSInteger)index;
- (VLCMediaListAspectNode *)nodeAtIndex:(NSInteger)index;
- (NSInteger)count;
- (VLCMediaList *)parentMediaList;
@end
......@@ -68,7 +68,7 @@ NSString * VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged";
value = VOLUME_MIN;
else if (value > VOLUME_MAX)
value = VOLUME_MAX;
libvlc_audio_set_volume([library instance], value, NULL);
libvlc_audio_set_volume([library instance], value);
}
- (void)volumeUp
......
......@@ -93,8 +93,7 @@ void __catch_exception( void * e, const char * function, const char * file, int
lib_vlc_params[paramNum] = [vlcParam cStringUsingEncoding:NSASCIIStringEncoding];
paramNum++;
}
instance = (void *)libvlc_new( sizeof(lib_vlc_params)/sizeof(lib_vlc_params[0]), lib_vlc_params, &ex );
catch_exception( &ex );
instance = (void *)libvlc_new( sizeof(lib_vlc_params)/sizeof(lib_vlc_params[0]), lib_vlc_params);
NSAssert(instance, @"libvlc failed to initialize");
// Assignment unneeded, as the audio unit will do it for us
......
......@@ -81,7 +81,6 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
// Initialize internals to defaults
cachedMedia = [[NSMutableArray alloc] init];
delegate = flatAspect = hierarchicalAspect = hierarchicalNodeAspect = nil;
[self initInternalMediaList];
}
return self;
......@@ -111,9 +110,6 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
libvlc_media_list_release( p_mlist );
[cachedMedia release];
[flatAspect release];
[hierarchicalAspect release];
[hierarchicalNodeAspect release];
[super dealloc];
}
......@@ -211,40 +207,6 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
return libvlc_media_list_is_readonly( p_mlist );
}
/* Media list aspect */
- (VLCMediaListAspect *)hierarchicalAspect
{
if( hierarchicalAspect )
return hierarchicalAspect;
libvlc_media_list_view_t * p_mlv = libvlc_media_list_hierarchical_view(p_mlist);
hierarchicalAspect = [[VLCMediaListAspect mediaListAspectWithLibVLCMediaListView:p_mlv andMediaList:self] retain];
libvlc_media_list_view_release( p_mlv );
return hierarchicalAspect;
}
- (VLCMediaListAspect *)hierarchicalNodeAspect
{
if( hierarchicalNodeAspect )
return hierarchicalNodeAspect;
libvlc_media_list_view_t * p_mlv = libvlc_media_list_hierarchical_node_view(p_mlist);
hierarchicalNodeAspect = [[VLCMediaListAspect mediaListAspectWithLibVLCMediaListView:p_mlv andMediaList:self] retain];
libvlc_media_list_view_release( p_mlv );
return hierarchicalNodeAspect;
}
- (VLCMediaListAspect *)flatAspect
{
if( flatAspect )
return flatAspect;
libvlc_media_list_view_t * p_mlv = libvlc_media_list_flat_view(p_mlist, NULL);
flatAspect = [[VLCMediaListAspect mediaListAspectWithLibVLCMediaListView:p_mlv andMediaList:self] retain];
libvlc_media_list_view_release( p_mlv );
return flatAspect;
}
@end
@implementation VLCMediaList (LibVLCBridging)
......
/*****************************************************************************
* VLCMediaListAspect.m: VLCKit.framework VLCMediaListAspect implementation
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
*
* 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 "VLCMediaListAspect.h"
#import "VLCLibrary.h"
#import "VLCEventManager.h"
#import "VLCLibVLCBridging.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc/vlc.h>
#include <vlc/libvlc.h>
// TODO: Documentation
@interface VLCMediaListAspect (Private)
/* Initializers */
- (void)initInternalMediaListView;
- (void)mediaListViewItemAdded:(NSArray *)args;
- (void)mediaListViewItemRemoved:(NSNumber *)index;
@end
@implementation VLCMediaListAspectNode
- (id)init
{
if(self = [super init])
{
media = nil;
children = nil;
}
return self;
}
- (void)dealloc
{
[media release];
[children release];
[super dealloc];
}
@synthesize media;
@synthesize children;
- (BOOL)isLeaf
{
return self.children == nil;
}
@end
@implementation VLCMediaListAspect (KeyValueCodingCompliance)
/* For the @"media" key */
- (NSInteger) countOfMedia
{
return [cachedNode count];
}
- (id) objectInMediaAtIndex:(NSInteger)i
{
return [[cachedNode objectAtIndex:i] media];
}
/* For the @"node" key */
- (NSInteger) countOfNode
{
return [cachedNode count];
}
- (id) objectInNodeAtIndex:(NSInteger)i
{
return [cachedNode objectAtIndex:i];
}
@end
/* libvlc event callback */
static void HandleMediaListViewItemAdded(const libvlc_event_t * event, void * user_data)
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
id self = user_data;
[[VLCEventManager sharedManager] callOnMainThreadObject:self
withMethod:@selector(mediaListViewItemAdded:)
withArgumentAsObject:[NSArray arrayWithObject:[NSDictionary dictionaryWithObjectsAndKeys:
[VLCMedia mediaWithLibVLCMediaDescriptor:event->u.media_list_item_added.item], @"media",
[NSNumber numberWithInt:event->u.media_list_item_added.index], @"index",
nil]]];
[pool release];
}
static void HandleMediaListViewItemDeleted( const libvlc_event_t * event, void * user_data)
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
id self = user_data;
[[VLCEventManager sharedManager] callOnMainThreadObject:self
withMethod:@selector(mediaListViewItemRemoved:)
withArgumentAsObject:[NSNumber numberWithInt:event->u.media_list_item_deleted.index]];
[pool release];
}
@implementation VLCMediaListAspect
- (void)dealloc
{
// Release allocated memory
libvlc_media_list_view_release(p_mlv);
[cachedNode release];
if( ownHisMediaList )
[parentMediaList release];
[super dealloc];
}
- (void)release
{
@synchronized(self)
{
if([self retainCount] <= 1)
{
/* We must make sure we won't receive new event after an upcoming dealloc
* We also may receive a -retain in some event callback that may occcur
* Before libvlc_event_detach. So this can't happen in dealloc */
libvlc_event_manager_t * p_em = libvlc_media_list_view_event_manager(p_mlv);
libvlc_event_detach(p_em, libvlc_MediaListViewItemDeleted, HandleMediaListViewItemDeleted, self);
libvlc_event_detach(p_em, libvlc_MediaListViewItemAdded, HandleMediaListViewItemAdded, self);
}
[super release];
}
}
- (NSString *)description
{
NSMutableString * content = [NSMutableString string];
NSUInteger i;
for( i = 0; i < [self count]; i++)
{
[content appendFormat:@"%@\n", [self mediaAtIndex: i]];
}
return [NSString stringWithFormat:@"<%@ %p> {\n%@}", [self className], self, content];
}
- (VLCMedia *)mediaAtIndex:(NSInteger)index
{
libvlc_exception_t p_e;
libvlc_exception_init( &p_e );
libvlc_media_t * p_md = libvlc_media_list_view_item_at_index( p_mlv, index, &p_e );
catch_exception( &p_e );
// Returns local object for media descriptor, searchs for user data first. If not found it creates a
// new cocoa object representation of the media descriptor.
return [VLCMedia mediaWithLibVLCMediaDescriptor:p_md];
}
- (VLCMediaListAspect *)childrenAtIndex:(NSInteger)index
{
libvlc_exception_t p_e;
libvlc_exception_init( &p_e );
libvlc_media_list_view_t * p_sub_mlv = libvlc_media_list_view_children_at_index( p_mlv, index, &p_e );
catch_exception( &p_e );
if( !p_sub_mlv )
return nil;
// Returns local object for media descriptor, searchs for user data first. If not found it creates a
// new cocoa object representation of the media descriptor.
return [VLCMediaListAspect mediaListAspectWithLibVLCMediaListView:p_sub_mlv];
}
- (VLCMediaListAspectNode *)nodeAtIndex:(NSInteger)index
{
VLCMediaListAspectNode * node = [[[VLCMediaListAspectNode alloc] init] autorelease];
[node setMedia:[self mediaAtIndex: index]];
libvlc_media_list_view_t * p_sub_mlv = libvlc_media_list_view_children_for_item([self libVLCMediaListView], [node.media libVLCMediaDescriptor], NULL);
if( p_sub_mlv )
{
[node setChildren:[VLCMediaListAspect mediaListAspectWithLibVLCMediaListView: p_sub_mlv]];
libvlc_media_list_view_release(p_sub_mlv);
}
return node;
}
- (NSInteger)count
{
libvlc_exception_t p_e;
libvlc_exception_init( &p_e );
NSInteger result = libvlc_media_list_view_count( p_mlv, &p_e );
catch_exception( &p_e );
return result;
}
- (VLCMediaList *)parentMediaList
{
return parentMediaList;
}
@end
@implementation VLCMediaListAspect (LibVLCBridging)
+ (id)mediaListAspectWithLibVLCMediaListView:(libvlc_media_list_view_t *)p_new_mlv
{
return [[[VLCMediaListAspect alloc] initWithLibVLCMediaListView:p_new_mlv andMediaList:nil] autorelease];
}
+ (id)mediaListAspectWithLibVLCMediaListView:(libvlc_media_list_view_t *)p_new_mlv andMediaList:(VLCMediaList *)mediaList;
{
return [[[VLCMediaListAspect alloc] initWithLibVLCMediaListView:p_new_mlv andMediaList:mediaList] autorelease];
}
- (id)initWithLibVLCMediaListView:(libvlc_media_list_view_t *)p_new_mlv andMediaList:(VLCMediaList *)mediaList;
{
if( self = [super init] )
{
p_mlv = p_new_mlv;
libvlc_media_list_view_retain(p_mlv);
/* parentMediaList isn't retained, because we need a mediaList to exists, and not the contrary */
parentMediaList = mediaList;
ownHisMediaList = NO;
if( !parentMediaList )
{
/* We have to create it then */
libvlc_media_list_view_retain(p_mlv);
libvlc_media_list_t * p_mlist = libvlc_media_list_view_parent_media_list(p_mlv, NULL);
parentMediaList = [[VLCMediaList mediaListWithLibVLCMediaList: p_mlist] retain];
libvlc_media_list_release( p_mlist );
/* This is an exception, and we owns it here */
ownHisMediaList = YES;
}
cachedNode = [[NSMutableArray alloc] initWithCapacity:libvlc_media_list_view_count(p_mlv, NULL)];
libvlc_media_list_t * p_mlist;
p_mlist = libvlc_media_list_view_parent_media_list( p_mlv, NULL );
libvlc_media_list_lock( p_mlist );
NSUInteger i, count = libvlc_media_list_view_count(p_mlv, NULL);
for( i = 0; i < count; i++ )
{
libvlc_media_t * p_md = libvlc_media_list_view_item_at_index(p_mlv, i, NULL);
libvlc_media_list_view_t * p_sub_mlv = libvlc_media_list_view_children_at_index(p_mlv, i, NULL);
VLCMediaListAspectNode * node = [[[VLCMediaListAspectNode alloc] init] autorelease];
[node setMedia:[VLCMedia mediaWithLibVLCMediaDescriptor: p_md]];
[node setChildren: p_sub_mlv ? [VLCMediaListAspect mediaListAspectWithLibVLCMediaListView: p_sub_mlv] : nil];
if( p_sub_mlv ) NSAssert(![node isLeaf], @"Not leaf");
[cachedNode addObject:node];
libvlc_media_release(p_md);
if( p_sub_mlv ) libvlc_media_list_view_release(p_sub_mlv);
}
[self initInternalMediaListView];
libvlc_media_list_unlock( p_mlist );
libvlc_media_list_release( p_mlist );
}
return self;
}
- (libvlc_media_list_view_t *)libVLCMediaListView
{
return (libvlc_media_list_view_t *)p_mlv;
}
@end
@implementation VLCMediaListAspect (Private)
- (void)initInternalMediaListView
{
libvlc_event_manager_t * p_em = libvlc_media_list_event_manager(p_mlv);
/* Add internal callback */
libvlc_event_attach(p_em, libvlc_MediaListViewItemAdded, HandleMediaListViewItemAdded, self);
libvlc_event_attach(p_em, libvlc_MediaListViewItemDeleted, HandleMediaListViewItemDeleted, self);
}
- (void)mediaListViewItemAdded:(NSArray *)arrayOfArgs
{
NSAssert([NSThread isMainThread], @"We are not on main thread");
/* We hope to receive index in a nide range, that could change one day */
NSInteger start = [[[arrayOfArgs objectAtIndex: 0] objectForKey:@"index"] intValue];
NSInteger end = [[[arrayOfArgs objectAtIndex: [arrayOfArgs count]-1] objectForKey:@"index"] intValue];
NSRange range = NSMakeRange(start, end-start);
[self willChange:NSKeyValueChangeInsertion valuesAtIndexes:[NSIndexSet indexSetWithIndexesInRange:range] forKey:@"media"];
[self willChange:NSKeyValueChangeInsertion valuesAtIndexes:[NSIndexSet indexSetWithIndexesInRange:range] forKey:@"node"];
for( NSDictionary * args in arrayOfArgs )
{
NSInteger index = [[args objectForKey:@"index"] intValue];
VLCMedia * media = [args objectForKey:@"media"];
VLCMediaListAspectNode * node = [[[VLCMediaListAspectNode alloc] init] autorelease];
[node setMedia:media];
/* Set the sub media list view we enventually have */
libvlc_media_list_view_t * p_sub_mlv = libvlc_media_list_view_children_for_item([self libVLCMediaListView], [media libVLCMediaDescriptor], NULL);
if( p_sub_mlv )
{
[node setChildren:[VLCMediaListAspect mediaListAspectWithLibVLCMediaListView: p_sub_mlv]];
libvlc_media_list_view_release(p_sub_mlv);
NSAssert(![node isLeaf], @"Not leaf");
}
/* Sanity check */
if( index && index > [cachedNode count] )
index = [cachedNode count];
[cachedNode insertObject:node atIndex:index];
}
[self didChange:NSKeyValueChangeInsertion valuesAtIndexes:[NSIndexSet indexSetWithIndexesInRange:range] forKey:@"node"];
[self didChange:NSKeyValueChangeInsertion valuesAtIndexes:[NSIndexSet indexSetWithIndexesInRange:range] forKey:@"media"];
}
- (void)mediaListViewItemRemoved:(NSNumber *)index
{
[self willChange:NSKeyValueChangeInsertion valuesAtIndexes:[NSIndexSet indexSetWithIndex:[index intValue]] forKey:@"media"];
[self willChange:NSKeyValueChangeInsertion valuesAtIndexes:[NSIndexSet indexSetWithIndex:[index intValue]] forKey:@"node"];
[cachedNode removeObjectAtIndex:[index intValue]];
[self didChange:NSKeyValueChangeInsertion valuesAtIndexes:[NSIndexSet indexSetWithIndex:[index intValue]] forKey:@"node"];
[self didChange:NSKeyValueChangeInsertion valuesAtIndexes:[NSIndexSet indexSetWithIndex:[index intValue]] forKey:@"media"];
}
@end
......@@ -37,10 +37,7 @@
{
_mediaPlayer = [[VLCMediaPlayer alloc] init];
libvlc_exception_t ex;
libvlc_exception_init(&ex);
instance = libvlc_media_list_player_new([VLCLibrary sharedInstance], &ex);
catch_exception(&ex);
instance = libvlc_media_list_player_new([VLCLibrary sharedInstance]);
libvlc_media_list_player_set_media_player(instance, [_mediaPlayer libVLCMediaPlayer]);
}
return self;
......
......@@ -257,11 +257,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
- (id)drawable
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
id ret = libvlc_media_player_get_nsobject(instance);
catch_exception( &ex );
return ret;
return libvlc_media_player_get_nsobject(instance);
}
- (VLCAudio *)audio
......@@ -304,19 +300,12 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
- (BOOL)openVideoSubTitlesFromFile:(NSString *)path
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
BOOL result = libvlc_video_set_subtitle_file( instance, [path UTF8String], &ex );
catch_exception( &ex );
return result;
return libvlc_video_set_subtitle_file(instance, [path UTF8String]);
}
- (NSArray *)videoSubTitles
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
libvlc_track_description_t *currentTrack = libvlc_video_get_spu_description( instance, &ex );
catch_exception( &ex );
libvlc_track_description_t *currentTrack = libvlc_video_get_spu_description(instance);
NSMutableArray *tempArray = [NSMutableArray array];
while (currentTrack) {
......@@ -383,23 +372,12 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
- (void)setRate:(float)value
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
libvlc_media_player_set_rate( instance, value, &ex );
catch_exception( &ex );
libvlc_media_player_set_rate(instance, value);
}
- (float)rate
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
float result = libvlc_media_player_get_rate( instance, &ex );
if (libvlc_exception_raised(&ex))
{
result = 1;
libvlc_exception_clear(&ex);
}
return result;
return libvlc_media_player_get_rate(instance);
}
- (NSSize)videoSize
......@@ -414,37 +392,19 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
- (BOOL)hasVideoOut
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
BOOL result = libvlc_media_player_has_vout((libvlc_media_player_t *)instance, &ex);
if (libvlc_exception_raised( &ex ))
{
libvlc_exception_clear( &ex );
return NO;
}
else
return result;
return libvlc_media_player_has_vout(instance);
}
- (float)framesPerSecond
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
float result = libvlc_media_player_get_fps( (libvlc_media_player_t *)instance, &ex );
catch_exception( &ex );
return result;
return libvlc_media_player_get_fps(instance);
}
- (void)setTime:(VLCTime *)value
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
// Time is managed in seconds, while duration is managed in microseconds
// TODO: Redo VLCTime to provide value numberAsMilliseconds, numberAsMicroseconds, numberAsSeconds, numberAsMinutes, numberAsHours
libvlc_media_player_set_time( (libvlc_media_player_t *)instance,
(value ? [[value numberValue] longLongValue] : 0),
&ex );
catch_exception( &ex );
libvlc_media_player_set_time(instance, value ? [[value numberValue] longLongValue] : 0);
}
- (VLCTime *)time
......@@ -459,70 +419,51 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
- (NSUInteger)fps
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
NSUInteger result = libvlc_media_player_get_fps( instance, &ex );
catch_exception( &ex );
return result;
return libvlc_media_player_get_fps(instance);
}
#pragma mark -
#pragma mark Chapters
- (void)setCurrentChapterIndex:(NSUInteger)value;
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
libvlc_media_player_set_chapter( instance, value, &ex );
catch_exception( &ex );
libvlc_media_player_set_chapter(instance, value);
}
- (NSUInteger)currentChapterIndex
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
NSInteger count = libvlc_media_player_get_chapter_count( instance, &ex );
catch_exception( &ex );
NSInteger count = libvlc_media_player_get_chapter_count(instance);
if (count <= 0)
return NSNotFound;
NSUInteger result = libvlc_media_player_get_chapter( instance, &ex );
catch_exception( &ex );
NSUInteger result = libvlc_media_player_get_chapter(instance);
return result;
}
- (void)nextChapter
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
libvlc_media_player_next_chapter( instance, &ex );
catch_exception( &ex );
libvlc_media_player_next_chapter(instance);
}
- (void)previousChapter
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
libvlc_media_player_previous_chapter( instance, &ex );
catch_exception( &ex );
libvlc_media_player_previous_chapter(instance);
}
- (NSArray *)chaptersForTitleIndex:(NSUInteger)title
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
NSInteger count = libvlc_media_player_get_chapter_count(instance, &ex);
NSInteger count = libvlc_media_player_get_chapter_count(instance);
if (count <= 0)
return [NSArray array];
libvlc_track_description_t *tracks = libvlc_video_get_chapter_description( instance, title, &ex );
libvlc_track_description_t *tracks = libvlc_video_get_chapter_description(instance, title);
NSMutableArray *tempArray = [NSMutableArray array];
NSInteger i;
for (i = 0; i < count ; i++)
{
[tempArray addObject:[NSString stringWithUTF8String: tracks->psz_name]];
[tempArray addObject:[NSString stringWithUTF8String:tracks->psz_name]];
tracks = tracks->p_next;
}
libvlc_track_description_release(tracks);
return [NSArray arrayWithArray: tempArray];
return [NSArray arrayWithArray:tempArray];
}
#pragma mark -
......@@ -530,41 +471,27 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
- (void)setCurrentTitleIndex:(NSUInteger)value
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
libvlc_media_player_set_title( instance, value, &ex );
catch_exception( &ex );
libvlc_media_player_set_title(instance, value);
}
- (NSUInteger)currentTitleIndex
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
NSInteger count = libvlc_media_player_get_title_count( instance, &ex );
catch_exception( &ex );
NSInteger count = libvlc_media_player_get_title_count(instance);
if (count <= 0)
return NSNotFound;
NSUInteger result = libvlc_media_player_get_title( instance, &ex );
catch_exception( &ex );
return result;
return libvlc_media_player_get_title(instance);
}
- (NSUInteger)countOfTitles
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
NSUInteger result = libvlc_media_player_get_title_count( instance, &ex );
catch_exception( &ex );
NSUInteger result = libvlc_media_player_get_title_count(instance);
return result;
}
- (NSArray *)titles
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
libvlc_track_description_t *tracks = libvlc_video_get_title_description( instance, &ex );
libvlc_track_description_t *tracks = libvlc_video_get_title_description(instance);
NSMutableArray *tempArray = [NSMutableArray array];
NSInteger i;
for (i = 0; i < [self countOfTitles] ; i++)
......@@ -580,36 +507,26 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
#pragma mark Audio tracks
- (void)setCurrentAudioTrackIndex:(NSUInteger)value
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
libvlc_audio_set_track( instance, (int)value, &ex );
catch_exception( &ex );
libvlc_audio_set_track( instance, (int)value);
}
- (NSUInteger)currentAudioTrackIndex
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
NSInteger count = libvlc_audio_get_track_count( instance, &ex );
catch_exception( &ex );
NSInteger count = libvlc_audio_get_track_count(instance);
if (count <= 0)
return NSNotFound;
NSUInteger result = libvlc_audio_get_track( instance, &ex );
catch_exception( &ex );
NSUInteger result = libvlc_audio_get_track(instance);
return result;
}
- (NSArray *)audioTracks
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
NSInteger count = libvlc_audio_get_track_count( instance, &ex );
catch_exception( &ex );
NSInteger count = libvlc_audio_get_track_count(instance);
if (count <= 0)
return [NSArray array];
libvlc_track_description_t *tracks = libvlc_audio_get_track_description( instance, &ex );
libvlc_track_description_t *tracks = libvlc_audio_get_track_description(instance);
NSMutableArray *tempArray = [NSMutableArray array];
NSUInteger i;
for (i = 0; i < count ; i++)
......@@ -624,19 +541,12 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
- (void)setAudioChannel:(NSInteger)value
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
libvlc_audio_set_channel( instance, value, &ex );
catch_exception( &ex );
libvlc_audio_set_channel(instance, value);
}
- (NSInteger)audioChannel
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
NSInteger result = libvlc_audio_get_channel( instance, &ex );
catch_exception( &ex );
return result;
return libvlc_audio_get_channel(instance);
}
- (void)setMedia:(VLCMedia *)value
......@@ -660,10 +570,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
- (BOOL)play
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
libvlc_media_player_play( (libvlc_media_player_t *)instance, &ex );
catch_exception( &ex );
libvlc_media_player_play(instance);
return YES;
}
......@@ -680,16 +587,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
}
// Pause the stream
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_media_player_pause(instance, &ex);
// fail gracefully
// in most cases, it's just EOF so let's stop
if (libvlc_exception_raised(&ex))
[self stop];
libvlc_exception_clear(&ex);
libvlc_media_player_pause(instance);
}
- (void)stop
......@@ -699,10 +597,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
- (void)gotoNextFrame
{
libvlc_exception_t e;
libvlc_exception_init(&e);
libvlc_media_player_next_frame(instance, &e);
catch_exception(&e);
libvlc_media_player_next_frame(instance);
}
......@@ -798,16 +693,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
- (BOOL)willPlay
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
BOOL ret = libvlc_media_player_will_play( (libvlc_media_player_t *)instance, &ex );
if (libvlc_exception_raised(&ex))
{
libvlc_exception_clear(&ex);
return NO;
}
else
return ret;
return libvlc_media_player_will_play(instance);
}
static const VLCMediaPlayerState libvlc_to_local_state[] =
......@@ -833,28 +719,17 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
- (void)setPosition:(float)newPosition
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
libvlc_media_player_set_position( instance, newPosition, &ex );
catch_exception( &ex );
libvlc_media_player_set_position(instance, newPosition);
}
- (BOOL)isSeekable
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
BOOL ret = libvlc_media_player_is_seekable( instance, &ex );
catch_exception( &ex );
return ret;
return libvlc_media_player_is_seekable(instance);
}
- (BOOL)canPause
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
BOOL ret = libvlc_media_player_can_pause( instance, &ex );
catch_exception( &ex );
return ret;
return libvlc_media_player_can_pause(instance);
}
- (void *)libVLCMediaPlayer
......@@ -880,7 +755,7 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
// instance
libvlc_exception_t ex;
libvlc_exception_init( &ex );
instance = (void *)libvlc_media_player_new([VLCLibrary sharedInstance], &ex);
instance = libvlc_media_player_new([VLCLibrary sharedInstance]);
catch_exception( &ex );
[self registerObservers];
......
......@@ -62,8 +62,6 @@
/* Begin PBXBuildFile section */
63014A7A1042ACE100534090 /* VLCMediaListPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 63014A781042ACE100534090 /* VLCMediaListPlayer.m */; };
63014B7E1042E64A00534090 /* VLCMediaListPlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 63014B7D1042E64A00534090 /* VLCMediaListPlayer.h */; settings = {ATTRIBUTES = (Public, ); }; };
6303C43A0CF45CAE0000ECC8 /* VLCMediaListAspect.m in Sources */ = {isa = PBXBuildFile; fileRef = 6303C4390CF45CAE0000ECC8 /* VLCMediaListAspect.m */; };
6303C43C0CF45CC30000ECC8 /* VLCMediaListAspect.h in Headers */ = {isa = PBXBuildFile; fileRef = 6303C43B0CF45CC30000ECC8 /* VLCMediaListAspect.h */; settings = {ATTRIBUTES = (Public, ); }; };
63098FDC110E7159005F46AE /* VLCExtensionsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 63098FDA110E7159005F46AE /* VLCExtensionsManager.m */; };
63099116110F0EC3005F46AE /* VLCExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63099114110F0EC3005F46AE /* VLCExtension.m */; };
6309994B110FC791005F46AE /* VLCExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 63099949110FC791005F46AE /* VLCExtension.h */; settings = {ATTRIBUTES = (Public, ); }; };
......@@ -141,8 +139,6 @@
63014A781042ACE100534090 /* VLCMediaListPlayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCMediaListPlayer.m; sourceTree = "<group>"; };
63014B7D1042E64A00534090 /* VLCMediaListPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCMediaListPlayer.h; path = Public/VLCMediaListPlayer.h; sourceTree = "<group>"; };
63030CC70CCA652C0088ECD1 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.xml; name = Info.plist; path = Resources/Info.plist; sourceTree = "<group>"; };
6303C4390CF45CAE0000ECC8 /* VLCMediaListAspect.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCMediaListAspect.m; sourceTree = "<group>"; };
6303C43B0CF45CC30000ECC8 /* VLCMediaListAspect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCMediaListAspect.h; path = Public/VLCMediaListAspect.h; sourceTree = "<group>"; };
63098FDA110E7159005F46AE /* VLCExtensionsManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCExtensionsManager.m; sourceTree = "<group>"; };
63099114110F0EC3005F46AE /* VLCExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCExtension.m; sourceTree = "<group>"; };
63099949110FC791005F46AE /* VLCExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCExtension.h; path = Public/VLCExtension.h; sourceTree = "<group>"; };
......@@ -247,7 +243,6 @@
637D5ADB0CF6F2720073EA45 /* VLCMediaDiscoverer.m */,
EF78BD410CAEEFF600354E6E /* VLCMediaList.m */,
63014A781042ACE100534090 /* VLCMediaListPlayer.m */,
6303C4390CF45CAE0000ECC8 /* VLCMediaListAspect.m */,
EF8BB8CF0CAFA8D80038A613 /* VLCMediaPlayer.m */,
EF78BD400CAEEFF600354E6E /* VLCMediaLibrary.m */,
A7A0CEA30D2EF13000F2C039 /* VLCVideoCommon.m */,
......@@ -332,7 +327,6 @@
EF78BD130CAEEEE700354E6E /* VLCMedia.h */,
637D5ABC0CF6F2650073EA45 /* VLCMediaDiscoverer.h */,
EF78BD160CAEEEE700354E6E /* VLCMediaList.h */,
6303C43B0CF45CC30000ECC8 /* VLCMediaListAspect.h */,
63014B7D1042E64A00534090 /* VLCMediaListPlayer.h */,
EF8BB8CE0CAFA8D80038A613 /* VLCMediaPlayer.h */,
EF78BD150CAEEEE700354E6E /* VLCMediaLibrary.h */,
......@@ -363,7 +357,6 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
6303C43C0CF45CC30000ECC8 /* VLCMediaListAspect.h in Headers */,
EF78BD100CAEEEC300354E6E /* VLCEventManager.h in Headers */,
EF78BD1B0CAEEEE700354E6E /* VLCKit.h in Headers */,
EF78BD1C0CAEEEE700354E6E /* VLCMedia.h in Headers */,
......@@ -574,7 +567,6 @@
EF78BEF40CAF07E500354E6E /* VLCVideoView.m in Sources */,
EF8BB8D10CAFA8D80038A613 /* VLCMediaPlayer.m in Sources */,
EF7311910CB5797B009473B4 /* VLCAudio.m in Sources */,
6303C43A0CF45CAE0000ECC8 /* VLCMediaListAspect.m in Sources */,
637D5ADC0CF6F2720073EA45 /* VLCMediaDiscoverer.m in Sources */,
6341FCB10D2C0936002A97B7 /* VLCVideoLayer.m in Sources */,
A7A0CEA50D2EF13000F2C039 /* VLCVideoCommon.m in Sources */,
......
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