Commit 89be0ac8 authored by Jon Lech Johansen's avatar Jon Lech Johansen

* MacOS X vout improvements

  * MacOS X intf now returns, allowing vlc to terminate properly
  * Added a new make target: package-macosx
parent de32203b
...@@ -458,6 +458,25 @@ package-beos: ...@@ -458,6 +458,25 @@ package-beos:
# Clean up # Clean up
rm -Rf tmp 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 libdvdcss-snapshot: snapshot-common
# Remove vlc sources and icons, doc, debian directory... # Remove vlc sources and icons, doc, debian directory...
rm -Rf tmp/vlc/src tmp/vlc/share tmp/vlc/plugins tmp/vlc/doc rm -Rf tmp/vlc/src tmp/vlc/share tmp/vlc/plugins tmp/vlc/doc
......
...@@ -7,7 +7,9 @@ ...@@ -7,7 +7,9 @@
openFile = id; openFile = id;
pause = id; pause = id;
play = id; play = id;
quit = id;
speedslider_update = id; speedslider_update = id;
stop = id;
timeslider_update = id; timeslider_update = id;
}; };
CLASS = Intf_Controller; CLASS = Intf_Controller;
...@@ -22,6 +24,7 @@ ...@@ -22,6 +24,7 @@
o_stepr = id; o_stepr = id;
o_stop = id; o_stop = id;
o_timeslider = id; o_timeslider = id;
o_window = id;
}; };
SUPERCLASS = NSObject; SUPERCLASS = NSObject;
}, },
...@@ -31,7 +34,6 @@ ...@@ -31,7 +34,6 @@
OUTLETS = {o_table = id; }; OUTLETS = {o_table = id; };
SUPERCLASS = NSObject; SUPERCLASS = NSObject;
}, },
{CLASS = VlcQuickDrawView; LANGUAGE = ObjC; SUPERCLASS = NSQuickDrawView; }
); );
IBVersion = 1; IBVersion = 1;
} }
...@@ -3,14 +3,21 @@ ...@@ -3,14 +3,21 @@
<plist version="0.9"> <plist version="0.9">
<dict> <dict>
<key>IBDocumentLocation</key> <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> <key>IBFramework Version</key>
<string>219.0</string> <string>248.0</string>
<key>IBMainMenuLocation</key> <key>IBOpenObjects</key>
<string>288 493 104 66 0 0 1280 938 </string> <array>
<integer>21</integer>
</array>
<key>IBSystem Version</key> <key>IBSystem Version</key>
<string>5L14</string> <string>5P48</string>
<key>IBUserGuides</key>
<dict/>
</dict> </dict>
</plist> </plist>
...@@ -67,14 +67,16 @@ ...@@ -67,14 +67,16 @@
F512122B0170635601A80A1F, F512122B0170635601A80A1F,
F512122C0170635601A80A1F, F512122C0170635601A80A1F,
F512122D0170635601A80A1F, F512122D0170635601A80A1F,
F512122F0170635601A80A1F,
F51212300170635601A80A1F, F51212300170635601A80A1F,
F51212310170635601A80A1F, F51212310170635601A80A1F,
F51212320170635601A80A1F, F51212320170635601A80A1F,
F510A6CC01738ED001A80A1F, F510A6CC01738ED001A80A1F,
F510A6CD01738ED001A80A1F, F510A6CD01738ED001A80A1F,
F53A3B49018DECF201A80A1F, F6799746020DCC2A01A80112,
F53A3B4A018DECF201A80A1F, F6799747020DCC2A01A80112,
F6799748020DCC2A01A80112,
F6799749020DCC2A01A80112,
F679974A020DCC2A01A80112,
); );
isa = PBXGroup; isa = PBXGroup;
name = Files; name = Files;
...@@ -113,12 +115,6 @@ ...@@ -113,12 +115,6 @@
path = plugins/macosx/intf_controller.h; path = plugins/macosx/intf_controller.h;
refType = 4; refType = 4;
}; };
F512122F0170635601A80A1F = {
isa = PBXFileReference;
name = intf_main.c;
path = plugins/macosx/intf_main.c;
refType = 4;
};
F51212300170635601A80A1F = { F51212300170635601A80A1F = {
isa = PBXFileReference; isa = PBXFileReference;
name = macosx.c; name = macosx.c;
...@@ -330,16 +326,44 @@ ...@@ -330,16 +326,44 @@
settings = { 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; isa = PBXFileReference;
name = intf_qdview.h; name = vout_window.c;
path = plugins/macosx/intf_qdview.h; path = plugins/macosx/vout_window.c;
refType = 4; refType = 4;
}; };
F53A3B4A018DECF201A80A1F = { F679974A020DCC2A01A80112 = {
isa = PBXFileReference; isa = PBXFileReference;
name = intf_qdview.c; name = vout_window.h;
path = plugins/macosx/intf_qdview.c; path = plugins/macosx/vout_window.h;
refType = 4; refType = 4;
}; };
}; };
......
#!/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 * 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> * 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 * 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 * it under the terms of the GNU General Public License as published by
...@@ -21,184 +22,184 @@ ...@@ -21,184 +22,184 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/ *****************************************************************************/
/* Remark: #import <ApplicationServices/ApplicationServices.h>
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
*/
#include <QuickTime/QuickTime.h> #include <videolan/vlc.h>
#include <ApplicationServices/ApplicationServices.h>
#import "intf_controller.h" #include "interface.h"
#import "intf_vlc_wrapper.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 @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 { /* Initialization & Event-Management */
if ([o_vlc manage])
[NSApp terminate: self] ;
[o_currenttime setStringValue: [o_vlc getTimeAsString]] ; - (void)awakeFromNib
[o_timeslider setFloatValue: [o_vlc getTimeAsFloat]] ; {
} NSString *pTitle = [NSString
stringWithCString: VOUT_TITLE " (Cocoa)"];
- (void)applicationDidBecomeActive:(NSNotification*)aNotification { o_vlc = [Intf_VlcWrapper instance];
if (b_window_is_fullscreen) { [o_vlc initWithDelegate: self];
[o_window orderFront:self] ;
[o_vlc playlistPlayCurrent] ;
}
}
- (void)applicationDidResignActive:(NSNotification*)aNotification { [o_window setTitle: pTitle];
if (b_window_is_fullscreen) { }
[o_vlc playlistPause] ;
[o_window orderOut:self] ;
}
}
- (void)applicationDidFinishLaunching:(NSNotification *)o_notification
{
[[o_vlc sendPort] setDelegate: self];
[[NSRunLoop currentRunLoop]
addPort: [o_vlc sendPort]
forMode: NSDefaultRunLoopMode];
[NSThread detachNewThreadSelector: @selector(manage)
toTarget: self withObject: nil];
}
//Functions attached to user interface - (void)manage
- (IBAction) openFile:(id)sender { {
NSOpenPanel *o_panel = [NSOpenPanel openPanel] ; NSDate *sleepDate;
NSAutoreleasePool *o_pool;
[o_panel setAllowsMultipleSelection:YES] ; o_pool = [[NSAutoreleasePool alloc] init];
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])) { while( ![o_vlc manage] )
[o_vlc playlistAdd:o_file] ; {
} [o_currenttime setStringValue: [o_vlc getTimeAsString]];
} [o_timeslider setFloatValue: [o_vlc getTimeAsFloat]];
[o_vlc playlistPlayCurrent] ;
}
- (IBAction) pause:(id)sender { if( [o_vlc playlistPlaying] )
[o_vlc playlistPause] ; {
UpdateSystemActivity( UsrActivity );
} }
- (IBAction) play:(id)sender { sleepDate = [NSDate dateWithTimeIntervalSinceNow: 0.1];
[o_vlc playlistPlayCurrent] ; [NSThread sleepUntilDate: sleepDate];
} }
- (IBAction) timeslider_update:(id)slider { [self terminate];
[o_vlc setTimeAsFloat: [o_timeslider floatValue]] ;
}
- (IBAction) speedslider_update:(id)slider { [o_pool release];
[o_vlc setSpeed: (intf_speed_t) [slider intValue]] ; }
}
- (IBAction) fullscreen_toggle:(id)sender { - (void)terminate
[self requestQDPortFullscreen:!b_window_is_fullscreen] ; {
} 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 */
//Callbacks - we are the delegate for the VlcWrapper - (IBAction)openFile:(id)sender
- (void) requestQDPortFullscreen:(bool)b_fullscreen { {
NSRect s_rect ; NSOpenPanel *o_panel = [NSOpenPanel openPanel];
VlcQuickDrawView *o_qdview ;
s_rect.origin.x = s_rect.origin.y = 0 ; [o_panel setAllowsMultipleSelection: YES];
[self releaseQDPort] ; if( [o_panel runModalForDirectory: NSHomeDirectory()
o_window = [NSWindow alloc] ; file: nil types: nil] == NSOKButton )
if (b_fullscreen) { {
[o_window NSString *o_file;
initWithContentRect: [[NSScreen mainScreen] frame] NSEnumerator *o_files = [[o_panel filenames] objectEnumerator];
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 { while( ( o_file = (NSString *)[o_files nextObject] ) )
[[NSNotificationCenter defaultCenter] {
removeObserver: nil [o_vlc playlistAdd: o_file];
name: nil
object: [o_window contentView]
] ;
[o_vlc setQDPort:nil] ;
if (o_window) {
[o_window close] ;
o_window = nil ;
}
} }
- (void) resizeQDPortFullscreen:(bool)b_fullscreen { [o_vlc playlistPlayCurrent];
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]] ;
}
} }
}
- (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
{
}
- (IBAction)quit:(id)sender
{
[o_vlc quit];
}
@end
@implementation Intf_Controller (Internal)
- (void)handlePortMessage:(NSPortMessage *)o_msg
{
[o_vlc handlePortMessage: o_msg];
}
@end @end
@implementation Intf_PlaylistDS @implementation Intf_PlaylistDS
- (void ) awakeFromNib {
o_vlc = [Intf_VlcWrapper instance] ;
o_playlist = nil ;
}
- (void) readPlaylist { - (void)awakeFromNib
o_playlist = [[o_vlc playlistAsArray] retain] ; {
} o_vlc = [Intf_VlcWrapper instance];
o_playlist = nil;
}
- (int) numberOfRowsInTableView:(NSTableView*)o_table { - (void)readPlaylist
[self readPlaylist] ; {
return [o_playlist count] ; o_playlist = [[o_vlc playlistAsArray] retain];
} }
- (id) tableView:(NSTableView*)o_table objectValueForTableColumn:(NSTableColumn*)o_column row:(int)i_row { - (int)numberOfRowsInTableView:(NSTableView*)o_table
return [o_playlist objectAtIndex:i_row] ; {
} [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] );
}
- (void)tableView:(NSTableView *)o_table setObjectValue:o_value forTableColumn:(NSTableColumn *)o_column row:(int)i_index
{
}
- (void)tableView:(NSTableView *)aTableView setObjectValue:anObject forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex {
}
@end @end
/***************************************************************************** /*****************************************************************************
* intf_controller.h : MacOS X plugin for vlc * intf_controller.h: MacOS X plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Florian G. Pflug <fgp@phlo.org>
* *
...@@ -21,54 +21,56 @@ ...@@ -21,54 +21,56 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/ *****************************************************************************/
#import <Cocoa/Cocoa.h> #include "intf_vlc_wrapper.h"
#import "intf_vlc_wrapper.h"
#import "intf_qdview.h"
@interface Intf_PlaylistDS : NSObject { @interface Intf_PlaylistDS : NSObject
Intf_VlcWrapper* o_vlc ; {
NSMutableArray* o_playlist ; Intf_VlcWrapper *o_vlc;
NSMutableArray *o_playlist;
IBOutlet NSTableView *o_table ; IBOutlet NSTableView *o_table;
} }
- (void ) awakeFromNib ; - (void)awakeFromNib;
- (void) readPlaylist ; - (void)readPlaylist;
- (int) numberOfRowsInTableView:(NSTableView*)o_table ; - (int)numberOfRowsInTableView:(NSTableView *)o_table;
- (id) tableView:(NSTableView*)o_table objectValueForTableColumn:(NSTableColumn*)o_column row:(int)i_row ; - (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 ; - (void)tableView:(NSTableView *)o_table setObjectValue:o_value forTableColumn:(NSTableColumn *)o_column row:(int)i_index;
@end
@interface Intf_Controller : NSObject <VlcWrapper_Delegate> { @end
Intf_VlcWrapper* o_vlc ;
NSWindow *o_window ; @interface Intf_Controller : NSObject
bool b_window_is_fullscreen ; {
Intf_VlcWrapper *o_vlc;
IBOutlet NSButton *o_play ; IBOutlet NSWindow *o_window;
IBOutlet NSButton *o_pause ; IBOutlet NSButton *o_play;
IBOutlet NSButton *o_stop ; IBOutlet NSButton *o_pause;
IBOutlet NSButton *o_stepr ; IBOutlet NSButton *o_stop;
IBOutlet NSButton *o_stepf ; IBOutlet NSButton *o_stepr;
IBOutlet NSSlider *o_timeslider ; IBOutlet NSButton *o_stepf;
IBOutlet NSTextField *o_currenttime ; IBOutlet NSSlider *o_timeslider;
IBOutlet NSMenuItem *o_menu_fullscreen ; IBOutlet NSTextField *o_currenttime;
IBOutlet NSMenuItem *o_menu_fs;
IBOutlet Intf_PlaylistDS *o_playlistds ; IBOutlet Intf_PlaylistDS *o_playlistds;
} }
//Initialization & Event-Management /* Initialization & Event-Management */
- (void) awakeFromNib ; - (void)awakeFromNib;
- (void) manage:(NSTimer *)timer ; - (void)applicationDidFinishLaunching:(NSNotification *)o_notification;
- (void)applicationDidBecomeActive:(NSNotification*)aNotification ; - (void)manage;
- (void)applicationDidResignActive:(NSNotification*)aNotification ; - (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 @end
/***************************************************************************** /*****************************************************************************
* intf_main.c: MacOS X interface plugin * intf_macosx.c: MacOS X interface plugin
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Colin Delacroix <colin@zoy.org>
* 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 * 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 * it under the terms of the GNU General Public License as published by
...@@ -30,10 +32,9 @@ ...@@ -30,10 +32,9 @@
#include <videolan/vlc.h> #include <videolan/vlc.h>
#include "macosx.h"
#include "interface.h" #include "interface.h"
#include "intf_main.h"
#include "macosx.h"
/***************************************************************************** /*****************************************************************************
* Local prototypes. * Local prototypes.
...@@ -62,12 +63,13 @@ static int intf_Open( intf_thread_t *p_intf ) ...@@ -62,12 +63,13 @@ static int intf_Open( intf_thread_t *p_intf )
if( p_intf->p_sys == NULL ) if( p_intf->p_sys == NULL )
{ {
return( 1 ); 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]; [[NSApplication sharedApplication] autorelease];
[NSBundle loadNibNamed:@"MainMenu" owner:NSApp]; [NSBundle loadNibNamed: @"MainMenu" owner: NSApp];
return( 0 ); return( 0 );
} }
...@@ -77,9 +79,12 @@ static int intf_Open( intf_thread_t *p_intf ) ...@@ -77,9 +79,12 @@ static int intf_Open( intf_thread_t *p_intf )
*****************************************************************************/ *****************************************************************************/
static void intf_Close( intf_thread_t *p_intf ) static void intf_Close( intf_thread_t *p_intf )
{ {
/* Destroy structure */ /* write cached user defaults to disk */
[NSApp terminate:NSApp] ; [[NSUserDefaults standardUserDefaults] synchronize];
[p_intf->p_sys->o_pool release] ;
[p_intf->p_sys->o_port release];
[p_intf->p_sys->o_pool release];
free( p_intf->p_sys ); free( p_intf->p_sys );
} }
...@@ -88,5 +93,5 @@ static void intf_Close( intf_thread_t *p_intf ) ...@@ -88,5 +93,5 @@ static void intf_Close( intf_thread_t *p_intf )
*****************************************************************************/ *****************************************************************************/
static void intf_Run( intf_thread_t *p_intf ) static void intf_Run( intf_thread_t *p_intf )
{ {
[NSApp run] ; [NSApp run];
} }
//
// 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
//
// 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 * 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> * 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 * 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 * it under the terms of the GNU General Public License as published by
...@@ -27,236 +28,379 @@ ...@@ -27,236 +28,379 @@
#include <videolan/vlc.h> #include <videolan/vlc.h>
#include "macosx.h"
#include "interface.h" #include "interface.h"
#include "intf_playlist.h" #include "intf_playlist.h"
#include "intf_main.h"
#include "video.h" #include "video.h"
#include "video_output.h" #include "video_output.h"
#include "stream_control.h" #include "stream_control.h"
#include "input_ext-intf.h" #include "input_ext-intf.h"
#import "intf_vlc_wrapper.h" #include "macosx.h"
#include "intf_vlc_wrapper.h"
#define p_area p_input_bank->pp_input[0]->stream.p_selected_area
@implementation Intf_VlcWrapper @implementation Intf_VlcWrapper
//Initialization,.....
+ (Intf_VlcWrapper*) instance { /* Initialization */
+ (Intf_VlcWrapper *)instance
{
static bool b_initialized = 0; static bool b_initialized = 0;
static Intf_VlcWrapper* o_vlc = nil ; static Intf_VlcWrapper* o_vlc = nil;
if (!b_initialized) { if( !b_initialized )
o_vlc = [[Intf_VlcWrapper alloc] init] ; {
b_initialized = TRUE ; o_vlc = [[Intf_VlcWrapper alloc] init];
b_initialized = TRUE;
} }
return o_vlc ; return o_vlc;
} }
- (Intf_VlcWrapper*) initWithDelegate:(id)_o_delegate { - (Intf_VlcWrapper *)initWithDelegate:(id)_o_delegate
e_speed = SPEED_NORMAL ; {
o_delegate = _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 );
}
- (bool) manage { return( 0 );
vout_thread_t *p_vout ; }
bool b_resize=FALSE, b_request=FALSE, b_release=FALSE;
bool b_fullscreen=FALSE ;
printf("start managing\n"); - (void)quit
p_main->p_intf->pf_manage( p_main->p_intf ) ; {
p_main->p_intf->b_die = 1;
}
if ((p_vout = p_main->p_intf->p_sys->osx_communication.p_vout)) { /* Vout requests */
printf("doing stuff with vout\n"); - (void)handlePortMessage:(NSPortMessage *)o_msg
i_width = p_vout->output.i_width ; {
i_height = p_vout->output.i_height ; NSData *o_req;
b_fullscreen = !!p_vout->b_fullscreen ; struct vout_req_s *p_req;
//Also mange the notifications for the output. o_req = [[o_msg components] lastObject];
if (p_vout->i_changes & (VOUT_SIZE_CHANGE | VOUT_FULLSCREEN_CHANGE)) b_resize = TRUE ; p_req = *((struct vout_req_s **)[o_req bytes]);
p_vout->i_changes &= ~(VOUT_SIZE_CHANGE | VOUT_FULLSCREEN_CHANGE) ;
}
if (b_resize) [o_delegate resizeQDPortFullscreen:b_fullscreen] ; [p_req->o_lock lock];
printf(" testing...\n"); if( p_req->i_type == VOUT_REQ_CREATE_WINDOW )
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..." ); VLCView *o_view;
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) ;
if (b_release) [o_delegate releaseQDPort] ; p_req->p_vout->p_sys->o_window = [VLCWindow alloc];
if (b_request) [o_delegate requestQDPortFullscreen:b_fullscreen] ; [p_req->p_vout->p_sys->o_window setVout: p_req->p_vout];
[p_req->p_vout->p_sys->o_window setReleasedWhenClosed: YES];
printf("end managing\n\n"); if( p_req->p_vout->b_fullscreen )
return p_main->p_intf->b_die ; {
[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()];
} }
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];
[o_view lockFocus];
p_req->p_vout->p_sys->p_qdport = [o_view qdPort];
[o_view unlockFocus];
//Function for the GUI. [p_req->p_vout->p_sys->o_window setTitle: [NSString
- (void) setQDPort:(CGrafPtr)p_qdport { stringWithCString: VOUT_TITLE]];
[p_req->p_vout->p_sys->o_window setAcceptsMouseMovedEvents: YES];
[p_req->p_vout->p_sys->o_window makeKeyAndOrderFront: nil];
printf("setQDPort !!\n"); p_req->i_result = 1;
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 ;
} }
else if( p_req->i_type == VOUT_REQ_DESTROY_WINDOW )
{
if( !p_req->p_vout->b_fullscreen )
{
NSRect s_rect;
- (void) sizeChangeQDPort { s_rect = [[p_req->p_vout->p_sys->o_window contentView] frame];
p_req->p_vout->p_sys->s_rect.size = s_rect.size;
printf("sizeChangeQDPort !!\n"); s_rect = [p_req->p_vout->p_sys->o_window frame];
p_main->p_intf->p_sys->osx_communication.i_changes |= OSX_INTF_VOUT_SIZE_CHANGE ; p_req->p_vout->p_sys->s_rect.origin = s_rect.origin;
}
- (NSSize) videoSize { p_req->p_vout->p_sys->b_pos_saved = 1;
return NSMakeSize(i_width, i_height) ;
} }
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;
p_req->i_result = 1;
}
[p_req->o_lock unlockWithCondition: 1];
}
- (NSPort *)sendPort
{
return( p_main->p_intf->p_sys->o_port );
}
//Playback control /* Playback control */
- (void) setSpeed:(intf_speed_t) _e_speed { - (void)setSpeed:(intf_speed_t)_e_speed
e_speed = _e_speed ; {
[self playlistPlayCurrent] ; e_speed = _e_speed;
} [self playlistPlayCurrent];
}
- (NSString *) getTimeAsString { #define p_area p_input_bank->pp_input[0]->stream.p_selected_area
static char psz_currenttime[ OFFSETTOTIME_MAX_SIZE ] ;
if (!p_input_bank->pp_input[0]) return [NSString stringWithCString:"00:00:00"] ; - (NSString *)getTimeAsString
{
static char psz_currenttime[ OFFSETTOTIME_MAX_SIZE ];
input_OffsetToTime( p_input_bank->pp_input[0], psz_currenttime, p_area->i_tell ) ; if( p_input_bank->pp_input[0] == NULL )
return [NSString stringWithCString:psz_currenttime] ; {
return [NSString stringWithCString:"00:00:00"];
} }
- (float) getTimeAsFloat { input_OffsetToTime( p_input_bank->pp_input[0],
if (!p_input_bank->pp_input[0]) return 0.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 );
} }
- (void) setTimeAsFloat:(float) f_position { return( (float)p_area->i_tell / (float)p_area->i_size );
if (!p_input_bank->pp_input[0]) return ; }
- (void)setTimeAsFloat:(float)f_position
{
vlc_mutex_lock( &p_input_bank->lock );
input_Seek(p_input_bank->pp_input[0], p_area->i_size * f_position) ; if( p_input_bank->pp_input[0] != NULL )
{
input_Seek( p_input_bank->pp_input[0], p_area->i_size * f_position );
} }
vlc_mutex_unlock( &p_input_bank->lock );
}
#undef p_area
/* Playlist control */
//Playlist control - (NSArray *)playlistAsArray
- (NSArray*) playlistAsArray { {
NSMutableArray* p_list = [NSMutableArray arrayWithCapacity:p_main->p_playlist->i_size] ; int i;
int i ; NSMutableArray* p_list =
[NSMutableArray arrayWithCapacity: p_main->p_playlist->i_size];
vlc_mutex_lock(&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++)
[p_list addObject:[NSString stringWithCString:p_main->p_playlist->p_item[i].psz_name]] ;
vlc_mutex_unlock(&p_main->p_playlist->change_lock) ;
return [NSArray arrayWithArray:p_list] ; 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]];
} }
- (int) playlistLength { vlc_mutex_unlock( &p_main->p_playlist->change_lock );
return p_main->p_playlist->i_size ;
} return( [NSArray arrayWithArray: p_list] );
}
- (NSString*) playlistItem:(int) i_pos { - (int)playlistLength
NSString* o_item = nil ; {
return( p_main->p_playlist->i_size );
}
vlc_mutex_lock(&p_main->p_playlist->change_lock) ; - (NSString*)playlistItem:(int)i_pos
if (i_pos < p_main->p_playlist->i_size) {
o_item = [NSString stringWithCString:p_main->p_playlist->p_item[i_pos].psz_name] ; NSString *o_item = nil;
vlc_mutex_unlock(&p_main->p_playlist->change_lock) ;
return o_item ; 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];
} }
- (bool) playlistPlayCurrent { vlc_mutex_unlock( &p_main->p_playlist->change_lock );
if (p_input_bank->pp_input[0]) {
return( o_item );
}
- (bool)playlistPlayCurrent
{
if( p_input_bank->pp_input[0] != NULL )
{
switch (e_speed) switch (e_speed)
{ {
case SPEED_SLOW: case SPEED_SLOW:
input_SetStatus(p_input_bank->pp_input[0], INPUT_STATUS_SLOWER) ; input_SetStatus( p_input_bank->pp_input[0],
break ; INPUT_STATUS_SLOWER );
break;
case SPEED_NORMAL: case SPEED_NORMAL:
input_SetStatus(p_input_bank->pp_input[0], INPUT_STATUS_PLAY) ; input_SetStatus( p_input_bank->pp_input[0],
break ; INPUT_STATUS_PLAY );
break;
case SPEED_FAST: case SPEED_FAST:
input_SetStatus(p_input_bank->pp_input[0], INPUT_STATUS_FASTER) ; input_SetStatus( p_input_bank->pp_input[0],
break ; INPUT_STATUS_FASTER );
break;
} }
p_main->p_playlist->b_stopped = 0 ;
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 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 else
return FALSE ; {
return FALSE;
} }
return TRUE ;
} }
- (void) playlistPause { return TRUE;
if (p_input_bank->pp_input[0]) }
input_SetStatus(p_input_bank->pp_input[0], INPUT_STATUS_PAUSE) ;
}
- (void) playlistStop { - (void)playlistPause
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) ; if ( p_input_bank->pp_input[0] != NULL )
p_main->p_playlist->i_index-- ; {
p_main->p_playlist->b_stopped = 1 ; input_SetStatus( p_input_bank->pp_input[0], INPUT_STATUS_PAUSE );
vlc_mutex_unlock(&p_main->p_playlist->change_lock) ;
}
- (void) playlistPlayNext { vlc_mutex_lock( &p_main->p_playlist->change_lock );
[self playlistStop] ; p_main->p_playlist->b_stopped = 0;
vlc_mutex_lock(&p_main->p_playlist->change_lock) ; vlc_mutex_unlock( &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 { - (void)playlistStop
[self playlistStop] ; {
vlc_mutex_lock(&p_main->p_playlist->change_lock) ; if( p_input_bank->pp_input[0] != NULL )
p_main->p_playlist->i_index-- ; {
vlc_mutex_unlock(&p_main->p_playlist->change_lock) ; /* end playing item */
[self playlistPlayCurrent] ; p_input_bank->pp_input[0]->b_eof = 1;
}
/* update playlist */
vlc_mutex_lock( &p_main->p_playlist->change_lock );
- (void) playlistPlayItem:(int)i_item { p_main->p_playlist->i_index--;
[self playlistStop] ; p_main->p_playlist->b_stopped = 1;
vlc_mutex_lock(&p_main->p_playlist->change_lock) ;
if (i_item < p_main->p_playlist->i_size) vlc_mutex_unlock( &p_main->p_playlist->change_lock );
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 );
- (void) playlistAdd:(NSString*)o_filename { if( i_item<p_main->p_playlist->i_size )
intf_PlaylistAdd(p_main->p_playlist, PLAYLIST_END, [o_filename lossyCString]) ; {
p_main->p_playlist->i_index--;
} }
- (void) clearPlaylist { vlc_mutex_unlock( &p_main->p_playlist->change_lock );
int i ;
[self playlistPlayCurrent];
}
- (void)playlistAdd:(NSString *)o_filename
{
intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END,
[o_filename lossyCString] );
}
- (void)clearPlaylist
{
int i;
vlc_mutex_lock( &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++ )
for(i=0; i < p_main->p_playlist->i_size; i++) {
intf_PlaylistDelete(p_main->p_playlist, i) ; intf_PlaylistDelete( p_main->p_playlist, i );
vlc_mutex_unlock(&p_main->p_playlist->change_lock) ;
} }
vlc_mutex_unlock( &p_main->p_playlist->change_lock );
}
- (bool)playlistPlaying
{
return( p_main->p_playlist->b_stopped );
}
@end @end
/***************************************************************************** /*****************************************************************************
* intf_vlc_wrapper.h : MacOS X plugin for vlc * intf_vlc_wrapper.h: MacOS X plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * 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 * 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 * it under the terms of the GNU General Public License as published by
...@@ -21,52 +22,51 @@ ...@@ -21,52 +22,51 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. * 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;
typedef enum intf_speed_e {SPEED_SLOW=0, SPEED_NORMAL, SPEED_FAST} intf_speed_t ; /* Intf_VlcWrapper is a singleton class
@protocol VlcWrapper_Delegate (only one instance at any time) */
- (void) requestQDPortFullscreen:(bool)b_fullscreen ;
- (void) releaseQDPort ;
- (void) resizeQDPortFullscreen:(bool)b_fullscreen ;
@end
// 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,.... /* Initialization */
+ (Intf_VlcWrapper*) instance ; + (Intf_VlcWrapper *)instance;
- (Intf_VlcWrapper*) initWithDelegate:(id)o_delegate ; - (Intf_VlcWrapper *)initWithDelegate:(id)o_delegate;
- (bool) manage ; - (bool)manage;
- (void)quit;
//Function for the GUI. /* Vout requests */
- (void) setQDPort:(CGrafPtr)p_qdport ; - (void)handlePortMessage:(NSPortMessage *)o_msg;
- (void) sizeChangeQDPort ; - (NSPort *)sendPort;
- (NSSize) videoSize ;
// Playback control /* Playback control */
- (void) setSpeed:(intf_speed_t)e_speed ; - (void)setSpeed:(intf_speed_t)e_speed;
- (NSString*) getTimeAsString ; - (NSString *)getTimeAsString;
- (float) getTimeAsFloat ; - (float)getTimeAsFloat;
- (void) setTimeAsFloat:(float)i_offset ; - (void)setTimeAsFloat:(float)i_offset;
// Playlist control /* Playlist control */
- (NSArray*) playlistAsArray ; - (NSArray *)playlistAsArray;
- (int) playlistLength ; - (int)playlistLength;
- (NSString*) playlistItem:(int) i_pos ; - (NSString *)playlistItem:(int)i_pos;
- (bool) playlistPlayCurrent ; - (bool)playlistPlayCurrent;
- (void) playlistPause ; - (void)playlistPause;
- (void) playlistStop ; - (void)playlistStop;
- (void) playlistPlayNext ; - (void)playlistPlayNext;
- (void) playlistPlayPrev ; - (void)playlistPlayPrev;
- (void) playlistPlayItem:(int)i_item ; - (void)playlistPlayItem:(int)i_item;
- (void) playlistAdd:(NSString*)o_filename ; - (void)playlistAdd:(NSString *)o_filename;
- (void) clearPlaylist ; - (void)clearPlaylist;
@end - (bool)playlistPlaying;
@end
/***************************************************************************** /*****************************************************************************
* macosx.c : MacOS X plugin for vlc * macosx.c: MacOS X plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Colin Delacroix <colin@zoy.org>
* Eugenio Jarosiewicz <ej0@cise.ufl.edu> * 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 * 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 * 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 * 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 * 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 * it under the terms of the GNU General Public License as published by
...@@ -21,27 +24,55 @@ ...@@ -21,27 +24,55 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. * 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> typedef struct intf_sys_s
{
#define OSX_INTF_VOUT_QDPORT_CHANGE 0x0001 NSPort *o_port;
#define OSX_INTF_VOUT_SIZE_CHANGE 0x0002 NSAutoreleasePool *o_pool;
#define OSX_VOUT_INTF_REQUEST_QDPORT 0x0004 } intf_sys_t;
#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 ;
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;
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* *
* Authors: Colin Delacroix <colin@zoy.org> * Authors: Colin Delacroix <colin@zoy.org>
* 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 * 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 * it under the terms of the GNU General Public License as published by
...@@ -30,32 +31,14 @@ ...@@ -30,32 +31,14 @@
#include <videolan/vlc.h> #include <videolan/vlc.h>
#include "interface.h"
#include "video.h" #include "video.h"
#include "video_output.h" #include "video_output.h"
#define OSX_COM_STRUCT intf_sys_s #include "interface.h"
#define OSX_COM_TYPE intf_sys_t
#include "macosx.h"
#include <QuickTime/QuickTime.h>
/***************************************************************************** #include "macosx.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 ;
} vout_sys_t; #define QT_MAX_DIRECTBUFFERS 10
typedef struct picture_sys_s typedef struct picture_sys_s
{ {
...@@ -63,34 +46,31 @@ typedef struct picture_sys_s ...@@ -63,34 +46,31 @@ typedef struct picture_sys_s
unsigned int i_size; unsigned int i_size;
/* When using I420 output */ /* When using I420 output */
PlanarPixmapInfoYUV420 pixmap_i420 ; PlanarPixmapInfoYUV420 pixmap_i420;
} picture_sys_t; } picture_sys_t;
#define MAX_DIRECTBUFFERS 10
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
*****************************************************************************/ *****************************************************************************/
static int vout_Create ( vout_thread_t * ); static int vout_Create ( struct vout_thread_s * );
static int vout_Init ( vout_thread_t * ); static int vout_Init ( struct vout_thread_s * );
static void vout_End ( vout_thread_t * ); static void vout_End ( struct vout_thread_s * );
static void vout_Destroy ( vout_thread_t * ); static void vout_Destroy ( struct vout_thread_s * );
static int vout_Manage ( vout_thread_t * ); static int vout_Manage ( struct vout_thread_s * );
static void vout_Display ( vout_thread_t *, picture_t * ); static void vout_Render ( struct vout_thread_s *, struct picture_s * );
static void vout_Render ( vout_thread_t *, picture_t * ); static void vout_Display ( struct vout_thread_s *, struct picture_s * );
/* OS Specific */ static int CoSendRequest ( struct vout_thread_s *, long i_request );
static int CreateQTSequence ( vout_thread_t *p_vout ) ; static int CoCreateWindow ( struct vout_thread_s * );
static void DestroyQTSequence( vout_thread_t *p_vout ) ; static int CoDestroyWindow ( struct vout_thread_s * );
static int CoToggleFullscreen ( struct vout_thread_s * );
static int NewPicture ( vout_thread_t *, picture_t * );
static void FreePicture ( vout_thread_t *, picture_t * ); static void QTScaleMatrix ( struct vout_thread_s * );
static int QTCreateSequence ( struct vout_thread_s * );
static void fillout_ImageDescription(ImageDescriptionHandle h_descr, static void QTDestroySequence ( struct vout_thread_s * );
unsigned int i_with, unsigned int i_height, static int QTNewPicture ( struct vout_thread_s *, struct picture_s * );
unsigned int c_codec) ; static void QTFreePicture ( struct vout_thread_s *, struct picture_s * );
static void fillout_ScalingMatrix( vout_thread_t *p_vout ) ;
/***************************************************************************** /*****************************************************************************
* Functions exported as capabilities. They are declared as static so that * Functions exported as capabilities. They are declared as static so that
...@@ -114,17 +94,78 @@ void _M( vout_getfunctions )( function_list_t * p_function_list ) ...@@ -114,17 +94,78 @@ void _M( vout_getfunctions )( function_list_t * p_function_list )
*****************************************************************************/ *****************************************************************************/
static int vout_Create( vout_thread_t *p_vout ) 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 ) ); p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL ) 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 ); 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 ); return( 0 );
} }
...@@ -139,36 +180,29 @@ static int vout_Init( vout_thread_t *p_vout ) ...@@ -139,36 +180,29 @@ static int vout_Init( vout_thread_t *p_vout )
I_OUTPUTPICTURES = 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_width = p_vout->render.i_width;
p_vout->output.i_height = p_vout->render.i_height; p_vout->output.i_height = p_vout->render.i_height;
p_vout->output.i_aspect = p_vout->render.i_aspect; 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': intf_ErrMsg( "vout error: unable to create sequence" );
p_vout->output.i_chroma = FOURCC_YUY2; return( 1 );
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;
} }
/* Try to initialize up to MAX_DIRECTBUFFERS direct buffers */ /* Try to initialize up to QT_MAX_DIRECTBUFFERS direct buffers */
while( I_OUTPUTPICTURES < MAX_DIRECTBUFFERS ) while( I_OUTPUTPICTURES < QT_MAX_DIRECTBUFFERS )
{ {
p_pic = NULL; p_pic = NULL;
/* Find an empty picture slot */ /* 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 ) if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
{ {
...@@ -178,7 +212,7 @@ static int vout_Init( vout_thread_t *p_vout ) ...@@ -178,7 +212,7 @@ static int vout_Init( vout_thread_t *p_vout )
} }
/* Allocate the picture */ /* Allocate the picture */
if( p_pic == NULL || NewPicture( p_vout, p_pic ) ) if( p_pic == NULL || QTNewPicture( p_vout, p_pic ) )
{ {
break; break;
} }
...@@ -191,7 +225,7 @@ static int vout_Init( vout_thread_t *p_vout ) ...@@ -191,7 +225,7 @@ static int vout_Init( vout_thread_t *p_vout )
I_OUTPUTPICTURES++; I_OUTPUTPICTURES++;
} }
return 0 ; return( 0 );
} }
/***************************************************************************** /*****************************************************************************
...@@ -201,15 +235,13 @@ static void vout_End( vout_thread_t *p_vout ) ...@@ -201,15 +235,13 @@ static void vout_End( vout_thread_t *p_vout )
{ {
int i_index; int i_index;
DestroyQTSequence( p_vout ) ; QTDestroySequence( p_vout );
p_main->p_intf->p_sys->p_vout = NULL;
p_main->p_intf->p_sys->i_changes |= OSX_VOUT_INTF_RELEASE_QDPORT ;
/* Free the direct buffers we allocated */ /* Free the direct buffers we allocated */
for( i_index = I_OUTPUTPICTURES ; i_index ; ) for( i_index = I_OUTPUTPICTURES; i_index; )
{ {
i_index--; i_index--;
FreePicture( p_vout, PP_OUTPUTPICTURE[ i_index ] ); QTFreePicture( p_vout, PP_OUTPUTPICTURE[ i_index ] );
} }
} }
...@@ -218,8 +250,15 @@ static void vout_End( vout_thread_t *p_vout ) ...@@ -218,8 +250,15 @@ static void vout_End( vout_thread_t *p_vout )
*****************************************************************************/ *****************************************************************************/
static void vout_Destroy( vout_thread_t *p_vout ) static void vout_Destroy( vout_thread_t *p_vout )
{ {
free( p_vout->p_sys->p_matrix ) ; if( CoDestroyWindow( p_vout ) )
DisposeHandle( (Handle)p_vout->p_sys->h_img_descr ) ; {
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 ); free( p_vout->p_sys );
} }
...@@ -231,238 +270,326 @@ static void vout_Destroy( vout_thread_t *p_vout ) ...@@ -231,238 +270,326 @@ static void vout_Destroy( vout_thread_t *p_vout )
*****************************************************************************/ *****************************************************************************/
static int vout_Manage( vout_thread_t *p_vout ) static int vout_Manage( vout_thread_t *p_vout )
{ {
if( p_main->p_intf->p_sys->i_changes if( p_vout->i_changes & VOUT_SIZE_CHANGE )
& OSX_INTF_VOUT_QDPORT_CHANGE )
{ {
intf_ErrMsg( "vout error: this change is unhandled yet !" ); QTScaleMatrix( p_vout );
return 1; 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 ) ; return( 1 );
SetDSequenceMatrix( p_vout->p_sys->i_seq,
p_vout->p_sys->p_matrix ) ;
} }
p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
} }
/* Clear flags */ /* hide/show mouse cursor */
p_main->p_intf->p_sys->i_changes &= ~( if( p_vout->p_sys->b_mouse_moved ||
OSX_INTF_VOUT_QDPORT_CHANGE | p_vout->p_sys->i_time_mouse_last_moved )
OSX_INTF_VOUT_SIZE_CHANGE {
) ; 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 * vout_Display: displays previously rendered output
***************************************************************************** *****************************************************************************
* This function send the currently rendered image to image, waits until * This function sends the currently rendered image to the display.
* it is displayed and switch the two rendering buffers, preparing next frame.
*****************************************************************************/ *****************************************************************************/
void vout_Display( vout_thread_t *p_vout, picture_t *p_pic ) static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
{ {
CodecFlags out_flags ; OSErr err;
CodecFlags flags;
switch (p_vout->p_sys->c_codec) if( ( err = DecompressSequenceFrameS(
{
case 'yuv2':
case 'y420':
DecompressSequenceFrameS(
p_vout->p_sys->i_seq, p_vout->p_sys->i_seq,
p_pic->p_sys->p_info, p_pic->p_sys->p_info,
p_pic->p_sys->i_size, p_pic->p_sys->i_size,
codecFlagUseScreenBuffer, codecFlagUseScreenBuffer, &flags, nil ) != noErr ) )
&out_flags, {
nil intf_ErrMsg( "DecompressSequenceFrameS failed: %d", err );
) ;
break ;
default:
intf_WarnMsg( 1, "vout_macosx: vout_Display called, but no codec available" ) ;
break;
} }
} }
static int CreateQTSequence( vout_thread_t *p_vout ) /*****************************************************************************
* CoSendRequest: send request to interface thread
*****************************************************************************
* Returns 0 on success, 1 otherwise
*****************************************************************************/
static int CoSendRequest( vout_thread_t *p_vout, long i_request )
{ {
p_vout->p_sys->c_codec = 'NONE' ; NSArray *o_array;
p_main->p_intf->p_sys->i_changes |= OSX_VOUT_INTF_REQUEST_QDPORT ; 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];
while ( p_main->p_intf->p_sys->p_qdport == nil memset( &req, 0, sizeof(req) );
&& !p_vout->b_die ) req.i_type = i_request;
{ req.p_vout = p_vout;
printf("WAITING for QD port ...\n");
if( p_main->p_intf->p_sys->i_changes req.o_lock = [[NSConditionLock alloc] initWithCondition: 0];
& OSX_INTF_VOUT_QDPORT_CHANGE )
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];
[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 ) )
{ {
p_main->p_intf->p_sys->i_changes &= ~( OSX_INTF_VOUT_QDPORT_CHANGE ) ; intf_ErrMsg( "CoSendRequest (CREATE_WINDOW) failed" );
intf_ErrMsg( "got a QDPORT_CHANGE" ); return( 1 );
break;
} }
msleep( 300000 );
return( 0 );
}
/*****************************************************************************
* CoDestroyWindow: destroy window
*****************************************************************************
* Returns 0 on success, 1 otherwise
*****************************************************************************/
static int CoDestroyWindow( vout_thread_t *p_vout )
{
if( !p_vout->p_sys->b_mouse_pointer_visible )
{
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"); intf_ErrMsg( "CoSendRequest (DESTROY_WINDOW) failed" );
p_vout->p_sys->c_codec = 'NONE' ; return( 1 );
return 1 ;
} }
SetPort( p_main->p_intf->p_sys->p_qdport ) ; return( 0 );
fillout_ScalingMatrix( p_vout ) ; }
/*****************************************************************************
* CoToggleFullscreen: toggle fullscreen
*****************************************************************************
* Returns 0 on success, 1 otherwise
*****************************************************************************/
static int CoToggleFullscreen( vout_thread_t *p_vout )
{
QTDestroySequence( p_vout );
if( CoDestroyWindow( p_vout ) )
{
intf_ErrMsg( "vout error: unable to destroy window" );
return( 1 );
}
fillout_ImageDescription( p_vout->p_sys->h_img_descr, p_vout->b_fullscreen = !p_vout->b_fullscreen;
p_vout->output.i_width, p_vout->output.i_height,
'y420' ) ;
if( !DecompressSequenceBeginS( &p_vout->p_sys->i_seq, if( CoCreateWindow( p_vout ) )
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) )
{ {
printf("OK !!!\n"); intf_ErrMsg( "vout error: unable to create window" );
p_vout->p_sys->c_codec = 'y420' ; return( 1 );
return 0 ;
} }
#if 0 SetPort( p_vout->p_sys->p_qdport );
/* For yuv2 */ QTScaleMatrix( p_vout );
if( QTCreateSequence( p_vout ) )
{ {
p_vout->p_sys->c_codec = 'yuv2' ; intf_ErrMsg( "vout error: unable to create sequence" );
return( 1 );
} }
#endif
printf("FUXK..\n"); return( 0 );
p_vout->p_sys->c_codec = 'NONE' ;
return 1 ;
} }
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') Rect s_rect;
return ; Fixed factor_x;
Fixed factor_y;
CDSequenceEnd( p_vout->p_sys->i_seq ) ; GetPortBounds( p_vout->p_sys->p_qdport, &s_rect );
p_vout->p_sys->c_codec = 'NONE' ;
}
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 ) );
static void fillout_ImageDescription(ImageDescriptionHandle h_descr, unsigned int i_width, unsigned int i_height, unsigned int c_codec) 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 ; OSErr err;
ImageDescriptionPtr p_descr;
HLock((Handle)h_descr) ;
p_descr = *h_descr ; HLock( (Handle)p_vout->p_sys->h_img_descr );
p_descr->idSize = sizeof(ImageDescription) ; p_descr = *p_vout->p_sys->h_img_descr;
p_descr->cType = c_codec ;
p_descr->resvd1 = 0 ; //Reserved p_descr->idSize = sizeof(ImageDescription);
p_descr->resvd2 = 0 ; //Reserved p_descr->cType = p_vout->p_sys->i_codec;
p_descr->dataRefIndex = 0 ; //Reserved p_descr->version = 1;
p_descr->version = 1 ; // p_descr->revisionLevel = 0;
p_descr->revisionLevel = 0 ; p_descr->vendor = 'appl';
p_descr->vendor = 'appl' ; //How do we get a vendor id?? p_descr->width = p_vout->output.i_width;
p_descr->width = i_width ; p_descr->height = p_vout->output.i_height;
p_descr->height = i_height ; p_descr->hRes = Long2Fix(72);
p_descr->hRes = Long2Fix(72) ; p_descr->vRes = Long2Fix(72);
p_descr->vRes = Long2Fix(72) ; p_descr->spatialQuality = codecLosslessQuality;
p_descr->spatialQuality = codecLosslessQuality ; p_descr->frameCount = 1;
p_descr->frameCount = 1 ; p_descr->clutID = -1;
p_descr->clutID = -1 ; //We don't need a color table
p_descr->dataSize = p_vout->output.i_width *
switch (c_codec) p_vout->output.i_height * 3 / 2;
{ p_descr->depth = 12;
case 'yuv2':
p_descr->dataSize=i_width * i_height * 2 ; HUnlock( (Handle)p_vout->p_sys->h_img_descr );
p_descr->depth = 24 ;
break ; if( ( err = DecompressSequenceBeginS(
case 'y420': &p_vout->p_sys->i_seq,
p_descr->dataSize=i_width * i_height * 3 / 2 ; p_vout->p_sys->h_img_descr,
p_descr->depth = 12 ; NULL, 0,
break ; p_vout->p_sys->p_qdport,
} NULL, NULL,
p_vout->p_sys->p_matrix,
HUnlock((Handle)h_descr) ; 0, NULL,
codecFlagUseScreenBuffer,
codecLosslessQuality,
p_vout->p_sys->img_dc ) ) )
{
intf_ErrMsg( "DecompressSequenceBeginS failed: %d", err );
return( 1 );
}
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 ; CDSequenceEnd( p_vout->p_sys->i_seq );
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) ) ;
} }
/***************************************************************************** /*****************************************************************************
* 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 /* We know the chroma, allocate a buffer which will be used
* directly by the decoder */ * directly by the decoder */
p_pic->p_sys = malloc( sizeof( picture_sys_t ) ); p_pic->p_sys = malloc( sizeof( picture_sys_t ) );
if( p_pic->p_sys == NULL ) if( p_pic->p_sys == NULL )
{ {
return -1; return( -1 );
} }
switch( p_vout->output.i_chroma ) switch( p_vout->output.i_chroma )
{ {
case FOURCC_I420: case FOURCC_I420:
p_pic->p_sys->p_info = (void *)&p_pic->p_sys->pixmap_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->i_size = sizeof(PlanarPixmapInfoYUV420);
p_pic->Y_PIXELS = memalign( 16, p_vout->output.i_width /* Y buffer */
* p_vout->output.i_height * 3 / 2 ); p_pic->Y_PIXELS = memalign( 16, i_width * i_height * 3 / 2 );
p_pic->p[Y_PLANE].i_lines = p_vout->output.i_height; p_pic->p[Y_PLANE].i_lines = i_height;
p_pic->p[Y_PLANE].i_pitch = p_vout->output.i_width; p_pic->p[Y_PLANE].i_pitch = i_width;
p_pic->p[Y_PLANE].i_pixel_bytes = 1; p_pic->p[Y_PLANE].i_pixel_bytes = 1;
p_pic->p[Y_PLANE].b_margin = 0; p_pic->p[Y_PLANE].b_margin = 0;
p_pic->U_PIXELS = p_pic->Y_PIXELS + p_vout->output.i_width /* U buffer */
* p_vout->output.i_height; p_pic->U_PIXELS = p_pic->Y_PIXELS + i_height * i_width;
p_pic->p[U_PLANE].i_lines = p_vout->output.i_height / 2; p_pic->p[U_PLANE].i_lines = i_height / 2;
p_pic->p[U_PLANE].i_pitch = p_vout->output.i_width / 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].i_pixel_bytes = 1;
p_pic->p[U_PLANE].b_margin = 0; p_pic->p[U_PLANE].b_margin = 0;
p_pic->V_PIXELS = p_pic->U_PIXELS + p_vout->output.i_width /* V buffer */
* p_vout->output.i_height / 4; p_pic->V_PIXELS = p_pic->U_PIXELS + i_height * i_width / 4;
p_pic->p[V_PLANE].i_lines = p_vout->output.i_height / 2; p_pic->p[V_PLANE].i_lines = i_height / 2;
p_pic->p[V_PLANE].i_pitch = p_vout->output.i_width / 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].i_pixel_bytes = 1;
p_pic->p[V_PLANE].b_margin = 0; p_pic->p[V_PLANE].b_margin = 0;
/* We allocated 3 planes */
p_pic->i_planes = 3; p_pic->i_planes = 3;
#define P p_pic->p_sys->pixmap_i420 #define P p_pic->p_sys->pixmap_i420
...@@ -473,21 +600,13 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -473,21 +600,13 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
P.componentInfoCr.offset = (void *)p_pic->V_PIXELS P.componentInfoCr.offset = (void *)p_pic->V_PIXELS
- p_pic->p_sys->p_info; - p_pic->p_sys->p_info;
P.componentInfoY.rowBytes = p_vout->output.i_width ; P.componentInfoY.rowBytes = i_width;
P.componentInfoCb.rowBytes = p_vout->output.i_width / 2 ; P.componentInfoCb.rowBytes = i_width / 2;
P.componentInfoCr.rowBytes = p_vout->output.i_width / 2 ; P.componentInfoCr.rowBytes = i_width / 2;
#undef P #undef P
break; 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: default:
/* Unknown chroma, tell the guy to get lost */ /* Unknown chroma, tell the guy to get lost */
free( p_pic->p_sys ); free( p_pic->p_sys );
...@@ -495,29 +614,17 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -495,29 +614,17 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
p_vout->output.i_chroma, p_vout->output.i_chroma,
(char*)&p_vout->output.i_chroma ); (char*)&p_vout->output.i_chroma );
p_pic->i_planes = 0; p_pic->i_planes = 0;
return -1; 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 ); free( p_pic->p_sys );
} }
/*****************************************************************************
* 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 * 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> * Authors: 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 * 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 * it under the terms of the GNU General Public License as published by
...@@ -21,16 +22,11 @@ ...@@ -21,16 +22,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/ *****************************************************************************/
/* OS specific */ @interface VLCView : NSQuickDrawView
#import <Cocoa/Cocoa.h>
/*****************************************************************************
* intf_sys_t: description and status of the interface
*****************************************************************************/
typedef struct intf_sys_s
{ {
osx_com_t osx_communication ; struct vout_thread_s *p_vout;
}
NSAutoreleasePool *o_pool ; - (id)initWithVout:(struct vout_thread_s *)_p_vout;
} intf_sys_t;
@end
/*****************************************************************************
* 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
/*****************************************************************************
* 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment