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

VLCKit: upgrade ObjC syntax

parent 7cbe8d56
......@@ -61,13 +61,13 @@ extern NSString * VLCMediaMetaChanged; //< Notification message for when the me
@class VLCMediaList;
@class VLCMedia;
typedef enum VLCMediaState
{
enum {
VLCMediaStateNothingSpecial, //< Nothing
VLCMediaStateBuffering, //< Stream is buffering
VLCMediaStatePlaying, //< Stream is playing
VLCMediaStateError, //< Can't be played because an error occurred
} VLCMediaState;
};
typedef NSInteger VLCMediaState;
/**
* Informal protocol declaration for VLCMedia delegates. Allows data changes to be
......
......@@ -44,7 +44,7 @@ extern NSString * VLCMediaPlayerStateChanged;
/**
* VLCMediaPlayerState describes the state of the media player.
*/
typedef enum VLCMediaPlayerState
enum
{
VLCMediaPlayerStateStopped, //< Player has stopped
VLCMediaPlayerStateOpening, //< Stream is opening
......@@ -53,7 +53,8 @@ typedef enum VLCMediaPlayerState
VLCMediaPlayerStateError, //< Player has generated an error
VLCMediaPlayerStatePlaying, //< Stream is playing
VLCMediaPlayerStatePaused //< Stream is paused
} VLCMediaPlayerState;
};
typedef NSInteger VLCMediaPlayerState;
/**
* Returns the name of the player state as a string.
......
......@@ -4,6 +4,7 @@ The entire framework was relicensed to LGPL 2.1 or later as well as its
underlying playback modules.
Support for transcoding and streaming as well as DVD playback was not affected
by this move and stays under GPL until further notice.
Please note that the Objective-C syntax was updated, so VLCKit may no longer compile with outdated versions of Xcode / clang.
New APIs:
- VLCStreamOutput:
......
......@@ -97,12 +97,12 @@ static void * EventDispatcherMainLoop(void * user_data)
if (message->type == VLCNotification) {
NSInteger last_match_msg = -1;
for (NSInteger i = [[self messageQueue] count]-1; i >= 0; i-- ) {
message_newer = (message_t *)[(NSData *)[[self messageQueue] objectAtIndex:i] bytes];
message_newer = (message_t *)[(NSData *)[self messageQueue][i] bytes];
if (message_newer->type == VLCNotification &&
message_newer->target == message->target &&
[message_newer->u.name isEqualToString:message->u.name]) {
if (last_match_msg >= 0) {
message_t * msg = (message_t *)[(NSData *)[[self messageQueue] objectAtIndex:last_match_msg] bytes];
message_t * msg = (message_t *)[(NSData *)[self messageQueue][last_match_msg] bytes];
[msg->u.name release];
[[self messageQueue] removeObjectAtIndex:last_match_msg];
}
......@@ -120,7 +120,7 @@ static void * EventDispatcherMainLoop(void * user_data)
/* Collapse messages that takes array arg by sending one bigger array */
for (NSInteger i = [[self messageQueue] count] - 1; i >= 0; i--) {
message_newer = (message_t *)[(NSData *)[[self messageQueue] objectAtIndex: i] bytes];
message_newer = (message_t *)[(NSData *)[self messageQueue][i] bytes];
if (message_newer->type == VLCObjectMethodWithArrayArg &&
message_newer->target == message->target &&
message_newer->sel == message->sel) {
......@@ -264,7 +264,7 @@ static void * EventDispatcherMainLoop(void * user_data)
NSMutableArray *queue = [self messageQueue];
for (int i = [queue count] - 1; i >= 0; i--) {
NSData *data = [queue objectAtIndex:i];
NSData *data = queue[i];
message_t *message = (message_t *)[data bytes];
if (message->target == target)
[queue removeObjectAtIndex:i];
......@@ -273,7 +273,7 @@ static void * EventDispatcherMainLoop(void * user_data)
// Remove all pending messages
NSMutableArray *messages = pendingMessagesOnMainThread;
for (int i = [messages count] - 1; i >= 0; i--) {
NSData *data = [messages objectAtIndex:i];
NSData *data = messages[i];
message_t *message = (message_t *)[data bytes];
if (message->target == target)
......
......@@ -53,7 +53,7 @@ static VLCLibrary * sharedLibrary = nil;
if (self = [super init]) {
NSArray *vlcParams;
#if TARGET_OS_IPHONE
vlcParams = [NSArray arrayWithObjects:@"--play-and-pause", @"--no-color", @"--no-video-title-show", @"--verbose=3", @"--avcodec-fast", @"--avcodec-skiploopfilter=all", @"--no-stats", @"--no-plugins-cache", @"--vout=vout_ios2", nil];
vlcParams = @[@"--play-and-pause", @"--no-color", @"--no-video-title-show", @"--verbose=3", @"--avcodec-fast", @"--avcodec-skiploopfilter=all", @"--no-stats", @"--no-plugins-cache", @"--vout=vout_ios2"];
#else
vlcParams = [[NSUserDefaults standardUserDefaults] objectForKey:@"VLCParams"];
if (!vlcParams) {
......@@ -78,7 +78,7 @@ static VLCLibrary * sharedLibrary = nil;
NSUInteger count = [vlcParams count];
const char *lib_vlc_params[count];
while (paramNum < count) {
NSString *vlcParam = [vlcParams objectAtIndex:paramNum];
NSString *vlcParam = vlcParams[paramNum];
lib_vlc_params[paramNum] = [vlcParam cStringUsingEncoding:NSASCIIStringEncoding];
paramNum++;
}
......@@ -91,12 +91,12 @@ static VLCLibrary * sharedLibrary = nil;
- (NSString *)version
{
return [NSString stringWithUTF8String:libvlc_get_version()];
return @(libvlc_get_version());
}
- (NSString *)changeset
{
return [NSString stringWithUTF8String:libvlc_get_changeset()];
return @(libvlc_get_changeset());
}
- (void)dealloc
......
......@@ -132,7 +132,7 @@ static void HandleMediaDurationChanged(const libvlc_event_t * event, void * self
[[VLCEventManager sharedManager] callOnMainThreadObject:self
withMethod:@selector(setLength:)
withArgumentAsObject:[VLCTime timeWithNumber:
[NSNumber numberWithLongLong:event->u.media_duration_changed.new_duration]]];
@(event->u.media_duration_changed.new_duration)]];
[pool drain];
}
......@@ -142,8 +142,7 @@ static void HandleMediaStateChanged(const libvlc_event_t * event, void * self)
[[VLCEventManager sharedManager] callOnMainThreadObject:self
withMethod:@selector(setStateAsNumber:)
withArgumentAsObject:[NSNumber numberWithInt:
LibVLCStateToMediaState(event->u.media_state_changed.new_state)]];
withArgumentAsObject:@(LibVLCStateToMediaState(event->u.media_state_changed.new_state))];
[pool drain];
}
......@@ -161,7 +160,7 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[[VLCEventManager sharedManager] callOnMainThreadObject:self
withMethod:@selector(parsedChanged:)
withArgumentAsObject:[NSNumber numberWithBool:event->u.media_parsed_changed.new_status]];
withArgumentAsObject:@((BOOL)event->u.media_parsed_changed.new_status)];
[pool release];
}
......@@ -251,7 +250,7 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
- (NSString *)description
{
NSString * result = [metaDictionary objectForKey:VLCMetaInformationTitle];
NSString * result = metaDictionary[VLCMetaInformationTitle];
return [NSString stringWithFormat:@"<%@ %p> %@", [self class], self, (result ? result : [url absoluteString])];
}
......@@ -272,7 +271,7 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
// Try figuring out what the length is
long long duration = libvlc_media_get_duration( p_md );
if (duration > -1) {
length = [[VLCTime timeWithNumber:[NSNumber numberWithLongLong:duration]] retain];
length = [[VLCTime timeWithNumber:@(duration)] retain];
return [[length retain] autorelease];
}
return [VLCTime nullTime];
......@@ -316,8 +315,8 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
{
if (p_md) {
for (NSString * key in [options allKeys]) {
if ([options objectForKey:key] != [NSNull null])
libvlc_media_add_option(p_md, [[NSString stringWithFormat:@"%@=%@", key, [options objectForKey:key]] UTF8String]);
if (options[key] != [NSNull null])
libvlc_media_add_option(p_md, [[NSString stringWithFormat:@"%@=%@", key, options[key]] UTF8String]);
else
libvlc_media_add_option(p_md, [[NSString stringWithFormat:@"%@", key] UTF8String]);
}
......@@ -333,21 +332,21 @@ static void HandleMediaParsedChanged(const libvlc_event_t * event, void * self)
libvlc_media_stats_t p_stats;
libvlc_media_get_stats(p_md, &p_stats);
[d setObject:[NSNumber numberWithFloat: p_stats.f_demux_bitrate] forKey:@"demuxBitrate"];
[d setObject:[NSNumber numberWithFloat: p_stats.f_input_bitrate] forKey:@"inputBitrate"];
[d setObject:[NSNumber numberWithFloat: p_stats.f_send_bitrate] forKey:@"sendBitrate"];
[d setObject:[NSNumber numberWithInt: p_stats.i_decoded_audio] forKey:@"decodedAudio"];
[d setObject:[NSNumber numberWithInt: p_stats.i_decoded_video] forKey:@"decodedVideo"];
[d setObject:[NSNumber numberWithInt: p_stats.i_demux_corrupted] forKey:@"demuxCorrupted"];
[d setObject:[NSNumber numberWithInt: p_stats.i_demux_discontinuity] forKey:@"demuxDiscontinuity"];
[d setObject:[NSNumber numberWithInt: p_stats.i_demux_read_bytes] forKey:@"demuxReadBytes"];
[d setObject:[NSNumber numberWithInt: p_stats.i_displayed_pictures] forKey:@"displayedPictures"];
[d setObject:[NSNumber numberWithInt: p_stats.i_lost_abuffers] forKey:@"lostAbuffers"];
[d setObject:[NSNumber numberWithInt: p_stats.i_lost_pictures] forKey:@"lostPictures"];
[d setObject:[NSNumber numberWithInt: p_stats.i_played_abuffers] forKey:@"playedAbuffers"];
[d setObject:[NSNumber numberWithInt: p_stats.i_read_bytes] forKey:@"readBytes"];
[d setObject:[NSNumber numberWithInt: p_stats.i_sent_bytes] forKey:@"sentBytes"];
[d setObject:[NSNumber numberWithInt: p_stats.i_sent_packets] forKey:@"sentPackets"];
d[@"demuxBitrate"] = @(p_stats.f_demux_bitrate);
d[@"inputBitrate"] = @(p_stats.f_input_bitrate);
d[@"sendBitrate"] = @(p_stats.f_send_bitrate);
d[@"decodedAudio"] = @(p_stats.i_decoded_audio);
d[@"decodedVideo"] = @(p_stats.i_decoded_video);
d[@"demuxCorrupted"] = @(p_stats.i_demux_corrupted);
d[@"demuxDiscontinuity"] = @(p_stats.i_demux_discontinuity);
d[@"demuxReadBytes"] = @(p_stats.i_demux_read_bytes);
d[@"displayedPictures"] = @(p_stats.i_displayed_pictures);
d[@"lostAbuffers"] = @(p_stats.i_lost_abuffers);
d[@"lostPictures"] = @(p_stats.i_lost_pictures);
d[@"playedAbuffers"] = @(p_stats.i_played_abuffers);
d[@"readBytes"] = @(p_stats.i_read_bytes);
d[@"sentBytes"] = @(p_stats.i_sent_bytes);
d[@"sentPackets"] = @(p_stats.i_sent_packets);
return d;
}
......@@ -557,54 +556,43 @@ NSString *VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
NSMutableArray *array = [NSMutableArray array];
for (NSUInteger i = 0; i < count; i++) {
NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithUnsignedInt:tracksInfo[i]->i_codec],
@(tracksInfo[i]->i_codec),
VLCMediaTracksInformationCodec,
[NSNumber numberWithInt:tracksInfo[i]->i_id],
@(tracksInfo[i]->i_id),
VLCMediaTracksInformationId,
[NSNumber numberWithInt:tracksInfo[i]->i_profile],
@(tracksInfo[i]->i_profile),
VLCMediaTracksInformationCodecProfile,
[NSNumber numberWithInt:tracksInfo[i]->i_level],
@(tracksInfo[i]->i_level),
VLCMediaTracksInformationCodecLevel,
[NSNumber numberWithUnsignedInt:tracksInfo[i]->i_bitrate],
@(tracksInfo[i]->i_bitrate),
VLCMediaTracksInformationBitrate,
nil];
if (tracksInfo[i]->psz_language)
[dictionary setObject:[NSString stringWithFormat:@"%s",tracksInfo[i]->psz_language]
forKey:VLCMediaTracksInformationLanguage];
dictionary[VLCMediaTracksInformationLanguage] = [NSString stringWithFormat:@"%s",tracksInfo[i]->psz_language];
if (tracksInfo[i]->psz_description)
[dictionary setObject:[NSString stringWithFormat:@"%s",tracksInfo[i]->psz_description]
forKey:VLCMediaTracksInformationDescription];
dictionary[VLCMediaTracksInformationDescription] = [NSString stringWithFormat:@"%s",tracksInfo[i]->psz_description];
NSString *type;
switch (tracksInfo[i]->i_type) {
case libvlc_track_audio:
type = VLCMediaTracksInformationTypeAudio;
[dictionary setObject:[NSNumber numberWithUnsignedInt:tracksInfo[i]->audio->i_channels]
forKey:VLCMediaTracksInformationAudioChannelsNumber];
[dictionary setObject:[NSNumber numberWithUnsignedInt:tracksInfo[i]->audio->i_rate]
forKey:VLCMediaTracksInformationAudioRate];
dictionary[VLCMediaTracksInformationAudioChannelsNumber] = @(tracksInfo[i]->audio->i_channels);
dictionary[VLCMediaTracksInformationAudioRate] = @(tracksInfo[i]->audio->i_rate);
break;
case libvlc_track_video:
type = VLCMediaTracksInformationTypeVideo;
[dictionary setObject:[NSNumber numberWithUnsignedInt:tracksInfo[i]->video->i_width]
forKey:VLCMediaTracksInformationVideoWidth];
[dictionary setObject:[NSNumber numberWithUnsignedInt:tracksInfo[i]->video->i_height]
forKey:VLCMediaTracksInformationVideoHeight];
[dictionary setObject:[NSNumber numberWithUnsignedInt:tracksInfo[i]->video->i_sar_num]
forKey:VLCMediaTracksInformationSourceAspectRatio];
[dictionary setObject:[NSNumber numberWithUnsignedInt:tracksInfo[i]->video->i_sar_den]
forKey:VLCMediaTracksInformationSourceAspectDenominator];
[dictionary setObject:[NSNumber numberWithUnsignedInt:tracksInfo[i]->video->i_frame_rate_num]
forKey:VLCMediaTracksInformationFrameRate];
[dictionary setObject:[NSNumber numberWithUnsignedInt:tracksInfo[i]->video->i_frame_rate_den]
forKey:VLCMediaTracksInformationFrameRateDenominator];
dictionary[VLCMediaTracksInformationVideoWidth] = @(tracksInfo[i]->video->i_width);
dictionary[VLCMediaTracksInformationVideoHeight] = @(tracksInfo[i]->video->i_height);
dictionary[VLCMediaTracksInformationSourceAspectRatio] = @(tracksInfo[i]->video->i_sar_num);
dictionary[VLCMediaTracksInformationSourceAspectDenominator] = @(tracksInfo[i]->video->i_sar_den);
dictionary[VLCMediaTracksInformationFrameRate] = @(tracksInfo[i]->video->i_frame_rate_num);
dictionary[VLCMediaTracksInformationFrameRateDenominator] = @(tracksInfo[i]->video->i_frame_rate_den);
break;
case libvlc_track_text:
type = VLCMediaTracksInformationTypeText;
if (tracksInfo[i]->subtitle->psz_encoding)
[dictionary setObject:[NSString stringWithFormat:@"%s", tracksInfo[i]->subtitle->psz_encoding]
forKey:VLCMediaTracksInformationTextEncoding];
dictionary[VLCMediaTracksInformationTextEncoding] = [NSString stringWithFormat:@"%s", tracksInfo[i]->subtitle->psz_encoding];
break;
case libvlc_track_unknown:
default:
......@@ -649,7 +637,7 @@ NSString *VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
char *answer = malloc(size);
sysctlbyname("hw.machine", answer, &size, NULL, 0);
NSString *currentMachine = [NSString stringWithCString:answer encoding: NSUTF8StringEncoding];
NSString *currentMachine = @(answer);
free(answer);
NSUInteger totalNumberOfPixels = biggestWidth * biggestHeight;
......@@ -710,8 +698,8 @@ NSString *VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
p_md = libvlc_media_duplicate([media libVLCMediaDescriptor]);
for (NSString * key in [options allKeys]) {
if ([options objectForKey:key] != [NSNull null])
libvlc_media_add_option(p_md, [[NSString stringWithFormat:@"%@=%@", key, [options objectForKey:key]] UTF8String]);
if (options[key] != [NSNull null])
libvlc_media_add_option(p_md, [[NSString stringWithFormat:@"%@=%@", key, options[key]] UTF8String]);
else
libvlc_media_add_option(p_md, [[NSString stringWithFormat:@"%@", key] UTF8String]);
......@@ -753,7 +741,7 @@ NSString *VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
nil] retain];
#undef VLCStringToMeta
}
NSNumber * number = [stringToMetaDictionary objectForKey:string];
NSNumber * number = stringToMetaDictionary[string];
return number ? [number intValue] : -1;
}
......@@ -784,9 +772,9 @@ NSString *VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
{
char * p_url = libvlc_media_get_mrl( p_md );
url = [[NSURL URLWithString:[NSString stringWithUTF8String:p_url]] retain];
url = [[NSURL URLWithString:@(p_url)] retain];
if (!url) /* Attempt to interpret as a file path then */
url = [[NSURL fileURLWithPath:[NSString stringWithUTF8String:p_url]] retain];
url = [[NSURL fileURLWithPath:@(p_url)] retain];
free(p_url);
libvlc_media_set_user_data(p_md, (void*)self);
......@@ -814,7 +802,7 @@ NSString *VLCMediaTracksInformationTextEncoding = @"encoding"; // NSString
- (void)fetchMetaInformationFromLibVLCWithType:(NSString *)metaType
{
char * psz_value = libvlc_media_get_meta( p_md, [VLCMedia stringToMetaType:metaType] );
NSString * newValue = psz_value ? [NSString stringWithUTF8String: psz_value] : nil;
NSString * newValue = psz_value ? @(psz_value) : nil;
NSString * oldValue = [metaDictionary valueForKey:metaType];
free(psz_value);
......
......@@ -29,7 +29,7 @@
#include <vlc/libvlc.h>
static NSMutableArray * availableMediaDiscoverer = nil; // Global list of media discoverers
static NSArray * availableMediaDiscoverer = nil; // Global list of media discoverers
/**
* Declares call back functions to be used with libvlc event callbacks.
......@@ -72,11 +72,10 @@ static void HandleMediaDiscovererEnded( const libvlc_event_t * event, void * use
+ (NSArray *)availableMediaDiscoverer
{
if (!availableMediaDiscoverer) {
availableMediaDiscoverer = [[NSArray arrayWithObjects:
[[[VLCMediaDiscoverer alloc] initWithName:@"sap"] autorelease],
availableMediaDiscoverer = [@[[[[VLCMediaDiscoverer alloc] initWithName:@"sap"] autorelease],
[[[VLCMediaDiscoverer alloc] initWithName:@"upnp"] autorelease],
[[[VLCMediaDiscoverer alloc] initWithName:@"freebox"] autorelease],
[[[VLCMediaDiscoverer alloc] initWithName:@"video_dir"] autorelease], nil] retain];
[[[VLCMediaDiscoverer alloc] initWithName:@"video_dir"] autorelease]] retain];
}
return availableMediaDiscoverer;
}
......@@ -131,7 +130,7 @@ static void HandleMediaDiscovererEnded( const libvlc_event_t * event, void * use
char * name = libvlc_media_discoverer_localized_name( mdis );
if (name) {
localizedName = [[NSString stringWithUTF8String:name] retain];
localizedName = [@(name) retain];
free( name );
}
return localizedName;
......
......@@ -56,10 +56,8 @@ static void HandleMediaListItemAdded(const libvlc_event_t * event, void * user_d
id self = user_data;
[[VLCEventManager sharedManager] callOnMainThreadObject:self
withMethod:@selector(mediaListItemAdded:)
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]]];
withArgumentAsObject:@[@{@"media": [VLCMedia mediaWithLibVLCMediaDescriptor:event->u.media_list_item_added.item],
@"index": @(event->u.media_list_item_added.index)}]];
[pool drain];
}
......@@ -69,7 +67,7 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
id self = user_data;
[[VLCEventManager sharedManager] callOnMainThreadObject:self
withMethod:@selector(mediaListItemRemoved:)
withArgumentAsObject:[NSNumber numberWithInt:event->u.media_list_item_deleted.index]];
withArgumentAsObject:@(event->u.media_list_item_deleted.index)];
[pool drain];
}
......@@ -149,7 +147,7 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
- (VLCMedia *)mediaAtIndex:(NSInteger)index
{
if (index < [cachedMedia count])
return [cachedMedia objectAtIndex:index];
return cachedMedia[index];
return NULL;
}
......@@ -238,14 +236,14 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
- (void)mediaListItemAdded:(NSArray *)arrayOfArgs
{
/* 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];
NSInteger start = [arrayOfArgs[0][@"index"] intValue];
NSInteger end = [arrayOfArgs[[arrayOfArgs count]-1][@"index"] intValue];
NSRange range = NSMakeRange(start, end-start);
[self willChange:NSKeyValueChangeInsertion valuesAtIndexes:[NSIndexSet indexSetWithIndexesInRange:range] forKey:@"media"];
for (NSDictionary * args in arrayOfArgs) {
NSInteger index = [[args objectForKey:@"index"] intValue];
VLCMedia * media = [args objectForKey:@"media"];
NSInteger index = [args[@"index"] intValue];
VLCMedia * media = args[@"media"];
/* Sanity check */
if (index && index > [cachedMedia count])
index = [cachedMedia count];
......@@ -272,9 +270,7 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
// Post the notification
[[NSNotificationCenter defaultCenter] postNotificationName:VLCMediaListItemDeleted
object:self
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
index, @"index",
nil]];
userInfo:@{@"index": index}];
// Let the delegate know that the item is being removed
if (delegate && [delegate respondsToSelector:@selector(mediaList:mediaRemovedAtIndex:)])
......
......@@ -78,7 +78,7 @@ static void HandleMediaTimeChanged(const libvlc_event_t * event, void * self)
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[[VLCEventManager sharedManager] callOnMainThreadObject:self
withMethod:@selector(mediaPlayerTimeChanged:)
withArgumentAsObject:[NSNumber numberWithLongLong:event->u.media_player_time_changed.new_time]];
withArgumentAsObject:@(event->u.media_player_time_changed.new_time)];
[[VLCEventManager sharedManager] callOnMainThreadDelegateOfObject:self
withDelegateMethod:@selector(mediaPlayerTimeChanged:)
......@@ -92,7 +92,7 @@ static void HandleMediaPositionChanged(const libvlc_event_t * event, void * self
[[VLCEventManager sharedManager] callOnMainThreadObject:self
withMethod:@selector(mediaPlayerPositionChanged:)
withArgumentAsObject:[NSNumber numberWithFloat:event->u.media_player_position_changed.new_position]];
withArgumentAsObject:@(event->u.media_player_position_changed.new_position)];
[pool drain];
}
......@@ -121,7 +121,7 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
[[VLCEventManager sharedManager] callOnMainThreadObject:self
withMethod:@selector(mediaPlayerStateChanged:)
withArgumentAsObject:[NSNumber numberWithInt:newState]];
withArgumentAsObject:@(newState)];
[[VLCEventManager sharedManager] callOnMainThreadDelegateOfObject:self
withDelegateMethod:@selector(mediaPlayerStateChanged:)
......@@ -164,19 +164,17 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
static NSDictionary * dict = nil;
NSSet * superKeyPaths;
if (!dict) {
dict = [[NSDictionary dictionaryWithObjectsAndKeys:
[NSSet setWithObject:@"state"], @"playing",
[NSSet setWithObjects:@"state", @"media", nil], @"seekable",
[NSSet setWithObjects:@"state", @"media", nil], @"canPause",
[NSSet setWithObjects:@"state", @"media", nil], @"description",
nil] retain];
dict = [@{@"playing": [NSSet setWithObject:@"state"],
@"seekable": [NSSet setWithObjects:@"state", @"media", nil],
@"canPause": [NSSet setWithObjects:@"state", @"media", nil],
@"description": [NSSet setWithObjects:@"state", @"media", nil]} retain];
}
if ((superKeyPaths = [super keyPathsForValuesAffectingValueForKey: key])) {
NSMutableSet * ret = [NSMutableSet setWithSet:[dict objectForKey: key]];
NSMutableSet * ret = [NSMutableSet setWithSet:dict[key]];
[ret unionSet:superKeyPaths];
return ret;
}
return [dict objectForKey: key];
return dict[key];
}
/* Contructor */
......@@ -289,13 +287,13 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
{
NSInteger count = libvlc_video_get_track_count(instance);
if (count <= 0)
return [NSArray array];
return @[];
libvlc_track_description_t *currentTrack = libvlc_video_get_track_description(instance);
NSMutableArray *tempArray = [NSMutableArray array];
while (currentTrack) {
[tempArray addObject:[NSString stringWithUTF8String:currentTrack->psz_name]];
[tempArray addObject:@(currentTrack->psz_name)];
currentTrack = currentTrack->p_next;
}
libvlc_track_description_list_release(currentTrack);
......@@ -306,13 +304,13 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
{
NSInteger count = libvlc_video_get_track_count(instance);
if (count <= 0)
return [NSArray array];
return @[];
libvlc_track_description_t *currentTrack = libvlc_video_get_track_description(instance);
NSMutableArray *tempArray = [NSMutableArray array];
while (currentTrack) {
[tempArray addObject:[NSNumber numberWithInt:currentTrack->i_id]];
[tempArray addObject:@(currentTrack->i_id)];
currentTrack = currentTrack->p_next;
}
libvlc_track_description_list_release(currentTrack);
......@@ -323,12 +321,12 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
{
NSInteger count = libvlc_video_get_track_count(instance);
if (count <= 0)
return [NSArray array];
return @[];
libvlc_track_description_t *tracks = libvlc_video_get_track_description(instance);
NSMutableArray *tempArray = [NSMutableArray array];
for (NSUInteger i = 0; i < count ; i++) {
[tempArray addObject:[NSString stringWithUTF8String: tracks->psz_name]];
[tempArray addObject:@(tracks->psz_name)];
tracks = tracks->p_next;
}
libvlc_track_description_list_release(tracks);
......@@ -358,13 +356,13 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
{
NSInteger count = libvlc_video_get_spu_count(instance);
if (count <= 0)
return [NSArray array];
return @[];
libvlc_track_description_t *currentTrack = libvlc_video_get_spu_description(instance);
NSMutableArray *tempArray = [NSMutableArray array];
while (currentTrack) {
[tempArray addObject:[NSString stringWithUTF8String:currentTrack->psz_name]];
[tempArray addObject:@(currentTrack->psz_name)];
currentTrack = currentTrack->p_next;
}
libvlc_track_description_list_release(currentTrack);
......@@ -375,13 +373,13 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
{
NSInteger count = libvlc_video_get_spu_count(instance);
if (count <= 0)
return [NSArray array];
return @[];
libvlc_track_description_t *currentTrack = libvlc_video_get_spu_description(instance);
NSMutableArray *tempArray = [NSMutableArray array];
while (currentTrack) {
[tempArray addObject:[NSNumber numberWithInt:currentTrack->i_id]];
[tempArray addObject:@(currentTrack->i_id)];
currentTrack = currentTrack->p_next;
}
libvlc_track_description_list_release(currentTrack);
......@@ -399,7 +397,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
NSMutableArray *tempArray = [NSMutableArray array];
while (currentTrack) {
[tempArray addObject:[NSString stringWithUTF8String:currentTrack->psz_name]];
[tempArray addObject:@(currentTrack->psz_name)];
currentTrack = currentTrack->p_next;
}
libvlc_track_description_list_release(currentTrack);
......@@ -598,12 +596,12 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
{
NSInteger count = libvlc_media_player_get_chapter_count(instance);
if (count <= 0)
return [NSArray array];
return @[];
libvlc_track_description_t *tracks = libvlc_video_get_chapter_description(instance, title);
NSMutableArray *tempArray = [NSMutableArray array];
for (NSInteger i = 0; i < count ; i++) {
[tempArray addObject:[NSString stringWithUTF8String:tracks->psz_name]];
[tempArray addObject:@(tracks->psz_name)];
tracks = tracks->p_next;
}
libvlc_track_description_list_release(tracks);
......@@ -638,7 +636,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
libvlc_track_description_t *tracks = libvlc_video_get_title_description(instance);
NSMutableArray *tempArray = [NSMutableArray array];
for (NSInteger i = 0; i < [self countOfTitles] ; i++) {
[tempArray addObject:[NSString stringWithUTF8String: tracks->psz_name]];
[tempArray addObject:@(tracks->psz_name)];
tracks = tracks->p_next;
}
libvlc_track_description_list_release(tracks);
......@@ -666,13 +664,13 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
{
NSInteger count = libvlc_audio_get_track_count(instance);
if (count <= 0)
return [NSArray array];
return @[];
libvlc_track_description_t *currentTrack = libvlc_audio_get_track_description(instance);
NSMutableArray *tempArray = [NSMutableArray array];
while (currentTrack) {
[tempArray addObject:[NSString stringWithUTF8String:currentTrack->psz_name]];
[tempArray addObject:@(currentTrack->psz_name)];
currentTrack = currentTrack->p_next;
}
libvlc_track_description_list_release(currentTrack);
......@@ -683,13 +681,13 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
{
NSInteger count = libvlc_audio_get_track_count(instance);
if (count <= 0)
return [NSArray array];
return @[];
libvlc_track_description_t *currentTrack = libvlc_audio_get_track_description(instance);
NSMutableArray *tempArray = [NSMutableArray array];
while (currentTrack) {
[tempArray addObject:[NSNumber numberWithInt:currentTrack->i_id]];
[tempArray addObject:@(currentTrack->i_id)];
currentTrack = currentTrack->p_next;
}
libvlc_track_description_list_release(currentTrack);
......@@ -700,12 +698,12 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
{
NSInteger count = libvlc_audio_get_track_count(instance);
if (count <= 0)
return [NSArray array];
return @[];
libvlc_track_description_t *tracks = libvlc_audio_get_track_description(instance);
NSMutableArray *tempArray = [NSMutableArray array];
for (NSUInteger i = 0; i < count ; i++) {
[tempArray addObject:[NSString stringWithUTF8String: tracks->psz_name]];
[tempArray addObject:@(tracks->psz_name)];
tracks = tracks->p_next;
}
libvlc_track_description_list_release(tracks);
......@@ -1018,7 +1016,7 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
[cachedRemainingTime release];
double currentTime = [[cachedTime numberValue] doubleValue];
double remaining = currentTime / position * (1 - position);
cachedRemainingTime = [[VLCTime timeWithNumber:[NSNumber numberWithDouble:-remaining]] retain];
cachedRemainingTime = [[VLCTime timeWithNumber:@(-remaining)] retain];
[self didChangeValueForKey:@"remainingTime"];
[self didChangeValueForKey:@"time"];
}
......
......@@ -123,7 +123,7 @@ void display(void *opaque, void *picture)
// Find the video track
NSDictionary *videoTrack = nil;
for (NSDictionary *track in tracks) {
NSString *type = [track objectForKey:VLCMediaTracksInformationType];
NSString *type = track[VLCMediaTracksInformationType];
if ([type isEqualToString:VLCMediaTracksInformationTypeVideo]) {
videoTrack = track;
break;
......@@ -136,8 +136,8 @@ void display(void *opaque, void *picture)
if (!videoTrack)
VKLog(@"WARNING: Can't find video track info, still attempting to thumbnail in doubt");
else {
int videoHeight = [[videoTrack objectForKey:VLCMediaTracksInformationVideoHeight] intValue];
int videoWidth = [[videoTrack objectForKey:VLCMediaTracksInformationVideoWidth] intValue];
int videoHeight = [videoTrack[VLCMediaTracksInformationVideoHeight] intValue];
int videoWidth = [videoTrack[VLCMediaTracksInformationVideoWidth] intValue];
// Constraining to the aspect ratio of the video.
double ratio;
......
......@@ -60,7 +60,7 @@
{
if (self = [super init]) {
if (aInt)
value = [[NSNumber numberWithInt: aInt] retain];
value = [@(aInt) retain];
else
value = nil;
}
......
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