Changeset 1286

Show
Ignore:
Timestamp:
06/22/10 18:27:49 (2 years ago)
Author:
gbooker
Message:

Made overlays more generic (just need an NSWindow now), not just for DVDs. Could be made even more generic later if necessary.
Increased update time in playhead making it more useful in fast forward.
Fixed crasher in SL
Fixed results from static analyzer.

Location:
trunk/CommonMediaPlayer
Files:
9 modified
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/CommonMediaPlayer/Classes/CMPDefines.h

    r1265 r1286  
    2222//Note, only defines should ever be in this file! 
    2323 
    24 #define CMPVersion 9  //Full Version Number 
     24#define CMPVersion 10  //Full Version Number 
    2525#define CMPAPIVersion 1 //API version 1 
  • trunk/CommonMediaPlayer/Classes/CMPPlayerManager.m

    r1262 r1286  
    3636+ (CMPPlayerManager *)sharedPlayerManager 
    3737{ 
    38         CMPPlayerManager *shared = nil; 
     38        static CMPPlayerManager *shared = nil; 
    3939        if(shared == nil) 
    4040                shared = [[CMPPlayerManager alloc] init]; 
     
    174174                { 
    175175                        //NSLog(@"Using Player"); 
    176                         [player retain]; 
    177176                        break; 
    178177                } 
     
    206205        //XXX Prefs 
    207206        id <CMPPlayerController> controller = [[(Class)[goodControllers anyObject] alloc] initWithScene:scene player:player]; 
     207        [goodControllers release]; 
    208208        return [controller autorelease]; 
    209209} 
  • trunk/CommonMediaPlayer/CommonMediaPlayer.xcodeproj/project.pbxproj

    r1266 r1286  
    5252                F50CCE911119DECA00213966 /* CMPDVDPlayerController.h in Headers */ = {isa = PBXBuildFile; fileRef = F50CCE8F1119DECA00213966 /* CMPDVDPlayerController.h */; settings = {ATTRIBUTES = (); }; }; 
    5353                F50CCE921119DECA00213966 /* CMPDVDPlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = F50CCE901119DECA00213966 /* CMPDVDPlayerController.m */; }; 
     54                F512FF4811D170D40062B86E /* CMPOverlayAction.h in Headers */ = {isa = PBXBuildFile; fileRef = F512FF4611D170D40062B86E /* CMPOverlayAction.h */; }; 
     55                F512FF4911D170D40062B86E /* CMPOverlayAction.m in Sources */ = {isa = PBXBuildFile; fileRef = F512FF4711D170D40062B86E /* CMPOverlayAction.m */; }; 
    5456                F531CAE3111E2EF9005DF910 /* CMPLeopardDVDPlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = F531CAE1111E2EF9005DF910 /* CMPLeopardDVDPlayer.h */; }; 
    5557                F531CAE4111E2EF9005DF910 /* CMPLeopardDVDPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = F531CAE2111E2EF9005DF910 /* CMPLeopardDVDPlayer.m */; }; 
     
    123125                F50CCE8F1119DECA00213966 /* CMPDVDPlayerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CMPDVDPlayerController.h; sourceTree = "<group>"; }; 
    124126                F50CCE901119DECA00213966 /* CMPDVDPlayerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CMPDVDPlayerController.m; sourceTree = "<group>"; }; 
     127                F512FF4611D170D40062B86E /* CMPOverlayAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CMPOverlayAction.h; sourceTree = "<group>"; }; 
     128                F512FF4711D170D40062B86E /* CMPOverlayAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CMPOverlayAction.m; sourceTree = "<group>"; }; 
    125129                F531CAE1111E2EF9005DF910 /* CMPLeopardDVDPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CMPLeopardDVDPlayer.h; sourceTree = "<group>"; }; 
    126130                F531CAE2111E2EF9005DF910 /* CMPLeopardDVDPlayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CMPLeopardDVDPlayer.m; sourceTree = "<group>"; }; 
     
    325329                                F5001CBD1120939D001B52FE /* CMPOverlayModeAction.h */, 
    326330                                F5001CBE1120939D001B52FE /* CMPOverlayModeAction.m */, 
     331                                F512FF4611D170D40062B86E /* CMPOverlayAction.h */, 
     332                                F512FF4711D170D40062B86E /* CMPOverlayAction.m */, 
    327333                        ); 
    328334                        path = "General Actions"; 
     
    374380                                87C75D8411BB51AE00D53B37 /* CMPMPPlayer.h in Headers */, 
    375381                                87C75D8611BB51AE00D53B37 /* CMPMPPlayerController.h in Headers */, 
     382                                F512FF4811D170D40062B86E /* CMPOverlayAction.h in Headers */, 
    376383                        ); 
    377384                        runOnlyForDeploymentPostprocessing = 0; 
     
    489496                                87C75D8511BB51AE00D53B37 /* CMPMPPlayer.m in Sources */, 
    490497                                87C75D8711BB51AE00D53B37 /* CMPMPPlayerController.m in Sources */, 
     498                                F512FF4911D170D40062B86E /* CMPOverlayAction.m in Sources */, 
    491499                        ); 
    492500                        runOnlyForDeploymentPostprocessing = 0; 
  • trunk/CommonMediaPlayer/General Actions/CMPOverlayAction.h

    r1179 r1286  
    11/* 
    2  * CMPDVDWindowCreationAction.h 
     2 * CMPOverlayAction.h 
    33 * CommonMediaPlayer 
    44 * 
    5  * Created by Graham Booker on Feb. 2 2010 
     5 * Created by Graham Booker on Jun. 22 2010 
    66 * Copyright 2010 Common Media Player 
    77 * All rights reserved. 
     
    2222#import "CMPActionController.h" 
    2323 
    24 @class CMPScreenReleaseAction, CMPDVDPlayer, CMPDVDPlayerPlayHeadView, CMPDVDSelectionView; 
     24@class CMPScreenReleaseAction, CMPPlayerPlayHeadView, CMPSelectionView; 
    2525 
    2626typedef enum { 
    27         CMPDVDOverlayUpperLeft, 
    28         CMPDVDOverlayUpperRight, 
    29         CMPDVDOverlayLowerLeft, 
    30         CMPDVDOverlayLowerRight, 
    31 } CMPDVDOverlayPosition; 
     27        CMPOverlayUpperLeft, 
     28        CMPOverlayUpperRight, 
     29        CMPOverlayLowerLeft, 
     30        CMPOverlayLowerRight, 
     31} CMPOverlayPosition; 
    3232 
    33 @interface CMPDVDOverlayWindow : NSWindow 
     33@interface CMPOverlayWindow : NSWindow 
    3434{ 
    3535        NSRect                                  screenRect; 
     
    4545@end 
    4646 
    47 @interface CMPDVDTextView : CMPDVDOverlayWindow 
     47@interface CMPTextView : CMPOverlayWindow 
    4848{ 
    49         CMPDVDOverlayPosition   position; 
     49        CMPOverlayPosition              position; 
    5050        NSTextField                             *textField; 
    5151} 
     
    5555@end 
    5656 
    57 @interface CMPDVDPlayerPlayHead : CMPDVDOverlayWindow { 
     57@interface CMPPlayerPlayHead : CMPOverlayWindow { 
    5858        NSTextField                                                     *elapsedField; 
    5959        NSTextField                                                     *durationField; 
    60         CMPDVDPlayer                                            *player; 
    61         CMPDVDPlayerPlayHeadView                        *playView; 
    62         NSTimer                                                         *updateTimer; 
     60        CMPPlayerPlayHeadView                           *playView; 
    6361} 
    64 - (void)setPlayer:(CMPDVDPlayer *)player; 
     62- (void)updateDisplayWithElapsed:(int)elapsedTime duration:(int)durationTime; 
    6563 
    6664@end 
    6765 
    68 @interface CMPDVDBlurredMenu : CMPDVDOverlayWindow 
     66@interface CMPBlurredMenu : CMPOverlayWindow 
    6967{ 
    7068        NSArray                                 *menuItems; 
    71         CMPDVDSelectionView             *selectionView; 
     69        CMPSelectionView                *selectionView; 
    7270        NSImageView                             *imageView; 
    7371        int                                             selectedItem; 
     
    7977@end 
    8078 
     79extern NSString *CMPOverlayActionWindowKey; 
    8180 
    82 @interface CMPDVDWindowCreationAction : NSObject <CMPActionController>{ 
    83         CMPScreenReleaseAction  *screenRelease; 
    84         NSWindow                                *dvdWindow; 
     81@interface CMPOverlayAction : NSObject <CMPActionController>{ 
     82        NSWindow                                *window; 
    8583        NSMutableArray                  *overlays; 
    8684} 
    8785 
    88 - (void)setWindowAlpha:(float)alpha; 
    89 - (CMPDVDOverlayWindow *)addBlackShieldWindow; 
    90 - (CMPDVDTextView *)addTextOverlayInPosition:(CMPDVDOverlayPosition)position; 
    91 - (CMPDVDPlayerPlayHead *)addPlayheadOverlay; 
    92 - (CMPDVDBlurredMenu *)addBlurredMenuOverlayWithItems:(NSArray *)items; 
    93 - (void)closeOverlay:(CMPDVDOverlayWindow *)overlay; 
    94 - (void)closeOverlay:(CMPDVDOverlayWindow *)overlay withFade:(NSNumber *)fadeTimeNumber; 
     86- (CMPOverlayWindow *)addBlackShieldWindow; 
     87- (CMPTextView *)addTextOverlayInPosition:(CMPOverlayPosition)position; 
     88- (CMPPlayerPlayHead *)addPlayheadOverlay; 
     89- (CMPBlurredMenu *)addBlurredMenuOverlayWithItems:(NSArray *)items; 
     90- (void)closeOverlay:(CMPOverlayWindow *)overlay; 
     91- (void)closeOverlay:(CMPOverlayWindow *)overlay withFade:(NSNumber *)fadeTimeNumber; 
    9592- (void)closeAllOverlays; 
    9693- (void)closeAllOverlaysWithFadeTime:(float)fadeTime; 
  • trunk/CommonMediaPlayer/General Actions/CMPOverlayAction.m

    r1179 r1286  
    11/* 
    2  * CMPDVDWindowCreationAction.m 
     2 * CMPOverlayAction.m 
    33 * CommonMediaPlayer 
    44 * 
    5  * Created by Graham Booker on Feb. 2 2010 
     5 * Created by Graham Booker on Jun. 22 2010 
    66 * Copyright 2010 Common Media Player 
    77 * All rights reserved. 
     
    2020 */ 
    2121 
    22 #import <DVDPlayback/DVDPlayback.h> 
    23  
    24 #import "CMPDVDWindowCreationAction.h" 
    25 #import "CMPScreenReleaseAction.h" 
     22#import "CMPOverlayAction.h" 
    2623#import "CoreGraphicsServices.h" 
    2724#import "CMPOverlayModeAction.h" 
    2825#import "CMPATVVersion.h" 
    29 #import "CMPDVDPlayer.h" 
    3026 
    3127#define ANIMATE_TIME_INTERVAL 0.02 
    3228 
    33 @implementation CMPDVDOverlayWindow 
     29@implementation CMPOverlayWindow 
    3430 
    3531- (id)initWithContentRect:(NSRect)contentRect overWindow:(int)windowID 
     
    127123@end 
    128124 
    129 @implementation CMPDVDTextView 
    130  
    131 - (id)initWithContentRect:(NSRect)contentRect position:(CMPDVDOverlayPosition)aPosition overWindow:(int)windowID 
     125@implementation CMPTextView 
     126 
     127- (id)initWithContentRect:(NSRect)contentRect position:(CMPOverlayPosition)aPosition overWindow:(int)windowID 
    132128{ 
    133129        self = [super initWithContentRect:contentRect overWindow:windowID]; 
     
    164160        //NSLog(@"Size is %fx%f", frameRect.size.width, frameRect.size.height); 
    165161        float distanceFromEdge = screenRect.size.height / 15; 
    166         if(position == CMPDVDOverlayUpperLeft || position == CMPDVDOverlayUpperRight) 
     162        if(position == CMPOverlayUpperLeft || position == CMPOverlayUpperRight) 
    167163                frameRect.origin.y = screenRect.size.height - frameRect.size.height - distanceFromEdge; 
    168164        else 
    169165                frameRect.origin.y = distanceFromEdge; 
    170         if(position == CMPDVDOverlayUpperRight || position == CMPDVDOverlayLowerRight) 
     166        if(position == CMPOverlayUpperRight || position == CMPOverlayLowerRight) 
    171167                frameRect.origin.x = screenRect.size.width - frameRect.size.width - distanceFromEdge; 
    172168        else 
     
    178174 
    179175 
    180 @interface CMPDVDPlayerPlayHeadView : NSView 
     176@interface CMPPlayerPlayHeadView : NSView 
    181177{ 
    182178        float                   playHeadLocation; 
     
    186182@end 
    187183 
    188 @implementation CMPDVDPlayerPlayHeadView 
     184@implementation CMPPlayerPlayHeadView 
    189185 
    190186- (void)drawRect:(NSRect)rect 
     
    225221 
    226222 
    227 @implementation CMPDVDPlayerPlayHead 
     223@implementation CMPPlayerPlayHead 
    228224 
    229225- (id)initWithContentRect:(NSRect)contentRect overWindow:(int)windowID 
     
    261257        [durationField setSelectable:NO]; 
    262258         
    263         playView = [[CMPDVDPlayerPlayHeadView alloc] initWithFrame:NSMakeRect(textWidth + textBuffer, textHeight / 5, myWidth-textWidth*2-textBuffer*2, textHeight * 3 /5)]; 
     259        playView = [[CMPPlayerPlayHeadView alloc] initWithFrame:NSMakeRect(textWidth + textBuffer, textHeight / 5, myWidth-textWidth*2-textBuffer*2, textHeight * 3 /5)]; 
    264260        [[self contentView] addSubview:playView]; 
    265261        [self setFrame:NSMakeRect(contentRect.size.width * 5 / 64, textHeight*2, myWidth, textHeight) display:NO]; 
     
    271267{ 
    272268        [durationField release]; 
    273         [player release]; 
    274269        [playView release]; 
    275         [updateTimer invalidate]; 
    276270        [super dealloc]; 
    277271} 
    278272 
    279 NSString *timeStringForTime(int time) 
     273static NSString *timeStringForTime(int time) 
    280274{ 
    281275        int seconds = time % 60; 
     
    291285} 
    292286 
    293 - (void)close 
    294 { 
    295         [updateTimer invalidate]; 
    296         updateTimer = nil; 
    297         [super close]; 
    298 } 
    299  
    300 - (void)updateDisplay 
    301 { 
    302         int elapsedTime = [player titleElapsedTime]; 
    303         int durationTime = [player titleDurationTime]; 
    304          
     287- (void)updateDisplayWithElapsed:(int)elapsedTime duration:(int)durationTime 
     288{ 
    305289        [elapsedField setStringValue:timeStringForTime(elapsedTime)]; 
    306290        [durationField setStringValue:timeStringForTime(durationTime)]; 
     
    308292} 
    309293 
    310 - (void)setPlayer:(CMPDVDPlayer *)aPlayer 
    311 { 
    312         [player release]; 
    313         player = [aPlayer retain]; 
    314          
    315         [self updateDisplay]; 
    316          
    317         [updateTimer invalidate]; 
    318         updateTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateDisplay) userInfo:nil repeats:YES]; 
    319 } 
    320  
    321 @end 
    322  
    323 @interface CMPDVDSelectionView : NSView 
     294@end 
     295 
     296@interface CMPSelectionView : NSView 
    324297{ 
    325298        NSTimer                 *moveTimer; 
     
    329302@end 
    330303 
    331 @implementation CMPDVDSelectionView 
    332  
    333 #define CMPDVDSelectionViewMoveTime 0.2 
     304@implementation CMPSelectionView 
     305 
     306#define CMPSelectionViewMoveTime 0.2 
    334307 
    335308- (id)initWithFrame:(NSRect)frame 
     
    351324} 
    352325 
    353 void Interpolate (void* info, float const* inData, float* outData) 
     326static void Interpolate (void* info, float const* inData, float* outData) 
    354327{ 
    355328        float value = sin(M_PI_2 * inData[0])/2; 
     
    412385        double interval = -[startTime timeIntervalSinceNow]; 
    413386        float currentY; 
    414         if(interval > CMPDVDSelectionViewMoveTime) 
     387        if(interval > CMPSelectionViewMoveTime) 
    415388        { 
    416389                currentY = finalY; 
     
    419392        } 
    420393        else 
    421                 currentY = initialY + (finalY - initialY) * interval / CMPDVDSelectionViewMoveTime; 
     394                currentY = initialY + (finalY - initialY) * interval / CMPSelectionViewMoveTime; 
    422395        NSRect frame = [self frame]; 
    423396        NSRect newFrame = frame; 
     
    442415 
    443416 
    444 @implementation CMPDVDBlurredMenu 
     417@implementation CMPBlurredMenu 
    445418 
    446419- (id)initWithItems:(NSArray*)anItems contentRect:(NSRect)contentRect overWindow:(int)windowID 
     
    463436        float inset = contentRect.size.height * 5 / 144; 
    464437        float borderSize = contentRect.size.height / 72; 
    465         selectionView = [[CMPDVDSelectionView alloc] initWithFrame:NSMakeRect(left, bottom + itemHeight * (itemCount-1) - borderSize, itemWidth, itemHeight+borderSize*2)]; 
     438        selectionView = [[CMPSelectionView alloc] initWithFrame:NSMakeRect(left, bottom + itemHeight * (itemCount-1) - borderSize, itemWidth, itemHeight+borderSize*2)]; 
    466439        [[self contentView] addSubview:selectionView]; 
    467440         
     
    595568@end 
    596569 
    597  
     570NSString *CMPOverlayActionWindowKey = @"window"; 
    598571 
    599572@interface BRDisplayManager (compat) 
     
    601574@end 
    602575 
    603 @implementation CMPDVDWindowCreationAction 
     576@implementation CMPOverlayAction 
    604577 
    605578- (id)initWithController:(id <CMPPlayerController>)controller andSettings:(NSDictionary *)settings 
    606579{ 
     580        NSWindow *win = [settings objectForKey:CMPOverlayActionWindowKey]; 
     581        if(win == nil) 
     582                return [self autorelease]; 
     583         
    607584        self = [super init]; 
    608585        if(!self) 
    609586                return self; 
    610587         
    611 //      screenRelease = [[CMPOverlayModeAction alloc] initWithController:controller andSettings:settings]; 
    612         screenRelease = [[CMPScreenReleaseAction alloc] initWithController:controller andSettings:settings]; 
     588        window = [win retain]; 
    613589        overlays = [[NSMutableArray alloc] init]; 
    614590         
     
    618594- (void) dealloc 
    619595{ 
    620         [screenRelease release]; 
    621         [dvdWindow release]; 
     596        [window release]; 
    622597        [overlays release]; 
    623598        [super dealloc]; 
    624599} 
    625600 
    626 static int CreateEmptyWindow(CGRect myFrame) 
    627 { 
    628         //NSLog(@"createEmptyWindow"); 
    629     CGSRegion frameRgn; 
    630     CGSRegion emptyRgn; 
    631     int window; 
    632     char something[100]; 
    633          
    634          
    635     CGSNewRegionWithRect(&myFrame, &frameRgn); 
    636     CGSNewEmptyRegion(&emptyRgn); 
    637          
    638     int conn = CGSMainConnectionID(); 
    639          
    640         //NSLog(@"connection id: %i", conn); 
    641          
    642     CGSNewWindowWithOpaqueShape(conn, 2, 0, 0, frameRgn, emptyRgn, 0, &something, 
    643                                                                 32, &window); 
    644          
    645      
    646         CGSSetWindowOpacity(conn, window, 1); 
    647          
    648          
    649     CGSReleaseRegion(emptyRgn); 
    650     CGSReleaseRegion(frameRgn); 
    651          
    652     return window; 
    653 } 
    654  
    655601- (BOOL)openWithError:(NSError **)error 
    656602{ 
    657         BOOL success = [screenRelease openWithError:error]; 
    658          
    659         if(!success) 
    660         {        
    661                 NSLog(@"Release failed"); 
    662                 return NO; 
    663         } 
    664          
    665         //NSLog(@"createDvdWindow"); 
    666     CGDirectDisplayID display = [(BRDisplayManager *)[BRDisplayManager sharedInstance] display]; 
    667     CGRect frame = CGDisplayBounds(display); 
    668     frame.size.width = CGDisplayPixelsWide(display); 
    669     frame.size.height = CGDisplayPixelsHigh(display); 
    670          
    671     if(frame.size.width < 0.0f) 
    672         frame.size.width = ABS(frame.size.width); 
    673     if(frame.size.height < 0.0f) 
    674         frame.size.height = ABS(frame.size.height); 
    675          
    676         NSRect frameRect = NSMakeRect(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); 
    677         NSApplicationLoad(); 
    678         dvdWindow = [[NSWindow alloc] initWithContentRect:frameRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; 
    679         [dvdWindow setReleasedWhenClosed:NO]; 
    680         [dvdWindow setBackgroundColor:[NSColor blackColor]]; 
    681         int dvdWindowID = [dvdWindow windowNumber]; 
    682         //dvdWindowID = CreateEmptyWindow(frame); 
    683         CGSSetWindowLevel(_CGSDefaultConnection(), dvdWindowID, CGShieldingWindowLevel()+1); 
    684                  
    685         CGSOrderWindow(_CGSDefaultConnection(), dvdWindowID, kCGSOrderAbove, 0); 
    686          
    687     CGContextRef ctx = (CGContextRef)CGWindowContextCreate(_CGSDefaultConnection(), dvdWindowID, NULL); 
    688          
    689     CGContextClear(ctx); 
    690     CGContextFlush(ctx); 
    691     CGContextRelease(ctx); 
    692                  
    693         OSStatus setWindowErr = DVDSetVideoWindowID(dvdWindowID); 
    694         if(setWindowErr != noErr) 
    695                 NSLog(@"Set DVD Window error is %d", setWindowErr); 
    696         OSStatus displayErr = DVDSetVideoDisplay([[BRDisplayManager sharedInstance] display]); 
    697         if(displayErr != noErr) 
    698                 NSLog(@"Set DVD Video error is %d", displayErr); 
    699          
    700         return setWindowErr == noErr && displayErr == noErr; 
    701 } 
    702  
    703 - (void)setWindowAlpha:(float)alpha 
    704 { 
    705         [dvdWindow setAlphaValue:alpha]; 
    706 } 
    707  
    708 - (CMPDVDOverlayWindow *)addBlackShieldWindow 
    709 { 
    710         CMPDVDOverlayWindow *ret = [[CMPDVDOverlayWindow alloc] initWithContentRect:[dvdWindow frame] overWindow:[dvdWindow windowNumber]]; 
     603        return YES; 
     604} 
     605 
     606- (CMPOverlayWindow *)addBlackShieldWindow 
     607{ 
     608        CMPOverlayWindow *ret = [[CMPOverlayWindow alloc] initWithContentRect:[window frame] overWindow:[window windowNumber]]; 
    711609         
    712610        [overlays addObject:ret]; 
     
    716614} 
    717615 
    718 - (CMPDVDTextView *)addTextOverlayInPosition:(CMPDVDOverlayPosition)position 
    719 { 
    720         CMPDVDTextView *ret = [[CMPDVDTextView alloc] initWithContentRect:[dvdWindow frame] position:position overWindow:[dvdWindow windowNumber]]; 
     616- (CMPTextView *)addTextOverlayInPosition:(CMPOverlayPosition)position 
     617{ 
     618        CMPTextView *ret = [[CMPTextView alloc] initWithContentRect:[window frame] position:position overWindow:[window windowNumber]]; 
    721619         
    722620        [overlays addObject:ret]; 
     
    726624} 
    727625 
    728 - (CMPDVDPlayerPlayHead *)addPlayheadOverlay 
    729 { 
    730         CMPDVDPlayerPlayHead *ret = [[CMPDVDPlayerPlayHead alloc] initWithContentRect:[dvdWindow frame] overWindow:[dvdWindow windowNumber]]; 
     626- (CMPPlayerPlayHead *)addPlayheadOverlay 
     627{ 
     628        CMPPlayerPlayHead *ret = [[CMPPlayerPlayHead alloc] initWithContentRect:[window frame] overWindow:[window windowNumber]]; 
    731629         
    732630        [overlays addObject:ret]; 
     
    736634} 
    737635 
    738 - (CMPDVDBlurredMenu *)addBlurredMenuOverlayWithItems:(NSArray *)items 
    739 { 
    740         CMPDVDBlurredMenu *ret = [[CMPDVDBlurredMenu alloc] initWithItems:items contentRect:[dvdWindow frame] overWindow:[dvdWindow windowNumber]]; 
     636- (CMPBlurredMenu *)addBlurredMenuOverlayWithItems:(NSArray *)items 
     637{ 
     638        CMPBlurredMenu *ret = [[CMPBlurredMenu alloc] initWithItems:items contentRect:[window frame] overWindow:[window windowNumber]]; 
    741639         
    742640        [overlays addObject:ret]; 
     
    746644} 
    747645 
    748 - (void)closeOverlay:(CMPDVDOverlayWindow *)overlay 
     646- (void)closeOverlay:(CMPOverlayWindow *)overlay 
    749647{ 
    750648        [self closeOverlay:overlay withFade:[NSNumber numberWithFloat:0]]; 
    751649} 
    752650 
    753 - (void)closeOverlay:(CMPDVDOverlayWindow *)overlay withFade:(NSNumber *)fadeTimeNumber 
     651- (void)closeOverlay:(CMPOverlayWindow *)overlay withFade:(NSNumber *)fadeTimeNumber 
    754652{ 
    755653        [overlay closeWithFadeTime:fadeTimeNumber]; 
     
    774672- (BOOL)closeWithError:(NSError **)error 
    775673{ 
    776 //      int conn = _CGSDefaultConnection(); 
    777 //      NSLog(@"conn: %i dvdWindow: %i", conn, dvdWindowID); 
    778 //      OSStatus theErr = CGSReleaseWindow(conn, dvdWindowID); 
    779 //      NSLog(@"CGSReleaseWindow: %d", theErr); 
    780674        [self closeAllOverlays]; 
    781         [dvdWindow close]; 
    782          
    783         return [screenRelease closeWithError:error]; 
    784 } 
    785 @end 
     675        [window close]; 
     676        return YES; 
     677} 
     678@end 
  • trunk/CommonMediaPlayer/Media Players/DVD Framework/CMPDVDPlayer.h

    r1208 r1286  
    5151} CMPDVDZoomLevel; 
    5252 
    53 @class CMPDVDPlayerController, CMPDVDFrameworkLoadAction; 
     53@class CMPDVDPlayerController, CMPDVDFrameworkLoadAction, CMPPlayerPlayHead; 
    5454 
    5555@interface CMPDVDPlayer : NSObject <CMPPlayer>{ 
     
    6565        CMPDVDZoomLevel                         zoomLevel; 
    6666        BOOL                                            useStopTimer; 
     67        CMPPlayerPlayHead                       *playhead; 
    6768} 
    6869 
     
    104105- (void)setZoomLevel:(CMPDVDZoomLevel)level; 
    105106- (CMPDVDZoomLevel)zoomLevel; 
     107- (void)setPlayhead:(CMPPlayerPlayHead *)playhead; 
    106108+ (BOOL)isVolume:(NSString *)theVolume; 
    107109+ (BOOL)isImage:(NSString *)theVolume; 
  • trunk/CommonMediaPlayer/Media Players/DVD Framework/CMPDVDPlayer.m

    r1211 r1286  
    2424#import "CMPDVDFrameworkLoadAction.h" 
    2525#import "CMPDVDPlayerController.h" 
     26#import "CMPOverlayAction.h" 
    2627#import <AudioUnit/AudioUnit.h> 
    2728 
     
    7778        [frameworkLoad release]; 
    7879        [stopTimer invalidate]; 
     80        [playhead release]; 
    7981        [super dealloc]; 
    8082} 
     
    707709} 
    708710 
     711- (void)setPlayhead:(CMPPlayerPlayHead *)aPlayhead 
     712{ 
     713        [playhead release]; 
     714        playhead = [aPlayhead retain]; 
     715        [playhead updateDisplayWithElapsed:currentElapsedTime duration:titleDuration]; 
     716} 
     717 
    709718static BOOL pauseOnPlay = NO; 
    710719- (void)initiatePlaybackWithResume:(BOOL *)resume; 
     
    759768        DVDCloseMediaFile(); 
    760769        DVDCloseMediaVolume(); 
    761         DVDSetVideoDisplay(kCGNullDirectDisplay); 
     770        //Seems to crash SL 
     771        //DVDSetVideoDisplay(kCGNullDirectDisplay); 
    762772        DVDDispose(); 
    763773} 
     
    910920} 
    911921 
     922- (void)updatePlayhead 
     923{ 
     924        [playhead updateDisplayWithElapsed:currentElapsedTime duration:titleDuration]; 
     925} 
     926 
    912927- (void)titleTimeChanged 
    913928{ 
     
    922937        if(time != 0) 
    923938                currentElapsedTime = time; 
     939        if(playhead != nil) 
     940                [self performSelectorOnMainThread:@selector(updatePlayhead) withObject:nil waitUntilDone:NO]; 
    924941} 
    925942 
     
    10941111                        return NO; 
    10951112        } 
     1113        DVDSetTimeEventRate(100); 
    10961114        return result == noErr; 
    10971115} 
  • trunk/CommonMediaPlayer/Media Players/DVD Framework/CMPDVDPlayerController.h

    r1179 r1286  
    2222#import "CMPPlayerController.h" 
    2323 
    24 @class CMPDVDPlayer, CMPDVDWindowCreationAction, CMPDVDTextView, CMPDVDPlayerPlayHead, CMPDVDBlurredMenu; 
     24@class CMPDVDPlayer, CMPDVDWindowCreationAction, CMPTextView, CMPPlayerPlayHead, CMPBlurredMenu, CMPOverlayAction; 
    2525 
    2626typedef enum { 
     
    3737        id <CMPPlayerControllerDelegate>        delegate; 
    3838        CMPDVDWindowCreationAction                      *windowCreation; 
     39        CMPOverlayAction                                        *overlay; 
    3940#ifdef PLAY_WITH_OVERLAY 
    4041        BOOL                                                            blacked; 
     
    4243        CMPDVDPlayerControllerOverlayMode       overlayMode; 
    4344        NSTimer                                                         *overlayDismiss; 
    44         CMPDVDTextView                                          *statusOverlay; 
    45         CMPDVDTextView                                          *subtitlesOverlay; 
    46         CMPDVDTextView                                          *audioOverlay; 
    47         CMPDVDTextView                                          *chapterOverlay; 
    48         CMPDVDTextView                                          *zoomOverlay; 
    49         CMPDVDPlayerPlayHead                            *playheadOverlay; 
    50         CMPDVDBlurredMenu                                       *blurredMenu; 
     45        CMPTextView                                                     *statusOverlay; 
     46        CMPTextView                                                     *subtitlesOverlay; 
     47        CMPTextView                                                     *audioOverlay; 
     48        CMPTextView                                                     *chapterOverlay; 
     49        CMPTextView                                                     *zoomOverlay; 
     50        CMPPlayerPlayHead                                       *playheadOverlay; 
     51        CMPBlurredMenu                                          *blurredMenu; 
    5152} 
    5253 
  • trunk/CommonMediaPlayer/Media Players/DVD Framework/CMPDVDPlayerController.m

    r1214 r1286  
    2323#import "CMPDVDPlayer.h" 
    2424#import "CMPDVDWindowCreationAction.h" 
     25#import "CMPOverlayAction.h" 
    2526#import "CMPATVVersion.h" 
    2627#import "CoreGraphicsServices.h" 
     
    140141        [delegate release]; 
    141142        [windowCreation release]; 
     143        [overlay release]; 
    142144        [overlayDismiss invalidate]; 
    143145        [statusOverlay release]; 
     
    195197//      [self setOpacity:0.0f]; 
    196198        [windowCreation openWithError:nil]; 
     199        overlay = [[windowCreation overlayAction] retain]; 
    197200        BOOL resume = NO; 
    198         CMPDVDOverlayWindow *shield = [windowCreation addBlackShieldWindow]; 
     201        CMPOverlayWindow *shield = [overlay addBlackShieldWindow]; 
    199202        [shield display]; 
    200203        [player initiatePlaybackWithResume:&resume]; 
     
    202205        { 
    203206                [self showResumeOverlayWithDismiss:NO]; 
    204                 [windowCreation performSelector:@selector(closeOverlay:) withObject:shield afterDelay:0.5]; 
     207                [overlay performSelector:@selector(closeOverlay:) withObject:shield afterDelay:0.5]; 
    205208        } 
    206209        else 
    207                 [windowCreation closeOverlay:shield withFade:[NSNumber numberWithFloat:0]]; 
     210                [overlay closeOverlay:shield withFade:[NSNumber numberWithFloat:0]]; 
    208211} 
    209212 
     
    343346} 
    344347 
    345 static void closeAndNilOverlay(CMPDVDWindowCreationAction *windowCreation, CMPDVDOverlayWindow * *overlay, NSNumber *fadeTime) 
    346 { 
    347         CMPDVDOverlayWindow *actualOverlay = *overlay; 
    348         [windowCreation closeOverlay:actualOverlay withFade:fadeTime]; 
     348static void closeAndNilOverlay(CMPOverlayAction *overlayAction, CMPOverlayWindow * *overlay, NSNumber *fadeTime) 
     349{ 
     350        CMPOverlayWindow *actualOverlay = *overlay; 
     351        [overlayAction closeOverlay:actualOverlay withFade:fadeTime]; 
    349352        [actualOverlay release]; 
    350353        *overlay = nil; 
     
    382385         
    383386        if(closeStatus) 
    384                 closeAndNilOverlay(windowCreation, &statusOverlay, fadeTime); 
     387                closeAndNilOverlay(overlay, &statusOverlay, fadeTime); 
    385388        if(closeSubtitles) 
    386                 closeAndNilOverlay(windowCreation, &subtitlesOverlay, fadeTime); 
     389                closeAndNilOverlay(overlay, &subtitlesOverlay, fadeTime); 
    387390        if(closeAudio) 
    388                 closeAndNilOverlay(windowCreation, &audioOverlay, fadeTime); 
     391                closeAndNilOverlay(overlay, &audioOverlay, fadeTime); 
    389392        if(closeChapter) 
    390                 closeAndNilOverlay(windowCreation, &chapterOverlay, fadeTime); 
     393                closeAndNilOverlay(overlay, &chapterOverlay, fadeTime); 
    391394        if(closeZoom) 
    392                 closeAndNilOverlay(windowCreation, &zoomOverlay, fadeTime); 
    393         if(closePlayhead) 
    394                 closeAndNilOverlay(windowCreation, &playheadOverlay, fadeTime); 
     395                closeAndNilOverlay(overlay, &zoomOverlay, fadeTime); 
     396        if(closePlayhead) { 
     397                [player setPlayhead:nil]; 
     398                closeAndNilOverlay(overlay, &playheadOverlay, fadeTime);                 
     399        } 
    395400} 
    396401 
     
    412417        if(playheadOverlay) 
    413418                return; 
    414         playheadOverlay = [[windowCreation addPlayheadOverlay] retain]; 
    415         [playheadOverlay setPlayer:player]; 
     419        playheadOverlay = [[overlay addPlayheadOverlay] retain]; 
    416420        [playheadOverlay displayWithFadeTime:0.1]; 
     421        [player setPlayhead:playheadOverlay]; 
    417422} 
    418423 
     
    423428         
    424429        if(!subtitlesOverlay) 
    425                 subtitlesOverlay = [[windowCreation addTextOverlayInPosition:CMPDVDOverlayUpperLeft] retain]; 
     430                subtitlesOverlay = [[overlay addTextOverlayInPosition:CMPOverlayUpperLeft] retain]; 
    426431        [subtitlesOverlay setText:[player currentSubFormat]]; 
    427432        [subtitlesOverlay displayWithFadeTime:0.25]; 
    428433        if(!audioOverlay) 
    429                 audioOverlay = [[windowCreation addTextOverlayInPosition:CMPDVDOverlayUpperRight] retain]; 
     434                audioOverlay = [[overlay addTextOverlayInPosition:CMPOverlayUpperRight] retain]; 
    430435        [audioOverlay setText:[player currentAudioFormat]]; 
    431436        [audioOverlay displayWithFadeTime:0.25]; 
     
    445450         
    446451        if(!chapterOverlay) 
    447                 chapterOverlay = [[windowCreation addTextOverlayInPosition:CMPDVDOverlayUpperLeft] retain]; 
     452                chapterOverlay = [[overlay addTextOverlayInPosition:CMPOverlayUpperLeft] retain]; 
    448453        [chapterOverlay setText:[self chapterString]]; 
    449454        [chapterOverlay displayWithFadeTime:0.25]; 
     
    470475         
    471476        if(!zoomOverlay) 
    472                 zoomOverlay = [[windowCreation addTextOverlayInPosition:CMPDVDOverlayUpperRight] retain]; 
     477                zoomOverlay = [[overlay addTextOverlayInPosition:CMPOverlayUpperRight] retain]; 
    473478        [zoomOverlay setText:[self zoomModeString]]; 
    474479        [zoomOverlay displayWithFadeTime:0.25]; 
     
    504509         
    505510        if(!statusOverlay) 
    506                 statusOverlay = [[windowCreation addTextOverlayInPosition:CMPDVDOverlayUpperLeft] retain]; 
     511                statusOverlay = [[overlay addTextOverlayInPosition:CMPOverlayUpperLeft] retain]; 
    507512        [statusOverlay setText:[self stringForPlayerState]]; 
    508513        [statusOverlay displayWithFadeTime:0.25]; 
     
    518523         
    519524        //Catch any others 
    520         [windowCreation closeAllOverlaysWithFadeTime:fadeTime]; 
     525        [overlay closeAllOverlaysWithFadeTime:fadeTime]; 
    521526         
    522527        [overlayDismiss invalidate]; 
     
    528533        if(dismiss) 
    529534                [self dismissOverlaysWithFadeTime:0]; 
    530         blurredMenu = [[windowCreation addBlurredMenuOverlayWithItems:[NSArray arrayWithObjects:@"Resume Playback", @"Start From Beginning", @"Main Menu", nil]] retain]; 
     535        blurredMenu = [[overlay addBlurredMenuOverlayWithItems:[NSArray arrayWithObjects:@"Resume Playback", @"Start From Beginning", @"Main Menu", nil]] retain]; 
    531536        [blurredMenu displayWithFadeTime:0.5]; 
    532537} 
  • trunk/CommonMediaPlayer/Media Players/DVD Framework/CMPDVDWindowCreationAction.h

    r1179 r1286  
    2222#import "CMPActionController.h" 
    2323 
    24 @class CMPScreenReleaseAction, CMPDVDPlayer, CMPDVDPlayerPlayHeadView, CMPDVDSelectionView; 
    25  
    26 typedef enum { 
    27         CMPDVDOverlayUpperLeft, 
    28         CMPDVDOverlayUpperRight, 
    29         CMPDVDOverlayLowerLeft, 
    30         CMPDVDOverlayLowerRight, 
    31 } CMPDVDOverlayPosition; 
    32  
    33 @interface CMPDVDOverlayWindow : NSWindow 
    34 { 
    35         NSRect                                  screenRect; 
    36         int                                             overWindowID; 
    37         float                                   initialOpacity, finalOpacity, fadeTime; 
    38         NSTimer                                 *opacityChangeTimer; 
    39         NSDate                                  *opacityChangeStartTime; 
    40 } 
    41  
    42 - (void)display; 
    43 - (void)displayWithFadeTime:(float)fadeTime; 
    44  
    45 @end 
    46  
    47 @interface CMPDVDTextView : CMPDVDOverlayWindow 
    48 { 
    49         CMPDVDOverlayPosition   position; 
    50         NSTextField                             *textField; 
    51 } 
    52  
    53 - (void)setText:(NSString *)text; 
    54  
    55 @end 
    56  
    57 @interface CMPDVDPlayerPlayHead : CMPDVDOverlayWindow { 
    58         NSTextField                                                     *elapsedField; 
    59         NSTextField                                                     *durationField; 
    60         CMPDVDPlayer                                            *player; 
    61         CMPDVDPlayerPlayHeadView                        *playView; 
    62         NSTimer                                                         *updateTimer; 
    63 } 
    64 - (void)setPlayer:(CMPDVDPlayer *)player; 
    65  
    66 @end 
    67  
    68 @interface CMPDVDBlurredMenu : CMPDVDOverlayWindow 
    69 { 
    70         NSArray                                 *menuItems; 
    71         CMPDVDSelectionView             *selectionView; 
    72         NSImageView                             *imageView; 
    73         int                                             selectedItem; 
    74         int                                             itemHeight; 
    75 } 
    76 - (BOOL)previousItem; 
    77 - (BOOL)nextItem; 
    78 - (int)selectedItem; 
    79 @end 
    80  
     24@class CMPScreenReleaseAction, CMPDVDPlayer, CMPOverlayAction; 
    8125 
    8226@interface CMPDVDWindowCreationAction : NSObject <CMPActionController>{ 
    8327        CMPScreenReleaseAction  *screenRelease; 
     28        CMPOverlayAction                *overlayAction; 
    8429        NSWindow                                *dvdWindow; 
    85         NSMutableArray                  *overlays; 
    8630} 
    8731 
    8832- (void)setWindowAlpha:(float)alpha; 
    89 - (CMPDVDOverlayWindow *)addBlackShieldWindow; 
    90 - (CMPDVDTextView *)addTextOverlayInPosition:(CMPDVDOverlayPosition)position; 
    91 - (CMPDVDPlayerPlayHead *)addPlayheadOverlay; 
    92 - (CMPDVDBlurredMenu *)addBlurredMenuOverlayWithItems:(NSArray *)items; 
    93 - (void)closeOverlay:(CMPDVDOverlayWindow *)overlay; 
    94 - (void)closeOverlay:(CMPDVDOverlayWindow *)overlay withFade:(NSNumber *)fadeTimeNumber; 
    95 - (void)closeAllOverlays; 
    96 - (void)closeAllOverlaysWithFadeTime:(float)fadeTime; 
    97  
     33- (CMPOverlayAction *)overlayAction; 
    9834@end 
  • trunk/CommonMediaPlayer/Media Players/DVD Framework/CMPDVDWindowCreationAction.m

    r1179 r1286  
    2828#import "CMPATVVersion.h" 
    2929#import "CMPDVDPlayer.h" 
    30  
    31 #define ANIMATE_TIME_INTERVAL 0.02 
    32  
    33 @implementation CMPDVDOverlayWindow 
    34  
    35 - (id)initWithContentRect:(NSRect)contentRect overWindow:(int)windowID 
    36 { 
    37         self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; 
    38         if(!self) 
    39                 return self; 
    40          
    41         screenRect = contentRect; 
    42         overWindowID = windowID; 
    43         [self setReleasedWhenClosed:NO]; 
    44          
    45         [self setBackgroundColor:[NSColor blackColor]]; 
    46         [[self contentView] setNeedsDisplay:YES]; 
    47          
    48         return self; 
    49 } 
    50  
    51 - (void) dealloc 
    52 { 
    53         [opacityChangeTimer invalidate]; 
    54         [opacityChangeStartTime release]; 
    55         [super dealloc]; 
    56 } 
    57  
    58 - (void)display 
    59 { 
    60         CGSSetWindowLevel(_CGSDefaultConnection(), [self windowNumber], CGShieldingWindowLevel()+1); 
    61         CGSOrderWindow(_CGSDefaultConnection(), [self windowNumber], kCGSOrderAbove, overWindowID); 
    62         [super display]; 
    63 } 
    64  
    65 - (void)closeWithFadeTime:(NSNumber *)aFadeTimeNumber 
    66 { 
    67         float aFadeTime = [aFadeTimeNumber floatValue]; 
    68         //Alpha is horrible on the ATV since it displays grey, but this one step fade forces everything to draw in the background before it is displayed. 
    69         if(![CMPATVVersion usingLeopard]) 
    70                 aFadeTime = ANIMATE_TIME_INTERVAL / 2; 
    71         if(aFadeTime == 0) 
    72         { 
    73                 [self close]; 
    74                 return; 
    75         } 
    76         initialOpacity = [self alphaValue]; 
    77         finalOpacity = 0; 
    78         fadeTime = aFadeTime; 
    79         [opacityChangeStartTime release]; 
    80         opacityChangeStartTime = [[NSDate date] retain]; 
    81         [opacityChangeTimer invalidate]; 
    82         opacityChangeTimer = [NSTimer scheduledTimerWithTimeInterval:ANIMATE_TIME_INTERVAL target:self selector:@selector(opacityTimerFire) userInfo:nil repeats:YES]; 
    83 } 
    84  
    85 - (void)displayWithFadeTime:(float)aFadeTime 
    86 { 
    87         if(finalOpacity == 1) 
    88                 //Already displayed 
    89                 return; 
    90         //Same as above 
    91         if(![CMPATVVersion usingLeopard]) 
    92                 aFadeTime = ANIMATE_TIME_INTERVAL / 2; 
    93         if(aFadeTime) 
    94                 [self setAlphaValue:0]; 
    95         [self display]; 
    96         if(aFadeTime) 
    97         { 
    98                 initialOpacity = 0; 
    99                 finalOpacity = 1; 
    100                 fadeTime = aFadeTime; 
    101                 opacityChangeStartTime = [[NSDate date] retain]; 
    102                 opacityChangeTimer = [NSTimer scheduledTimerWithTimeInterval:ANIMATE_TIME_INTERVAL target:self selector:@selector(opacityTimerFire) userInfo:nil repeats:YES];           
    103         } 
    104 } 
    105  
    106 - (void)opacityTimerFire 
    107 { 
    108         double interval = -[opacityChangeStartTime timeIntervalSinceNow]; 
    109         float currentOpacity; 
    110         if(interval > fadeTime) 
    111         { 
    112                 [[self retain] autorelease];    //Prevent us from being released with the invalidate 
    113                 currentOpacity = finalOpacity; 
    114                 [opacityChangeTimer invalidate]; 
    115                 opacityChangeTimer = nil; 
    116                 if(finalOpacity == 0) 
    117                 { 
    118                         [self close]; 
    119                         return; 
    120                 } 
    121         } 
    122         else 
    123                 currentOpacity = initialOpacity + (finalOpacity - initialOpacity) * interval / fadeTime; 
    124         [self setAlphaValue:currentOpacity]; 
    125 } 
    126  
    127 @end 
    128  
    129 @implementation CMPDVDTextView 
    130  
    131 - (id)initWithContentRect:(NSRect)contentRect position:(CMPDVDOverlayPosition)aPosition overWindow:(int)windowID 
    132 { 
    133         self = [super initWithContentRect:contentRect overWindow:windowID]; 
    134         if(!self) 
    135                 return nil; 
    136          
    137         position = aPosition; 
    138         textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 300, 300)]; 
    139         [[self contentView] addSubview:textField]; 
    140         [textField setStringValue:@""]; 
    141         [textField setTextColor:[NSColor colorWithDeviceHue:227.0f/360.0f saturation:.60f brightness:1 alpha:1]]; 
    142         [textField setBackgroundColor:[NSColor blackColor]]; 
    143         NSFont *font = [textField font]; 
    144         NSFont *newFont = [NSFont fontWithName:[font fontName] size:contentRect.size.height / 15]; 
    145         [textField setFont:newFont]; 
    146         [textField setBezeled:NO]; 
    147         [textField setBordered:NO]; 
    148          
    149         return self; 
    150 } 
    151  
    152 - (void)dealloc 
    153 { 
    154         [textField release]; 
    155         [super dealloc]; 
    156 } 
    157  
    158 - (void)setText:(NSString *)text 
    159 { 
    160         [textField setStringValue:text]; 
    161         [textField sizeToFit]; 
    162         NSRect frameRect; 
    163         frameRect.size = [textField frame].size; 
    164         //NSLog(@"Size is %fx%f", frameRect.size.width, frameRect.size.height); 
    165         float distanceFromEdge = screenRect.size.height / 15; 
    166         if(position == CMPDVDOverlayUpperLeft || position == CMPDVDOverlayUpperRight) 
    167                 frameRect.origin.y = screenRect.size.height - frameRect.size.height - distanceFromEdge; 
    168         else 
    169                 frameRect.origin.y = distanceFromEdge; 
    170         if(position == CMPDVDOverlayUpperRight || position == CMPDVDOverlayLowerRight) 
    171                 frameRect.origin.x = screenRect.size.width - frameRect.size.width - distanceFromEdge; 
    172         else 
    173                 frameRect.origin.x = distanceFromEdge; 
    174         [self setFrame:frameRect display:YES];   
    175 } 
    176  
    177 @end 
    178  
    179  
    180 @interface CMPDVDPlayerPlayHeadView : NSView 
    181 { 
    182         float                   playHeadLocation; 
    183 } 
    184 - (void)setPlayHeadLocation:(float)playHeadLocation; 
    185  
    186 @end 
    187  
    188 @implementation CMPDVDPlayerPlayHeadView 
    189  
    190 - (void)drawRect:(NSRect)rect 
    191 { 
    192         NSRect myFrame = [self frame]; 
    193         float height = myFrame.size.height; 
    194         float width = myFrame.size.width; 
    195         [[NSColor blackColor] set]; 
    196         NSRectFill(rect); 
    197         NSBezierPath *path = [NSBezierPath bezierPath]; 
    198         [path moveToPoint:NSMakePoint(height/2, height)]; 
    199         [path appendBezierPathWithArcWithCenter:NSMakePoint(height/2, height/2) radius:height/2 startAngle:90 endAngle:270]; 
    200         [path lineToPoint:NSMakePoint(width-height/2, 0)]; 
    201         [path appendBezierPathWithArcWithCenter:NSMakePoint(width-height/2, height/2) radius:height/2 startAngle:270 endAngle:90]; 
    202         [path closePath]; 
    203         [[NSColor colorWithDeviceHue:227.0f/360.0f saturation:.60f brightness:1 alpha:1] set]; 
    204         [path fill]; 
    205          
    206         path = [NSBezierPath bezierPath]; 
    207         float position = playHeadLocation * (width - height) + height/2; 
    208         float border = height / 20; 
    209         [path moveToPoint:NSMakePoint(position, border)]; 
    210         [path lineToPoint:NSMakePoint(position-height/2+border, height/2)]; 
    211         [path lineToPoint:NSMakePoint(position, height-border)]; 
    212         [path lineToPoint:NSMakePoint(position+height/2-border, height/2)]; 
    213         [path closePath]; 
    214         [[NSColor blackColor] set]; 
    215         [path fill]; 
    216 } 
    217  
    218 - (void)setPlayHeadLocation:(float)aPlayHeadLocation 
    219 { 
    220         playHeadLocation = aPlayHeadLocation; 
    221         [self setNeedsDisplay:YES]; 
    222 } 
    223  
    224 @end 
    225  
    226  
    227 @implementation CMPDVDPlayerPlayHead 
    228  
    229 - (id)initWithContentRect:(NSRect)contentRect overWindow:(int)windowID 
    230 { 
    231         self = [super initWithContentRect:contentRect overWindow:windowID]; 
    232         if(!self) 
    233                 return self; 
    234          
    235         float myWidth = contentRect.size.width * 27 / 32; 
    236         float textHeight = contentRect.size.height * 3 / 72; 
    237         float textWidth = textHeight * 3; 
    238         float textBuffer = textHeight / 2; 
    239         float textSize = contentRect.size.height / 33; 
    240         elapsedField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, (textSize-textHeight)/7, textWidth, textHeight)]; 
    241         [[self contentView] addSubview:elapsedField]; 
    242         [elapsedField setStringValue:@""]; 
    243         [elapsedField setTextColor:[NSColor whiteColor]]; 
    244         [elapsedField setBackgroundColor:[NSColor blackColor]]; 
    245         NSFont *font = [elapsedField font]; 
    246         NSFont *newFont = [NSFont fontWithName:[font fontName] size:textSize]; 
    247         [elapsedField setFont:newFont]; 
    248         [elapsedField setBezeled:NO]; 
    249         [elapsedField setBordered:NO]; 
    250         [elapsedField setSelectable:NO]; 
    251         [elapsedField setAlignment:NSRightTextAlignment]; 
    252          
    253         durationField = [[NSTextField alloc] initWithFrame:NSMakeRect(myWidth-textWidth, (textSize-textHeight)/7, textWidth, textHeight)]; 
    254         [[self contentView] addSubview:durationField]; 
    255         [durationField setStringValue:@""]; 
    256         [durationField setTextColor:[NSColor whiteColor]]; 
    257         [durationField setBackgroundColor:[NSColor blackColor]]; 
    258         [durationField setFont:newFont]; 
    259         [durationField setBezeled:NO]; 
    260         [durationField setBordered:NO]; 
    261         [durationField setSelectable:NO]; 
    262          
    263         playView = [[CMPDVDPlayerPlayHeadView alloc] initWithFrame:NSMakeRect(textWidth + textBuffer, textHeight / 5, myWidth-textWidth*2-textBuffer*2, textHeight * 3 /5)]; 
    264         [[self contentView] addSubview:playView]; 
    265         [self setFrame:NSMakeRect(contentRect.size.width * 5 / 64, textHeight*2, myWidth, textHeight) display:NO]; 
    266          
    267         return self; 
    268 } 
    269  
    270 - (void) dealloc 
    271 { 
    272         [durationField release]; 
    273         [player release]; 
    274         [playView release]; 
    275         [updateTimer invalidate]; 
    276         [super dealloc]; 
    277 } 
    278  
    279 NSString *timeStringForTime(int time) 
    280 { 
    281         int seconds = time % 60; 
    282         time /= 60; 
    283         int minutes = time % 60; 
    284         time /= 60; 
    285         int hours = time; 
    286          
    287         if(hours == 0) 
    288                 return [NSString stringWithFormat:@"%d:%02d", minutes, seconds]; 
    289          
    290         return [NSString stringWithFormat:@"%d:%02d:%02d", hours, minutes, seconds]; 
    291 } 
    292  
    293 - (void)close 
    294 { 
    295         [updateTimer invalidate]; 
    296         updateTimer = nil; 
    297         [super close]; 
    298 } 
    299  
    300 - (void)updateDisplay 
    301 { 
    302         int elapsedTime = [player titleElapsedTime]; 
    303         int durationTime = [player titleDurationTime]; 
    304          
    305         [elapsedField setStringValue:timeStringForTime(elapsedTime)]; 
    306         [durationField setStringValue:timeStringForTime(durationTime)]; 
    307         [playView setPlayHeadLocation:((float)elapsedTime)/((float)durationTime)]; 
    308 } 
    309  
    310 - (void)setPlayer:(CMPDVDPlayer *)aPlayer 
    311 { 
    312         [player release]; 
    313         player = [aPlayer retain]; 
    314          
    315         [self updateDisplay]; 
    316          
    317         [updateTimer invalidate]; 
    318         updateTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateDisplay) userInfo:nil repeats:YES]; 
    319 } 
    320  
    321 @end 
    322  
    323 @interface CMPDVDSelectionView : NSView 
    324 { 
    325         NSTimer                 *moveTimer; 
    326         float                   initialY, finalY; 
    327         NSDate                  *startTime; 
    328 } 
    329 @end 
    330  
    331 @implementation CMPDVDSelectionView 
    332  
    333 #define CMPDVDSelectionViewMoveTime 0.2 
    334  
    335 - (id)initWithFrame:(NSRect)frame 
    336 { 
    337         self = [super initWithFrame:frame]; 
    338         if(!self) 
    339                 return self; 
    340          
    341         initialY = finalY = frame.origin.y; 
    342          
    343         return self; 
    344 } 
    345  
    346 - (void)dealloc 
    347 { 
    348         [moveTimer invalidate]; 
    349         [startTime release]; 
    350         [super dealloc]; 
    351 } 
    352  
    353 void Interpolate (void* info, float const* inData, float* outData) 
    354 { 
    355         float value = sin(M_PI_2 * inData[0])/2; 
    356         outData[0] = value; 
    357         outData[1] = value; 
    358         outData[2] = value; 
    359         outData[3] = 1.0; 
    360 } 
    361  
    362 - (void)drawRect:(NSRect)rect 
    363 { 
    364         NSRect frame = [self frame]; 
    365         NSRect drawPath = frame; 
    366         drawPath.origin.x = frame.size.height/8; 
    367         drawPath.origin.y = frame.size.height/8; 
    368         drawPath.size.width -= frame.size.height/4; 
    369         drawPath.size.height -= frame.size.height/4; 
    370         NSBezierPath *path = [NSBezierPath bezierPathWithRect:drawPath]; 
    371          
    372         NSShadow *theShadow = [[NSShadow alloc] init]; 
    373         [theShadow setShadowOffset:NSMakeSize(0, 0)]; 
    374         [theShadow setShadowBlurRadius:frame.size.height/8]; 
    375         [theShadow setShadowColor:[NSColor blueColor]]; 
    376         [NSGraphicsContext saveGraphicsState]; 
    377         [theShadow set]; 
    378         [[NSColor blueColor] set]; 
    379         [path fill]; 
    380          
    381         [NSGraphicsContext restoreGraphicsState]; 
    382         [theShadow release]; 
    383  
    384         [[NSColor blackColor] set]; 
    385         NSRectFill(drawPath); 
    386          
    387         //Gradient 
    388         struct CGFunctionCallbacks callbacks = { 0, Interpolate, NULL }; 
    389          
    390         CGFunctionRef function = CGFunctionCreate(NULL, 1, NULL, 4, NULL, &callbacks); 
    391         CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB(); 
    392          
    393         CGPoint start = CGPointMake(drawPath.origin.x, drawPath.origin.y + drawPath.size.height); 
    394         CGPoint end = CGPointMake(drawPath.origin.x, drawPath.origin.y + drawPath.size.height/2); 
    395         CGShadingRef shading = CGShadingCreateAxial(cspace, start, end, function, false, false); 
    396          
    397         CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; 
    398         CGContextSaveGState(context); 
    399         CGContextClipToRect(context, CGRectMake(drawPath.origin.x, drawPath.origin.y, drawPath.size.width, drawPath.size.height)); 
    400         CGContextDrawShading(context, shading); 
    401         CGContextRestoreGState(context); 
    402          
    403         CGShadingRelease(shading); 
    404         CGColorSpaceRelease(cspace); 
    405         CGFunctionRelease(function); 
    406         [[NSColor blackColor] set]; 
    407         [path stroke]; 
    408 } 
    409  
    410 - (void)moveTimerFire 
    411 { 
    412         double interval = -[startTime timeIntervalSinceNow]; 
    413         float currentY; 
    414         if(interval > CMPDVDSelectionViewMoveTime) 
    415         { 
    416                 currentY = finalY; 
    417                 [moveTimer invalidate]; 
    418                 moveTimer = nil; 
    419         } 
    420         else 
    421                 currentY = initialY + (finalY - initialY) * interval / CMPDVDSelectionViewMoveTime; 
    422         NSRect frame = [self frame]; 
    423         NSRect newFrame = frame; 
    424         newFrame.origin.y = currentY; 
    425         [self setFrame:newFrame]; 
    426         [[self superview] setNeedsDisplayInRect:frame]; 
    427         [self setNeedsDisplay:YES]; 
    428 } 
    429  
    430 - (void)animateMoveToYDelta:(float)newY 
    431 { 
    432         [moveTimer invalidate]; 
    433         finalY += newY; 
    434         initialY = [self frame].origin.y; 
    435         [startTime release]; 
    436         startTime = [[NSDate date] retain]; 
    437         moveTimer = [NSTimer scheduledTimerWithTimeInterval:ANIMATE_TIME_INTERVAL target:self selector:@selector(moveTimerFire) userInfo:nil repeats:YES]; 
    438 } 
    439  
    440 @end 
    441  
    442  
    443  
    444 @implementation CMPDVDBlurredMenu 
    445  
    446 - (id)initWithItems:(NSArray*)anItems contentRect:(NSRect)contentRect overWindow:(int)windowID 
    447 { 
    448         self = [super initWithContentRect:contentRect overWindow:windowID]; 
    449         if(!self) 
    450                 return self; 
    451          
    452         imageView = [[NSImageView alloc] initWithFrame:contentRect]; 
    453         [[self contentView] addSubview:imageView]; 
    454          
    455         NSMutableArray *items = [[NSMutableArray alloc] init]; 
    456          
    457         int itemCount = [anItems count]; 
    458         itemHeight = contentRect.size.height / 12; 
    459         int itemWidth = itemHeight * 10; 
    460         int bottom = (contentRect.size.height - itemHeight * itemCount) / 2; 
    461         int left = (contentRect.size.width - itemWidth) / 2; 
    462          
    463         float inset = contentRect.size.height * 5 / 144; 
    464         float borderSize = contentRect.size.height / 72; 
    465         selectionView = [[CMPDVDSelectionView alloc] initWithFrame:NSMakeRect(left, bottom + itemHeight * (itemCount-1) - borderSize, itemWidth, itemHeight+borderSize*2)]; 
    466         [[self contentView] addSubview:selectionView]; 
    467          
    468         NSFont *newFont = nil; 
    469         for(int i=0; i<itemCount; i++) 
    470         { 
    471                 NSTextField *menuItem = [[NSTextField alloc] initWithFrame:NSMakeRect(left+inset, bottom+itemHeight*(itemCount-1-i), itemWidth-inset, itemHeight)]; 
    472                 [menuItem setStringValue:[anItems objectAtIndex:i]]; 
    473                 [[self contentView] addSubview:menuItem]; 
    474                 [menuItem setTextColor:[NSColor whiteColor]]; 
    475                 [menuItem setDrawsBackground:NO]; 
    476                 [menuItem setBezeled:NO]; 
    477                 [menuItem setBordered:NO]; 
    478                 [menuItem setSelectable:NO]; 
    479                 if(newFont == nil) 
    480                 { 
    481                         NSFont *font = [menuItem font]; 
    482                         newFont = [NSFont fontWithName:[font fontName] size:contentRect.size.height / 20]; 
    483                 } 
    484                 [menuItem setFont:newFont]; 
    485                  
    486                 [menuItem sizeToFit]; 
    487                 NSRect frame = [menuItem frame]; 
    488                 frame.origin.y += (itemHeight - frame.size.height) / 2; 
    489                 [menuItem setFrame:frame]; 
    490                  
    491                 [items addObject:menuItem]; 
    492                 [menuItem release]; 
    493         } 
    494          
    495         menuItems = [items copy]; 
    496         [items release]; 
    497          
    498         [self setFrame:contentRect display:YES]; 
    499          
    500         return self; 
    501 } 
    502  
    503 - (void) dealloc 
    504 { 
    505         [menuItems release]; 
    506         [selectionView release]; 
    507         [imageView release]; 
    508         [super dealloc]; 
    509 } 
    510  
    511  
    512 - (void)display 
    513 { 
    514         if(!overWindowID) 
    515                 return; 
    516         CGSConnectionID cid = _CGSDefaultConnection(); 
    517         CGRect bounds; 
    518         CGSGetWindowBounds(cid, overWindowID, &bounds); 
    519         //NSLog(@"Bounds is %fx%f - %fx%f", bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height); 
    520         //      CGLGetCurrentContext() 
    521         //NSLog(@"bounds is %fx%f-%fx%f", bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height); 
    522         CGRect imageBounds = bounds; 
    523         if(bounds.size.height > 480 || bounds.size.width > 720) 
    524         { 
    525                 float py = bounds.size.height / 480; 
    526                 float px = bounds.size.width / 720; 
    527                 float divisor = MIN(py, px); 
    528                 imageBounds.size.width = floorf(imageBounds.size.width / divisor); 
    529                 imageBounds.size.height = floorf(imageBounds.size.height / divisor); 
    530         } 
    531         int bitmapSize = imageBounds.size.width *imageBounds.size.height * 4; 
    532         char *bitmap = malloc(bitmapSize); 
    533         CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); 
    534         CGContextRef context = CGBitmapContextCreate(bitmap, imageBounds.size.width, imageBounds.size.height, 8, imageBounds.size.width * 4, colorspace, kCGImageAlphaNoneSkipFirst); 
    535     // Copy the contents of the window to the graphic context 
    536         CGContextCopyWindowCaptureContentsToRect(context, imageBounds, cid, overWindowID, 0);    
    537          
    538         NSData *bitmapData = [NSData dataWithBytesNoCopy:bitmap length:bitmapSize]; 
    539         CIImage *myCIImage = [[CIImage alloc] initWithBitmapData:bitmapData bytesPerRow:imageBounds.size.width * 4 size:imageBounds.size format:kCIFormatARGB8 colorSpace:colorspace]; 
    540         CIFilter *gaussianBlur = [CIFilter filterWithName:@"CIGaussianBlur"]; 
    541         [gaussianBlur setDefaults]; 
    542         [gaussianBlur setValue:myCIImage forKey:@"inputImage"]; 
    543         [myCIImage release]; 
    544          
    545         CIImage *result = [gaussianBlur valueForKey:@"outputImage"]; 
    546         CIFilter *crop = [CIFilter filterWithName:@"CICrop"]; 
    547         [crop setDefaults]; 
    548         [crop setValue:result forKey:@"inputImage"]; 
    549         [crop setValue:[CIVector vectorWithX:0 Y:0 Z:imageBounds.size.width W:imageBounds.size.height] forKey:@"inputRectangle"]; 
    550         result = [crop valueForKey:@"outputImage"]; 
    551         NSImage *resultAsNSImage; 
    552         if([result isKindOfClass:[CIImage class]]) 
    553         { 
    554                 resultAsNSImage = [[NSImage alloc] initWithSize:NSMakeSize([result extent].size.width, [result extent].size.height)]; 
    555                 [resultAsNSImage addRepresentation:[NSCIImageRep imageRepWithCIImage:result]]; 
    556                 [resultAsNSImage autorelease]; 
    557         } 
    558         else 
    559                 resultAsNSImage = (NSImage *)result; 
    560          
    561         [resultAsNSImage setScalesWhenResized:YES]; 
    562         [resultAsNSImage setSize:NSMakeSize(bounds.size.width, bounds.size.height)]; 
    563         [imageView setImage:resultAsNSImage]; 
    564         [imageView setImageScaling:NSScaleProportionally]; 
    565          
    566         CGContextRelease(context); 
    567         CGColorSpaceRelease(colorspace); 
    568          
    569         [super display]; 
    570 } 
    571  
    572 - (BOOL)previousItem 
    573 { 
    574         if(selectedItem == 0) 
    575                 return NO; 
    576         [selectionView animateMoveToYDelta:itemHeight]; 
    577         selectedItem--; 
    578         return YES; 
    579 } 
    580  
    581 - (BOOL)nextItem 
    582 { 
    583         if(selectedItem == [menuItems count]-1) 
    584                 return NO; 
    585         [selectionView animateMoveToYDelta:-itemHeight]; 
    586         selectedItem++; 
    587         return YES; 
    588 } 
    589  
    590 - (int)selectedItem 
    591 { 
    592         return selectedItem; 
    593 } 
    594  
    595 @end 
    596  
    597  
     30#import "CMPOverlayAction.h" 
    59831 
    59932@interface BRDisplayManager (compat) 
     
    61144//      screenRelease = [[CMPOverlayModeAction alloc] initWithController:controller andSettings:settings]; 
    61245        screenRelease = [[CMPScreenReleaseAction alloc] initWithController:controller andSettings:settings]; 
    613         overlays = [[NSMutableArray alloc] init]; 
    61446         
    61547        return self; 
     
    61951{ 
    62052        [screenRelease release]; 
     53        [overlayAction release]; 
    62154        [dvdWindow release]; 
    622         [overlays release]; 
    62355        [super dealloc]; 
    62456} 
     
    690122    CGContextFlush(ctx); 
    691123    CGContextRelease(ctx); 
     124         
     125        overlayAction = [[CMPOverlayAction alloc] initWithController:nil andSettings:[NSDictionary dictionaryWithObjectsAndKeys:dvdWindow, CMPOverlayActionWindowKey, nil]]; 
     126        [overlayAction openWithError:nil]; 
    692127                 
    693128        OSStatus setWindowErr = DVDSetVideoWindowID(dvdWindowID); 
     
    706141} 
    707142 
    708 - (CMPDVDOverlayWindow *)addBlackShieldWindow 
     143- (CMPOverlayAction *)overlayAction 
    709144{ 
    710         CMPDVDOverlayWindow *ret = [[CMPDVDOverlayWindow alloc] initWithContentRect:[dvdWindow frame] overWindow:[dvdWindow windowNumber]]; 
    711          
    712         [overlays addObject:ret]; 
    713         [ret release]; 
    714          
    715         return ret; 
    716 } 
    717  
    718 - (CMPDVDTextView *)addTextOverlayInPosition:(CMPDVDOverlayPosition)position 
    719 { 
    720         CMPDVDTextView *ret = [[CMPDVDTextView alloc] initWithContentRect:[dvdWindow frame] position:position overWindow:[dvdWindow windowNumber]]; 
    721          
    722         [overlays addObject:ret]; 
    723         [ret release]; 
    724          
    725         return ret; 
    726 } 
    727  
    728 - (CMPDVDPlayerPlayHead *)addPlayheadOverlay 
    729 { 
    730         CMPDVDPlayerPlayHead *ret = [[CMPDVDPlayerPlayHead alloc] initWithContentRect:[dvdWindow frame] overWindow:[dvdWindow windowNumber]]; 
    731          
    732         [overlays addObject:ret]; 
    733         [ret release]; 
    734          
    735         return ret; 
    736 } 
    737  
    738 - (CMPDVDBlurredMenu *)addBlurredMenuOverlayWithItems:(NSArray *)items 
    739 { 
    740         CMPDVDBlurredMenu *ret = [[CMPDVDBlurredMenu alloc] initWithItems:items contentRect:[dvdWindow frame] overWindow:[dvdWindow windowNumber]]; 
    741          
    742         [overlays addObject:ret]; 
    743         [ret release]; 
    744          
    745         return ret; 
    746 } 
    747  
    748 - (void)closeOverlay:(CMPDVDOverlayWindow *)overlay 
    749 { 
    750         [self closeOverlay:overlay withFade:[NSNumber numberWithFloat:0]]; 
    751 } 
    752  
    753 - (void)closeOverlay:(CMPDVDOverlayWindow *)overlay withFade:(NSNumber *)fadeTimeNumber 
    754 { 
    755         [overlay closeWithFadeTime:fadeTimeNumber]; 
    756         [overlays removeObject:overlay]; 
    757 } 
    758  
    759 - (void)closeAllOverlays 
    760 { 
    761         [overlays makeObjectsPerformSelector:@selector(close)]; 
    762         [overlays removeAllObjects]; 
    763 } 
    764  
    765 - (void)closeAllOverlaysWithFadeTime:(float)fadeTime 
    766 { 
    767         if(fadeTime > 0.0f) 
    768                 [overlays makeObjectsPerformSelector:@selector(closeWithFadeTime:) withObject:[NSNumber numberWithFloat:fadeTime]]; 
    769         else 
    770                 [overlays makeObjectsPerformSelector:@selector(close)]; 
    771         [overlays removeAllObjects]; 
     145        return overlayAction; 
    772146} 
    773147 
     
    778152//      OSStatus theErr = CGSReleaseWindow(conn, dvdWindowID); 
    779153//      NSLog(@"CGSReleaseWindow: %d", theErr); 
    780         [self closeAllOverlays]; 
    781154        [dvdWindow close]; 
     155        [overlayAction closeWithError:error]; 
    782156         
    783157        return [screenRelease closeWithError:error];