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