Mercurial > mplayer.hg
annotate libvo/vo_quartz.c @ 24744:d81eef9beb1b
DirectShow based tv:// driver for win32
Teletext is also supported (but 625 system parameters are hardcoded).
pthreads is required for teletext.
Code is still experimental.
author | voroshil |
---|---|
date | Sat, 13 Oct 2007 17:14:39 +0000 |
parents | f3cb35ec74c3 |
children | 70b6cb8bbfd8 |
rev | line source |
---|---|
12296 | 1 /* |
2 vo_quartz.c | |
3 | |
13693
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
4 by Nicolas Plourde <nicolasplourde@gmail.com> |
12296 | 5 |
6 Copyright (c) Nicolas Plourde - April 2004 | |
12414 | 7 |
8 YUV support Copyright (C) 2004 Romain Dolbeau <romain@dolbeau.org> | |
12296 | 9 |
10 MPlayer Mac OSX Quartz video out module. | |
11 | |
13707
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
12 todo: -screen overlay output |
13818
9f707a805967
window now save is old position when going in fullscreen or while using resize preset
nplourde
parents:
13796
diff
changeset
|
13 -fit osd in black bar when available |
15702 | 14 -fix RGB32 |
12296 | 15 -(add sugestion here) |
12120 | 16 */ |
17 | |
18 //SYS | |
19 #include <stdio.h> | |
20 | |
21 //OSX | |
22 #include <Carbon/Carbon.h> | |
12414 | 23 #include <QuickTime/QuickTime.h> |
12120 | 24 |
25 //MPLAYER | |
26 #include "config.h" | |
12414 | 27 #include "fastmemcpy.h" |
12120 | 28 #include "video_out.h" |
29 #include "video_out_internal.h" | |
30 #include "aspect.h" | |
12414 | 31 #include "mp_msg.h" |
32 #include "m_option.h" | |
22823
98eaf29b5dee
Code cleanup: don't include a .c file in mplayer.c and fix a few
rathann
parents:
21396
diff
changeset
|
33 #include "mp_fifo.h" |
23676
f3cb35ec74c3
bugfix intel mac vo_quartz, PlanarPixmapInfoYUV420 structure requires big-endian value. author Taihei Monma tmkk@mac.com
nplourde
parents:
23457
diff
changeset
|
34 #include "mpbswap.h" |
12120 | 35 |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
13779
diff
changeset
|
36 #include "input/input.h" |
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
13779
diff
changeset
|
37 #include "input/mouse.h" |
12120 | 38 |
39 #include "vo_quartz.h" | |
40 | |
12296 | 41 static vo_info_t info = |
42 { | |
43 "Mac OSX (Quartz)", | |
44 "quartz", | |
12414 | 45 "Nicolas Plourde <nicolasplourde@hotmail.com>, Romain Dolbeau <romain@dolbeau.org>", |
12296 | 46 "" |
12120 | 47 }; |
48 | |
12296 | 49 LIBVO_EXTERN(quartz) |
12120 | 50 |
12414 | 51 static uint32_t image_depth; |
52 static uint32_t image_format; | |
53 static uint32_t image_size; | |
54 static uint32_t image_buffer_size; | |
12432 | 55 static char *image_data; |
12414 | 56 |
12432 | 57 static ImageSequence seqId; |
12414 | 58 static CodecType image_qtcodec; |
12487 | 59 static PlanarPixmapInfoYUV420 *P = NULL; |
12424 | 60 static struct |
61 { | |
62 ImageDescriptionHandle desc; | |
63 Handle extension_colr; | |
64 Handle extension_fiel; | |
65 Handle extension_clap; | |
66 Handle extension_pasp; | |
12414 | 67 } yuv_qt_stuff; |
12432 | 68 static MatrixRecord matrix; |
12414 | 69 static int EnterMoviesDone = 0; |
12487 | 70 static int get_image_done = 0; |
12120 | 71 |
12487 | 72 static int vo_quartz_fs; // we are in fullscreen |
13791 | 73 extern float monitor_aspect; |
13792
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
74 extern float movie_aspect; |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
75 static float old_movie_aspect; |
12120 | 76 |
12826
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
77 static int winLevel = 1; |
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
78 int levelList[] = |
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
79 { |
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
80 kCGDesktopWindowLevelKey, |
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
81 kCGNormalWindowLevelKey, |
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
82 kCGScreenSaverWindowLevelKey |
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
83 }; |
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
84 |
12487 | 85 static int int_pause = 0; |
86 static float winAlpha = 1; | |
15892 | 87 static int mouseHide = FALSE; |
12296 | 88 |
12487 | 89 static int device_width; |
90 static int device_height; | |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
91 static int device_id; |
12120 | 92 |
13788
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
93 static short fs_res_x=0; |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
94 static short fs_res_y=0; |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
95 |
12487 | 96 static WindowRef theWindow = NULL; |
12826
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
97 static WindowGroupRef winGroup = NULL; |
13124 | 98 static CGContextRef context; |
99 static CGRect bounds; | |
13840 | 100 static GDHandle deviceHdl; |
13124 | 101 |
102 static CGDataProviderRef dataProviderRef; | |
103 static CGImageRef image; | |
12296 | 104 |
12487 | 105 static Rect imgRect; // size of the original image (unscaled) |
106 static Rect dstRect; // size of the displayed image (after scaling) | |
107 static Rect winRect; // size of the window containg the displayed image (include padding) | |
108 static Rect oldWinRect; // size of the window containg the displayed image (include padding) when NOT in FS mode | |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
109 static Rect deviceRect; // size of the display device |
13840 | 110 static Rect oldWinBounds; |
12296 | 111 |
13792
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
112 static MenuRef windMenu; |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
113 static MenuRef movMenu; |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
114 static MenuRef aspectMenu; |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
115 |
13693
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
116 enum |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
117 { |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
118 kQuitCmd = 1, |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
119 kHalfScreenCmd = 2, |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
120 kNormalScreenCmd = 3, |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
121 kDoubleScreenCmd = 4, |
13792
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
122 kFullScreenCmd = 5, |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
123 kKeepAspectCmd = 6, |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
124 kAspectOrgCmd = 7, |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
125 kAspectFullCmd = 8, |
13795 | 126 kAspectWideCmd = 9, |
127 kPanScanCmd = 10 | |
13693
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
128 }; |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
129 |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
13779
diff
changeset
|
130 #include "osdep/keycodes.h" |
15702 | 131 |
12296 | 132 extern void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)); |
12120 | 133 |
134 //PROTOTYPE///////////////////////////////////////////////////////////////// | |
15702 | 135 static OSStatus KeyEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData); |
136 static OSStatus MouseEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData); | |
137 static OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData); | |
12296 | 138 void window_resized(); |
139 void window_ontop(); | |
140 void window_fullscreen(); | |
13840 | 141 void window_panscan(); |
12120 | 142 |
12886
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
143 static inline int convert_key(UInt32 key, UInt32 charcode) |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
144 { |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
145 switch(key) |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
146 { |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
147 case QZ_IBOOK_ENTER: |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
148 case QZ_RETURN: return KEY_ENTER; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
149 case QZ_ESCAPE: return KEY_ESC; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
150 case QZ_BACKSPACE: return KEY_BACKSPACE; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
151 case QZ_LALT: return KEY_BACKSPACE; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
152 case QZ_LCTRL: return KEY_BACKSPACE; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
153 case QZ_LSHIFT: return KEY_BACKSPACE; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
154 case QZ_F1: return KEY_F+1; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
155 case QZ_F2: return KEY_F+2; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
156 case QZ_F3: return KEY_F+3; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
157 case QZ_F4: return KEY_F+4; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
158 case QZ_F5: return KEY_F+5; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
159 case QZ_F6: return KEY_F+6; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
160 case QZ_F7: return KEY_F+7; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
161 case QZ_F8: return KEY_F+8; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
162 case QZ_F9: return KEY_F+9; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
163 case QZ_F10: return KEY_F+10; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
164 case QZ_F11: return KEY_F+11; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
165 case QZ_F12: return KEY_F+12; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
166 case QZ_INSERT: return KEY_INSERT; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
167 case QZ_DELETE: return KEY_DELETE; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
168 case QZ_HOME: return KEY_HOME; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
169 case QZ_END: return KEY_END; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
170 case QZ_KP_PLUS: return '+'; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
171 case QZ_KP_MINUS: return '-'; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
172 case QZ_TAB: return KEY_TAB; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
173 case QZ_PAGEUP: return KEY_PAGE_UP; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
174 case QZ_PAGEDOWN: return KEY_PAGE_DOWN; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
175 case QZ_UP: return KEY_UP; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
176 case QZ_DOWN: return KEY_DOWN; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
177 case QZ_LEFT: return KEY_LEFT; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
178 case QZ_RIGHT: return KEY_RIGHT; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
179 case QZ_KP_MULTIPLY: return '*'; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
180 case QZ_KP_DIVIDE: return '/'; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
181 case QZ_KP_ENTER: return KEY_BACKSPACE; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
182 case QZ_KP_PERIOD: return KEY_KPDEC; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
183 case QZ_KP0: return KEY_KP0; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
184 case QZ_KP1: return KEY_KP1; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
185 case QZ_KP2: return KEY_KP2; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
186 case QZ_KP3: return KEY_KP3; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
187 case QZ_KP4: return KEY_KP4; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
188 case QZ_KP5: return KEY_KP5; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
189 case QZ_KP6: return KEY_KP6; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
190 case QZ_KP7: return KEY_KP7; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
191 case QZ_KP8: return KEY_KP8; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
192 case QZ_KP9: return KEY_KP9; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
193 default: return charcode; |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
194 } |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
195 } |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
196 |
12296 | 197 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride) |
198 { | |
12424 | 199 switch (image_format) |
200 { | |
201 case IMGFMT_RGB32: | |
202 vo_draw_alpha_rgb32(w,h,src,srca,stride,image_data+4*(y0*imgRect.right+x0),4*imgRect.right); | |
203 break; | |
204 case IMGFMT_YV12: | |
205 case IMGFMT_IYUV: | |
206 case IMGFMT_I420: | |
23676
f3cb35ec74c3
bugfix intel mac vo_quartz, PlanarPixmapInfoYUV420 structure requires big-endian value. author Taihei Monma tmkk@mac.com
nplourde
parents:
23457
diff
changeset
|
207 vo_draw_alpha_yv12(w,h,src,srca,stride, ((char*)P) + be2me_32(P->componentInfoY.offset) + x0 + y0 * imgRect.right, imgRect.right); |
12424 | 208 break; |
209 case IMGFMT_UYVY: | |
12517 | 210 vo_draw_alpha_uyvy(w,h,src,srca,stride,((char*)P) + (x0 + y0 * imgRect.right) * 2,imgRect.right*2); |
12424 | 211 break; |
212 case IMGFMT_YUY2: | |
12487 | 213 vo_draw_alpha_yuy2(w,h,src,srca,stride,((char*)P) + (x0 + y0 * imgRect.right) * 2,imgRect.right*2); |
12424 | 214 break; |
12487 | 215 } |
12296 | 216 } |
12120 | 217 |
15702 | 218 //default keyboard event handler |
219 static OSStatus KeyEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData) | |
12120 | 220 { |
12624 | 221 OSStatus result = noErr; |
12460 | 222 UInt32 class = GetEventClass (event); |
223 UInt32 kind = GetEventKind (event); | |
12624 | 224 |
225 result = CallNextEventHandler(nextHandler, event); | |
13693
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
226 |
13712
f6ef5a0ad7e4
removed duplicate case and fixed aspect ratio for window zoom feature
nplourde
parents:
13707
diff
changeset
|
227 if(class == kEventClassKeyboard) |
12460 | 228 { |
229 char macCharCodes; | |
230 UInt32 macKeyCode; | |
231 UInt32 macKeyModifiers; | |
232 | |
233 GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(macCharCodes), NULL, &macCharCodes); | |
234 GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(macKeyCode), NULL, &macKeyCode); | |
235 GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(macKeyModifiers), NULL, &macKeyModifiers); | |
13693
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
236 |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
237 if(macKeyModifiers != 256) |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
238 { |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
239 if (kind == kEventRawKeyRepeat || kind == kEventRawKeyDown) |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
240 { |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
241 int key = convert_key(macKeyCode, macCharCodes); |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
242 if(key != -1) |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
243 mplayer_put_key(key); |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
244 } |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
245 } |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
246 else if(macKeyModifiers == 256) |
12296 | 247 { |
13693
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
248 switch(macCharCodes) |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
249 { |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
250 case '[': SetWindowAlpha(theWindow, winAlpha-=0.05); break; |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
251 case ']': SetWindowAlpha(theWindow, winAlpha+=0.05); break; |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
252 } |
12460 | 253 } |
12886
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
254 else |
9b95958f4eb0
listen for key repeats, patch by Dan Christiansen
nplourde
parents:
12830
diff
changeset
|
255 result = eventNotHandledErr; |
12460 | 256 } |
15702 | 257 |
258 return result; | |
259 } | |
260 | |
261 //default mouse event handler | |
262 static OSStatus MouseEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData) | |
263 { | |
264 OSStatus result = noErr; | |
265 UInt32 class = GetEventClass (event); | |
266 UInt32 kind = GetEventKind (event); | |
267 | |
268 result = CallNextEventHandler(nextHandler, event); | |
269 | |
270 if(class == kEventClassMouse) | |
12460 | 271 { |
272 WindowPtr tmpWin; | |
273 Point mousePos; | |
15702 | 274 Point winMousePos; |
12460 | 275 |
276 GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, 0, sizeof(Point), 0, &mousePos); | |
15702 | 277 GetEventParameter(event, kEventParamWindowMouseLocation, typeQDPoint, 0, sizeof(Point), 0, &winMousePos); |
12460 | 278 |
279 switch (kind) | |
280 { | |
15881 | 281 case kEventMouseMoved: |
282 { | |
283 if(vo_quartz_fs) | |
284 { | |
18057 | 285 CGDisplayShowCursor(kCGDirectMainDisplay); |
15881 | 286 mouseHide = FALSE; |
287 } | |
288 } | |
289 break; | |
290 | |
15702 | 291 case kEventMouseWheelMoved: |
292 { | |
293 int wheel; | |
294 short part; | |
295 | |
296 GetEventParameter(event, kEventParamMouseWheelDelta, typeSInt32, 0, sizeof(int), 0, &wheel); | |
297 | |
298 part = FindWindow(mousePos,&tmpWin); | |
299 | |
300 if(part == inContent) | |
301 { | |
302 if(wheel > 0) | |
303 mplayer_put_key(MOUSE_BTN3); | |
304 else | |
305 mplayer_put_key(MOUSE_BTN4); | |
306 } | |
307 } | |
308 break; | |
309 | |
12460 | 310 case kEventMouseDown: |
12296 | 311 { |
12460 | 312 EventMouseButton button; |
13719 | 313 short part; |
15702 | 314 Rect bounds; |
315 | |
316 GetWindowPortBounds(theWindow, &bounds); | |
12460 | 317 GetEventParameter(event, kEventParamMouseButton, typeMouseButton, 0, sizeof(EventMouseButton), 0, &button); |
318 | |
13719 | 319 part = FindWindow(mousePos,&tmpWin); |
12296 | 320 |
15702 | 321 if( (winMousePos.h > (bounds.right - 15)) && (winMousePos.v > (bounds.bottom)) ) |
322 { | |
15723 | 323 if(!vo_quartz_fs) |
324 { | |
325 GrowWindow(theWindow, mousePos, NULL); | |
326 } | |
15702 | 327 } |
328 else if(part == inMenuBar) | |
12296 | 329 { |
330 MenuSelect(mousePos); | |
12460 | 331 HiliteMenu(0); |
12296 | 332 } |
12460 | 333 else if(part == inContent) |
334 { | |
335 switch(button) | |
336 { | |
337 case 1: mplayer_put_key(MOUSE_BTN0);break; | |
338 case 2: mplayer_put_key(MOUSE_BTN2);break; | |
339 case 3: mplayer_put_key(MOUSE_BTN1);break; | |
340 | |
12624 | 341 default:result = eventNotHandledErr;break; |
12460 | 342 } |
343 } | |
344 } | |
345 break; | |
346 | |
15702 | 347 case kEventMouseUp: |
12460 | 348 break; |
349 | |
15702 | 350 case kEventMouseDragged: |
351 break; | |
352 | |
12624 | 353 default:result = eventNotHandledErr;break; |
12460 | 354 } |
355 } | |
15702 | 356 |
12624 | 357 return result; |
12296 | 358 } |
12120 | 359 |
15702 | 360 //default window event handler |
361 static OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData) | |
13707
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
362 { |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
363 OSStatus result = noErr; |
13722 | 364 uint32_t d_width; |
365 uint32_t d_height; | |
13707
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
366 UInt32 class = GetEventClass (event); |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
367 UInt32 kind = GetEventKind (event); |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
368 |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
369 result = CallNextEventHandler(nextHandler, event); |
13712
f6ef5a0ad7e4
removed duplicate case and fixed aspect ratio for window zoom feature
nplourde
parents:
13707
diff
changeset
|
370 |
f6ef5a0ad7e4
removed duplicate case and fixed aspect ratio for window zoom feature
nplourde
parents:
13707
diff
changeset
|
371 aspect(&d_width,&d_height,A_NOZOOM); |
13707
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
372 |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
373 if(class == kEventClassCommand) |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
374 { |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
375 HICommand theHICommand; |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
376 GetEventParameter( event, kEventParamDirectObject, typeHICommand, NULL, sizeof( HICommand ), NULL, &theHICommand ); |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
377 |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
378 switch ( theHICommand.commandID ) |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
379 { |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
380 case kHICommandQuit: |
16892
3470c810527b
libvo input cleanup: remove the dependency on libinput,
albeu
parents:
16280
diff
changeset
|
381 mplayer_put_key(KEY_CLOSE_WIN); |
13707
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
382 break; |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
383 |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
384 case kHalfScreenCmd: |
13734 | 385 if(vo_quartz_fs) |
386 { | |
387 vo_fs = (!(vo_fs)); window_fullscreen(); | |
388 } | |
389 | |
15702 | 390 SizeWindow(theWindow, (d_width/2), ((d_width/movie_aspect)/2), 1); |
13707
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
391 window_resized(); |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
392 break; |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
393 |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
394 case kNormalScreenCmd: |
13734 | 395 if(vo_quartz_fs) |
396 { | |
397 vo_fs = (!(vo_fs)); window_fullscreen(); | |
398 } | |
399 | |
15702 | 400 SizeWindow(theWindow, d_width, (d_width/movie_aspect), 1); |
13707
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
401 window_resized(); |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
402 break; |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
403 |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
404 case kDoubleScreenCmd: |
13734 | 405 if(vo_quartz_fs) |
406 { | |
407 vo_fs = (!(vo_fs)); window_fullscreen(); | |
408 } | |
409 | |
15702 | 410 SizeWindow(theWindow, (d_width*2), ((d_width/movie_aspect)*2), 1); |
13707
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
411 window_resized(); |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
412 break; |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
413 |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
414 case kFullScreenCmd: |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
415 vo_fs = (!(vo_fs)); window_fullscreen(); |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
416 break; |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
417 |
13792
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
418 case kKeepAspectCmd: |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
419 vo_keepaspect = (!(vo_keepaspect)); |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
420 CheckMenuItem (aspectMenu, 1, vo_keepaspect); |
15909 | 421 window_resized(); |
13792
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
422 break; |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
423 |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
424 case kAspectOrgCmd: |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
425 movie_aspect = old_movie_aspect; |
15902
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15892
diff
changeset
|
426 if(!vo_quartz_fs) |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15892
diff
changeset
|
427 { |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15892
diff
changeset
|
428 SizeWindow(theWindow, dstRect.right, (dstRect.right/movie_aspect),1); |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15892
diff
changeset
|
429 } |
13792
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
430 window_resized(); |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
431 break; |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
432 |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
433 case kAspectFullCmd: |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
434 movie_aspect = 4.0f/3.0f; |
15892 | 435 if(!vo_quartz_fs) |
436 { | |
437 SizeWindow(theWindow, dstRect.right, (dstRect.right/movie_aspect),1); | |
438 } | |
13792
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
439 window_resized(); |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
440 break; |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
441 |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
442 case kAspectWideCmd: |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
443 movie_aspect = 16.0f/9.0f; |
15892 | 444 if(!vo_quartz_fs) |
445 { | |
446 SizeWindow(theWindow, dstRect.right, (dstRect.right/movie_aspect),1); | |
447 } | |
13792
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
448 window_resized(); |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
449 break; |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
450 |
13795 | 451 case kPanScanCmd: |
13840 | 452 vo_panscan = (!(vo_panscan)); |
453 CheckMenuItem (aspectMenu, 2, vo_panscan); | |
15902
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15892
diff
changeset
|
454 window_panscan(); |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15892
diff
changeset
|
455 window_resized(); |
13795 | 456 break; |
457 | |
13707
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
458 default: |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
459 result = eventNotHandledErr; |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
460 break; |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
461 } |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
462 } |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
463 else if(class == kEventClassWindow) |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
464 { |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
465 WindowRef window; |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
466 Rect rectPort = {0,0,0,0}; |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
467 |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
468 GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window); |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
469 |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
470 if(window) |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
471 { |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
472 GetPortBounds(GetWindowPort(window), &rectPort); |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
473 } |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
474 |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
475 switch (kind) |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
476 { |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
477 case kEventWindowClosed: |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
478 theWindow = NULL; |
16892
3470c810527b
libvo input cleanup: remove the dependency on libinput,
albeu
parents:
16280
diff
changeset
|
479 mplayer_put_key(KEY_CLOSE_WIN); |
13707
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
480 break; |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
481 |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
482 //resize window |
15702 | 483 case kEventWindowZoomed: |
13707
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
484 case kEventWindowBoundsChanged: |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
485 window_resized(); |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
486 flip_page(); |
15885
b2f434649dec
properly redraw fullscreen window with -fs and zoom
nplourde
parents:
15881
diff
changeset
|
487 window_resized(); |
13707
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
488 break; |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
489 |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
490 default: |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
491 result = eventNotHandledErr; |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
492 break; |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
493 } |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
494 } |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
495 |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
496 return result; |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
497 } |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
498 |
12487 | 499 static void quartz_CreateWindow(uint32_t d_width, uint32_t d_height, WindowAttributes windowAttrs) |
500 { | |
501 CFStringRef titleKey; | |
502 CFStringRef windowTitle; | |
503 OSStatus result; | |
13792
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
504 |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
505 MenuItemIndex index; |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
506 CFStringRef movMenuTitle; |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
507 CFStringRef aspMenuTitle; |
12487 | 508 |
509 SetRect(&winRect, 0, 0, d_width, d_height); | |
510 SetRect(&oldWinRect, 0, 0, d_width, d_height); | |
511 SetRect(&dstRect, 0, 0, d_width, d_height); | |
13693
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
512 |
14081 | 513 //Clear Menu Bar |
514 ClearMenuBar(); | |
515 | |
13792
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
516 //Create Window Menu |
13693
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
517 CreateStandardWindowMenu(0, &windMenu); |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
518 InsertMenu(windMenu, 0); |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
519 |
13792
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
520 //Create Movie Menu |
13693
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
521 CreateNewMenu (1004, 0, &movMenu); |
13792
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
522 movMenuTitle = CFSTR("Movie"); |
13693
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
523 SetMenuTitleWithCFString(movMenu, movMenuTitle); |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
524 |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
525 AppendMenuItemTextWithCFString(movMenu, CFSTR("Half Size"), 0, kHalfScreenCmd, &index); |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
526 SetMenuItemCommandKey(movMenu, index, 0, '0'); |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
527 |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
528 AppendMenuItemTextWithCFString(movMenu, CFSTR("Normal Size"), 0, kNormalScreenCmd, &index); |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
529 SetMenuItemCommandKey(movMenu, index, 0, '1'); |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
530 |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
531 AppendMenuItemTextWithCFString(movMenu, CFSTR("Double Size"), 0, kDoubleScreenCmd, &index); |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
532 SetMenuItemCommandKey(movMenu, index, 0, '2'); |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
533 |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
534 AppendMenuItemTextWithCFString(movMenu, CFSTR("Full Size"), 0, kFullScreenCmd, &index); |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
535 SetMenuItemCommandKey(movMenu, index, 0, 'F'); |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
536 |
13792
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
537 AppendMenuItemTextWithCFString(movMenu, NULL, kMenuItemAttrSeparator, NULL, &index); |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
538 |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
539 AppendMenuItemTextWithCFString(movMenu, CFSTR("Aspect Ratio"), 0, NULL, &index); |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
540 |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
541 ////Create Aspect Ratio Sub Menu |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
542 CreateNewMenu (0, 0, &aspectMenu); |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
543 aspMenuTitle = CFSTR("Aspect Ratio"); |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
544 SetMenuTitleWithCFString(aspectMenu, aspMenuTitle); |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
545 SetMenuItemHierarchicalMenu(movMenu, 6, aspectMenu); |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
546 |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
547 AppendMenuItemTextWithCFString(aspectMenu, CFSTR("Keep"), 0, kKeepAspectCmd, &index); |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
548 CheckMenuItem (aspectMenu, 1, vo_keepaspect); |
13795 | 549 AppendMenuItemTextWithCFString(aspectMenu, CFSTR("Pan-Scan"), 0, kPanScanCmd, &index); |
13840 | 550 CheckMenuItem (aspectMenu, 2, vo_panscan); |
13792
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
551 AppendMenuItemTextWithCFString(aspectMenu, NULL, kMenuItemAttrSeparator, NULL, &index); |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
552 AppendMenuItemTextWithCFString(aspectMenu, CFSTR("Original"), 0, kAspectOrgCmd, &index); |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
553 AppendMenuItemTextWithCFString(aspectMenu, CFSTR("4:3"), 0, kAspectFullCmd, &index); |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
554 AppendMenuItemTextWithCFString(aspectMenu, CFSTR("16:9"), 0, kAspectWideCmd, &index); |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
555 |
13693
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
556 InsertMenu(movMenu, GetMenuID(windMenu)); //insert before Window menu |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
557 |
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
558 DrawMenuBar(); |
12487 | 559 |
13693
abba514689a1
fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents:
13124
diff
changeset
|
560 //create window |
12487 | 561 CreateNewWindow(kDocumentWindowClass, windowAttrs, &winRect, &theWindow); |
12826
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
562 |
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
563 CreateWindowGroup(0, &winGroup); |
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
564 SetWindowGroup(theWindow, winGroup); |
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
565 |
12487 | 566 //Set window title |
12785
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
567 titleKey = CFSTR("MPlayer - The Movie Player"); |
12487 | 568 windowTitle = CFCopyLocalizedString(titleKey, NULL); |
569 result = SetWindowTitleWithCFString(theWindow, windowTitle); | |
570 CFRelease(titleKey); | |
571 CFRelease(windowTitle); | |
572 | |
573 //Install event handler | |
15702 | 574 const EventTypeSpec win_events[] = { |
13707
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
575 { kEventClassWindow, kEventWindowClosed }, |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
576 { kEventClassWindow, kEventWindowBoundsChanged }, |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
577 { kEventClassCommand, kEventCommandProcess } |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
578 }; |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
579 |
15702 | 580 const EventTypeSpec key_events[] = { |
13707
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
581 { kEventClassKeyboard, kEventRawKeyDown }, |
15702 | 582 { kEventClassKeyboard, kEventRawKeyRepeat } |
13707
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
583 }; |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
584 |
15702 | 585 const EventTypeSpec mouse_events[] = { |
15881 | 586 { kEventClassMouse, kEventMouseMoved }, |
15702 | 587 { kEventClassMouse, kEventMouseWheelMoved }, |
588 { kEventClassMouse, kEventMouseDown }, | |
589 { kEventClassMouse, kEventMouseUp }, | |
590 { kEventClassMouse, kEventMouseDragged } | |
591 }; | |
592 | |
593 InstallApplicationEventHandler (NewEventHandlerUPP (KeyEventHandler), GetEventTypeCount(key_events), key_events, NULL, NULL); | |
594 InstallApplicationEventHandler (NewEventHandlerUPP (MouseEventHandler), GetEventTypeCount(mouse_events), mouse_events, NULL, NULL); | |
595 InstallWindowEventHandler (theWindow, NewEventHandlerUPP (WindowEventHandler), GetEventTypeCount(win_events), win_events, theWindow, NULL); | |
12487 | 596 } |
597 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15909
diff
changeset
|
598 static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) |
12296 | 599 { |
600 WindowAttributes windowAttrs; | |
12414 | 601 OSErr qterr; |
13719 | 602 int i; |
15702 | 603 CGRect tmpBounds; |
13719 | 604 |
12296 | 605 //Get Main device info/////////////////////////////////////////////////// |
13719 | 606 |
607 | |
12296 | 608 deviceHdl = GetMainDevice(); |
609 | |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
610 for(i=0; i<device_id; i++) |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
611 { |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
612 deviceHdl = GetNextDevice(deviceHdl); |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
613 |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
614 if(deviceHdl == NULL) |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
615 { |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
616 mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: Device ID %d do not exist, falling back to main device.\n", device_id); |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
617 deviceHdl = GetMainDevice(); |
14699
779230cb313d
set device id to 0 if the device selected on startup do not exist
nplourde
parents:
14082
diff
changeset
|
618 device_id = 0; |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
619 break; |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
620 } |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
621 } |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
622 |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
623 deviceRect = (*deviceHdl)->gdRect; |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
624 device_width = deviceRect.right-deviceRect.left; |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
625 device_height = deviceRect.bottom-deviceRect.top; |
12296 | 626 |
13791 | 627 monitor_aspect = (float)device_width/(float)device_height; |
628 | |
12296 | 629 //misc mplayer setup///////////////////////////////////////////////////// |
12487 | 630 SetRect(&imgRect, 0, 0, width, height); |
12414 | 631 switch (image_format) |
632 { | |
633 case IMGFMT_RGB32: | |
12432 | 634 image_depth = 32; |
12414 | 635 break; |
636 case IMGFMT_YV12: | |
637 case IMGFMT_IYUV: | |
638 case IMGFMT_I420: | |
639 case IMGFMT_UYVY: | |
640 case IMGFMT_YUY2: | |
641 image_depth = 16; | |
642 break; | |
643 } | |
12487 | 644 image_size = ((imgRect.right*imgRect.bottom*image_depth)+7)/8; |
12296 | 645 |
646 vo_fs = flags & VOFLAG_FULLSCREEN; | |
647 | |
648 //get movie aspect | |
13795 | 649 panscan_init(); |
12296 | 650 aspect_save_orig(width,height); |
651 aspect_save_prescale(d_width,d_height); | |
652 aspect_save_screenres(device_width, device_height); | |
13792
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
653 |
12296 | 654 aspect(&d_width,&d_height,A_NOZOOM); |
13124 | 655 |
13793 | 656 movie_aspect = (float)d_width/(float)d_height; |
657 old_movie_aspect = movie_aspect; | |
658 | |
13124 | 659 if(image_data) |
660 free(image_data); | |
661 | |
662 image_data = malloc(image_size); | |
12296 | 663 |
664 //Create player window////////////////////////////////////////////////// | |
665 windowAttrs = kWindowStandardDocumentAttributes | |
666 | kWindowStandardHandlerAttribute | |
667 | kWindowLiveResizeAttribute; | |
12425 | 668 |
15702 | 669 windowAttrs &= (~kWindowResizableAttribute); |
670 | |
12487 | 671 if (theWindow == NULL) |
672 { | |
15702 | 673 quartz_CreateWindow(d_width, d_height, windowAttrs); |
12487 | 674 |
675 if (theWindow == NULL) | |
676 { | |
677 mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: Couldn't create window !!!!!\n"); | |
678 return -1; | |
679 } | |
15702 | 680 tmpBounds = CGRectMake( 0, 0, winRect.right, winRect.bottom); |
681 CreateCGContextForPort(GetWindowPort(theWindow),&context); | |
682 CGContextFillRect(context, tmpBounds); | |
12487 | 683 } |
684 else | |
685 { | |
686 HideWindow(theWindow); | |
687 ChangeWindowAttributes(theWindow, ~windowAttrs, windowAttrs); | |
688 SetRect(&winRect, 0, 0, d_width, d_height); | |
689 SetRect(&oldWinRect, 0, 0, d_width, d_height); | |
690 SizeWindow (theWindow, d_width, d_height, 1); | |
691 } | |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
692 |
12432 | 693 switch (image_format) |
694 { | |
13124 | 695 case IMGFMT_RGB32: |
696 { | |
697 CreateCGContextForPort (GetWindowPort (theWindow), &context); | |
698 | |
699 dataProviderRef = CGDataProviderCreateWithData (0, image_data, imgRect.right * imgRect.bottom * 4, 0); | |
700 | |
701 image = CGImageCreate (imgRect.right, | |
702 imgRect.bottom, | |
703 8, | |
704 image_depth, | |
705 ((imgRect.right*32)+7)/8, | |
706 CGColorSpaceCreateDeviceRGB(), | |
707 kCGImageAlphaNoneSkipFirst, | |
708 dataProviderRef, 0, 1, kCGRenderingIntentDefault); | |
709 break; | |
710 } | |
711 | |
12432 | 712 case IMGFMT_YV12: |
713 case IMGFMT_IYUV: | |
714 case IMGFMT_I420: | |
715 case IMGFMT_UYVY: | |
716 case IMGFMT_YUY2: | |
12424 | 717 { |
12623 | 718 get_image_done = 0; |
719 | |
720 if (!EnterMoviesDone) | |
721 { | |
722 qterr = EnterMovies(); | |
723 EnterMoviesDone = 1; | |
724 } | |
725 else | |
726 qterr = 0; | |
727 | |
728 if (qterr) | |
729 { | |
730 mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: EnterMovies (%d)\n", qterr); | |
731 return -1; | |
732 } | |
733 | |
734 | |
735 SetIdentityMatrix(&matrix); | |
736 | |
737 if ((d_width != width) || (d_height != height)) | |
738 { | |
739 ScaleMatrix(&matrix, FixDiv(Long2Fix(d_width),Long2Fix(width)), FixDiv(Long2Fix(d_height),Long2Fix(height)), 0, 0); | |
740 } | |
741 | |
12432 | 742 yuv_qt_stuff.desc = (ImageDescriptionHandle)NewHandleClear( sizeof(ImageDescription) ); |
12424 | 743 |
12432 | 744 yuv_qt_stuff.extension_colr = NewHandleClear(sizeof(NCLCColorInfoImageDescriptionExtension)); |
745 ((NCLCColorInfoImageDescriptionExtension*)(*yuv_qt_stuff.extension_colr))->colorParamType = kVideoColorInfoImageDescriptionExtensionType; | |
746 ((NCLCColorInfoImageDescriptionExtension*)(*yuv_qt_stuff.extension_colr))->primaries = 2; | |
747 ((NCLCColorInfoImageDescriptionExtension*)(*yuv_qt_stuff.extension_colr))->transferFunction = 2; | |
748 ((NCLCColorInfoImageDescriptionExtension*)(*yuv_qt_stuff.extension_colr))->matrix = 2; | |
749 | |
750 yuv_qt_stuff.extension_fiel = NewHandleClear(sizeof(FieldInfoImageDescriptionExtension)); | |
751 ((FieldInfoImageDescriptionExtension*)(*yuv_qt_stuff.extension_fiel))->fieldCount = 1; | |
752 ((FieldInfoImageDescriptionExtension*)(*yuv_qt_stuff.extension_fiel))->fieldOrderings = 0; | |
12424 | 753 |
12432 | 754 yuv_qt_stuff.extension_clap = NewHandleClear(sizeof(CleanApertureImageDescriptionExtension)); |
12487 | 755 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->cleanApertureWidthN = imgRect.right; |
12432 | 756 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->cleanApertureWidthD = 1; |
12487 | 757 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->cleanApertureHeightN = imgRect.bottom; |
12432 | 758 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->cleanApertureHeightD = 1; |
759 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->horizOffN = 0; | |
760 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->horizOffD = 1; | |
761 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->vertOffN = 0; | |
762 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->vertOffD = 1; | |
763 | |
764 yuv_qt_stuff.extension_pasp = NewHandleClear(sizeof(PixelAspectRatioImageDescriptionExtension)); | |
765 ((PixelAspectRatioImageDescriptionExtension*)(*yuv_qt_stuff.extension_pasp))->hSpacing = 1; | |
766 ((PixelAspectRatioImageDescriptionExtension*)(*yuv_qt_stuff.extension_pasp))->vSpacing = 1; | |
767 | |
768 (*yuv_qt_stuff.desc)->idSize = sizeof(ImageDescription); | |
769 (*yuv_qt_stuff.desc)->cType = image_qtcodec; | |
770 (*yuv_qt_stuff.desc)->version = 2; | |
771 (*yuv_qt_stuff.desc)->revisionLevel = 0; | |
772 (*yuv_qt_stuff.desc)->vendor = 'mpla'; | |
12487 | 773 (*yuv_qt_stuff.desc)->width = imgRect.right; |
774 (*yuv_qt_stuff.desc)->height = imgRect.bottom; | |
12432 | 775 (*yuv_qt_stuff.desc)->hRes = Long2Fix(72); |
776 (*yuv_qt_stuff.desc)->vRes = Long2Fix(72); | |
777 (*yuv_qt_stuff.desc)->temporalQuality = 0; | |
778 (*yuv_qt_stuff.desc)->spatialQuality = codecLosslessQuality; | |
779 (*yuv_qt_stuff.desc)->frameCount = 1; | |
780 (*yuv_qt_stuff.desc)->dataSize = 0; | |
781 (*yuv_qt_stuff.desc)->depth = 24; | |
782 (*yuv_qt_stuff.desc)->clutID = -1; | |
12424 | 783 |
12432 | 784 qterr = AddImageDescriptionExtension(yuv_qt_stuff.desc, yuv_qt_stuff.extension_colr, kColorInfoImageDescriptionExtension); |
785 if (qterr) | |
786 { | |
12487 | 787 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: AddImageDescriptionExtension [colr] (%d)\n", qterr); |
12432 | 788 } |
789 | |
790 qterr = AddImageDescriptionExtension(yuv_qt_stuff.desc, yuv_qt_stuff.extension_fiel, kFieldInfoImageDescriptionExtension); | |
791 if (qterr) | |
792 { | |
12487 | 793 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: AddImageDescriptionExtension [fiel] (%d)\n", qterr); |
12432 | 794 } |
795 | |
796 qterr = AddImageDescriptionExtension(yuv_qt_stuff.desc, yuv_qt_stuff.extension_clap, kCleanApertureImageDescriptionExtension); | |
797 if (qterr) | |
798 { | |
12487 | 799 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: AddImageDescriptionExtension [clap] (%d)\n", qterr); |
12432 | 800 } |
801 | |
802 qterr = AddImageDescriptionExtension(yuv_qt_stuff.desc, yuv_qt_stuff.extension_pasp, kCleanApertureImageDescriptionExtension); | |
803 if (qterr) | |
804 { | |
12487 | 805 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: AddImageDescriptionExtension [pasp] (%d)\n", qterr); |
12432 | 806 } |
12487 | 807 if (P != NULL) { // second or subsequent movie |
808 free(P); | |
809 } | |
12432 | 810 P = calloc(sizeof(PlanarPixmapInfoYUV420) + image_size, 1); |
811 switch (image_format) | |
812 { | |
813 case IMGFMT_YV12: | |
814 case IMGFMT_IYUV: | |
815 case IMGFMT_I420: | |
23676
f3cb35ec74c3
bugfix intel mac vo_quartz, PlanarPixmapInfoYUV420 structure requires big-endian value. author Taihei Monma tmkk@mac.com
nplourde
parents:
23457
diff
changeset
|
816 P->componentInfoY.offset = be2me_32(sizeof(PlanarPixmapInfoYUV420)); |
f3cb35ec74c3
bugfix intel mac vo_quartz, PlanarPixmapInfoYUV420 structure requires big-endian value. author Taihei Monma tmkk@mac.com
nplourde
parents:
23457
diff
changeset
|
817 P->componentInfoCb.offset = be2me_32(be2me_32(P->componentInfoY.offset) + image_size / 2); |
f3cb35ec74c3
bugfix intel mac vo_quartz, PlanarPixmapInfoYUV420 structure requires big-endian value. author Taihei Monma tmkk@mac.com
nplourde
parents:
23457
diff
changeset
|
818 P->componentInfoCr.offset = be2me_32(be2me_32(P->componentInfoCb.offset) + image_size / 4); |
f3cb35ec74c3
bugfix intel mac vo_quartz, PlanarPixmapInfoYUV420 structure requires big-endian value. author Taihei Monma tmkk@mac.com
nplourde
parents:
23457
diff
changeset
|
819 P->componentInfoY.rowBytes = be2me_32(imgRect.right); |
f3cb35ec74c3
bugfix intel mac vo_quartz, PlanarPixmapInfoYUV420 structure requires big-endian value. author Taihei Monma tmkk@mac.com
nplourde
parents:
23457
diff
changeset
|
820 P->componentInfoCb.rowBytes = be2me_32(imgRect.right / 2); |
f3cb35ec74c3
bugfix intel mac vo_quartz, PlanarPixmapInfoYUV420 structure requires big-endian value. author Taihei Monma tmkk@mac.com
nplourde
parents:
23457
diff
changeset
|
821 P->componentInfoCr.rowBytes = be2me_32(imgRect.right / 2); |
12432 | 822 image_buffer_size = image_size + sizeof(PlanarPixmapInfoYUV420); |
823 break; | |
824 case IMGFMT_UYVY: | |
825 case IMGFMT_YUY2: | |
826 image_buffer_size = image_size; | |
827 break; | |
828 } | |
12414 | 829 |
12432 | 830 qterr = DecompressSequenceBeginS(&seqId, |
12414 | 831 yuv_qt_stuff.desc, |
12432 | 832 (char *)P, |
12414 | 833 image_buffer_size, |
12623 | 834 GetWindowPort(theWindow), |
12432 | 835 NULL, |
836 NULL, | |
12414 | 837 ((d_width != width) || (d_height != height)) ? |
12432 | 838 &matrix : NULL, |
12414 | 839 srcCopy, |
12432 | 840 NULL, |
841 0, | |
12414 | 842 codecLosslessQuality, |
843 bestSpeedCodec); | |
12432 | 844 |
845 if (qterr) | |
846 { | |
847 mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: DecompressSequenceBeginS (%d)\n", qterr); | |
12487 | 848 return -1; |
12432 | 849 } |
12424 | 850 } |
12432 | 851 break; |
12414 | 852 } |
12296 | 853 |
15885
b2f434649dec
properly redraw fullscreen window with -fs and zoom
nplourde
parents:
15881
diff
changeset
|
854 //Show window |
b2f434649dec
properly redraw fullscreen window with -fs and zoom
nplourde
parents:
15881
diff
changeset
|
855 RepositionWindow(theWindow, NULL, kWindowCenterOnMainScreen); |
b2f434649dec
properly redraw fullscreen window with -fs and zoom
nplourde
parents:
15881
diff
changeset
|
856 ShowWindow (theWindow); |
b2f434649dec
properly redraw fullscreen window with -fs and zoom
nplourde
parents:
15881
diff
changeset
|
857 |
12296 | 858 if(vo_fs) |
859 window_fullscreen(); | |
860 | |
861 if(vo_ontop) | |
862 window_ontop(); | |
12888 | 863 |
12912
1f6bb2356d18
add var vo_rootwin and -rootwin switch for mac osx
nplourde
parents:
12889
diff
changeset
|
864 if(vo_rootwin) |
12888 | 865 { |
866 vo_fs = TRUE; | |
867 winLevel = 0; | |
868 SetWindowGroupLevel(winGroup, CGWindowLevelForKey(levelList[winLevel])); | |
869 window_fullscreen(); | |
870 } | |
12296 | 871 |
15885
b2f434649dec
properly redraw fullscreen window with -fs and zoom
nplourde
parents:
15881
diff
changeset
|
872 window_resized(); |
15702 | 873 |
12296 | 874 return 0; |
12120 | 875 } |
876 | |
12296 | 877 static void check_events(void) |
12120 | 878 { |
12296 | 879 EventRef theEvent; |
880 EventTargetRef theTarget; | |
881 OSStatus theErr; | |
882 | |
883 //Get event | |
884 theTarget = GetEventDispatcherTarget(); | |
885 theErr = ReceiveNextEvent(0, 0, kEventDurationNoWait,true, &theEvent); | |
886 if(theErr == noErr && theEvent != NULL) | |
887 { | |
888 SendEventToEventTarget (theEvent, theTarget); | |
889 ReleaseEvent(theEvent); | |
890 } | |
891 } | |
12120 | 892 |
12296 | 893 static void draw_osd(void) |
894 { | |
12487 | 895 vo_draw_text(imgRect.right,imgRect.bottom,draw_alpha); |
12296 | 896 } |
12120 | 897 |
12296 | 898 static void flip_page(void) |
899 { | |
21396 | 900 int curTime; |
901 static int lastTime; | |
902 | |
13707
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
903 if(theWindow == NULL) |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
904 return; |
3fff37ed4fe7
Fixed event handling for menubar and window close button.
nplourde
parents:
13693
diff
changeset
|
905 |
12432 | 906 switch (image_format) |
907 { | |
13124 | 908 case IMGFMT_RGB32: |
909 { | |
910 CGContextDrawImage (context, bounds, image); | |
911 } | |
912 break; | |
913 | |
12433 | 914 case IMGFMT_YV12: |
915 case IMGFMT_IYUV: | |
916 case IMGFMT_I420: | |
917 case IMGFMT_UYVY: | |
918 case IMGFMT_YUY2: | |
919 if (EnterMoviesDone) | |
920 { | |
921 OSErr qterr; | |
922 CodecFlags flags = 0; | |
923 qterr = DecompressSequenceFrameWhen(seqId, | |
924 (char *)P, | |
925 image_buffer_size, | |
926 0, //codecFlagUseImageBuffer, | |
927 &flags, | |
928 NULL, | |
929 NULL); | |
930 if (qterr) | |
931 { | |
12487 | 932 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: DecompressSequenceFrameWhen in flip_page (%d) flags:0x%08x\n", qterr, flags); |
12433 | 933 } |
934 } | |
935 break; | |
936 } | |
15723 | 937 |
938 if(!vo_quartz_fs) | |
939 { | |
940 //render resize box | |
941 CGContextBeginPath(context); | |
942 CGContextSetAllowsAntialiasing(context, false); | |
943 //CGContextSaveGState(context); | |
944 | |
945 //line white | |
946 CGContextSetRGBStrokeColor (context, 0.2, 0.2, 0.2, 0.5); | |
947 CGContextMoveToPoint( context, winRect.right-1, 1); CGContextAddLineToPoint( context, winRect.right-1, 1); | |
948 CGContextMoveToPoint( context, winRect.right-1, 5); CGContextAddLineToPoint( context, winRect.right-5, 1); | |
949 CGContextMoveToPoint( context, winRect.right-1, 9); CGContextAddLineToPoint( context, winRect.right-9, 1); | |
950 CGContextStrokePath( context ); | |
951 | |
952 //line gray | |
953 CGContextSetRGBStrokeColor (context, 0.4, 0.4, 0.4, 0.5); | |
954 CGContextMoveToPoint( context, winRect.right-1, 2); CGContextAddLineToPoint( context, winRect.right-2, 1); | |
955 CGContextMoveToPoint( context, winRect.right-1, 6); CGContextAddLineToPoint( context, winRect.right-6, 1); | |
956 CGContextMoveToPoint( context, winRect.right-1, 10); CGContextAddLineToPoint( context, winRect.right-10, 1); | |
957 CGContextStrokePath( context ); | |
958 | |
959 //line black | |
960 CGContextSetRGBStrokeColor (context, 0.6, 0.6, 0.6, 0.5); | |
961 CGContextMoveToPoint( context, winRect.right-1, 3); CGContextAddLineToPoint( context, winRect.right-3, 1); | |
962 CGContextMoveToPoint( context, winRect.right-1, 7); CGContextAddLineToPoint( context, winRect.right-7, 1); | |
963 CGContextMoveToPoint( context, winRect.right-1, 11); CGContextAddLineToPoint( context, winRect.right-11, 1); | |
964 CGContextStrokePath( context ); | |
965 | |
966 //CGContextRestoreGState( context ); | |
967 CGContextFlush (context); | |
968 } | |
15881 | 969 |
970 //auto hide mouse cursor and futur on-screen control? | |
971 if(vo_quartz_fs && !mouseHide) | |
972 { | |
18057 | 973 int curTime = TickCount()/60; |
974 static int lastTime = 0; | |
15881 | 975 |
976 if( ((curTime - lastTime) >= 5) || (lastTime == 0) ) | |
977 { | |
18057 | 978 CGDisplayHideCursor(kCGDirectMainDisplay); |
15881 | 979 mouseHide = TRUE; |
980 lastTime = curTime; | |
981 } | |
982 } | |
17546 | 983 |
984 //update activity every 30 seconds to prevent | |
985 //screensaver from starting up. | |
21396 | 986 curTime = TickCount()/60; |
987 lastTime = 0; | |
18057 | 988 |
989 if( ((curTime/ - lastTime) >= 5) || (lastTime == 0) ) | |
17546 | 990 { |
991 UpdateSystemActivity(UsrActivity); | |
992 lastTime = curTime; | |
993 } | |
12296 | 994 } |
995 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15909
diff
changeset
|
996 static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) |
12296 | 997 { |
12433 | 998 switch (image_format) |
999 { | |
12487 | 1000 case IMGFMT_YV12: |
1001 case IMGFMT_I420: | |
23676
f3cb35ec74c3
bugfix intel mac vo_quartz, PlanarPixmapInfoYUV420 structure requires big-endian value. author Taihei Monma tmkk@mac.com
nplourde
parents:
23457
diff
changeset
|
1002 memcpy_pic(((char*)P) + be2me_32(P->componentInfoY.offset) + x + imgRect.right * y, src[0], w, h, imgRect.right, stride[0]); |
12487 | 1003 x=x/2;y=y/2;w=w/2;h=h/2; |
1004 | |
23676
f3cb35ec74c3
bugfix intel mac vo_quartz, PlanarPixmapInfoYUV420 structure requires big-endian value. author Taihei Monma tmkk@mac.com
nplourde
parents:
23457
diff
changeset
|
1005 memcpy_pic(((char*)P) + be2me_32(P->componentInfoCb.offset) + x + imgRect.right / 2 * y, src[1], w, h, imgRect.right / 2, stride[1]); |
f3cb35ec74c3
bugfix intel mac vo_quartz, PlanarPixmapInfoYUV420 structure requires big-endian value. author Taihei Monma tmkk@mac.com
nplourde
parents:
23457
diff
changeset
|
1006 memcpy_pic(((char*)P) + be2me_32(P->componentInfoCr.offset) + x + imgRect.right / 2 * y, src[2], w, h, imgRect.right / 2, stride[2]); |
12487 | 1007 return 0; |
1008 | |
1009 case IMGFMT_IYUV: | |
23676
f3cb35ec74c3
bugfix intel mac vo_quartz, PlanarPixmapInfoYUV420 structure requires big-endian value. author Taihei Monma tmkk@mac.com
nplourde
parents:
23457
diff
changeset
|
1010 memcpy_pic(((char*)P) + be2me_32(P->componentInfoY.offset) + x + imgRect.right * y, src[0], w, h, imgRect.right, stride[0]); |
12487 | 1011 x=x/2;y=y/2;w=w/2;h=h/2; |
1012 | |
23676
f3cb35ec74c3
bugfix intel mac vo_quartz, PlanarPixmapInfoYUV420 structure requires big-endian value. author Taihei Monma tmkk@mac.com
nplourde
parents:
23457
diff
changeset
|
1013 memcpy_pic(((char*)P) + be2me_32(P->componentInfoCr.offset) + x + imgRect.right / 2 * y, src[1], w, h, imgRect.right / 2, stride[1]); |
f3cb35ec74c3
bugfix intel mac vo_quartz, PlanarPixmapInfoYUV420 structure requires big-endian value. author Taihei Monma tmkk@mac.com
nplourde
parents:
23457
diff
changeset
|
1014 memcpy_pic(((char*)P) + be2me_32(P->componentInfoCb.offset) + x + imgRect.right / 2 * y, src[2], w, h, imgRect.right / 2, stride[2]); |
12487 | 1015 return 0; |
12433 | 1016 } |
12296 | 1017 return -1; |
1018 } | |
1019 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15909
diff
changeset
|
1020 static int draw_frame(uint8_t *src[]) |
12296 | 1021 { |
12433 | 1022 switch (image_format) |
1023 { | |
13124 | 1024 case IMGFMT_RGB32: |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
23381
diff
changeset
|
1025 fast_memcpy(image_data,src[0],image_size); |
13124 | 1026 return 0; |
1027 | |
12433 | 1028 case IMGFMT_UYVY: |
1029 case IMGFMT_YUY2: | |
12487 | 1030 memcpy_pic(((char*)P), src[0], imgRect.right * 2, imgRect.bottom, imgRect.right * 2, imgRect.right * 2); |
12433 | 1031 return 0; |
1032 } | |
1033 return -1; | |
12296 | 1034 } |
12120 | 1035 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15909
diff
changeset
|
1036 static int query_format(uint32_t format) |
12296 | 1037 { |
1038 image_format = format; | |
12432 | 1039 image_qtcodec = 0; |
13124 | 1040 |
1041 if (format == IMGFMT_RGB32) | |
1042 { | |
1043 return VFCAP_CSP_SUPPORTED | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; | |
1044 } | |
12432 | 1045 |
12424 | 1046 if ((format == IMGFMT_YV12) || (format == IMGFMT_IYUV) || (format == IMGFMT_I420)) |
1047 { | |
1048 image_qtcodec = kMpegYUV420CodecType; //kYUV420CodecType ?; | |
12487 | 1049 return VFCAP_CSP_SUPPORTED | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_ACCEPT_STRIDE; |
12414 | 1050 } |
1051 | |
12424 | 1052 if (format == IMGFMT_YUY2) |
1053 { | |
1054 image_qtcodec = kComponentVideoUnsigned; | |
12487 | 1055 return VFCAP_CSP_SUPPORTED | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; |
12414 | 1056 } |
1057 | |
12424 | 1058 if (format == IMGFMT_UYVY) |
1059 { | |
1060 image_qtcodec = k422YpCbCr8CodecType; | |
12487 | 1061 return VFCAP_CSP_SUPPORTED | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; |
12424 | 1062 } |
12414 | 1063 |
12296 | 1064 return 0; |
1065 } | |
12120 | 1066 |
12296 | 1067 static void uninit(void) |
1068 { | |
12432 | 1069 OSErr qterr; |
13124 | 1070 |
1071 switch (image_format) | |
12432 | 1072 { |
13124 | 1073 case IMGFMT_YV12: |
1074 case IMGFMT_IYUV: | |
1075 case IMGFMT_I420: | |
1076 case IMGFMT_UYVY: | |
1077 case IMGFMT_YUY2: | |
12432 | 1078 { |
13124 | 1079 if (EnterMoviesDone) |
1080 { | |
1081 qterr = CDSequenceEnd(seqId); | |
1082 if (qterr) | |
1083 { | |
1084 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: CDSequenceEnd (%d)\n", qterr); | |
1085 } | |
1086 } | |
1087 break; | |
12424 | 1088 } |
13124 | 1089 default: |
1090 break; | |
12414 | 1091 } |
12432 | 1092 |
12296 | 1093 ShowMenuBar(); |
1094 } | |
12120 | 1095 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15909
diff
changeset
|
1096 static int preinit(const char *arg) |
12296 | 1097 { |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
1098 int parse_err = 0; |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
1099 |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
1100 if(arg) |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
1101 { |
12623 | 1102 char *parse_pos = (char *)&arg[0]; |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
1103 while (parse_pos[0] && !parse_err) |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
1104 { |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
1105 if (strncmp (parse_pos, "device_id=", 10) == 0) |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
1106 { |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
1107 parse_pos = &parse_pos[10]; |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
1108 device_id = strtol(parse_pos, &parse_pos, 0); |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
1109 } |
13788
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1110 if (strncmp (parse_pos, "fs_res=", 7) == 0) |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1111 { |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1112 parse_pos = &parse_pos[7]; |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1113 fs_res_x = strtol(parse_pos, &parse_pos, 0); |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1114 parse_pos = &parse_pos[1]; |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1115 fs_res_y = strtol(parse_pos, &parse_pos, 0); |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1116 } |
12519
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
1117 if (parse_pos[0] == ':') parse_pos = &parse_pos[1]; |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
1118 else if (parse_pos[0]) parse_err = 1; |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
1119 } |
12a87d539f6d
choose fullscreen device with suboption device_id=#
nplourde
parents:
12517
diff
changeset
|
1120 } |
12785
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1121 |
14082 | 1122 #if !defined (MACOSX_FINDER_SUPPORT) || !defined (HAVE_SDL) |
12785
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1123 //this chunk of code is heavily based off SDL_macosx.m from SDL |
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1124 //it uses an Apple private function to request foreground operation |
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1125 |
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1126 void CPSEnableForegroundOperation(ProcessSerialNumber* psn); |
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1127 ProcessSerialNumber myProc, frProc; |
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1128 Boolean sameProc; |
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1129 |
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1130 if (GetFrontProcess(&frProc) == noErr) |
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1131 { |
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1132 if (GetCurrentProcess(&myProc) == noErr) |
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1133 { |
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1134 if (SameProcess(&frProc, &myProc, &sameProc) == noErr && !sameProc) |
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1135 { |
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1136 CPSEnableForegroundOperation(&myProc); |
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1137 } |
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1138 SetFrontProcess(&myProc); |
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1139 } |
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1140 } |
13909
07dadc3066f3
add support for macosx finder argument support (let you bundle mplayer to be a finder compliant .app) patch by Chris Roccati <roccati@pobox.com>
nplourde
parents:
13856
diff
changeset
|
1141 #endif |
12785
33f58bfc8a1b
make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents:
12624
diff
changeset
|
1142 |
12296 | 1143 return 0; |
12120 | 1144 } |
1145 | |
12424 | 1146 static uint32_t draw_yuv_image(mp_image_t *mpi) |
1147 { | |
1148 // ATM we're only called for planar IMGFMT | |
1149 // drawing is done directly in P | |
1150 // and displaying is in flip_page. | |
12487 | 1151 return get_image_done ? VO_TRUE : VO_FALSE; |
12414 | 1152 } |
1153 | |
12424 | 1154 static uint32_t get_yuv_image(mp_image_t *mpi) |
1155 { | |
1156 if(mpi->type!=MP_IMGTYPE_EXPORT) return VO_FALSE; | |
12414 | 1157 |
12424 | 1158 if(mpi->imgfmt!=image_format) return VO_FALSE; |
12414 | 1159 |
12424 | 1160 if(mpi->flags&MP_IMGFLAG_PLANAR) |
1161 { | |
1162 if (mpi->num_planes != 3) | |
1163 { | |
1164 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: only 3 planes allowed in get_yuv_image for planar (%d) \n", mpi->num_planes); | |
1165 return VO_FALSE; | |
1166 } | |
12414 | 1167 |
23676
f3cb35ec74c3
bugfix intel mac vo_quartz, PlanarPixmapInfoYUV420 structure requires big-endian value. author Taihei Monma tmkk@mac.com
nplourde
parents:
23457
diff
changeset
|
1168 mpi->planes[0]=((char*)P) + be2me_32(P->componentInfoY.offset); |
12487 | 1169 mpi->stride[0]=imgRect.right; |
1170 mpi->width=imgRect.right; | |
12414 | 1171 |
12424 | 1172 if(mpi->flags&MP_IMGFLAG_SWAPPED) |
1173 { | |
1174 // I420 | |
23676
f3cb35ec74c3
bugfix intel mac vo_quartz, PlanarPixmapInfoYUV420 structure requires big-endian value. author Taihei Monma tmkk@mac.com
nplourde
parents:
23457
diff
changeset
|
1175 mpi->planes[1]=((char*)P) + be2me_32(P->componentInfoCb.offset); |
f3cb35ec74c3
bugfix intel mac vo_quartz, PlanarPixmapInfoYUV420 structure requires big-endian value. author Taihei Monma tmkk@mac.com
nplourde
parents:
23457
diff
changeset
|
1176 mpi->planes[2]=((char*)P) + be2me_32(P->componentInfoCr.offset); |
12487 | 1177 mpi->stride[1]=imgRect.right/2; |
1178 mpi->stride[2]=imgRect.right/2; | |
12424 | 1179 } |
1180 else | |
1181 { | |
1182 // YV12 | |
23676
f3cb35ec74c3
bugfix intel mac vo_quartz, PlanarPixmapInfoYUV420 structure requires big-endian value. author Taihei Monma tmkk@mac.com
nplourde
parents:
23457
diff
changeset
|
1183 mpi->planes[1]=((char*)P) + be2me_32(P->componentInfoCr.offset); |
f3cb35ec74c3
bugfix intel mac vo_quartz, PlanarPixmapInfoYUV420 structure requires big-endian value. author Taihei Monma tmkk@mac.com
nplourde
parents:
23457
diff
changeset
|
1184 mpi->planes[2]=((char*)P) + be2me_32(P->componentInfoCb.offset); |
12487 | 1185 mpi->stride[1]=imgRect.right/2; |
1186 mpi->stride[2]=imgRect.right/2; | |
12424 | 1187 } |
1188 | |
1189 mpi->flags|=MP_IMGFLAG_DIRECT; | |
12487 | 1190 get_image_done = 1; |
12424 | 1191 return VO_TRUE; |
1192 } | |
1193 else | |
12433 | 1194 { |
1195 // doesn't work yet | |
12424 | 1196 if (mpi->num_planes != 1) |
1197 { | |
1198 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: only 1 plane allowed in get_yuv_image for packed (%d) \n", mpi->num_planes); | |
1199 return VO_FALSE; | |
1200 } | |
12414 | 1201 |
12424 | 1202 mpi->planes[0] = (char*)P; |
12487 | 1203 mpi->stride[0] = imgRect.right * 2; |
1204 mpi->width=imgRect.right; | |
12424 | 1205 mpi->flags|=MP_IMGFLAG_DIRECT; |
12487 | 1206 get_image_done = 1; |
12424 | 1207 return VO_TRUE; |
1208 } | |
1209 return VO_FALSE; | |
12414 | 1210 } |
1211 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15909
diff
changeset
|
1212 static int control(uint32_t request, void *data, ...) |
12120 | 1213 { |
12424 | 1214 switch (request) |
1215 { | |
1216 case VOCTRL_PAUSE: return (int_pause=1); | |
1217 case VOCTRL_RESUME: return (int_pause=0); | |
12460 | 1218 case VOCTRL_FULLSCREEN: vo_fs = (!(vo_fs)); window_fullscreen(); return VO_TRUE; |
1219 case VOCTRL_ONTOP: vo_ontop = (!(vo_ontop)); window_ontop(); return VO_TRUE; | |
12424 | 1220 case VOCTRL_QUERY_FORMAT: return query_format(*((uint32_t*)data)); |
13795 | 1221 case VOCTRL_GET_PANSCAN: return VO_TRUE; |
13840 | 1222 case VOCTRL_SET_PANSCAN: window_panscan(); return VO_TRUE; |
13795 | 1223 |
12424 | 1224 case VOCTRL_GET_IMAGE: |
1225 switch (image_format) | |
1226 { | |
1227 case IMGFMT_YV12: | |
1228 case IMGFMT_IYUV: | |
1229 case IMGFMT_I420: | |
12487 | 1230 case IMGFMT_UYVY: |
1231 case IMGFMT_YUY2: | |
12424 | 1232 return get_yuv_image(data); |
1233 break; | |
12487 | 1234 default: |
1235 break; | |
12424 | 1236 } |
1237 case VOCTRL_DRAW_IMAGE: | |
1238 switch (image_format) | |
1239 { | |
1240 case IMGFMT_YV12: | |
1241 case IMGFMT_IYUV: | |
1242 case IMGFMT_I420: | |
12487 | 1243 case IMGFMT_UYVY: |
1244 case IMGFMT_YUY2: | |
12424 | 1245 return draw_yuv_image(data); |
1246 break; | |
12487 | 1247 default: |
1248 break; | |
12424 | 1249 } |
1250 } | |
1251 return VO_NOTIMPL; | |
12120 | 1252 } |
1253 | |
12296 | 1254 void window_resized() |
12120 | 1255 { |
12296 | 1256 float aspectX; |
1257 float aspectY; | |
1258 | |
13855 | 1259 int padding = 0; |
12296 | 1260 |
1261 uint32_t d_width; | |
1262 uint32_t d_height; | |
1263 | |
13779 | 1264 CGRect tmpBounds; |
13734 | 1265 |
12623 | 1266 GetPortBounds( GetWindowPort(theWindow), &winRect ); |
12120 | 1267 |
13792
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
1268 if(vo_keepaspect) |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
1269 { |
12296 | 1270 aspect( &d_width, &d_height, A_NOZOOM); |
13792
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
1271 d_height = ((float)d_width/movie_aspect); |
12296 | 1272 |
1273 aspectX = (float)((float)winRect.right/(float)d_width); | |
15702 | 1274 aspectY = (float)((float)(winRect.bottom)/(float)d_height); |
12296 | 1275 |
15702 | 1276 if((d_height*aspectX)>(winRect.bottom)) |
12296 | 1277 { |
1278 padding = (winRect.right - d_width*aspectY)/2; | |
1279 SetRect(&dstRect, padding, 0, d_width*aspectY+padding, d_height*aspectY); | |
1280 } | |
1281 else | |
1282 { | |
15702 | 1283 padding = ((winRect.bottom) - d_height*aspectX)/2; |
12296 | 1284 SetRect(&dstRect, 0, padding, (d_width*aspectX), d_height*aspectX+padding); |
1285 } | |
13792
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
1286 } |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
1287 else |
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
1288 { |
15702 | 1289 SetRect(&dstRect, 0, 0, winRect.right, winRect.bottom); |
13792
d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents:
13791
diff
changeset
|
1290 } |
13124 | 1291 |
1292 switch (image_format) | |
12432 | 1293 { |
13124 | 1294 case IMGFMT_RGB32: |
1295 { | |
15702 | 1296 bounds = CGRectMake(dstRect.left, dstRect.top, dstRect.right-dstRect.left, dstRect.bottom-dstRect.top); |
13124 | 1297 CreateCGContextForPort (GetWindowPort (theWindow), &context); |
1298 break; | |
1299 } | |
1300 case IMGFMT_YV12: | |
1301 case IMGFMT_IYUV: | |
1302 case IMGFMT_I420: | |
1303 case IMGFMT_UYVY: | |
1304 case IMGFMT_YUY2: | |
12432 | 1305 { |
13124 | 1306 long scale_X = FixDiv(Long2Fix(dstRect.right - dstRect.left),Long2Fix(imgRect.right)); |
1307 long scale_Y = FixDiv(Long2Fix(dstRect.bottom - dstRect.top),Long2Fix(imgRect.bottom)); | |
1308 | |
1309 SetIdentityMatrix(&matrix); | |
1310 if (((dstRect.right - dstRect.left) != imgRect.right) || ((dstRect.bottom - dstRect.right) != imgRect.bottom)) | |
1311 { | |
1312 ScaleMatrix(&matrix, scale_X, scale_Y, 0, 0); | |
1313 | |
1314 if (padding > 0) | |
1315 { | |
1316 TranslateMatrix(&matrix, Long2Fix(dstRect.left), Long2Fix(dstRect.top)); | |
1317 } | |
1318 } | |
1319 | |
1320 SetDSequenceMatrix(seqId, &matrix); | |
1321 break; | |
12432 | 1322 } |
13124 | 1323 default: |
1324 break; | |
12432 | 1325 } |
15702 | 1326 |
1327 //Clear Background | |
1328 tmpBounds = CGRectMake( 0, 0, winRect.right, winRect.bottom); | |
1329 CreateCGContextForPort(GetWindowPort(theWindow),&context); | |
1330 CGContextFillRect(context, tmpBounds); | |
12120 | 1331 } |
1332 | |
12296 | 1333 void window_ontop() |
12460 | 1334 { |
13788
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1335 if(!vo_quartz_fs) |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1336 { |
12826
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
1337 //Cycle between level |
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
1338 winLevel++; |
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
1339 if(winLevel>2) |
15524 | 1340 winLevel = 1; |
13788
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1341 } |
12826
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
1342 SetWindowGroupLevel(winGroup, CGWindowLevelForKey(levelList[winLevel])); |
12120 | 1343 } |
1344 | |
12296 | 1345 void window_fullscreen() |
12120 | 1346 { |
13788
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1347 static Ptr restoreState = NULL; |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1348 |
12296 | 1349 //go fullscreen |
12432 | 1350 if(vo_fs) |
12296 | 1351 { |
12826
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
1352 if(winLevel != 0) |
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
1353 { |
13841
394deaee5d21
do not hide mouse and menubar in fulscreen if not using main device
nplourde
parents:
13840
diff
changeset
|
1354 if(device_id == 0) |
394deaee5d21
do not hide mouse and menubar in fulscreen if not using main device
nplourde
parents:
13840
diff
changeset
|
1355 { |
15881 | 1356 SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar); |
18057 | 1357 CGDisplayHideCursor(kCGDirectMainDisplay); |
15892 | 1358 mouseHide = TRUE; |
13841
394deaee5d21
do not hide mouse and menubar in fulscreen if not using main device
nplourde
parents:
13840
diff
changeset
|
1359 } |
13788
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1360 |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1361 if(fs_res_x != 0 || fs_res_y != 0) |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1362 { |
13840 | 1363 BeginFullScreen( &restoreState, deviceHdl, &fs_res_x, &fs_res_y, NULL, NULL, NULL); |
13788
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1364 |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1365 //Get Main device info/////////////////////////////////////////////////// |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1366 deviceRect = (*deviceHdl)->gdRect; |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1367 |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1368 device_width = deviceRect.right; |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1369 device_height = deviceRect.bottom; |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1370 } |
12826
fb55f94f3001
Add Window Level Key, Can switch mode with T key
nplourde
parents:
12785
diff
changeset
|
1371 } |
12120 | 1372 |
12296 | 1373 //save old window size |
12487 | 1374 if (!vo_quartz_fs) |
13818
9f707a805967
window now save is old position when going in fullscreen or while using resize preset
nplourde
parents:
13796
diff
changeset
|
1375 { |
12487 | 1376 GetWindowPortBounds(theWindow, &oldWinRect); |
13818
9f707a805967
window now save is old position when going in fullscreen or while using resize preset
nplourde
parents:
13796
diff
changeset
|
1377 GetWindowBounds(theWindow, kWindowContentRgn, &oldWinBounds); |
9f707a805967
window now save is old position when going in fullscreen or while using resize preset
nplourde
parents:
13796
diff
changeset
|
1378 } |
12296 | 1379 |
1380 //go fullscreen | |
13840 | 1381 panscan_calc(); |
15702 | 1382 ChangeWindowAttributes(theWindow, kWindowNoShadowAttribute, 0); |
13840 | 1383 MoveWindow(theWindow, deviceRect.left-(vo_panscan_x >> 1), deviceRect.top-(vo_panscan_y >> 1), 1); |
1384 SizeWindow(theWindow, device_width+vo_panscan_x, device_height+vo_panscan_y,1); | |
12487 | 1385 |
1386 vo_quartz_fs = 1; | |
12296 | 1387 } |
1388 else //go back to windowed mode | |
1389 { | |
15892 | 1390 vo_quartz_fs = 0; |
13788
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1391 if(restoreState != NULL) |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1392 { |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1393 EndFullScreen(restoreState, NULL); |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1394 |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1395 //Get Main device info/////////////////////////////////////////////////// |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1396 deviceRect = (*deviceHdl)->gdRect; |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1397 |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1398 device_width = deviceRect.right; |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1399 device_height = deviceRect.bottom; |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1400 restoreState = NULL; |
ced61fa921ca
let you choose fullscreen resolution for slower system
nplourde
parents:
13787
diff
changeset
|
1401 } |
15881 | 1402 SetSystemUIMode( kUIModeNormal, NULL); |
12120 | 1403 |
12296 | 1404 //show mouse cursor |
18057 | 1405 CGDisplayShowCursor(kCGDirectMainDisplay); |
15892 | 1406 mouseHide = FALSE; |
12296 | 1407 |
1408 //revert window to previous setting | |
15702 | 1409 ChangeWindowAttributes(theWindow, 0, kWindowNoShadowAttribute); |
12487 | 1410 SizeWindow(theWindow, oldWinRect.right, oldWinRect.bottom,1); |
13818
9f707a805967
window now save is old position when going in fullscreen or while using resize preset
nplourde
parents:
13796
diff
changeset
|
1411 MoveWindow(theWindow, oldWinBounds.left, oldWinBounds.top, 1); |
12296 | 1412 } |
15702 | 1413 window_resized(); |
12120 | 1414 } |
13840 | 1415 |
1416 void window_panscan() | |
1417 { | |
1418 panscan_calc(); | |
1419 | |
1420 if(vo_panscan > 0) | |
1421 CheckMenuItem (aspectMenu, 2, 1); | |
1422 else | |
1423 CheckMenuItem (aspectMenu, 2, 0); | |
1424 | |
1425 if(vo_quartz_fs) | |
1426 { | |
1427 MoveWindow(theWindow, deviceRect.left-(vo_panscan_x >> 1), deviceRect.top-(vo_panscan_y >> 1), 1); | |
1428 SizeWindow(theWindow, device_width+vo_panscan_x, device_height+vo_panscan_y,1); | |
1429 } | |
1430 } |