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

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 @@
extern NSString * VLCMediaPlayerTimeChanged;
extern NSString * VLCMediaPlayerStateChanged;
// TODO: Documentation
/**
* TODO: Documentation VLCMediaPlayerState
*/
typedef enum VLCMediaPlayerState
{
VLCMediaPlayerStateStopped, //< Player has stopped
......@@ -43,26 +45,36 @@ typedef enum VLCMediaPlayerState
VLCMediaPlayerStatePaused //< Stream is paused
} 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
* to be trapped by delegated objects.
*/
@protocol VLCMediaPlayerDelegate
/**
* TODO: Documentation - [VLCMediaPlayerDelegate ]
*/
- (void)mediaPlayerTimeChanged:(NSNotification *)aNotification;
/**
* TODO: Documentation - [VLCMediaPlayerDelegate ]
*/
- (void)mediaPlayerStateChanged:(NSNotification *)aNotification;
@end
// TODO: Should we use medialist_player or our own flavor of media player?
@interface VLCMediaPlayer : NSObject
{
id delegate; //< Object delegate
VLCVideoView *videoView;//< NSView instance where media is rendered to
id delegate; //< Object delegate
VLCVideoView * videoView; //< NSView instance where media is rendered to
void *instance; // Internal
VLCMedia *media; //< Current media being played
VLCTime *cachedTime;
void * instance; // Internal
VLCMedia * media; //< Current media being played
VLCTime * cachedTime;
VLCMediaPlayerState cachedState;
float position;
}
......
......@@ -27,15 +27,16 @@
#import "VLCMediaPlayer.h"
#import "VLCEventManager.h"
#import "VLCLibVLCBridging.h"
#import "VLCVideoView.h"
#include <vlc/vlc.h>
/* Notification Messages */
NSString *VLCMediaPlayerTimeChanged = @"VLCMediaPlayerTimeChanged";
NSString *VLCMediaPlayerStateChanged = @"VLCMediaPlayerStateChanged";
NSString * VLCMediaPlayerTimeChanged = @"VLCMediaPlayerTimeChanged";
NSString * VLCMediaPlayerStateChanged = @"VLCMediaPlayerStateChanged";
NSString *VLCMediaPlayerStateToString(VLCMediaPlayerState state)
NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state)
{
static NSString *stateToStrings[] = {
static NSString * stateToStrings[] = {
[VLCMediaPlayerStateStopped] = @"VLCMediaPlayerStateStopped",
[VLCMediaPlayerStateOpening] = @"VLCMediaPlayerStateOpening",
[VLCMediaPlayerStateBuffering] = @"VLCMediaPlayerStateBuffering",
......@@ -48,7 +49,7 @@ NSString *VLCMediaPlayerStateToString(VLCMediaPlayerState state)
}
/* 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
withDelegateMethod:@selector(mediaPlayerVolumeChanged:)
......@@ -78,7 +79,7 @@ static void HandleMediaPositionChanged(const libvlc_event_t * event, void * self
[pool release];
}
static void HandleMediaInstanceStateChanged(const libvlc_event_t *event, void *self)
static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void * self)
{
VLCMediaPlayerState newState;
......@@ -233,7 +234,7 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t *event, void *s
{
libvlc_exception_t 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 );
return result;
}
......@@ -261,7 +262,7 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t *event, void *s
{
libvlc_exception_t 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 );
return result;
}
......@@ -559,7 +560,7 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
libvlc_exception_init( &ex );
// 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_MediaInstancePaused, HandleMediaInstanceStateChanged, self, &ex );
libvlc_event_attach( p_em, libvlc_MediaInstanceReachedEnd, HandleMediaInstanceStateChanged, self, &ex );
......@@ -571,7 +572,7 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
- (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_MediaInstancePaused, 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