# Clean up
rm -Rf tmp
+package-macosx:
+ # Check that tmp isn't in the way
+ @if test -e tmp; then \
+ echo "Error: please remove ./tmp, it is in the way"; false; \
+ else \
+ echo "OK."; mkdir tmp; \
+ fi
+
+ # Copy relevant files
+ cp -R vlc.app tmp/
+ cp AUTHORS COPYING ChangeLog ChangeLog.libdvdcss \
+ README README.libdvdcss FAQ TODO tmp/
+
+ # Create disk image
+ ./macosx-dmg 0 "vlc-${VLC_QUICKVERSION}" tmp/*
+
+ # Clean up
+ rm -Rf tmp
+
libdvdcss-snapshot: snapshot-common
# Remove vlc sources and icons, doc, debian directory...
rm -Rf tmp/vlc/src tmp/vlc/share tmp/vlc/plugins tmp/vlc/doc
openFile = id;
pause = id;
play = id;
+ quit = id;
speedslider_update = id;
+ stop = id;
timeslider_update = id;
};
CLASS = Intf_Controller;
o_stepr = id;
o_stop = id;
o_timeslider = id;
+ o_window = id;
};
SUPERCLASS = NSObject;
},
OUTLETS = {o_table = id; };
SUPERCLASS = NSObject;
},
- {CLASS = VlcQuickDrawView; LANGUAGE = ObjC; SUPERCLASS = NSQuickDrawView; }
);
IBVersion = 1;
-}
\ No newline at end of file
+}
<plist version="0.9">
<dict>
<key>IBDocumentLocation</key>
- <string>87 157 428 240 0 0 1280 938 </string>
+ <string>120 494 428 240 0 0 1600 1178 </string>
+ <key>IBEditorPositions</key>
+ <dict>
+ <key>29</key>
+ <string>110 456 257 44 0 0 1600 1178 </string>
+ <key>460</key>
+ <string>120 456 104 66 0 0 1600 1178 </string>
+ </dict>
<key>IBFramework Version</key>
- <string>219.0</string>
- <key>IBMainMenuLocation</key>
- <string>288 493 104 66 0 0 1280 938 </string>
+ <string>248.0</string>
+ <key>IBOpenObjects</key>
+ <array>
+ <integer>21</integer>
+ </array>
<key>IBSystem Version</key>
- <string>5L14</string>
- <key>IBUserGuides</key>
- <dict/>
+ <string>5P48</string>
</dict>
</plist>
F512122B0170635601A80A1F,
F512122C0170635601A80A1F,
F512122D0170635601A80A1F,
- F512122F0170635601A80A1F,
F51212300170635601A80A1F,
F51212310170635601A80A1F,
F51212320170635601A80A1F,
F510A6CC01738ED001A80A1F,
F510A6CD01738ED001A80A1F,
- F53A3B49018DECF201A80A1F,
- F53A3B4A018DECF201A80A1F,
+ F6799746020DCC2A01A80112,
+ F6799747020DCC2A01A80112,
+ F6799748020DCC2A01A80112,
+ F6799749020DCC2A01A80112,
+ F679974A020DCC2A01A80112,
);
isa = PBXGroup;
name = Files;
path = plugins/macosx/intf_controller.h;
refType = 4;
};
- F512122F0170635601A80A1F = {
- isa = PBXFileReference;
- name = intf_main.c;
- path = plugins/macosx/intf_main.c;
- refType = 4;
- };
F51212300170635601A80A1F = {
isa = PBXFileReference;
name = macosx.c;
settings = {
};
};
- F53A3B49018DECF201A80A1F = {
+//F50
+//F51
+//F52
+//F53
+//F54
+//F60
+//F61
+//F62
+//F63
+//F64
+ F6799746020DCC2A01A80112 = {
+ isa = PBXFileReference;
+ name = intf_macosx.c;
+ path = plugins/macosx/intf_macosx.c;
+ refType = 4;
+ };
+ F6799747020DCC2A01A80112 = {
+ isa = PBXFileReference;
+ name = vout_qdview.c;
+ path = plugins/macosx/vout_qdview.c;
+ refType = 4;
+ };
+ F6799748020DCC2A01A80112 = {
+ isa = PBXFileReference;
+ name = vout_qdview.h;
+ path = plugins/macosx/vout_qdview.h;
+ refType = 4;
+ };
+ F6799749020DCC2A01A80112 = {
isa = PBXFileReference;
- name = intf_qdview.h;
- path = plugins/macosx/intf_qdview.h;
+ name = vout_window.c;
+ path = plugins/macosx/vout_window.c;
refType = 4;
};
- F53A3B4A018DECF201A80A1F = {
+ F679974A020DCC2A01A80112 = {
isa = PBXFileReference;
- name = intf_qdview.c;
- path = plugins/macosx/intf_qdview.c;
+ name = vout_window.h;
+ path = plugins/macosx/vout_window.h;
refType = 4;
};
};
--- /dev/null
+#!/bin/sh
+#
+# Posted to the projectbuilder-users list by Mike Ferris
+# Modified for vlc by Jon Lech Johansen
+#
+
+set -e
+
+# Requires at least three args
+if [ $# -lt 3 ] ; then
+ echo "usage: $0 size name file ..." 1>&2
+ exit 1
+fi
+
+# Grab size and name
+imgSize=$1
+shift
+imgName=$1
+shift
+
+if [ $((${imgSize} < 5)) != 0 ] ; then
+ imgSize=5;
+fi
+
+# Create the image and format it
+rm -f "${imgName}.dmg"
+echo; echo "Creating ${imgSize} MB disk image named ${imgName}"
+hdiutil create "${imgName}.dmg" -megabytes "${imgSize}" -layout NONE -quiet
+dev=`hdid -nomount "${imgName}.dmg" | grep '/dev/disk[0-9]*' | cut -d " " -f 1`
+/sbin/newfs_hfs -w -v "${imgName}" -b 4096 "${dev}" > /dev/null
+hdiutil eject "${dev}" -quiet
+
+# Mount the image and copy stuff
+dev=`hdid "${imgName}.dmg" | grep '/dev/disk[0-9]*' | cut -d " " -f 1`
+
+echo "Copying contents to ${imgName}:"
+while [ $# -gt 0 ] ; do
+ echo " ${1}"
+ /Developer/Tools/CpMac -r "${1}" "/Volumes/${imgName}"
+ shift
+done
+
+hdiutil eject "${dev}" -quiet
+
+# Compress the image
+echo "Compressing ${imgName} disk image"
+mv "${imgName}.dmg" "${imgName}.orig.dmg"
+hdiutil convert "${imgName}.orig.dmg" -format UDZO -o "${imgName}" -quiet
+rm "${imgName}.orig.dmg"
+
+# Done
+echo; echo "Disk image creation completed:"
+ls -la "${imgName}.dmg"; echo
-macosx_SOURCES = macosx.c intf_main.c intf_controller.c aout_macosx.c vout_macosx.c intf_vlc_wrapper.c intf_qdview.c
+macosx_SOURCES = macosx.c aout_macosx.c vout_macosx.c vout_window.c vout_qdview.c intf_macosx.c intf_controller.c intf_vlc_wrapper.c
/*****************************************************************************
- * intf_controller.c : MacOS X plugin for vlc
+ * intf_controller.c: MacOS X plugin for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $$
+ * $Id: intf_controller.c,v 1.3 2002/02/18 01:34:44 jlj Exp $
*
* Authors: Florian G. Pflug <fgp@phlo.org>
+ * Jon Lech Johansen <jon-vl@nanocrew.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
-/* Remark:
- I need to subclass NSQuickDrawView, and post a notification when its display
- method is called. This is necessary because GetPortBound and similar functions
- return the actual on-screen size of the QDPort, which isn't updated immidiately
- after calling e.g. setFrame
-*/
+#import <ApplicationServices/ApplicationServices.h>
-#include <QuickTime/QuickTime.h>
-#include <ApplicationServices/ApplicationServices.h>
-#import "intf_controller.h"
-#import "intf_vlc_wrapper.h"
+#include <videolan/vlc.h>
+
+#include "interface.h"
+#include "intf_playlist.h"
+
+#include "macosx.h"
+#include "intf_controller.h"
+
+@interface Intf_Controller (Internal)
+- (void)handlePortMessage:(NSPortMessage *)o_msg;
+@end
@implementation Intf_Controller
-//Initialization & Event-Management
- - (void) awakeFromNib {
- o_vlc = [Intf_VlcWrapper instance] ;
- b_window_is_fullscreen = FALSE ;
- [NSTimer scheduledTimerWithTimeInterval: 0.5
- target: self
- selector: @selector(manage:)
- userInfo: nil
- repeats:TRUE
- ] ;
- [o_vlc initWithDelegate:self] ;
- }
- - (void) manage:(NSTimer *)timer {
- if ([o_vlc manage])
- [NSApp terminate: self] ;
-
- [o_currenttime setStringValue: [o_vlc getTimeAsString]] ;
- [o_timeslider setFloatValue: [o_vlc getTimeAsFloat]] ;
- }
+/* Initialization & Event-Management */
+
+- (void)awakeFromNib
+{
+ NSString *pTitle = [NSString
+ stringWithCString: VOUT_TITLE " (Cocoa)"];
+
+ o_vlc = [Intf_VlcWrapper instance];
+ [o_vlc initWithDelegate: self];
+
+ [o_window setTitle: pTitle];
+}
+
+- (void)applicationDidFinishLaunching:(NSNotification *)o_notification
+{
+ [[o_vlc sendPort] setDelegate: self];
+
+ [[NSRunLoop currentRunLoop]
+ addPort: [o_vlc sendPort]
+ forMode: NSDefaultRunLoopMode];
- - (void)applicationDidBecomeActive:(NSNotification*)aNotification {
- if (b_window_is_fullscreen) {
- [o_window orderFront:self] ;
- [o_vlc playlistPlayCurrent] ;
+ [NSThread detachNewThreadSelector: @selector(manage)
+ toTarget: self withObject: nil];
+}
+
+- (void)manage
+{
+ NSDate *sleepDate;
+ NSAutoreleasePool *o_pool;
+
+ o_pool = [[NSAutoreleasePool alloc] init];
+
+ while( ![o_vlc manage] )
+ {
+ [o_currenttime setStringValue: [o_vlc getTimeAsString]];
+ [o_timeslider setFloatValue: [o_vlc getTimeAsFloat]];
+
+ if( [o_vlc playlistPlaying] )
+ {
+ UpdateSystemActivity( UsrActivity );
}
+
+ sleepDate = [NSDate dateWithTimeIntervalSinceNow: 0.1];
+ [NSThread sleepUntilDate: sleepDate];
}
+
+ [self terminate];
+
+ [o_pool release];
+}
+
+- (void)terminate
+{
+ NSEvent *pEvent;
+
+ [NSApp stop: nil];
+
+ /* send a dummy event to break out of the event loop */
+ pEvent = [NSEvent mouseEventWithType: NSLeftMouseDown
+ location: NSMakePoint( 1, 1 ) modifierFlags: 0
+ timestamp: 1 windowNumber: [[NSApp mainWindow] windowNumber]
+ context: [NSGraphicsContext currentContext] eventNumber: 1
+ clickCount: 1 pressure: 0.0];
+ [NSApp postEvent: pEvent atStart: YES];
+}
+
+/* Functions attached to user interface */
+
+- (IBAction)openFile:(id)sender
+{
+ NSOpenPanel *o_panel = [NSOpenPanel openPanel];
- - (void)applicationDidResignActive:(NSNotification*)aNotification {
- if (b_window_is_fullscreen) {
- [o_vlc playlistPause] ;
- [o_window orderOut:self] ;
+ [o_panel setAllowsMultipleSelection: YES];
+
+ if( [o_panel runModalForDirectory: NSHomeDirectory()
+ file: nil types: nil] == NSOKButton )
+ {
+ NSString *o_file;
+ NSEnumerator *o_files = [[o_panel filenames] objectEnumerator];
+
+ while( ( o_file = (NSString *)[o_files nextObject] ) )
+ {
+ [o_vlc playlistAdd: o_file];
}
- }
-
-
-
-//Functions attached to user interface
- - (IBAction) openFile:(id)sender {
- NSOpenPanel *o_panel = [NSOpenPanel openPanel] ;
-
- [o_panel setAllowsMultipleSelection:YES] ;
- if ([o_panel runModalForDirectory:NSHomeDirectory() file:nil types:nil] == NSOKButton) {
- NSEnumerator* o_files = [[o_panel filenames] objectEnumerator] ;
- NSString* o_file ;
-
- while ((o_file = (NSString*)[o_files nextObject])) {
- [o_vlc playlistAdd:o_file] ;
- }
- }
- [o_vlc playlistPlayCurrent] ;
- }
-
- - (IBAction) pause:(id)sender {
- [o_vlc playlistPause] ;
- }
-
- - (IBAction) play:(id)sender {
- [o_vlc playlistPlayCurrent] ;
- }
-
- - (IBAction) timeslider_update:(id)slider {
- [o_vlc setTimeAsFloat: [o_timeslider floatValue]] ;
+ [o_vlc playlistPlayCurrent];
}
+}
- - (IBAction) speedslider_update:(id)slider {
- [o_vlc setSpeed: (intf_speed_t) [slider intValue]] ;
- }
+- (IBAction)pause:(id)sender
+{
+ [o_vlc playlistPause];
+}
+
+- (IBAction)play:(id)sender
+{
+ [o_vlc playlistPlayCurrent];
+}
+
+- (IBAction)stop:(id)sender
+{
+ [o_vlc playlistStop];
+}
+
+- (IBAction)timeslider_update:(id)slider
+{
+ [o_vlc setTimeAsFloat: [o_timeslider floatValue]];
+}
+
+- (IBAction)speedslider_update:(id)slider
+{
+ [o_vlc setSpeed: (intf_speed_t)[slider intValue]];
+}
- - (IBAction) fullscreen_toggle:(id)sender {
- [self requestQDPortFullscreen:!b_window_is_fullscreen] ;
- }
+- (IBAction)fullscreen_toggle:(id)sender
+{
+}
+- (IBAction)quit:(id)sender
+{
+ [o_vlc quit];
+}
+
+@end
+
+@implementation Intf_Controller (Internal)
+
+- (void)handlePortMessage:(NSPortMessage *)o_msg
+{
+ [o_vlc handlePortMessage: o_msg];
+}
-
-//Callbacks - we are the delegate for the VlcWrapper
- - (void) requestQDPortFullscreen:(bool)b_fullscreen {
- NSRect s_rect ;
- VlcQuickDrawView *o_qdview ;
-
- s_rect.origin.x = s_rect.origin.y = 0 ;
-
- [self releaseQDPort] ;
- o_window = [NSWindow alloc] ;
- if (b_fullscreen) {
- [o_window
- initWithContentRect: [[NSScreen mainScreen] frame]
- styleMask: NSBorderlessWindowMask
- backing: NSBackingStoreBuffered
- defer:NO screen:[NSScreen mainScreen]
- ] ;
- [o_window setLevel:CGShieldingWindowLevel()] ;
- b_window_is_fullscreen = TRUE ;
- }
- else {
- s_rect.size = [o_vlc videoSize] ;
- [o_window
- initWithContentRect: s_rect
- styleMask: (NSTitledWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)
- backing: NSBackingStoreBuffered
- defer:NO screen:[NSScreen mainScreen]
- ] ;
- [o_window setAspectRatio:[o_vlc videoSize]] ;
- [o_window center] ;
- [o_window setDelegate:self] ;
- b_window_is_fullscreen = FALSE ;
- }
- o_qdview = [[VlcQuickDrawView alloc] init] ;
- [o_qdview setPostsFrameChangedNotifications:YES] ;
- [[NSNotificationCenter defaultCenter]
- addObserver: o_vlc
- selector: @selector(sizeChangeQDPort)
- name: VlcQuickDrawViewDidResize
- object: o_qdview
- ] ;
- [o_window setContentView:o_qdview] ;
- [o_window orderFront:self] ;
- [o_vlc setQDPort:[o_qdview qdPort]] ;
- [o_menu_fullscreen setState:(b_window_is_fullscreen ? NSOnState : NSOffState)] ;
- }
-
- - (void) releaseQDPort {
- [[NSNotificationCenter defaultCenter]
- removeObserver: nil
- name: nil
- object: [o_window contentView]
- ] ;
- [o_vlc setQDPort:nil] ;
- if (o_window) {
- [o_window close] ;
- o_window = nil ;
- }
- }
-
- - (void) resizeQDPortFullscreen:(bool)b_fullscreen {
- if (b_window_is_fullscreen != b_fullscreen) {
- [self requestQDPortFullscreen:b_fullscreen] ;
- }
- else if (!b_window_is_fullscreen && !b_fullscreen) {
- [o_window setAspectRatio:[o_vlc videoSize]] ;
- }
- }
@end
@implementation Intf_PlaylistDS
- - (void ) awakeFromNib {
- o_vlc = [Intf_VlcWrapper instance] ;
- o_playlist = nil ;
- }
+
+- (void)awakeFromNib
+{
+ o_vlc = [Intf_VlcWrapper instance];
+ o_playlist = nil;
+}
- - (void) readPlaylist {
- o_playlist = [[o_vlc playlistAsArray] retain] ;
- }
+- (void)readPlaylist
+{
+ o_playlist = [[o_vlc playlistAsArray] retain];
+}
- - (int) numberOfRowsInTableView:(NSTableView*)o_table {
- [self readPlaylist] ;
- return [o_playlist count] ;
- }
+- (int)numberOfRowsInTableView:(NSTableView*)o_table
+{
+ [self readPlaylist];
+ return( [o_playlist count] );
+}
- - (id) tableView:(NSTableView*)o_table objectValueForTableColumn:(NSTableColumn*)o_column row:(int)i_row {
- return [o_playlist objectAtIndex:i_row] ;
- }
+- (id)tableView:(NSTableView *)o_table objectValueForTableColumn:(NSTableColumn*)o_column row:(int)i_row
+{
+ return( [o_playlist objectAtIndex: i_row] );
+}
- - (void)tableView:(NSTableView *)aTableView setObjectValue:anObject forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex {
- }
+- (void)tableView:(NSTableView *)o_table setObjectValue:o_value forTableColumn:(NSTableColumn *)o_column row:(int)i_index
+{
+}
+
@end
+
/*****************************************************************************
- * intf_controller.h : MacOS X plugin for vlc
+ * intf_controller.h: MacOS X plugin for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $$
+ * $Id: intf_controller.h,v 1.3 2002/02/18 01:34:44 jlj Exp $
*
* Authors: Florian G. Pflug <fgp@phlo.org>
*
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
-#import <Cocoa/Cocoa.h>
-#import "intf_vlc_wrapper.h"
-#import "intf_qdview.h"
+#include "intf_vlc_wrapper.h"
-@interface Intf_PlaylistDS : NSObject {
- Intf_VlcWrapper* o_vlc ;
- NSMutableArray* o_playlist ;
+@interface Intf_PlaylistDS : NSObject
+{
+ Intf_VlcWrapper *o_vlc;
+ NSMutableArray *o_playlist;
- IBOutlet NSTableView *o_table ;
+ IBOutlet NSTableView *o_table;
}
-- (void ) awakeFromNib ;
-- (void) readPlaylist ;
+- (void)awakeFromNib;
+- (void)readPlaylist;
+
+- (int)numberOfRowsInTableView:(NSTableView *)o_table;
+- (id)tableView:(NSTableView *)o_table objectValueForTableColumn:(NSTableColumn *)o_column row:(int)i_row;
+- (void)tableView:(NSTableView *)o_table setObjectValue:o_value forTableColumn:(NSTableColumn *)o_column row:(int)i_index;
-- (int) numberOfRowsInTableView:(NSTableView*)o_table ;
-- (id) tableView:(NSTableView*)o_table objectValueForTableColumn:(NSTableColumn*)o_column row:(int)i_row ;
-- (void)tableView:(NSTableView *)aTableView setObjectValue:anObject forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex ;
@end
-@interface Intf_Controller : NSObject <VlcWrapper_Delegate> {
- Intf_VlcWrapper* o_vlc ;
+@interface Intf_Controller : NSObject
+{
+ Intf_VlcWrapper *o_vlc;
+
+ IBOutlet NSWindow *o_window;
+ IBOutlet NSButton *o_play;
+ IBOutlet NSButton *o_pause;
+ IBOutlet NSButton *o_stop;
+ IBOutlet NSButton *o_stepr;
+ IBOutlet NSButton *o_stepf;
+ IBOutlet NSSlider *o_timeslider;
+ IBOutlet NSTextField *o_currenttime;
+ IBOutlet NSMenuItem *o_menu_fs;
- NSWindow *o_window ;
- bool b_window_is_fullscreen ;
-
- IBOutlet NSButton *o_play ;
- IBOutlet NSButton *o_pause ;
- IBOutlet NSButton *o_stop ;
- IBOutlet NSButton *o_stepr ;
- IBOutlet NSButton *o_stepf ;
- IBOutlet NSSlider *o_timeslider ;
- IBOutlet NSTextField *o_currenttime ;
- IBOutlet NSMenuItem *o_menu_fullscreen ;
-
- IBOutlet Intf_PlaylistDS *o_playlistds ;
+ IBOutlet Intf_PlaylistDS *o_playlistds;
}
-//Initialization & Event-Management
-- (void) awakeFromNib ;
-- (void) manage:(NSTimer *)timer ;
-- (void)applicationDidBecomeActive:(NSNotification*)aNotification ;
-- (void)applicationDidResignActive:(NSNotification*)aNotification ;
+/* Initialization & Event-Management */
+- (void)awakeFromNib;
+- (void)applicationDidFinishLaunching:(NSNotification *)o_notification;
+- (void)manage;
+- (void)terminate;
+
+/* Functions atteched to user interface */
+- (IBAction)openFile:(id)sender;
+- (IBAction)pause:(id)sender;
+- (IBAction)play:(id)sender;
+- (IBAction)stop:(id)sender;
+- (IBAction)timeslider_update:(id)slider;
+- (IBAction)speedslider_update:(id)slider;
+- (IBAction)fullscreen_toggle:(id)sender;
+- (IBAction)quit:(id)sender;
-//Functions atteched to user interface
-- (IBAction) openFile:(id)sender ;
-- (IBAction) pause:(id)sender ;
-- (IBAction) play:(id)sender ;
-- (IBAction) timeslider_update:(id)slider ;
-- (IBAction) speedslider_update:(id)slider ;
-- (IBAction) fullscreen_toggle:(id)sender ;
@end
/*****************************************************************************
- * intf_main.c: MacOS X interface plugin
+ * intf_macosx.c: MacOS X interface plugin
*****************************************************************************
* Copyright (C) 2001 VideoLAN
+ * $Id: intf_macosx.c,v 1.11 2002/02/18 01:34:44 jlj Exp $
*
* Authors: Colin Delacroix <colin@zoy.org>
* Florian G. Pflug <fgp@phlo.org>
+ * Jon Lech Johansen <jon-vl@nanocrew.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <videolan/vlc.h>
-#include "macosx.h"
-
#include "interface.h"
-#include "intf_main.h"
+
+#include "macosx.h"
/*****************************************************************************
* Local prototypes.
if( p_intf->p_sys == NULL )
{
return( 1 );
- };
+ }
- p_intf->p_sys->o_pool =[[NSAutoreleasePool alloc] init];
+ p_intf->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
+ p_intf->p_sys->o_port = [[NSPort port] retain];
- [NSApplication sharedApplication];
- [NSBundle loadNibNamed:@"MainMenu" owner:NSApp];
+ [[NSApplication sharedApplication] autorelease];
+ [NSBundle loadNibNamed: @"MainMenu" owner: NSApp];
return( 0 );
}
*****************************************************************************/
static void intf_Close( intf_thread_t *p_intf )
{
- /* Destroy structure */
- [NSApp terminate:NSApp] ;
- [p_intf->p_sys->o_pool release] ;
+ /* write cached user defaults to disk */
+ [[NSUserDefaults standardUserDefaults] synchronize];
+
+ [p_intf->p_sys->o_port release];
+ [p_intf->p_sys->o_pool release];
+
free( p_intf->p_sys );
}
*****************************************************************************/
static void intf_Run( intf_thread_t *p_intf )
{
- [NSApp run] ;
+ [NSApp run];
}
+++ /dev/null
-//
-// intf_qdview.c
-// vlc
-//
-// Created by fgp on Mon Oct 29 2001.
-// Copyright (c) 2001 __MyCompanyName__. All rights reserved.
-//
-
-#import "intf_qdview.h"
-
-NSString *VlcQuickDrawViewDidResize = @"VlcQuickDrawViewDidDraw" ;
-
-@implementation VlcQuickDrawView
-
-- (id)initWithFrame:(NSRect)frame {
- self = [super initWithFrame:frame];
- return self;
-}
-
-- (void)drawRect:(NSRect)rect {
- [super drawRect:rect] ;
- [[NSNotificationCenter defaultCenter] postNotificationName:VlcQuickDrawViewDidResize object:self] ;
-}
-
-@end
+++ /dev/null
-//
-// intf_qdview.h
-// vlc
-//
-// Created by fgp on Mon Oct 29 2001.
-// Copyright (c) 2001 __MyCompanyName__. All rights reserved.
-//
-
-#import <Cocoa/Cocoa.h>
-
-extern NSString *VlcQuickDrawViewDidResize ;
-
-@interface VlcQuickDrawView : NSQuickDrawView {
-}
-
-@end
/*****************************************************************************
- * intf_vlc_wrapper.c : MacOS X plugin for vlc
+ * intf_vlc_wrapper.c: MacOS X plugin for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: intf_vlc_wrapper.c,v 1.7 2002/02/15 13:32:53 sam Exp $
+ * $Id: intf_vlc_wrapper.c,v 1.8 2002/02/18 01:34:44 jlj Exp $
*
* Authors: Florian G. Pflug <fgp@phlo.org>
+ * Jon Lech Johansen <jon-vl@nanocrew.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <videolan/vlc.h>
-#include "macosx.h"
-
#include "interface.h"
#include "intf_playlist.h"
-#include "intf_main.h"
#include "video.h"
#include "video_output.h"
#include "stream_control.h"
#include "input_ext-intf.h"
-#import "intf_vlc_wrapper.h"
-
-#define p_area p_input_bank->pp_input[0]->stream.p_selected_area
+#include "macosx.h"
+#include "intf_vlc_wrapper.h"
@implementation Intf_VlcWrapper
-//Initialization,.....
- + (Intf_VlcWrapper*) instance {
- static bool b_initialized = 0;
- static Intf_VlcWrapper* o_vlc = nil ;
+
+/* Initialization */
+
++ (Intf_VlcWrapper *)instance
+{
+ static bool b_initialized = 0;
+ static Intf_VlcWrapper* o_vlc = nil;
- if (!b_initialized) {
- o_vlc = [[Intf_VlcWrapper alloc] init] ;
- b_initialized = TRUE ;
- }
-
- return o_vlc ;
+ if( !b_initialized )
+ {
+ o_vlc = [[Intf_VlcWrapper alloc] init];
+ b_initialized = TRUE;
}
+
+ return o_vlc;
+}
- - (Intf_VlcWrapper*) initWithDelegate:(id)_o_delegate {
- e_speed = SPEED_NORMAL ;
- o_delegate = _o_delegate ;
+- (Intf_VlcWrapper *)initWithDelegate:(id)_o_delegate
+{
+ e_speed = SPEED_NORMAL;
+ o_delegate = _o_delegate;
- return self ;
+ return self;
+}
+
+- (bool)manage
+{
+ p_main->p_intf->pf_manage( p_main->p_intf );
+
+ if( p_main->p_intf->b_die )
+ {
+ /* Vout depends on intf */
+ input_EndBank();
+ vout_EndBank();
+ input_InitBank();
+ vout_InitBank();
+
+ return( 1 );
}
+ return( 0 );
+}
+- (void)quit
+{
+ p_main->p_intf->b_die = 1;
+}
+/* Vout requests */
+- (void)handlePortMessage:(NSPortMessage *)o_msg
+{
+ NSData *o_req;
+ struct vout_req_s *p_req;
- - (bool) manage {
- vout_thread_t *p_vout ;
- bool b_resize=FALSE, b_request=FALSE, b_release=FALSE;
- bool b_fullscreen=FALSE ;
+ o_req = [[o_msg components] lastObject];
+ p_req = *((struct vout_req_s **)[o_req bytes]);
-printf("start managing\n");
- p_main->p_intf->pf_manage( p_main->p_intf ) ;
-
- if ((p_vout = p_main->p_intf->p_sys->osx_communication.p_vout)) {
-printf("doing stuff with vout\n");
- i_width = p_vout->output.i_width ;
- i_height = p_vout->output.i_height ;
- b_fullscreen = !!p_vout->b_fullscreen ;
-
- //Also mange the notifications for the output.
- if (p_vout->i_changes & (VOUT_SIZE_CHANGE | VOUT_FULLSCREEN_CHANGE)) b_resize = TRUE ;
- p_vout->i_changes &= ~(VOUT_SIZE_CHANGE | VOUT_FULLSCREEN_CHANGE) ;
+ [p_req->o_lock lock];
+
+ if( p_req->i_type == VOUT_REQ_CREATE_WINDOW )
+ {
+ VLCView *o_view;
+
+ p_req->p_vout->p_sys->o_window = [VLCWindow alloc];
+ [p_req->p_vout->p_sys->o_window setVout: p_req->p_vout];
+ [p_req->p_vout->p_sys->o_window setReleasedWhenClosed: YES];
+
+ if( p_req->p_vout->b_fullscreen )
+ {
+ [p_req->p_vout->p_sys->o_window
+ initWithContentRect: [[NSScreen mainScreen] frame]
+ styleMask: NSBorderlessWindowMask
+ backing: NSBackingStoreBuffered
+ defer: NO screen: [NSScreen mainScreen]];
+
+ [p_req->p_vout->p_sys->o_window
+ setLevel: CGShieldingWindowLevel()];
}
-
- if (b_resize) [o_delegate resizeQDPortFullscreen:b_fullscreen] ;
+ else
+ {
+ unsigned int i_stylemask = NSTitledWindowMask |
+ NSMiniaturizableWindowMask |
+ NSResizableWindowMask;
+
+ [p_req->p_vout->p_sys->o_window
+ initWithContentRect: p_req->p_vout->p_sys->s_rect
+ styleMask: i_stylemask
+ backing: NSBackingStoreBuffered
+ defer: NO screen: [NSScreen mainScreen]];
+
+ if( !p_req->p_vout->p_sys->b_pos_saved )
+ {
+ [p_req->p_vout->p_sys->o_window center];
+ }
+ }
+
+ o_view = [[VLCView alloc] initWithVout: p_req->p_vout];
+ [p_req->p_vout->p_sys->o_window setContentView: o_view];
-printf(" testing...\n");
- if (p_main->p_intf->p_sys->osx_communication.i_changes & OSX_VOUT_INTF_REQUEST_QDPORT) b_request = TRUE ;
-printf(" tested : %s\n", b_request ? "YES !!!" : "nope..." );
- if (p_main->p_intf->p_sys->osx_communication.i_changes & OSX_VOUT_INTF_RELEASE_QDPORT) b_release = TRUE ;
-
- p_main->p_intf->p_sys->osx_communication.i_changes &= ~(OSX_VOUT_INTF_REQUEST_QDPORT | OSX_VOUT_INTF_RELEASE_QDPORT) ;
+ [o_view lockFocus];
+ p_req->p_vout->p_sys->p_qdport = [o_view qdPort];
+ [o_view unlockFocus];
- if (b_release) [o_delegate releaseQDPort] ;
- if (b_request) [o_delegate requestQDPortFullscreen:b_fullscreen] ;
+ [p_req->p_vout->p_sys->o_window setTitle: [NSString
+ stringWithCString: VOUT_TITLE]];
+ [p_req->p_vout->p_sys->o_window setAcceptsMouseMovedEvents: YES];
+ [p_req->p_vout->p_sys->o_window makeKeyAndOrderFront: nil];
-printf("end managing\n\n");
- return p_main->p_intf->b_die ;
+ p_req->i_result = 1;
}
+ else if( p_req->i_type == VOUT_REQ_DESTROY_WINDOW )
+ {
+ if( !p_req->p_vout->b_fullscreen )
+ {
+ NSRect s_rect;
+ s_rect = [[p_req->p_vout->p_sys->o_window contentView] frame];
+ p_req->p_vout->p_sys->s_rect.size = s_rect.size;
+ s_rect = [p_req->p_vout->p_sys->o_window frame];
+ p_req->p_vout->p_sys->s_rect.origin = s_rect.origin;
+ p_req->p_vout->p_sys->b_pos_saved = 1;
+ }
-//Function for the GUI.
- - (void) setQDPort:(CGrafPtr)p_qdport {
-
-printf("setQDPort !!\n");
- p_main->p_intf->p_sys->osx_communication.p_qdport = p_qdport ;
- p_main->p_intf->p_sys->osx_communication.i_changes |= OSX_INTF_VOUT_QDPORT_CHANGE ;
- }
-
- - (void) sizeChangeQDPort {
-
-printf("sizeChangeQDPort !!\n");
- p_main->p_intf->p_sys->osx_communication.i_changes |= OSX_INTF_VOUT_SIZE_CHANGE ;
- }
+ p_req->p_vout->p_sys->p_qdport = nil;
+ [p_req->p_vout->p_sys->o_window close];
+ p_req->p_vout->p_sys->o_window = nil;
- - (NSSize) videoSize {
- return NSMakeSize(i_width, i_height) ;
+ p_req->i_result = 1;
}
+ [p_req->o_lock unlockWithCondition: 1];
+}
+- (NSPort *)sendPort
+{
+ return( p_main->p_intf->p_sys->o_port );
+}
+/* Playback control */
+- (void)setSpeed:(intf_speed_t)_e_speed
+{
+ e_speed = _e_speed;
+ [self playlistPlayCurrent];
+}
-//Playback control
- - (void) setSpeed:(intf_speed_t) _e_speed {
- e_speed = _e_speed ;
- [self playlistPlayCurrent] ;
- }
-
- - (NSString *) getTimeAsString {
- static char psz_currenttime[ OFFSETTOTIME_MAX_SIZE ] ;
-
- if (!p_input_bank->pp_input[0]) return [NSString stringWithCString:"00:00:00"] ;
+#define p_area p_input_bank->pp_input[0]->stream.p_selected_area
+
+- (NSString *)getTimeAsString
+{
+ static char psz_currenttime[ OFFSETTOTIME_MAX_SIZE ];
- input_OffsetToTime( p_input_bank->pp_input[0], psz_currenttime, p_area->i_tell ) ;
- return [NSString stringWithCString:psz_currenttime] ;
- }
-
- - (float) getTimeAsFloat {
- if (!p_input_bank->pp_input[0]) return 0.0 ;
+ if( p_input_bank->pp_input[0] == NULL )
+ {
+ return [NSString stringWithCString:"00:00:00"];
+ }
+
+ input_OffsetToTime( p_input_bank->pp_input[0],
+ psz_currenttime, p_area->i_tell );
+
+ return( [NSString stringWithCString: psz_currenttime] );
+}
- return (float)p_area->i_tell / (float)p_area->i_size ;
+- (float)getTimeAsFloat
+{
+ if( p_input_bank->pp_input[0] == NULL )
+ {
+ return( 0.0 );
+ }
+
+ return( (float)p_area->i_tell / (float)p_area->i_size );
+}
+
+- (void)setTimeAsFloat:(float)f_position
+{
+ vlc_mutex_lock( &p_input_bank->lock );
+
+ if( p_input_bank->pp_input[0] != NULL )
+ {
+ input_Seek( p_input_bank->pp_input[0], p_area->i_size * f_position );
}
- - (void) setTimeAsFloat:(float) f_position {
- if (!p_input_bank->pp_input[0]) return ;
+ vlc_mutex_unlock( &p_input_bank->lock );
+}
+
+#undef p_area
+
+/* Playlist control */
+
+- (NSArray *)playlistAsArray
+{
+ int i;
+ NSMutableArray* p_list =
+ [NSMutableArray arrayWithCapacity: p_main->p_playlist->i_size];
- input_Seek(p_input_bank->pp_input[0], p_area->i_size * f_position) ;
+ vlc_mutex_lock( &p_main->p_playlist->change_lock );
+
+ for( i = 0; i < p_main->p_playlist->i_size; i++ )
+ {
+ [p_list addObject: [NSString
+ stringWithCString: p_main->p_playlist->p_item[i].psz_name]];
}
-
-
-
-//Playlist control
- - (NSArray*) playlistAsArray {
- NSMutableArray* p_list = [NSMutableArray arrayWithCapacity:p_main->p_playlist->i_size] ;
- int i ;
-
- vlc_mutex_lock(&p_main->p_playlist->change_lock) ;
- for (i=0; i < p_main->p_playlist->i_size; i++)
- [p_list addObject:[NSString stringWithCString:p_main->p_playlist->p_item[i].psz_name]] ;
- vlc_mutex_unlock(&p_main->p_playlist->change_lock) ;
+ vlc_mutex_unlock( &p_main->p_playlist->change_lock );
- return [NSArray arrayWithArray:p_list] ;
- }
+ return( [NSArray arrayWithArray: p_list] );
+}
- - (int) playlistLength {
- return p_main->p_playlist->i_size ;
- }
-
- - (NSString*) playlistItem:(int) i_pos {
- NSString* o_item = nil ;
+- (int)playlistLength
+{
+ return( p_main->p_playlist->i_size );
+}
+
+- (NSString*)playlistItem:(int)i_pos
+{
+ NSString *o_item = nil;
+
+ vlc_mutex_lock( &p_main->p_playlist->change_lock );
- vlc_mutex_lock(&p_main->p_playlist->change_lock) ;
- if (i_pos < p_main->p_playlist->i_size)
- o_item = [NSString stringWithCString:p_main->p_playlist->p_item[i_pos].psz_name] ;
- vlc_mutex_unlock(&p_main->p_playlist->change_lock) ;
-
- return o_item ;
+ if( i_pos < p_main->p_playlist->i_size )
+ {
+ o_item = [NSString
+ stringWithCString: p_main->p_playlist->p_item[i_pos].psz_name];
}
+
+ vlc_mutex_unlock( &p_main->p_playlist->change_lock );
+
+ return( o_item );
+}
- - (bool) playlistPlayCurrent {
- if (p_input_bank->pp_input[0]) {
- switch (e_speed)
- {
- case SPEED_SLOW:
- input_SetStatus(p_input_bank->pp_input[0], INPUT_STATUS_SLOWER) ;
- break ;
- case SPEED_NORMAL:
- input_SetStatus(p_input_bank->pp_input[0], INPUT_STATUS_PLAY) ;
- break ;
- case SPEED_FAST:
- input_SetStatus(p_input_bank->pp_input[0], INPUT_STATUS_FASTER) ;
- break ;
- }
- p_main->p_playlist->b_stopped = 0 ;
- }
- else if (p_main->p_playlist->b_stopped) {
- if (p_main->p_playlist->i_size)
- intf_PlaylistJumpto(p_main->p_playlist, p_main->p_playlist->i_index) ;
- else
- return FALSE ;
+- (bool)playlistPlayCurrent
+{
+ if( p_input_bank->pp_input[0] != NULL )
+ {
+ switch (e_speed)
+ {
+ case SPEED_SLOW:
+ input_SetStatus( p_input_bank->pp_input[0],
+ INPUT_STATUS_SLOWER );
+ break;
+
+ case SPEED_NORMAL:
+ input_SetStatus( p_input_bank->pp_input[0],
+ INPUT_STATUS_PLAY );
+ break;
+
+ case SPEED_FAST:
+ input_SetStatus( p_input_bank->pp_input[0],
+ INPUT_STATUS_FASTER );
+ break;
}
-
- return TRUE ;
- }
- - (void) playlistPause {
- if (p_input_bank->pp_input[0])
- input_SetStatus(p_input_bank->pp_input[0], INPUT_STATUS_PAUSE) ;
+ p_main->p_playlist->b_stopped = 0;
}
-
- - (void) playlistStop {
- if (p_input_bank->pp_input[0]) p_input_bank->pp_input[0]->b_eof = 1 ;
- vlc_mutex_lock(&p_main->p_playlist->change_lock) ;
- p_main->p_playlist->i_index-- ;
- p_main->p_playlist->b_stopped = 1 ;
- vlc_mutex_unlock(&p_main->p_playlist->change_lock) ;
+ else if( p_main->p_playlist->b_stopped )
+ {
+ if( p_main->p_playlist->i_size )
+ {
+ intf_PlaylistJumpto( p_main->p_playlist,
+ p_main->p_playlist->i_index );
+ }
+ else
+ {
+ return FALSE;
+ }
}
-
- - (void) playlistPlayNext {
- [self playlistStop] ;
- vlc_mutex_lock(&p_main->p_playlist->change_lock) ;
- p_main->p_playlist->i_index++ ;
- vlc_mutex_unlock(&p_main->p_playlist->change_lock) ;
- [self playlistPlayCurrent] ;
+
+ return TRUE;
+}
+
+- (void)playlistPause
+{
+ if ( p_input_bank->pp_input[0] != NULL )
+ {
+ input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PAUSE );
+
+ vlc_mutex_lock( &p_main->p_playlist->change_lock );
+ p_main->p_playlist->b_stopped = 0;
+ vlc_mutex_unlock( &p_main->p_playlist->change_lock );
}
+}
- - (void) playlistPlayPrev {
- [self playlistStop] ;
- vlc_mutex_lock(&p_main->p_playlist->change_lock) ;
- p_main->p_playlist->i_index-- ;
- vlc_mutex_unlock(&p_main->p_playlist->change_lock) ;
- [self playlistPlayCurrent] ;
+- (void)playlistStop
+{
+ if( p_input_bank->pp_input[0] != NULL )
+ {
+ /* end playing item */
+ p_input_bank->pp_input[0]->b_eof = 1;
+
+ /* update playlist */
+ vlc_mutex_lock( &p_main->p_playlist->change_lock );
+
+ p_main->p_playlist->i_index--;
+ p_main->p_playlist->b_stopped = 1;
+
+ vlc_mutex_unlock( &p_main->p_playlist->change_lock );
}
-
- - (void) playlistPlayItem:(int)i_item {
- [self playlistStop] ;
- vlc_mutex_lock(&p_main->p_playlist->change_lock) ;
- if (i_item < p_main->p_playlist->i_size)
- p_main->p_playlist->i_index-- ;
- vlc_mutex_unlock(&p_main->p_playlist->change_lock) ;
- [self playlistPlayCurrent] ;
+}
+
+- (void)playlistPlayNext
+{
+ [self playlistStop];
+
+ vlc_mutex_lock( &p_main->p_playlist->change_lock );
+ p_main->p_playlist->i_index++;
+ vlc_mutex_unlock( &p_main->p_playlist->change_lock );
+
+ [self playlistPlayCurrent];
+}
+
+- (void)playlistPlayPrev
+{
+ [self playlistStop];
+
+ vlc_mutex_lock( &p_main->p_playlist->change_lock );
+ p_main->p_playlist->i_index--;
+ vlc_mutex_unlock( &p_main->p_playlist->change_lock );
+
+ [self playlistPlayCurrent];
+}
+
+- (void)playlistPlayItem:(int)i_item
+{
+ [self playlistStop];
+
+ vlc_mutex_lock( &p_main->p_playlist->change_lock );
+
+ if( i_item<p_main->p_playlist->i_size )
+ {
+ p_main->p_playlist->i_index--;
}
+
+ vlc_mutex_unlock( &p_main->p_playlist->change_lock );
+
+ [self playlistPlayCurrent];
+}
- - (void) playlistAdd:(NSString*)o_filename {
- intf_PlaylistAdd(p_main->p_playlist, PLAYLIST_END, [o_filename lossyCString]) ;
- }
+- (void)playlistAdd:(NSString *)o_filename
+{
+ intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END,
+ [o_filename lossyCString] );
+}
- - (void) clearPlaylist {
- int i ;
+- (void)clearPlaylist
+{
+ int i;
- vlc_mutex_lock(&p_main->p_playlist->change_lock) ;
- for(i=0; i < p_main->p_playlist->i_size; i++)
- intf_PlaylistDelete(p_main->p_playlist, i) ;
- vlc_mutex_unlock(&p_main->p_playlist->change_lock) ;
+ vlc_mutex_lock( &p_main->p_playlist->change_lock );
+
+ for( i = 0; i < p_main->p_playlist->i_size; i++ )
+ {
+ intf_PlaylistDelete( p_main->p_playlist, i );
}
+
+ vlc_mutex_unlock( &p_main->p_playlist->change_lock );
+}
+
+- (bool)playlistPlaying
+{
+ return( p_main->p_playlist->b_stopped );
+}
+
@end
/*****************************************************************************
- * intf_vlc_wrapper.h : MacOS X plugin for vlc
+ * intf_vlc_wrapper.h: MacOS X plugin for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $$
+ * $Id: intf_vlc_wrapper.h,v 1.3 2002/02/18 01:34:44 jlj Exp $
*
* Authors: Florian G. Pflug <fgp@phlo.org>
+ * Jon Lech Johansen <jon-vl@nanocrew.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
-#import <Cocoa/Cocoa.h>
-
-typedef enum intf_speed_e {SPEED_SLOW=0, SPEED_NORMAL, SPEED_FAST} intf_speed_t ;
-@protocol VlcWrapper_Delegate
- - (void) requestQDPortFullscreen:(bool)b_fullscreen ;
- - (void) releaseQDPort ;
- - (void) resizeQDPortFullscreen:(bool)b_fullscreen ;
-@end
+typedef enum intf_speed_e
+{
+ SPEED_SLOW = 0,
+ SPEED_NORMAL,
+ SPEED_FAST
+} intf_speed_t;
+/* Intf_VlcWrapper is a singleton class
+ (only one instance at any time) */
-// Intf_VlcWrapper is a singleton class (there is only one instance at any time)
-@interface Intf_VlcWrapper : NSObject {
- id<VlcWrapper_Delegate> o_delegate ;
- intf_speed_t e_speed ;
-
- unsigned int i_width, i_height ;
+@interface Intf_VlcWrapper : NSObject
+{
+ id o_delegate;
+ intf_speed_t e_speed;
}
-// Initialization,....
-+ (Intf_VlcWrapper*) instance ;
-- (Intf_VlcWrapper*) initWithDelegate:(id)o_delegate ;
+/* Initialization */
++ (Intf_VlcWrapper *)instance;
+- (Intf_VlcWrapper *)initWithDelegate:(id)o_delegate;
-- (bool) manage ;
+- (bool)manage;
+- (void)quit;
-//Function for the GUI.
-- (void) setQDPort:(CGrafPtr)p_qdport ;
-- (void) sizeChangeQDPort ;
-- (NSSize) videoSize ;
+/* Vout requests */
+- (void)handlePortMessage:(NSPortMessage *)o_msg;
+- (NSPort *)sendPort;
-// Playback control
-- (void) setSpeed:(intf_speed_t)e_speed ;
-- (NSString*) getTimeAsString ;
-- (float) getTimeAsFloat ;
-- (void) setTimeAsFloat:(float)i_offset ;
+/* Playback control */
+- (void)setSpeed:(intf_speed_t)e_speed;
+- (NSString *)getTimeAsString;
+- (float)getTimeAsFloat;
+- (void)setTimeAsFloat:(float)i_offset;
-// Playlist control
-- (NSArray*) playlistAsArray ;
-- (int) playlistLength ;
-- (NSString*) playlistItem:(int) i_pos ;
-- (bool) playlistPlayCurrent ;
-- (void) playlistPause ;
-- (void) playlistStop ;
-- (void) playlistPlayNext ;
-- (void) playlistPlayPrev ;
-- (void) playlistPlayItem:(int)i_item ;
-- (void) playlistAdd:(NSString*)o_filename ;
-- (void) clearPlaylist ;
-@end
+/* Playlist control */
+- (NSArray *)playlistAsArray;
+- (int)playlistLength;
+- (NSString *)playlistItem:(int)i_pos;
+- (bool)playlistPlayCurrent;
+- (void)playlistPause;
+- (void)playlistStop;
+- (void)playlistPlayNext;
+- (void)playlistPlayPrev;
+- (void)playlistPlayItem:(int)i_item;
+- (void)playlistAdd:(NSString *)o_filename;
+- (void)clearPlaylist;
+- (bool)playlistPlaying;
+@end
/*****************************************************************************
- * macosx.c : MacOS X plugin for vlc
+ * macosx.c: MacOS X plugin for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: macosx.c,v 1.12 2002/01/21 00:52:07 sam Exp $
+ * $Id: macosx.c,v 1.13 2002/02/18 01:34:44 jlj Exp $
*
* Authors: Colin Delacroix <colin@zoy.org>
* Eugenio Jarosiewicz <ej0@cise.ufl.edu>
- * Florian G. Pflug <fgp@phlo.org>
+ * Florian G. Pflug <fgp@phlo.org>
+ * Jon Lech Johansen <jon-vl@nanocrew.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*****************************************************************************
- * macosx.h : MacOS X plugin for vlc
+ * macosx.h: MacOS X plugin for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: macosx.h,v 1.4 2002/02/15 13:32:53 sam Exp $
+ * $Id: macosx.h,v 1.5 2002/02/18 01:34:44 jlj Exp $
*
- * Authors: Florian G. Pflug <fgp@phlo.org>
+ * Authors: Colin Delacroix <colin@zoy.org>
+ * Eugenio Jarosiewicz <ej0@cise.ufl.edu>
+ * Florian G. Pflug <fgp@phlo.org>
+ * Jon Lech Johansen <jon-vl@nanocrew.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#import <Cocoa/Cocoa.h>
+#import <QuickTime/QuickTime.h>
+
+#include "vout_window.h"
+#include "vout_qdview.h"
+
/*****************************************************************************
- * The vout struct as access from both, the output and the interface module
+ * intf_sys_t: description and status of the interface
*****************************************************************************/
-#include <QuickTime/QuickTime.h>
-
-#define OSX_INTF_VOUT_QDPORT_CHANGE 0x0001
-#define OSX_INTF_VOUT_SIZE_CHANGE 0x0002
-#define OSX_VOUT_INTF_REQUEST_QDPORT 0x0004
-#define OSX_VOUT_INTF_RELEASE_QDPORT 0x0008
-
-/* This struct is included as the _FIRST_ member in intf_sys_t */
-/* That way the video output can cast the intf_sys_t to osx_com_t */
-/* and doesn't need the definition of intf_sys_t */
-#ifndef OSX_COM_TYPE
- #define OSX_COM_TYPE osx_com_t
- #define OSX_COM_STRUCT osx_com_s
-#endif
-typedef struct OSX_COM_STRUCT {
- unsigned int i_changes ;
- CGrafPtr p_qdport ;
+typedef struct intf_sys_s
+{
+ NSPort *o_port;
+ NSAutoreleasePool *o_pool;
+} intf_sys_t;
- struct vout_thread_s *p_vout;
-} OSX_COM_TYPE ;
+/*****************************************************************************
+ * vout_sys_t: MacOS X video output method descriptor
+ *****************************************************************************/
+typedef struct vout_sys_s
+{
+ VLCWindow *o_window;
+
+ NSRect s_rect;
+ int b_pos_saved;
+
+ boolean_t b_mouse_moved;
+ boolean_t b_mouse_pointer_visible;
+ mtime_t i_time_mouse_last_moved;
+ CodecType i_codec;
+ CGrafPtr p_qdport;
+ ImageSequence i_seq;
+ MatrixRecordPtr p_matrix;
+ DecompressorComponent img_dc;
+ ImageDescriptionHandle h_img_descr;
+} vout_sys_t;
+
+/*****************************************************************************
+ * vout_req_t: MacOS X video output request
+ *****************************************************************************/
+#define VOUT_REQ_CREATE_WINDOW 0x00000001
+#define VOUT_REQ_DESTROY_WINDOW 0x00000002
+
+typedef struct vout_req_s
+{
+ int i_type;
+ int i_result;
+
+ NSConditionLock *o_lock;
+
+ struct vout_thread_s *p_vout;
+} vout_req_t;
*
* Authors: Colin Delacroix <colin@zoy.org>
* Florian G. Pflug <fgp@phlo.org>
+ * Jon Lech Johansen <jon-vl@nanocrew.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <videolan/vlc.h>
-#include "interface.h"
-
#include "video.h"
#include "video_output.h"
-#define OSX_COM_STRUCT intf_sys_s
-#define OSX_COM_TYPE intf_sys_t
-#include "macosx.h"
-
-#include <QuickTime/QuickTime.h>
+#include "interface.h"
-/*****************************************************************************
- * vout_sys_t: MacOS X video output method descriptor
- *****************************************************************************
- * This structure is part of the video output thread descriptor.
- * It describes the MacOS X specific properties of an output thread.
- *****************************************************************************/
-typedef struct vout_sys_s
-{
- /* QT sequence information */
- ImageDescriptionHandle h_img_descr ;
- ImageSequence i_seq ;
- unsigned int c_codec ;
- MatrixRecordPtr p_matrix ;
+#include "macosx.h"
-} vout_sys_t;
+#define QT_MAX_DIRECTBUFFERS 10
typedef struct picture_sys_s
{
unsigned int i_size;
/* When using I420 output */
- PlanarPixmapInfoYUV420 pixmap_i420 ;
+ PlanarPixmapInfoYUV420 pixmap_i420;
} picture_sys_t;
-#define MAX_DIRECTBUFFERS 10
-
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static int vout_Create ( vout_thread_t * );
-static int vout_Init ( vout_thread_t * );
-static void vout_End ( vout_thread_t * );
-static void vout_Destroy ( vout_thread_t * );
-static int vout_Manage ( vout_thread_t * );
-static void vout_Display ( vout_thread_t *, picture_t * );
-static void vout_Render ( vout_thread_t *, picture_t * );
-
-/* OS Specific */
-static int CreateQTSequence ( vout_thread_t *p_vout ) ;
-static void DestroyQTSequence( vout_thread_t *p_vout ) ;
-
-static int NewPicture ( vout_thread_t *, picture_t * );
-static void FreePicture ( vout_thread_t *, picture_t * );
-
-static void fillout_ImageDescription(ImageDescriptionHandle h_descr,
- unsigned int i_with, unsigned int i_height,
- unsigned int c_codec) ;
-static void fillout_ScalingMatrix( vout_thread_t *p_vout ) ;
+static int vout_Create ( struct vout_thread_s * );
+static int vout_Init ( struct vout_thread_s * );
+static void vout_End ( struct vout_thread_s * );
+static void vout_Destroy ( struct vout_thread_s * );
+static int vout_Manage ( struct vout_thread_s * );
+static void vout_Render ( struct vout_thread_s *, struct picture_s * );
+static void vout_Display ( struct vout_thread_s *, struct picture_s * );
+
+static int CoSendRequest ( struct vout_thread_s *, long i_request );
+static int CoCreateWindow ( struct vout_thread_s * );
+static int CoDestroyWindow ( struct vout_thread_s * );
+static int CoToggleFullscreen ( struct vout_thread_s * );
+
+static void QTScaleMatrix ( struct vout_thread_s * );
+static int QTCreateSequence ( struct vout_thread_s * );
+static void QTDestroySequence ( struct vout_thread_s * );
+static int QTNewPicture ( struct vout_thread_s *, struct picture_s * );
+static void QTFreePicture ( struct vout_thread_s *, struct picture_s * );
/*****************************************************************************
* Functions exported as capabilities. They are declared as static so that
*****************************************************************************/
static int vout_Create( vout_thread_t *p_vout )
{
+ OSErr err;
+
+ if( !p_main->p_intf || !p_main->p_intf->p_module ||
+ strcmp( p_main->p_intf->p_module->psz_name, MODULE_STRING ) != 0 )
+ {
+ intf_ErrMsg( "vout error: MacOS X interface module required" );
+ return( 1 );
+ }
+
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
- intf_ErrMsg( "error: %s", strerror( ENOMEM ) );
+ intf_ErrMsg( "vout error: %s", strerror( ENOMEM ) );
+ return( 1 );
+ }
+
+ memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );
+
+ p_vout->p_sys->h_img_descr =
+ (ImageDescriptionHandle)NewHandleClear( sizeof(ImageDescription) );
+ p_vout->p_sys->p_matrix = (MatrixRecordPtr)malloc( sizeof(MatrixRecord) );
+
+ p_vout->p_sys->b_mouse_pointer_visible = 1;
+
+ p_vout->p_sys->s_rect.size.width = p_vout->render.i_width;
+ p_vout->p_sys->s_rect.size.height = p_vout->render.i_height;
+
+ if( ( err = EnterMovies() ) != noErr )
+ {
+ intf_ErrMsg( "vout error: EnterMovies failed: %d", err );
+ free( p_vout->p_sys->p_matrix );
+ DisposeHandle( (Handle)p_vout->p_sys->h_img_descr );
+ free( p_vout->p_sys );
+ return( 1 );
+ }
+
+ if( vout_ChromaCmp( p_vout->render.i_chroma, FOURCC_I420 ) )
+ {
+ err = FindCodec( kYUV420CodecType, bestSpeedCodec,
+ nil, &p_vout->p_sys->img_dc );
+ if( err == noErr && p_vout->p_sys->img_dc != 0 )
+ {
+ p_vout->output.i_chroma = FOURCC_I420;
+ p_vout->p_sys->i_codec = kYUV420CodecType;
+ }
+ else
+ {
+ intf_ErrMsg( "vout error: failed to find an appropriate codec" );
+ }
+ }
+ else
+ {
+ intf_ErrMsg( "vout error: chroma 0x%08x not supported",
+ p_vout->render.i_chroma );
+ }
+
+ if( p_vout->p_sys->img_dc == 0 )
+ {
+ free( p_vout->p_sys->p_matrix );
+ DisposeHandle( (Handle)p_vout->p_sys->h_img_descr );
+ free( p_vout->p_sys );
+ return( 1 );
+ }
+
+ if( CoCreateWindow( p_vout ) )
+ {
+ intf_ErrMsg( "vout error: unable to create window" );
+ free( p_vout->p_sys->p_matrix );
+ DisposeHandle( (Handle)p_vout->p_sys->h_img_descr );
+ free( p_vout->p_sys );
return( 1 );
}
- p_main->p_intf->p_sys->i_changes = 0;
- p_main->p_intf->p_sys->p_vout = p_vout;
- p_vout->p_sys->h_img_descr = (ImageDescriptionHandle)NewHandleClear( sizeof( ImageDescription ) ) ;
- p_vout->p_sys->p_matrix = (MatrixRecordPtr)malloc( sizeof( MatrixRecord ) ) ;
- EnterMovies() ;
return( 0 );
}
I_OUTPUTPICTURES = 0;
- /* Since we can arbitrary scale, stick to the coordinates and aspect. */
+ /* Initialize the output structure; we already found a codec,
+ * and the corresponding chroma we will be using. Since we can
+ * arbitrary scale, stick to the coordinates and aspect. */
p_vout->output.i_width = p_vout->render.i_width;
p_vout->output.i_height = p_vout->render.i_height;
p_vout->output.i_aspect = p_vout->render.i_aspect;
- CreateQTSequence( p_vout ) ;
+ SetPort( p_vout->p_sys->p_qdport );
+ QTScaleMatrix( p_vout );
- switch( p_vout->p_sys->c_codec )
+ if( QTCreateSequence( p_vout ) )
{
- case 'yuv2':
- p_vout->output.i_chroma = FOURCC_YUY2;
- break;
- case 'y420':
- p_vout->output.i_chroma = FOURCC_I420;
- break;
- case 'NONE':
- intf_ErrMsg( "vout error: no QT codec found" );
- return 0;
- default:
- intf_ErrMsg( "vout error: unknown QT codec" );
- return 0;
+ intf_ErrMsg( "vout error: unable to create sequence" );
+ return( 1 );
}
- /* Try to initialize up to MAX_DIRECTBUFFERS direct buffers */
- while( I_OUTPUTPICTURES < MAX_DIRECTBUFFERS )
+ /* Try to initialize up to QT_MAX_DIRECTBUFFERS direct buffers */
+ while( I_OUTPUTPICTURES < QT_MAX_DIRECTBUFFERS )
{
p_pic = NULL;
/* Find an empty picture slot */
- for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
+ for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++ )
{
if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
{
}
/* Allocate the picture */
- if( p_pic == NULL || NewPicture( p_vout, p_pic ) )
+ if( p_pic == NULL || QTNewPicture( p_vout, p_pic ) )
{
break;
}
I_OUTPUTPICTURES++;
}
- return 0 ;
+ return( 0 );
}
/*****************************************************************************
{
int i_index;
- DestroyQTSequence( p_vout ) ;
- p_main->p_intf->p_sys->p_vout = NULL;
- p_main->p_intf->p_sys->i_changes |= OSX_VOUT_INTF_RELEASE_QDPORT ;
+ QTDestroySequence( p_vout );
/* Free the direct buffers we allocated */
- for( i_index = I_OUTPUTPICTURES ; i_index ; )
+ for( i_index = I_OUTPUTPICTURES; i_index; )
{
i_index--;
- FreePicture( p_vout, PP_OUTPUTPICTURE[ i_index ] );
+ QTFreePicture( p_vout, PP_OUTPUTPICTURE[ i_index ] );
}
}
*****************************************************************************/
static void vout_Destroy( vout_thread_t *p_vout )
{
- free( p_vout->p_sys->p_matrix ) ;
- DisposeHandle( (Handle)p_vout->p_sys->h_img_descr ) ;
+ if( CoDestroyWindow( p_vout ) )
+ {
+ intf_ErrMsg( "vout error: unable to destroy window" );
+ }
+
+ ExitMovies();
+
+ free( p_vout->p_sys->p_matrix );
+ DisposeHandle( (Handle)p_vout->p_sys->h_img_descr );
free( p_vout->p_sys );
}
*****************************************************************************/
static int vout_Manage( vout_thread_t *p_vout )
{
- if( p_main->p_intf->p_sys->i_changes
- & OSX_INTF_VOUT_QDPORT_CHANGE )
+ if( p_vout->i_changes & VOUT_SIZE_CHANGE )
{
- intf_ErrMsg( "vout error: this change is unhandled yet !" );
- return 1;
+ QTScaleMatrix( p_vout );
+ SetDSequenceMatrix( p_vout->p_sys->i_seq,
+ p_vout->p_sys->p_matrix );
+
+ p_vout->i_changes &= ~VOUT_SIZE_CHANGE;
}
- else if( p_main->p_intf->p_sys->i_changes
- & OSX_INTF_VOUT_SIZE_CHANGE )
+
+ if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE )
{
- if( p_vout->p_sys->c_codec != 'NONE' )
+ if( CoToggleFullscreen( p_vout ) )
{
- fillout_ScalingMatrix( p_vout ) ;
- SetDSequenceMatrix( p_vout->p_sys->i_seq,
- p_vout->p_sys->p_matrix ) ;
+ return( 1 );
}
+
+ p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
}
- /* Clear flags */
- p_main->p_intf->p_sys->i_changes &= ~(
- OSX_INTF_VOUT_QDPORT_CHANGE |
- OSX_INTF_VOUT_SIZE_CHANGE
- ) ;
+ /* hide/show mouse cursor */
+ if( p_vout->p_sys->b_mouse_moved ||
+ p_vout->p_sys->i_time_mouse_last_moved )
+ {
+ boolean_t b_change = 0;
- return 0 ;
-}
+ if( !p_vout->p_sys->b_mouse_pointer_visible )
+ {
+ CGDisplayShowCursor( kCGDirectMainDisplay );
+ b_change = 1;
+ }
+ else if( !p_vout->p_sys->b_mouse_moved &&
+ mdate() - p_vout->p_sys->i_time_mouse_last_moved > 2000000 &&
+ p_vout->p_sys->b_mouse_pointer_visible )
+ {
+ CGDisplayHideCursor( kCGDirectMainDisplay );
+ b_change = 1;
+ }
+ if( b_change )
+ {
+ p_vout->p_sys->i_time_mouse_last_moved = 0;
+ p_vout->p_sys->b_mouse_moved = 0;
+ p_vout->p_sys->b_mouse_pointer_visible =
+ !p_vout->p_sys->b_mouse_pointer_visible;
+ }
+ }
+
+ return( 0 );
+}
/*****************************************************************************
- * vout_Render: renders previously calculated output
+ * vout_Render: render previously calculated output
*****************************************************************************/
-void vout_Render( vout_thread_t *p_vout, picture_t *p_pic )
+static void vout_Render( vout_thread_t *p_vout, picture_t *p_pic )
{
;
}
- /*****************************************************************************
+/*****************************************************************************
* vout_Display: displays previously rendered output
*****************************************************************************
- * This function send the currently rendered image to image, waits until
- * it is displayed and switch the two rendering buffers, preparing next frame.
+ * This function sends the currently rendered image to the display.
+ *****************************************************************************/
+static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
+{
+ OSErr err;
+ CodecFlags flags;
+
+ if( ( err = DecompressSequenceFrameS(
+ p_vout->p_sys->i_seq,
+ p_pic->p_sys->p_info,
+ p_pic->p_sys->i_size,
+ codecFlagUseScreenBuffer, &flags, nil ) != noErr ) )
+ {
+ intf_ErrMsg( "DecompressSequenceFrameS failed: %d", err );
+ }
+}
+
+/*****************************************************************************
+ * CoSendRequest: send request to interface thread
+ *****************************************************************************
+ * Returns 0 on success, 1 otherwise
*****************************************************************************/
-void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
+static int CoSendRequest( vout_thread_t *p_vout, long i_request )
{
- CodecFlags out_flags ;
+ NSArray *o_array;
+ NSPortMessage *o_msg;
+ struct vout_req_s req;
+ struct vout_req_s *p_req = &req;
+ NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
+ NSPort *recvPort = [[NSPort port] retain];
+
+ memset( &req, 0, sizeof(req) );
+ req.i_type = i_request;
+ req.p_vout = p_vout;
+
+ req.o_lock = [[NSConditionLock alloc] initWithCondition: 0];
+
+ o_array = [NSArray arrayWithObject:
+ [NSData dataWithBytes: &p_req length: sizeof(void *)]];
+ o_msg = [[NSPortMessage alloc]
+ initWithSendPort: p_main->p_intf->p_sys->o_port
+ receivePort: recvPort
+ components: o_array];
+
+ [o_msg sendBeforeDate: [NSDate distantPast]];
+ [req.o_lock lockWhenCondition: 1];
+ [req.o_lock unlock];
+
+ [o_msg release];
+ [req.o_lock release];
- switch (p_vout->p_sys->c_codec)
+ [recvPort release];
+ [o_pool release];
+
+ return( !req.i_result );
+}
+
+/*****************************************************************************
+ * CoCreateWindow: create new window
+ *****************************************************************************
+ * Returns 0 on success, 1 otherwise
+ *****************************************************************************/
+static int CoCreateWindow( vout_thread_t *p_vout )
+{
+ if( CoSendRequest( p_vout, VOUT_REQ_CREATE_WINDOW ) )
{
- case 'yuv2':
- case 'y420':
- DecompressSequenceFrameS(
- p_vout->p_sys->i_seq,
- p_pic->p_sys->p_info,
- p_pic->p_sys->i_size,
- codecFlagUseScreenBuffer,
- &out_flags,
- nil
- ) ;
- break ;
- default:
- intf_WarnMsg( 1, "vout_macosx: vout_Display called, but no codec available" ) ;
- break;
+ intf_ErrMsg( "CoSendRequest (CREATE_WINDOW) failed" );
+ return( 1 );
}
+
+ return( 0 );
}
-static int CreateQTSequence( vout_thread_t *p_vout )
+/*****************************************************************************
+ * CoDestroyWindow: destroy window
+ *****************************************************************************
+ * Returns 0 on success, 1 otherwise
+ *****************************************************************************/
+static int CoDestroyWindow( vout_thread_t *p_vout )
{
- p_vout->p_sys->c_codec = 'NONE' ;
- p_main->p_intf->p_sys->i_changes |= OSX_VOUT_INTF_REQUEST_QDPORT ;
-
- while ( p_main->p_intf->p_sys->p_qdport == nil
- && !p_vout->b_die )
+ if( !p_vout->p_sys->b_mouse_pointer_visible )
{
-printf("WAITING for QD port ...\n");
- if( p_main->p_intf->p_sys->i_changes
- & OSX_INTF_VOUT_QDPORT_CHANGE )
- {
- p_main->p_intf->p_sys->i_changes &= ~( OSX_INTF_VOUT_QDPORT_CHANGE ) ;
- intf_ErrMsg( "got a QDPORT_CHANGE" );
- break;
- }
- msleep( 300000 );
+ CGDisplayShowCursor( kCGDirectMainDisplay );
+ p_vout->p_sys->b_mouse_pointer_visible = 1;
}
- if ( p_main->p_intf->p_sys->p_qdport == nil)
+ if( CoSendRequest( p_vout, VOUT_REQ_DESTROY_WINDOW ) )
{
-printf("BLAAAAAAAAAAH\n");
- p_vout->p_sys->c_codec = 'NONE' ;
- return 1 ;
+ intf_ErrMsg( "CoSendRequest (DESTROY_WINDOW) failed" );
+ return( 1 );
}
- SetPort( p_main->p_intf->p_sys->p_qdport ) ;
- fillout_ScalingMatrix( p_vout ) ;
-
- fillout_ImageDescription( p_vout->p_sys->h_img_descr,
- p_vout->output.i_width, p_vout->output.i_height,
- 'y420' ) ;
-
- if( !DecompressSequenceBeginS( &p_vout->p_sys->i_seq,
- p_vout->p_sys->h_img_descr, NULL, 0,
- p_main->p_intf->p_sys->p_qdport,
- NULL, //device to display (is set implicit via the qdPort)
- NULL, //src-rect
- p_vout->p_sys->p_matrix, //matrix
- 0, //just do plain copying
- NULL, //no mask region
- codecFlagUseScreenBuffer, codecLosslessQuality,
- (DecompressorComponent) bestSpeedCodec) )
+ return( 0 );
+}
+
+/*****************************************************************************
+ * CoToggleFullscreen: toggle fullscreen
+ *****************************************************************************
+ * Returns 0 on success, 1 otherwise
+ *****************************************************************************/
+static int CoToggleFullscreen( vout_thread_t *p_vout )
+{
+ QTDestroySequence( p_vout );
+
+ if( CoDestroyWindow( p_vout ) )
{
-printf("OK !!!\n");
- p_vout->p_sys->c_codec = 'y420' ;
- return 0 ;
+ intf_ErrMsg( "vout error: unable to destroy window" );
+ return( 1 );
}
+
+ p_vout->b_fullscreen = !p_vout->b_fullscreen;
-#if 0
- /* For yuv2 */
+ if( CoCreateWindow( p_vout ) )
{
- p_vout->p_sys->c_codec = 'yuv2' ;
+ intf_ErrMsg( "vout error: unable to create window" );
+ return( 1 );
}
-#endif
-
-printf("FUXK..\n");
- p_vout->p_sys->c_codec = 'NONE' ;
- return 1 ;
+
+ SetPort( p_vout->p_sys->p_qdport );
+ QTScaleMatrix( p_vout );
+
+ if( QTCreateSequence( p_vout ) )
+ {
+ intf_ErrMsg( "vout error: unable to create sequence" );
+ return( 1 );
+ }
+
+ return( 0 );
}
-static void DestroyQTSequence( vout_thread_t *p_vout )
+/*****************************************************************************
+ * QTScaleMatrix: scale matrix
+ *****************************************************************************/
+static void QTScaleMatrix( vout_thread_t *p_vout )
{
- if (p_vout->p_sys->c_codec == 'NONE')
- return ;
-
- CDSequenceEnd( p_vout->p_sys->i_seq ) ;
- p_vout->p_sys->c_codec = 'NONE' ;
-}
+ Rect s_rect;
+ Fixed factor_x;
+ Fixed factor_y;
+ GetPortBounds( p_vout->p_sys->p_qdport, &s_rect );
-static void fillout_ImageDescription(ImageDescriptionHandle h_descr, unsigned int i_width, unsigned int i_height, unsigned int c_codec)
+ factor_x = FixDiv( Long2Fix( s_rect.right - s_rect.left ),
+ Long2Fix( p_vout->output.i_width ) );
+ factor_y = FixDiv( Long2Fix( s_rect.bottom - s_rect.top ),
+ Long2Fix( p_vout->output.i_height ) );
+
+ SetIdentityMatrix( p_vout->p_sys->p_matrix );
+ ScaleMatrix( p_vout->p_sys->p_matrix,
+ factor_x, factor_y,
+ Long2Fix(0), Long2Fix(0) );
+}
+
+/*****************************************************************************
+ * QTCreateSequence: create a new sequence
+ *****************************************************************************
+ * Returns 0 on success, 1 otherwise
+ *****************************************************************************/
+static int QTCreateSequence( vout_thread_t *p_vout )
{
- ImageDescriptionPtr p_descr ;
-
- HLock((Handle)h_descr) ;
- p_descr = *h_descr ;
- p_descr->idSize = sizeof(ImageDescription) ;
- p_descr->cType = c_codec ;
- p_descr->resvd1 = 0 ; //Reserved
- p_descr->resvd2 = 0 ; //Reserved
- p_descr->dataRefIndex = 0 ; //Reserved
- p_descr->version = 1 ; //
- p_descr->revisionLevel = 0 ;
- p_descr->vendor = 'appl' ; //How do we get a vendor id??
- p_descr->width = i_width ;
- p_descr->height = i_height ;
- p_descr->hRes = Long2Fix(72) ;
- p_descr->vRes = Long2Fix(72) ;
- p_descr->spatialQuality = codecLosslessQuality ;
- p_descr->frameCount = 1 ;
- p_descr->clutID = -1 ; //We don't need a color table
-
- switch (c_codec)
+ OSErr err;
+ ImageDescriptionPtr p_descr;
+
+ HLock( (Handle)p_vout->p_sys->h_img_descr );
+ p_descr = *p_vout->p_sys->h_img_descr;
+
+ p_descr->idSize = sizeof(ImageDescription);
+ p_descr->cType = p_vout->p_sys->i_codec;
+ p_descr->version = 1;
+ p_descr->revisionLevel = 0;
+ p_descr->vendor = 'appl';
+ p_descr->width = p_vout->output.i_width;
+ p_descr->height = p_vout->output.i_height;
+ p_descr->hRes = Long2Fix(72);
+ p_descr->vRes = Long2Fix(72);
+ p_descr->spatialQuality = codecLosslessQuality;
+ p_descr->frameCount = 1;
+ p_descr->clutID = -1;
+
+ p_descr->dataSize = p_vout->output.i_width *
+ p_vout->output.i_height * 3 / 2;
+ p_descr->depth = 12;
+
+ HUnlock( (Handle)p_vout->p_sys->h_img_descr );
+
+ if( ( err = DecompressSequenceBeginS(
+ &p_vout->p_sys->i_seq,
+ p_vout->p_sys->h_img_descr,
+ NULL, 0,
+ p_vout->p_sys->p_qdport,
+ NULL, NULL,
+ p_vout->p_sys->p_matrix,
+ 0, NULL,
+ codecFlagUseScreenBuffer,
+ codecLosslessQuality,
+ p_vout->p_sys->img_dc ) ) )
{
- case 'yuv2':
- p_descr->dataSize=i_width * i_height * 2 ;
- p_descr->depth = 24 ;
- break ;
- case 'y420':
- p_descr->dataSize=i_width * i_height * 3 / 2 ;
- p_descr->depth = 12 ;
- break ;
+ intf_ErrMsg( "DecompressSequenceBeginS failed: %d", err );
+ return( 1 );
}
-
- HUnlock((Handle)h_descr) ;
+
+ return( 0 );
}
-static void fillout_ScalingMatrix( vout_thread_t *p_vout)
+/*****************************************************************************
+ * QTDestroySequence: destroy sequence
+ *****************************************************************************/
+static void QTDestroySequence( vout_thread_t *p_vout )
{
- Rect s_rect ;
- Fixed factor_x ;
- Fixed factor_y ;
-
- GetPortBounds( p_main->p_intf->p_sys->p_qdport, &s_rect ) ;
-// if (((s_rect.right - s_rect.left) / ((float) p_vout->i_width)) < ((s_rect.bottom - s_rect.top) / ((float) p_vout->i_height)))
- factor_x = FixDiv(Long2Fix(s_rect.right - s_rect.left), Long2Fix(p_vout->output.i_width)) ;
-// else
- factor_y = FixDiv(Long2Fix(s_rect.bottom - s_rect.top), Long2Fix(p_vout->output.i_height)) ;
-
- SetIdentityMatrix(p_vout->p_sys->p_matrix) ;
- ScaleMatrix( p_vout->p_sys->p_matrix, factor_x, factor_y, Long2Fix(0), Long2Fix(0) ) ;
+ CDSequenceEnd( p_vout->p_sys->i_seq );
}
/*****************************************************************************
- * NewPicture: allocate a picture
+ * QTNewPicture: allocate a picture
*****************************************************************************
- * Returns 0 on success, -1 otherwise
+ * Returns 0 on success, 1 otherwise
*****************************************************************************/
-static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
+static int QTNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
{
+ int i_width = p_vout->output.i_width;
+ int i_height = p_vout->output.i_height;
+
/* We know the chroma, allocate a buffer which will be used
* directly by the decoder */
p_pic->p_sys = malloc( sizeof( picture_sys_t ) );
if( p_pic->p_sys == NULL )
{
- return -1;
+ return( -1 );
}
switch( p_vout->output.i_chroma )
{
case FOURCC_I420:
- p_pic->p_sys->p_info = (void *)&p_pic->p_sys->pixmap_i420 ;
- p_pic->p_sys->i_size = sizeof(PlanarPixmapInfoYUV420) ;
+ p_pic->p_sys->p_info = (void *)&p_pic->p_sys->pixmap_i420;
+ p_pic->p_sys->i_size = sizeof(PlanarPixmapInfoYUV420);
- p_pic->Y_PIXELS = memalign( 16, p_vout->output.i_width
- * p_vout->output.i_height * 3 / 2 );
- p_pic->p[Y_PLANE].i_lines = p_vout->output.i_height;
- p_pic->p[Y_PLANE].i_pitch = p_vout->output.i_width;
+ /* Y buffer */
+ p_pic->Y_PIXELS = memalign( 16, i_width * i_height * 3 / 2 );
+ p_pic->p[Y_PLANE].i_lines = i_height;
+ p_pic->p[Y_PLANE].i_pitch = i_width;
p_pic->p[Y_PLANE].i_pixel_bytes = 1;
p_pic->p[Y_PLANE].b_margin = 0;
- p_pic->U_PIXELS = p_pic->Y_PIXELS + p_vout->output.i_width
- * p_vout->output.i_height;
- p_pic->p[U_PLANE].i_lines = p_vout->output.i_height / 2;
- p_pic->p[U_PLANE].i_pitch = p_vout->output.i_width / 2;
+ /* U buffer */
+ p_pic->U_PIXELS = p_pic->Y_PIXELS + i_height * i_width;
+ p_pic->p[U_PLANE].i_lines = i_height / 2;
+ p_pic->p[U_PLANE].i_pitch = i_width / 2;
p_pic->p[U_PLANE].i_pixel_bytes = 1;
p_pic->p[U_PLANE].b_margin = 0;
- p_pic->V_PIXELS = p_pic->U_PIXELS + p_vout->output.i_width
- * p_vout->output.i_height / 4;
- p_pic->p[V_PLANE].i_lines = p_vout->output.i_height / 2;
- p_pic->p[V_PLANE].i_pitch = p_vout->output.i_width / 2;
+ /* V buffer */
+ p_pic->V_PIXELS = p_pic->U_PIXELS + i_height * i_width / 4;
+ p_pic->p[V_PLANE].i_lines = i_height / 2;
+ p_pic->p[V_PLANE].i_pitch = i_width / 2;
p_pic->p[V_PLANE].i_pixel_bytes = 1;
p_pic->p[V_PLANE].b_margin = 0;
+ /* We allocated 3 planes */
p_pic->i_planes = 3;
#define P p_pic->p_sys->pixmap_i420
P.componentInfoCr.offset = (void *)p_pic->V_PIXELS
- p_pic->p_sys->p_info;
- P.componentInfoY.rowBytes = p_vout->output.i_width ;
- P.componentInfoCb.rowBytes = p_vout->output.i_width / 2 ;
- P.componentInfoCr.rowBytes = p_vout->output.i_width / 2 ;
+ P.componentInfoY.rowBytes = i_width;
+ P.componentInfoCb.rowBytes = i_width / 2;
+ P.componentInfoCr.rowBytes = i_width / 2;
#undef P
break;
- case FOURCC_YUY2:
-
- /* XXX: TODO */
- free( p_pic->p_sys );
- intf_ErrMsg( "vout error: YUV2 not supported yet" );
- p_pic->i_planes = 0;
- break;
-
- default:
- /* Unknown chroma, tell the guy to get lost */
- free( p_pic->p_sys );
- intf_ErrMsg( "vout error: never heard of chroma 0x%.8x (%4.4s)",
- p_vout->output.i_chroma,
- (char*)&p_vout->output.i_chroma );
- p_pic->i_planes = 0;
- return -1;
+ default:
+ /* Unknown chroma, tell the guy to get lost */
+ free( p_pic->p_sys );
+ intf_ErrMsg( "vout error: never heard of chroma 0x%.8x (%4.4s)",
+ p_vout->output.i_chroma,
+ (char*)&p_vout->output.i_chroma );
+ p_pic->i_planes = 0;
+ return( -1 );
}
- return 0;
+ return( 0 );
}
/*****************************************************************************
- * FreePicture: destroy a picture allocated with NewPicture
+ * QTFreePicture: destroy a picture allocated with QTNewPicture
*****************************************************************************/
-static void FreePicture( vout_thread_t *p_vout, picture_t *p_pic )
+static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
{
- switch (p_vout->p_sys->c_codec)
- {
- case 'yuv2':
- free( p_pic->p_sys->p_info ) ;
- p_pic->p_sys->i_size = 0 ;
- break ;
- case 'y420':
- break ;
- default:
- break ;
- }
-
free( p_pic->p_sys );
}
--- /dev/null
+/*****************************************************************************
+ * vout_qdview.c: MacOS X plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 2001 VideoLAN
+ * $Id: vout_qdview.c,v 1.1 2002/02/18 01:34:44 jlj Exp $
+ *
+ * Authors: Florian G. Pflug <fgp@phlo.org>
+ * Jon Lech Johansen <jon-vl@nanocrew.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include <errno.h> /* ENOMEM */
+#include <stdlib.h> /* free() */
+#include <string.h> /* strerror() */
+
+#include <videolan/vlc.h>
+
+#include "video.h"
+#include "video_output.h"
+
+#include "macosx.h"
+
+/*****************************************************************************
+ * VLCView implementation
+ *****************************************************************************/
+@implementation VLCView
+
+- (id)initWithVout:(struct vout_thread_s *)_p_vout
+{
+ if( [super init] == nil )
+ return nil;
+
+ p_vout = _p_vout;
+
+ return self;
+}
+
+- (void)drawRect:(NSRect)rect
+{
+ [super drawRect: rect];
+ p_vout->i_changes |= VOUT_SIZE_CHANGE;
+}
+
+@end
/*****************************************************************************
- * intf_main.h: MacOS X interface plugin
+ * vout_qdview.h: MacOS X plugin for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
+ * $Id: vout_qdview.h,v 1.1 2002/02/18 01:34:44 jlj Exp $
*
- * Authors: Colin Delacroix <colin@zoy.org>
- * Florian G. Pflug <fgp@phlo.org>
+ * Authors: Florian G. Pflug <fgp@phlo.org>
+ * Jon Lech Johansen <jon-vl@nanocrew.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
-/* OS specific */
-#import <Cocoa/Cocoa.h>
-
-/*****************************************************************************
- * intf_sys_t: description and status of the interface
- *****************************************************************************/
-typedef struct intf_sys_s
+@interface VLCView : NSQuickDrawView
{
- osx_com_t osx_communication ;
+ struct vout_thread_s *p_vout;
+}
- NSAutoreleasePool *o_pool ;
-} intf_sys_t;
+- (id)initWithVout:(struct vout_thread_s *)_p_vout;
+@end
--- /dev/null
+/*****************************************************************************
+ * vout_window.c: MacOS X plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 2001 VideoLAN
+ * $Id: vout_window.c,v 1.1 2002/02/18 01:34:44 jlj Exp $
+ *
+ * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include <errno.h> /* ENOMEM */
+#include <stdlib.h> /* free() */
+#include <string.h> /* strerror() */
+
+#include <videolan/vlc.h>
+
+#include "video.h"
+#include "video_output.h"
+
+#include "interface.h"
+
+#include "macosx.h"
+
+/*****************************************************************************
+ * VLCWindow implementation
+ *****************************************************************************/
+@implementation VLCWindow
+
+- (void)setVout:(struct vout_thread_s *)_p_vout
+{
+ p_vout = _p_vout;
+}
+
+- (BOOL)canBecomeKeyWindow
+{
+ return( YES );
+}
+
+- (void)becomeKeyWindow
+{
+ [super becomeKeyWindow];
+ p_vout->p_sys->b_mouse_moved = 0;
+ p_vout->p_sys->i_time_mouse_last_moved = mdate();
+}
+
+- (void)resignKeyWindow
+{
+ [super resignKeyWindow];
+ p_vout->p_sys->b_mouse_moved = 1;
+ p_vout->p_sys->i_time_mouse_last_moved = 0;
+}
+
+- (void)keyDown:(NSEvent *)theEvent
+{
+ unichar key = 0;
+
+ if( [[theEvent characters] length] )
+ {
+ key = [[theEvent characters] characterAtIndex: 0];
+ }
+
+ switch( key )
+ {
+ case 'f': case 'F':
+ p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
+ break;
+
+ case 'q': case 'Q':
+ p_main->p_intf->b_die = 1;
+ break;
+
+ default:
+ [super keyDown: theEvent];
+ break;
+ }
+}
+
+- (void)mouseMoved:(NSEvent *)theEvent
+{
+ p_vout->p_sys->i_time_mouse_last_moved = mdate();
+}
+
+@end
--- /dev/null
+/*****************************************************************************
+ * vout_window.h: MacOS X plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 2001 VideoLAN
+ * $Id: vout_window.h,v 1.1 2002/02/18 01:34:44 jlj Exp $
+ *
+ * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ *****************************************************************************/
+
+@interface VLCWindow : NSWindow
+{
+ struct vout_thread_s *p_vout;
+}
+
+- (void)setVout:(struct vout_thread_s *)_p_vout;
+
+@end