Commit a5015dec authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

MacOSX/Framework/VLCMediaPlayer: Code cleanup and use Objective-C 2.0...

MacOSX/Framework/VLCMediaPlayer: Code cleanup and use Objective-C 2.0 @property. (Patch by Enrique Osuna).
parent 95ce3115
...@@ -31,7 +31,9 @@ ...@@ -31,7 +31,9 @@
extern NSString * VLCMediaPlayerTimeChanged; extern NSString * VLCMediaPlayerTimeChanged;
extern NSString * VLCMediaPlayerStateChanged; extern NSString * VLCMediaPlayerStateChanged;
// TODO: Documentation /**
* TODO: Documentation VLCMediaPlayerState
*/
typedef enum VLCMediaPlayerState typedef enum VLCMediaPlayerState
{ {
VLCMediaPlayerStateStopped, //< Player has stopped VLCMediaPlayerStateStopped, //< Player has stopped
...@@ -43,26 +45,36 @@ typedef enum VLCMediaPlayerState ...@@ -43,26 +45,36 @@ typedef enum VLCMediaPlayerState
VLCMediaPlayerStatePaused //< Stream is paused VLCMediaPlayerStatePaused //< Stream is paused
} VLCMediaPlayerState; } VLCMediaPlayerState;
extern NSString *VLCMediaPlayerStateToString(VLCMediaPlayerState state); /**
* TODO: Documentation extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState)
*/
extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
/** /**
* Formal protocol declaration for playback delegates. Allows playback messages * Formal protocol declaration for playback delegates. Allows playback messages
* to be trapped by delegated objects. * to be trapped by delegated objects.
*/ */
@protocol VLCMediaPlayerDelegate @protocol VLCMediaPlayerDelegate
/**
* TODO: Documentation - [VLCMediaPlayerDelegate ]
*/
- (void)mediaPlayerTimeChanged:(NSNotification *)aNotification; - (void)mediaPlayerTimeChanged:(NSNotification *)aNotification;
/**
* TODO: Documentation - [VLCMediaPlayerDelegate ]
*/
- (void)mediaPlayerStateChanged:(NSNotification *)aNotification; - (void)mediaPlayerStateChanged:(NSNotification *)aNotification;
@end @end
// TODO: Should we use medialist_player or our own flavor of media player? // TODO: Should we use medialist_player or our own flavor of media player?
@interface VLCMediaPlayer : NSObject @interface VLCMediaPlayer : NSObject
{ {
id delegate; //< Object delegate id delegate; //< Object delegate
VLCVideoView *videoView;//< NSView instance where media is rendered to VLCVideoView * videoView; //< NSView instance where media is rendered to
void *instance; // Internal void * instance; // Internal
VLCMedia *media; //< Current media being played VLCMedia * media; //< Current media being played
VLCTime *cachedTime; VLCTime * cachedTime;
VLCMediaPlayerState cachedState; VLCMediaPlayerState cachedState;
float position; float position;
} }
......
...@@ -27,15 +27,16 @@ ...@@ -27,15 +27,16 @@
#import "VLCMediaPlayer.h" #import "VLCMediaPlayer.h"
#import "VLCEventManager.h" #import "VLCEventManager.h"
#import "VLCLibVLCBridging.h" #import "VLCLibVLCBridging.h"
#import "VLCVideoView.h"
#include <vlc/vlc.h> #include <vlc/vlc.h>
/* Notification Messages */ /* Notification Messages */
NSString *VLCMediaPlayerTimeChanged = @"VLCMediaPlayerTimeChanged"; NSString * VLCMediaPlayerTimeChanged = @"VLCMediaPlayerTimeChanged";
NSString *VLCMediaPlayerStateChanged = @"VLCMediaPlayerStateChanged"; NSString * VLCMediaPlayerStateChanged = @"VLCMediaPlayerStateChanged";
NSString *VLCMediaPlayerStateToString(VLCMediaPlayerState state) NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state)
{ {
static NSString *stateToStrings[] = { static NSString * stateToStrings[] = {
[VLCMediaPlayerStateStopped] = @"VLCMediaPlayerStateStopped", [VLCMediaPlayerStateStopped] = @"VLCMediaPlayerStateStopped",
[VLCMediaPlayerStateOpening] = @"VLCMediaPlayerStateOpening", [VLCMediaPlayerStateOpening] = @"VLCMediaPlayerStateOpening",
[VLCMediaPlayerStateBuffering] = @"VLCMediaPlayerStateBuffering", [VLCMediaPlayerStateBuffering] = @"VLCMediaPlayerStateBuffering",
...@@ -48,7 +49,7 @@ NSString *VLCMediaPlayerStateToString(VLCMediaPlayerState state) ...@@ -48,7 +49,7 @@ NSString *VLCMediaPlayerStateToString(VLCMediaPlayerState state)
} }
/* libvlc event callback */ /* libvlc event callback */
static void HandleMediaInstanceVolumeChanged(const libvlc_event_t *event, void *self) static void HandleMediaInstanceVolumeChanged(const libvlc_event_t * event, void * self)
{ {
[[VLCEventManager sharedManager] callOnMainThreadDelegateOfObject:self [[VLCEventManager sharedManager] callOnMainThreadDelegateOfObject:self
withDelegateMethod:@selector(mediaPlayerVolumeChanged:) withDelegateMethod:@selector(mediaPlayerVolumeChanged:)
...@@ -78,7 +79,7 @@ static void HandleMediaPositionChanged(const libvlc_event_t * event, void * self ...@@ -78,7 +79,7 @@ static void HandleMediaPositionChanged(const libvlc_event_t * event, void * self
[pool release]; [pool release];
} }
static void HandleMediaInstanceStateChanged(const libvlc_event_t *event, void *self) static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void * self)
{ {
VLCMediaPlayerState newState; VLCMediaPlayerState newState;
...@@ -233,7 +234,7 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t *event, void *s ...@@ -233,7 +234,7 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t *event, void *s
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init( &ex ); libvlc_exception_init( &ex );
char *result = libvlc_video_get_aspect_ratio( instance, &ex ); char * result = libvlc_video_get_aspect_ratio( instance, &ex );
quit_on_exception( &ex ); quit_on_exception( &ex );
return result; return result;
} }
...@@ -261,7 +262,7 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t *event, void *s ...@@ -261,7 +262,7 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t *event, void *s
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init( &ex ); libvlc_exception_init( &ex );
char *result = libvlc_video_get_crop_geometry( instance, &ex ); char * result = libvlc_video_get_crop_geometry( instance, &ex );
quit_on_exception( &ex ); quit_on_exception( &ex );
return result; return result;
} }
...@@ -559,7 +560,7 @@ static const VLCMediaPlayerState libvlc_to_local_state[] = ...@@ -559,7 +560,7 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
libvlc_exception_init( &ex ); libvlc_exception_init( &ex );
// Attach event observers into the media instance // Attach event observers into the media instance
libvlc_event_manager_t *p_em = libvlc_media_instance_event_manager( instance, &ex ); libvlc_event_manager_t * p_em = libvlc_media_instance_event_manager( instance, &ex );
libvlc_event_attach( p_em, libvlc_MediaInstancePlayed, HandleMediaInstanceStateChanged, self, &ex ); libvlc_event_attach( p_em, libvlc_MediaInstancePlayed, HandleMediaInstanceStateChanged, self, &ex );
libvlc_event_attach( p_em, libvlc_MediaInstancePaused, HandleMediaInstanceStateChanged, self, &ex ); libvlc_event_attach( p_em, libvlc_MediaInstancePaused, HandleMediaInstanceStateChanged, self, &ex );
libvlc_event_attach( p_em, libvlc_MediaInstanceReachedEnd, HandleMediaInstanceStateChanged, self, &ex ); libvlc_event_attach( p_em, libvlc_MediaInstanceReachedEnd, HandleMediaInstanceStateChanged, self, &ex );
...@@ -571,7 +572,7 @@ static const VLCMediaPlayerState libvlc_to_local_state[] = ...@@ -571,7 +572,7 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
- (void)unregisterObservers - (void)unregisterObservers
{ {
libvlc_event_manager_t *p_em = libvlc_media_instance_event_manager( instance, NULL ); libvlc_event_manager_t * p_em = libvlc_media_instance_event_manager( instance, NULL );
libvlc_event_detach( p_em, libvlc_MediaInstancePlayed, HandleMediaInstanceStateChanged, self, NULL ); libvlc_event_detach( p_em, libvlc_MediaInstancePlayed, HandleMediaInstanceStateChanged, self, NULL );
libvlc_event_detach( p_em, libvlc_MediaInstancePaused, HandleMediaInstanceStateChanged, self, NULL ); libvlc_event_detach( p_em, libvlc_MediaInstancePaused, HandleMediaInstanceStateChanged, self, NULL );
libvlc_event_detach( p_em, libvlc_MediaInstanceReachedEnd, HandleMediaInstanceStateChanged, self, NULL ); libvlc_event_detach( p_em, libvlc_MediaInstanceReachedEnd, HandleMediaInstanceStateChanged, self, NULL );
......
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