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