Commit 6f4f5211 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

macosx/framework: Simplify the API for audio tracks, chapters, titles, and subtitles.

parent e0ee5193
......@@ -105,11 +105,6 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
- (void)setVideoAspectRatio:(char *)value;
- (char *)videoAspectRatio;
- (void)setVideoSubTitles:(int)value;
- (int)countOfVideoSubTitles;
- (BOOL)openVideoSubTitlesFromFile:(NSString *)path;
- (int)currentVideoSubTitles;
- (NSArray *)videoSubTitles;
- (void)setVideoCropGeometry:(char *)value;
- (char *)videoCropGeometry;
......@@ -161,20 +156,47 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
@property (readonly) VLCTime *remainingTime;
@property (readonly) int fps;
- (void)setChapter:(int)value;
- (int)currentChapter;
- (int)countOfChapters;
- (NSArray *)chaptersForTitle:(int)title;
/**
* Return the current video subtitle index, or
* \return NSNotFound if none is set.
*
* To disable subtitle pass NSNotFound.
*/
@property (readwrite) NSUInteger currentVideoSubTitleIndex;
- (NSArray *)videoSubTitles;
/**
* Load and set a specific video subtitle, from a file.
* \param path to a file
* \return if the call succeed..
*/
- (BOOL)openVideoSubTitlesFromFile:(NSString *)path;
- (void)setCurrentTitle:(int)value;
- (int)currentTitle;
- (int)countOfTitles;
/**
* Chapter selection and enumeration, it is bound
* to a title option.
*/
/**
* Return the current video subtitle index, or
* \return NSNotFound if none is set.
*
* To disable subtitle pass NSNotFound.
*/
@property (readwrite) NSUInteger currentChapterIndex;
- (void)previousChapter;
- (void)nextChapter;
- (NSArray *)chaptersForTitleIndex:(NSUInteger)titleIndex;
/**
* Title selection and enumeration
* \return NSNotFound if none is set.
*/
@property (readwrite) NSUInteger currentTitleIndex;
- (NSArray *)titles;
/* Audio Options */
- (void)setAudioTrack:(int)value;
- (int)currentAudioTrack;
- (int)countOfAudioTracks;
@property (readwrite) NSUInteger currentAudioTrackIndex;
- (NSArray *)audioTracks;
- (void)setAudioChannel:(int)value;
......
......@@ -258,45 +258,26 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
return [[VLCLibrary sharedLibrary] audio];
}
- (void)setVideoAspectRatio:(char *)value
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
libvlc_video_set_aspect_ratio( instance, value, &ex );
catch_exception( &ex );
}
- (char *)videoAspectRatio
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
char * result = libvlc_video_get_aspect_ratio( instance, &ex );
catch_exception( &ex );
return result;
}
#pragma mark -
#pragma mark Subtitles
- (void)setVideoSubTitles:(int)value
- (void)setCurrentVideoSubTitleIndex:(NSUInteger)index
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
libvlc_video_set_spu( instance, value, &ex );
libvlc_video_set_spu( instance, (int)index, &ex );
catch_exception( &ex );
}
- (int)countOfVideoSubTitles
- (NSUInteger)currentVideoSubTitleIndex
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
int result = libvlc_video_get_spu_count( instance, &ex );
int count = libvlc_video_get_spu_count( instance, &ex );
catch_exception( &ex );
return result;
}
- (int)currentVideoSubTitles
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
int result = libvlc_video_get_spu( instance, &ex );
if (count <= 0)
return NSNotFound;
NSUInteger result = libvlc_video_get_spu( instance, &ex );
catch_exception( &ex );
return result;
}
......@@ -314,10 +295,13 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
int count = libvlc_video_get_spu_count( instance, &ex );
catch_exception( &ex );
libvlc_track_description_t *tracks = libvlc_video_get_spu_description( instance, &ex );
NSMutableArray *tempArray = [NSMutableArray array];
NSInteger i;
for (i = 0; i < [self countOfVideoSubTitles] ; i++)
for (i = 0; i < count; i++)
{
[tempArray addObject:[NSString stringWithUTF8String: tracks->psz_name]];
tracks = tracks->p_next;
......@@ -325,6 +309,10 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
return [NSArray arrayWithArray: tempArray];
}
#pragma mark -
#pragma mark Video Crop geometry
- (void)setVideoCropGeometry:(char *)value
{
libvlc_exception_t ex;
......@@ -342,6 +330,23 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
return result;
}
- (void)setVideoAspectRatio:(char *)value
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
libvlc_video_set_aspect_ratio( instance, value, &ex );
catch_exception( &ex );
}
- (char *)videoAspectRatio
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
char * result = libvlc_video_get_aspect_ratio( instance, &ex );
catch_exception( &ex );
return result;
}
- (void)setVideoTeleText:(int)value
{
libvlc_exception_t ex;
......@@ -458,7 +463,9 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
return result;
}
- (void)setChapter:(int)value;
#pragma mark -
#pragma mark Chapters
- (void)setCurrentChapterIndex:(NSUInteger)value;
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
......@@ -466,20 +473,15 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
catch_exception( &ex );
}
- (int)currentChapter
- (NSUInteger)currentChapterIndex
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
int result = libvlc_media_player_get_chapter( instance, &ex );
int count = libvlc_media_player_get_chapter_count( instance, &ex );
catch_exception( &ex );
return result;
}
- (int)countOfChapters
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
int result = libvlc_media_player_get_chapter_count( instance, &ex );
if (count <= 0)
return NSNotFound;
NSUInteger result = libvlc_media_player_get_chapter( instance, &ex );
catch_exception( &ex );
return result;
}
......@@ -500,14 +502,18 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
catch_exception( &ex );
}
- (NSArray *)chaptersForTitle:(int)title
- (NSArray *)chaptersForTitleIndex:(NSUInteger)title
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
int count = libvlc_media_player_get_chapter_count(instance, &ex);
if (count <= 0)
return [NSArray array];
libvlc_track_description_t *tracks = libvlc_video_get_chapter_description( instance, title, &ex );
NSMutableArray *tempArray = [NSMutableArray array];
NSInteger i;
for (i = 0; i < [self countOfChapters] ; i++)
for (i = 0; i < count ; i++)
{
[tempArray addObject:[NSString stringWithUTF8String: tracks->psz_name]];
tracks = tracks->p_next;
......@@ -515,19 +521,28 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
return [NSArray arrayWithArray: tempArray];
}
- (void)setCurrentTitle:(int)value
#pragma mark -
#pragma mark Titles
- (void)setCurrentTitleIndex:(NSUInteger)value
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
libvlc_exception_init( &ex );
libvlc_media_player_set_title( instance, value, &ex );
catch_exception( &ex );
}
- (int)currentTitle
- (NSUInteger)currentTitleIndex
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
int result = libvlc_media_player_get_title( instance, &ex );
int count = libvlc_media_player_get_title_count( instance, &ex );
catch_exception( &ex );
if (count <= 0)
return NSNotFound;
NSUInteger result = libvlc_media_player_get_title( instance, &ex );
catch_exception( &ex );
return result;
}
......@@ -556,28 +571,26 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
return [NSArray arrayWithArray: tempArray];
}
- (void)setAudioTrack:(int)value
#pragma mark -
#pragma mark Audio tracks
- (void)setCurrentAudioTrackIndex:(NSUInteger)value
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
libvlc_audio_set_track( instance, value, &ex );
libvlc_audio_set_track( instance, (int)value, &ex );
catch_exception( &ex );
}
- (int)currentAudioTrack
- (NSUInteger)currentAudioTrackIndex
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
int result = libvlc_audio_get_track( instance, &ex );
int count = libvlc_audio_get_track_count( instance, &ex );
catch_exception( &ex );
return result;
}
- (int)countOfAudioTracks
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
int result = libvlc_audio_get_track_count( instance, &ex );
if (count <= 0)
return NSNotFound;
NSUInteger result = libvlc_audio_get_track( instance, &ex );
catch_exception( &ex );
return result;
}
......@@ -586,10 +599,15 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
int count = libvlc_audio_get_track_count( instance, &ex );
catch_exception( &ex );
if (count <= 0)
return [NSArray array];
libvlc_track_description_t *tracks = libvlc_audio_get_track_description( instance, &ex );
NSMutableArray *tempArray = [NSMutableArray array];
NSInteger i;
for (i = 0; i < [self countOfAudioTracks] ; i++)
for (i = 0; i < count ; i++)
{
[tempArray addObject:[NSString stringWithUTF8String: tracks->psz_name]];
tracks = tracks->p_next;
......
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