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