From: Andre P. <at...@us...> - 2004-06-30 08:09:50
|
Update of /cvsroot/xine/xine-macosx/Cocoaxine/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31706/src Modified Files: XineController.h XineController.m Log Message: Refactored XineController to properly handle audio output, video output, and loop mode choices Index: XineController.h =================================================================== RCS file: /cvsroot/xine/xine-macosx/Cocoaxine/src/XineController.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- XineController.h 29 Jun 2004 07:54:19 -0000 1.5 +++ XineController.h 30 Jun 2004 08:09:37 -0000 1.6 @@ -25,12 +25,29 @@ #import <Cocoaxine/XineStream.h> #import <Cocoaxine/XineOpenGLView.h> -#import <Cocoaxine/XineVideoWindow.h> #include <xine.h> -// TODO: Get rid of window IBOutlet (make XineControllerToolbar a separate -// class rather than a category) + +typedef enum +{ + XINE_VIDEO_OUTPUT_USES_CONNECTED_VIEW = 0, + XINE_VIDEO_OUTPUT_USES_SEPARATE_VIDEO_WINDOW, + XINE_VIDEO_OUTPUT_IS_IGNORED, +} XineVideoOutputChoiceTag; + +typedef enum +{ + XINE_AUDIO_OUTPUT_USES_COREAUDIO = 0, + XINE_AUDIO_OUTPUT_IS_IGNORED, +} XineAudioOutputChoiceTag; + +typedef enum +{ + XINE_LOOP_MODE_NORMAL = 0, + XINE_LOOP_MODE_LOOPING, +} XineLoopModeTag; + @interface XineController : NSObject <NSCoding> { @@ -42,8 +59,10 @@ IBOutlet NSProgressIndicator * loadingProgress; /* Instance variables */ - XineStream * stream; - BOOL useSeparateVideoOutputWindow; + XineStream * stream; + XineVideoOutputChoiceTag videoOutputChoice; + XineAudioOutputChoiceTag audioOutputChoice; + XineLoopModeTag loopMode; } /* @@ -74,7 +93,11 @@ */ - (XineOpenGLView *) view; -- (void) setUsesSeparateVideoOutputWindow:(BOOL)flag; -- (BOOL) usesSeparateVideoOutputWindow; +- (void) setVideoOutputChoice:(XineVideoOutputChoiceTag)choice; +- (XineVideoOutputChoiceTag) videoOutputChoice; +- (void) setAudioOutputChoice:(XineAudioOutputChoiceTag)choice; +- (XineAudioOutputChoiceTag) audioOutputChoice; +- (void) setLoopMode:(XineLoopModeTag)mode; +- (XineLoopModeTag) loopMode; @end Index: XineController.m =================================================================== RCS file: /cvsroot/xine/xine-macosx/Cocoaxine/src/XineController.m,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- XineController.m 29 Jun 2004 07:54:20 -0000 1.6 +++ XineController.m 30 Jun 2004 08:09:38 -0000 1.7 @@ -24,13 +24,17 @@ #import <Cocoaxine/XineController.h> #import <Cocoaxine/XineEngine.h> #import <Cocoaxine/XineError.h> +#import <Cocoaxine/XineVideoWindow.h> #include <xine.h> static inline NSString *secondsToTimeString (int time); -@implementation XineController +static NSString *XineVideoOutputChoiceKey = @"videoOutputChoice"; +static NSString *XineAudioOutputChoiceKey = @"audioOutputChoice"; +static NSString *XineLoopModeKey = @"loopMode"; +@implementation XineController - (id) init { @@ -54,8 +58,9 @@ loadingProgress = [coder decodeObjectForKey:@"loadingProgress"]; view = [coder decodeObjectForKey:@"view"]; #endif - - useSeparateVideoOutputWindow = [coder decodeBoolForKey:@"useSeparateVideoOutputWindow"]; + videoOutputChoice = [coder decodeIntForKey:XineVideoOutputChoiceKey]; + audioOutputChoice = [coder decodeIntForKey:XineAudioOutputChoiceKey]; + loopMode = [coder decodeIntForKey:XineLoopModeKey]; return self; } @@ -68,10 +73,11 @@ [coder encodeObject:streamLength forKey:@"streamLength"]; [coder encodeObject:timeSlider forKey:@"timeSlider"]; [coder encodeObject:loadingProgress forKey:@"loadingProgress"]; - [coder encodeObject:view forKey:@"view"]; + [coder encodeObject:view forKey:@"view"]; #endif - - [coder encodeBool:useSeparateVideoOutputWindow forKey:@"useSeparateVideoOutputWindow"]; + [coder encodeInt:videoOutputChoice forKey:XineVideoOutputChoiceKey]; + [coder encodeInt:audioOutputChoice forKey:XineAudioOutputChoiceKey]; + [coder encodeInt:loopMode forKey:XineLoopModeKey]; } - (void) awakeFromNib @@ -85,35 +91,64 @@ [timeSlider setMinValue:0]; [timeSlider setMaxValue:65535]; - if (useSeparateVideoOutputWindow) - { - XineVideoWindow *window = [[XineVideoWindow alloc] init]; - view = [((XineVideoWindow *) window) xineView]; - [view retain]; - } - - NSNotificationCenter *noticeBoard = [NSNotificationCenter defaultCenter]; - [noticeBoard addObserver:self selector:@selector(viewWindowClosed:) - name:NSWindowWillCloseNotification - object:[view window]]; + /* initialise A/V ports */ + XineAudioPort *audioPort = nil; + XineVideoPort *videoPort = nil; - XineAudioPort *audioPort = [[XineAudioPort alloc] init]; - - XineVideoPort *videoPort; - if (view) + /* initialise audio port */ + switch (audioOutputChoice) { - videoPort = [[XineVideoPort alloc] initWithView:view]; + case XINE_AUDIO_OUTPUT_USES_COREAUDIO: + audioPort = [[XineAudioPort alloc] init]; + break; + + case XINE_AUDIO_OUTPUT_IS_IGNORED: + audioPort = [[XineAudioPort alloc] initWithPluginName:@"none" + withData:nil]; + break; + + default: + NSLog(@"awakeFromNib: Invalid audio output choice %d", + audioOutputChoice); + break; } - else + + /* initialise video port */ + switch (videoOutputChoice) { - videoPort = [[XineVideoPort alloc] initWithView:nil - withPluginName:@"none" - withVisualType:XINE_VISUAL_TYPE_NONE]; + case XINE_VIDEO_OUTPUT_USES_CONNECTED_VIEW: + videoPort = [[XineVideoPort alloc] initWithView:view]; + break; + + case XINE_VIDEO_OUTPUT_USES_SEPARATE_VIDEO_WINDOW: + view = [[[XineVideoWindow alloc] init] xineView]; + [view retain]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(viewWindowClosed:) + name:NSWindowWillCloseNotification + object:[view window]]; + + videoPort = [[XineVideoPort alloc] initWithView:view]; + NSLog(@"Window initialised"); + break; + + case XINE_VIDEO_OUTPUT_IS_IGNORED: + videoPort = [[XineVideoPort alloc] initWithView:nil + withPluginName:@"none" + withVisualType:XINE_VISUAL_TYPE_NONE]; + break; + + default: + NSLog(@"awakeFromNib: Invalid video output choice %d", + videoOutputChoice); + break; + } stream = [[XineStream alloc] initWithVideoPort:videoPort withAudioPort:audioPort]; - + if ([self respondsToSelector:@selector(awakeFromNibPostAdvice)]) { [self performSelector:@selector(awakeFromNibPostAdvice)]; @@ -132,8 +167,6 @@ [loadingProgress startAnimation:nil]; { - if (useSeparateVideoOutputWindow) - [[view window] makeKeyAndOrderFront:nil]; [stream open:mrl]; } [loadingProgress stopAnimation:nil]; @@ -143,6 +176,9 @@ { if ([stream play]) { + if (videoOutputChoice == XINE_VIDEO_OUTPUT_USES_SEPARATE_VIDEO_WINDOW) + [[view window] makeKeyAndOrderFront:nil]; + [NSTimer scheduledTimerWithTimeInterval:0.30 target:self selector:@selector(updateDisplay:) @@ -190,6 +226,9 @@ - (IBAction) stop:(id)sender { [stream stop]; + + if (videoOutputChoice == XINE_VIDEO_OUTPUT_USES_SEPARATE_VIDEO_WINDOW) + [[view window] orderOut:nil]; } - (IBAction) fastForward:(id)sender @@ -242,7 +281,7 @@ { [[NSNotificationCenter defaultCenter] removeObserver:self]; - if (useSeparateVideoOutputWindow) + if (videoOutputChoice == XINE_VIDEO_OUTPUT_USES_SEPARATE_VIDEO_WINDOW) { if (view) { @@ -261,21 +300,67 @@ * Accessors */ -- (void) setUsesSeparateVideoOutputWindow:(BOOL)flag +- (XineOpenGLView *) view +{ + return view; +} + +- (void) setVideoOutputChoice:(XineVideoOutputChoiceTag)choice { - useSeparateVideoOutputWindow = flag; + switch (choice) + { + case XINE_VIDEO_OUTPUT_USES_CONNECTED_VIEW: + case XINE_VIDEO_OUTPUT_USES_SEPARATE_VIDEO_WINDOW: + case XINE_VIDEO_OUTPUT_IS_IGNORED: + videoOutputChoice = choice; + break; + default: + NSLog(@"setVideoOutputChoice: invalid choice %d", choice); + } } -- (BOOL) usesSeparateVideoOutputWindow +- (XineVideoOutputChoiceTag) videoOutputChoice { - return useSeparateVideoOutputWindow; + return videoOutputChoice; } -- (XineOpenGLView *) view +- (void) setAudioOutputChoice:(XineAudioOutputChoiceTag)choice { - return view; + switch (choice) + { + case XINE_AUDIO_OUTPUT_USES_COREAUDIO: + case XINE_AUDIO_OUTPUT_IS_IGNORED: + audioOutputChoice = choice; + break; + default: + NSLog(@"setAudioOutputChoice: invalid choice %d", choice); + } +} + +- (XineAudioOutputChoiceTag) audioOutputChoice +{ + return audioOutputChoice; } - + +- (void) setLoopMode:(XineLoopModeTag)mode +{ + switch (mode) + { + case XINE_LOOP_MODE_NORMAL: + case XINE_LOOP_MODE_LOOPING: + loopMode = mode; + break; + default: + NSLog(@"setLoopMode: invalid mode %d", mode); + } +} + +- (XineLoopModeTag) loopMode +{ + return loopMode; +} + + @end |