Mercurial > mplayer.hg
annotate Gui/win32/interface.c @ 19245:15b9a8cdea4c
improved fullscreen switching
author | vayne |
---|---|
date | Sat, 29 Jul 2006 19:30:38 +0000 |
parents | 2149651156bc |
children | 64d82a45a05d |
rev | line source |
---|---|
18914 | 1 /* |
2 MPlayer Gui for win32 | |
3 Copyright (c) 2003 Sascha Sommer <saschasommer@freenet.de> | |
4 Copyright (c) 2006 Erik Augustson <erik_27can@yahoo.com> | |
5 Copyright (c) 2006 Gianluigi Tiesi <sherpya@netfarm.it> | |
6 | |
7 This program is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
9 the Free Software Foundation; either version 2 of the License, or | |
10 (at your option) any later version. | |
11 | |
12 This program is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with this program; if not, write to the Free Software | |
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA | |
20 */ | |
21 | |
22 #include <windows.h> | |
23 #include <interface.h> | |
24 #include <m_option.h> | |
25 #include <mixer.h> | |
26 #include <mp_msg.h> | |
27 #include <help_mp.h> | |
28 #include <codec-cfg.h> | |
29 #include <libmpdemux/stream.h> | |
30 #include <libmpdemux/demuxer.h> | |
31 #include <libmpdemux/stheader.h> | |
32 #ifdef USE_DVDREAD | |
33 #include <libmpdemux/stream_dvd.h> | |
34 #endif | |
35 #include <input/input.h> | |
36 #include <libvo/video_out.h> | |
37 #include <libao2/audio_out.h> | |
38 #include "gui.h" | |
39 #include "dialogs.h" | |
40 #include "wincfg.h" | |
41 #ifdef HAVE_LIBCDIO | |
42 #include <cdio/cdio.h> | |
43 #endif | |
44 | |
45 extern m_obj_settings_t* vo_plugin_args; | |
46 extern vo_functions_t *video_out; | |
47 extern ao_functions_t *audio_out; | |
19104
2ec2301183cd
marks several read-only string parameters which aren't modified inside the called function as const. Patch by Stefan Huehner, stefan AT huehner-org
reynaldo
parents:
19061
diff
changeset
|
48 extern void exit_player(const char *how); |
18914 | 49 extern char *filename; |
50 extern int abs_seek_pos; | |
51 extern float rel_seek_secs; | |
52 extern mixer_t mixer; | |
53 extern int audio_id; | |
54 extern int video_id; | |
55 extern int dvdsub_id; | |
56 extern int vobsub_id; | |
57 extern int stream_cache_size; | |
58 extern int autosync; | |
59 extern int vcd_track; | |
60 extern int dvd_title; | |
61 extern float force_fps; | |
62 extern af_cfg_t af_cfg; | |
63 int guiWinID = 0; | |
64 | |
65 char *skinName = NULL; | |
66 char *codecname = NULL; | |
67 int mplGotoTheNext = 1; | |
68 static gui_t *mygui = NULL; | |
69 static int update_subwindow(void); | |
19245 | 70 static RECT old_rect; |
18914 | 71 |
72 /* test for playlist files, no need to specify -playlist on the commandline. | |
73 * add any conceivable playlist extensions here. | |
74 * - Erik | |
75 */ | |
76 int parse_filename(char *file, play_tree_t *playtree, m_config_t *mconfig, int clear) | |
77 { | |
78 if(clear) | |
79 mygui->playlist->clear_playlist(mygui->playlist); | |
80 | |
81 if(strstr(file, ".m3u") || strstr(file, ".pls")) | |
82 { | |
83 playtree = parse_playlist_file(file); | |
84 import_playtree_playlist_into_gui(playtree, mconfig); | |
85 return 1; | |
86 } | |
87 return 0; | |
88 } | |
89 | |
90 /** | |
91 * \brief this actually creates a new list containing only one element... | |
92 */ | |
19147
2149651156bc
Compile fix, patch by Aidan Thornton % makomk # lycos P co P uk %
gpoirier
parents:
19104
diff
changeset
|
93 void gaddlist( char ***list, const char *entry) |
18914 | 94 { |
95 int i; | |
96 | |
97 if (*list) | |
98 { | |
99 for (i=0; (*list)[i]; i++) free((*list)[i]); | |
100 free(*list); | |
101 } | |
102 | |
103 *list = malloc(2 * sizeof(char **)); | |
104 (*list)[0] = gstrdup(entry); | |
105 (*list)[1] = NULL; | |
106 } | |
107 | |
19147
2149651156bc
Compile fix, patch by Aidan Thornton % makomk # lycos P co P uk %
gpoirier
parents:
19104
diff
changeset
|
108 char *gstrdup(const char *str) |
18914 | 109 { |
110 if (!str) return NULL; | |
111 return strdup(str); | |
112 } | |
113 | |
114 /** | |
115 * \brief this replaces a string starting with search by replace. | |
116 * If not found, replace is appended. | |
117 */ | |
118 void greplace(char ***list, char *search, char *replace) | |
119 { | |
120 int i = 0; | |
121 int len = (search) ? strlen(search) : 0; | |
122 | |
123 if (*list) | |
124 { | |
125 for (i = 0; (*list)[i]; i++) | |
126 { | |
127 if (search && (!strncmp((*list)[i], search, len))) | |
128 { | |
129 free((*list)[i]); | |
130 (*list)[i] = gstrdup(replace); | |
131 return; | |
132 } | |
133 } | |
134 *list = realloc(*list, (i + 2) * sizeof(char *)); | |
135 } | |
136 else | |
137 *list = malloc(2 * sizeof(char *)); | |
138 | |
139 (*list)[i] = gstrdup(replace); | |
140 (*list)[i + 1] = NULL; | |
141 } | |
142 | |
143 /* this function gets called by the gui to update mplayer */ | |
144 static void guiSetEvent(int event) | |
145 { | |
146 switch(event) | |
147 { | |
148 case evPlay: | |
149 case evPlaySwitchToPause: | |
150 mplPlay(); | |
151 break; | |
152 case evPause: | |
153 mplPause(); | |
154 break; | |
155 #ifdef USE_DVDREAD | |
156 case evPlayDVD: | |
157 { | |
158 static char dvdname[MAX_PATH]; | |
159 guiIntfStruct.DVD.current_title = dvd_title; | |
160 guiIntfStruct.DVD.current_chapter = dvd_chapter; | |
161 guiIntfStruct.DVD.current_angle = dvd_angle; | |
162 guiIntfStruct.DiskChanged = 1; | |
163 | |
164 mplSetFileName(NULL, dvd_device, STREAMTYPE_DVD); | |
165 guiIntfStruct.Title = guiIntfStruct.DVD.current_title; | |
166 guiIntfStruct.Chapter = guiIntfStruct.DVD.current_chapter; | |
167 guiIntfStruct.Angle = guiIntfStruct.DVD.current_angle; | |
168 | |
169 dvdname[0] = 0; | |
170 strcat(dvdname, "DVD Movie"); | |
171 GetVolumeInformation(dvd_device, dvdname, MAX_PATH, NULL, NULL, NULL, NULL, 0); | |
172 capitalize(dvdname); | |
173 mp_msg(MSGT_GPLAYER, MSGL_V, "Opening DVD %s -> %s\n", dvd_device, dvdname); | |
174 guiGetEvent(guiSetParameters, (char *) STREAMTYPE_DVD); | |
175 mygui->playlist->clear_playlist(mygui->playlist); | |
176 mygui->playlist->add_track(mygui->playlist, filename, NULL, dvdname, 0); | |
177 mygui->startplay(mygui); | |
178 break; | |
179 } | |
180 #endif | |
181 #ifdef HAVE_LIBCDIO | |
182 case evPlayCD: | |
183 { | |
184 int i; | |
185 char track[10]; | |
186 char trackname[10]; | |
187 CdIo_t *p_cdio = cdio_open(NULL, DRIVER_UNKNOWN); | |
188 track_t i_tracks; | |
189 | |
190 if(p_cdio == NULL) printf("Couldn't find a driver.\n"); | |
191 i_tracks = cdio_get_num_tracks(p_cdio); | |
192 | |
193 mygui->playlist->clear_playlist(mygui->playlist); | |
194 for(i=0;i<i_tracks;i++) | |
195 { | |
196 sprintf(track, "cdda://%d", i+1); | |
197 sprintf(trackname, "Track %d", i+1); | |
198 mygui->playlist->add_track(mygui->playlist, track, NULL, trackname, 0); | |
199 } | |
200 cdio_destroy(p_cdio); | |
201 mygui->startplay(mygui); | |
202 break; | |
203 } | |
204 #endif | |
205 case evFullScreen: | |
206 mp_input_queue_cmd(mp_input_parse_cmd("vo_fullscreen")); | |
207 break; | |
208 case evExit: | |
209 { | |
210 /* We are asking mplayer to exit, later it will ask us after uninit is made | |
211 this should be the only safe way to quit */ | |
212 mygui->activewidget = NULL; | |
213 mp_input_queue_cmd(mp_input_parse_cmd("quit")); | |
214 break; | |
215 } | |
216 case evStop: | |
217 if(guiIntfStruct.Playing) | |
218 guiGetEvent(guiCEvent, (void *) guiSetStop); | |
219 break; | |
220 case evSetMoviePosition: | |
221 { | |
222 rel_seek_secs = guiIntfStruct.Position / 100.0f; | |
223 abs_seek_pos = 3; | |
224 break; | |
225 } | |
226 case evForward10sec: | |
227 { | |
228 rel_seek_secs = 10.0f; | |
229 abs_seek_pos = 0; | |
230 break; | |
231 } | |
232 case evBackward10sec: | |
233 { | |
234 rel_seek_secs = -10.0f; | |
235 abs_seek_pos = 0; | |
236 break; | |
237 } | |
238 case evSetBalance: | |
239 case evSetVolume: | |
240 { | |
241 float l,r; | |
242 | |
18953
b83cefcd7e41
crash fix when clicking on volume sliders when in stop state.
vayne
parents:
18947
diff
changeset
|
243 if (guiIntfStruct.Playing == 0) |
b83cefcd7e41
crash fix when clicking on volume sliders when in stop state.
vayne
parents:
18947
diff
changeset
|
244 break; |
b83cefcd7e41
crash fix when clicking on volume sliders when in stop state.
vayne
parents:
18947
diff
changeset
|
245 |
18914 | 246 if (guiIntfStruct.Balance == 50.0f) |
247 mixer_setvolume(&mixer, guiIntfStruct.Volume, guiIntfStruct.Volume); | |
248 | |
249 l = guiIntfStruct.Volume * ((100.0f - guiIntfStruct.Balance) / 50.0f); | |
250 r = guiIntfStruct.Volume * ((guiIntfStruct.Balance) / 50.0f); | |
251 | |
252 if (l > guiIntfStruct.Volume) l=guiIntfStruct.Volume; | |
253 if (r > guiIntfStruct.Volume) r=guiIntfStruct.Volume; | |
254 mixer_setvolume(&mixer, l, r); | |
255 /* Check for balance support on mixer - there is a better way ?? */ | |
256 if (r != l) | |
257 { | |
258 mixer_getvolume(&mixer, &l, &r); | |
259 if (r == l) | |
260 { | |
261 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Mixer doesn't support balanced audio\n"); | |
262 mixer_setvolume(&mixer, guiIntfStruct.Volume, guiIntfStruct.Volume); | |
263 guiIntfStruct.Balance = 50.0f; | |
264 } | |
265 } | |
266 break; | |
267 } | |
268 case evMute: | |
269 { | |
19061
86350b4b8203
drops casts from void * on malloc/calloc from the gui code
reynaldo
parents:
18953
diff
changeset
|
270 mp_cmd_t * cmd = calloc(1, sizeof(*cmd)); |
18914 | 271 cmd->id=MP_CMD_MUTE; |
272 cmd->name=strdup("mute"); | |
273 mp_input_queue_cmd(cmd); | |
274 break; | |
275 } | |
276 case evDropFile: | |
277 case evLoadPlay: | |
278 { | |
279 mplSetFileName(NULL, filename, STREAMTYPE_FILE); | |
280 guiIntfStruct.FilenameChanged = guiIntfStruct.NewPlay = 1; | |
281 update_playlistwindow(); | |
282 guiGetEvent(guiCEvent, (void *) guiSetStop); | |
283 guiGetEvent(guiCEvent, (void *) guiSetPlay); | |
284 break; | |
285 } | |
286 case evNext: | |
287 mplNext(); | |
288 break; | |
289 case evPrev: | |
290 mplPrev(); | |
291 break; | |
292 } | |
293 } | |
294 | |
295 void mplPlay( void ) | |
296 { | |
297 if((!guiIntfStruct.Filename ) || (guiIntfStruct.Filename[0] == 0)) | |
298 return; | |
299 | |
300 if(guiIntfStruct.Playing > 0) | |
301 { | |
302 mplPause(); | |
303 return; | |
304 } | |
305 guiIntfStruct.NewPlay = 1; | |
306 guiGetEvent(guiCEvent, (void *) guiSetPlay); | |
307 } | |
308 | |
309 void mplPause( void ) | |
310 { | |
311 if(!guiIntfStruct.Playing) return; | |
312 | |
313 if(guiIntfStruct.Playing == 1) | |
314 { | |
19061
86350b4b8203
drops casts from void * on malloc/calloc from the gui code
reynaldo
parents:
18953
diff
changeset
|
315 mp_cmd_t * cmd = calloc(1, sizeof(*cmd)); |
18914 | 316 cmd->id=MP_CMD_PAUSE; |
317 cmd->name=strdup("pause"); | |
318 mp_input_queue_cmd(cmd); | |
319 } else guiIntfStruct.Playing = 1; | |
320 } | |
321 | |
322 void mplNext(void) | |
323 { | |
324 if(guiIntfStruct.Playing == 2) return; | |
325 switch(guiIntfStruct.StreamType) | |
326 { | |
327 #ifdef USE_DVDREAD | |
328 case STREAMTYPE_DVD: | |
329 if(guiIntfStruct.DVD.current_chapter == (guiIntfStruct.DVD.chapters - 1)) | |
330 return; | |
331 guiIntfStruct.DVD.current_chapter++; | |
332 break; | |
333 #endif | |
334 default: | |
335 if(mygui->playlist->current == (mygui->playlist->trackcount - 1)) | |
336 return; | |
337 mplSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)++]->filename, | |
338 STREAMTYPE_STREAM); | |
339 break; | |
340 } | |
341 mplGotoTheNext = 0; | |
342 mygui->startplay(mygui); | |
343 } | |
344 | |
345 void mplPrev(void) | |
346 { | |
347 if(guiIntfStruct.Playing == 2) return; | |
348 switch(guiIntfStruct.StreamType) | |
349 { | |
350 #ifdef USE_DVDREAD | |
351 case STREAMTYPE_DVD: | |
352 if(guiIntfStruct.DVD.current_chapter == 1) | |
353 return; | |
354 guiIntfStruct.DVD.current_chapter--; | |
355 break; | |
356 #endif | |
357 default: | |
358 if(mygui->playlist->current == 0) | |
359 return; | |
360 mplSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)--]->filename, | |
361 STREAMTYPE_STREAM); | |
362 break; | |
363 } | |
364 mplGotoTheNext = 0; | |
365 mygui->startplay(mygui); | |
366 } | |
367 | |
368 void mplEnd( void ) | |
369 { | |
370 if(!mplGotoTheNext && guiIntfStruct.Playing) | |
371 { | |
372 mplGotoTheNext = 1; | |
373 return; | |
374 } | |
375 | |
376 if(mplGotoTheNext && guiIntfStruct.Playing && | |
377 (mygui->playlist->current < (mygui->playlist->trackcount - 1)) && | |
378 guiIntfStruct.StreamType != STREAMTYPE_DVD && | |
379 guiIntfStruct.StreamType != STREAMTYPE_DVDNAV) | |
380 { | |
381 /* we've finished this file, reset the aspect */ | |
382 if(movie_aspect >= 0) | |
383 movie_aspect = -1; | |
384 | |
385 mplGotoTheNext = guiIntfStruct.FilenameChanged = guiIntfStruct.NewPlay = 1; | |
386 mplSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)++]->filename, STREAMTYPE_STREAM); | |
387 //sprintf(guiIntfStruct.Filename, mygui->playlist->tracks[(mygui->playlist->current)++]->filename); | |
388 } | |
389 | |
390 if(guiIntfStruct.FilenameChanged && guiIntfStruct.NewPlay) | |
391 return; | |
392 | |
393 guiIntfStruct.TimeSec = 0; | |
394 guiIntfStruct.Position = 0; | |
395 guiIntfStruct.AudioType = 0; | |
396 | |
397 #ifdef USE_DVDREAD | |
398 guiIntfStruct.DVD.current_title = 1; | |
399 guiIntfStruct.DVD.current_chapter = 1; | |
400 guiIntfStruct.DVD.current_angle = 1; | |
401 #endif | |
402 | |
403 if (mygui->playlist->current == (mygui->playlist->trackcount - 1)) | |
404 mygui->playlist->current = 0; | |
405 | |
19245 | 406 fullscreen = vo_fs = 0; |
18914 | 407 guiGetEvent(guiCEvent, (void *) guiSetStop); |
408 } | |
409 | |
410 void mplSetFileName(char *dir, char *name, int type) | |
411 { | |
412 if(!name) return; | |
413 if(!dir) | |
414 guiSetFilename(guiIntfStruct.Filename, name) | |
415 else | |
416 guiSetDF(guiIntfStruct.Filename, dir, name); | |
417 | |
418 guiIntfStruct.StreamType = type; | |
419 free((void **) &guiIntfStruct.AudioFile); | |
420 free((void **) &guiIntfStruct.Subtitlename); | |
421 } | |
422 | |
423 static DWORD WINAPI GuiThread(void) | |
424 { | |
425 MSG msg; | |
426 | |
427 if(!skinName) skinName = strdup("Blue"); | |
428 if(!mygui) mygui = create_gui(get_path("skins"), skinName, guiSetEvent); | |
429 if(!mygui) exit_player("Unable to load gui"); | |
430 | |
431 if(autosync && autosync != gtkAutoSync) | |
432 { | |
433 gtkAutoSyncOn = 1; | |
434 gtkAutoSync = autosync; | |
435 } | |
436 | |
19245 | 437 old_rect.left = gui_sub_pos_x; |
438 old_rect.top = gui_sub_pos_y; | |
439 | |
18914 | 440 while(mygui) |
441 { | |
442 GetMessage(&msg, NULL, 0, 0); | |
443 TranslateMessage(&msg); | |
444 DispatchMessage(&msg); | |
445 } | |
446 fprintf(stderr, "[GUI] Gui Thread Terminated\n"); | |
447 fflush(stderr); | |
448 return 0; | |
449 } | |
450 | |
451 void guiInit(void) | |
452 { | |
453 memset(&guiIntfStruct, 0, sizeof(guiIntfStruct)); | |
454 /* Create The gui thread */ | |
455 if (!mygui) | |
456 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Creating GUI Thread 0x%04x\n", | |
457 (int) CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) GuiThread, NULL, 0, NULL)); | |
458 | |
459 /* Wait until the gui is created */ | |
460 while(!mygui) Sleep(100); | |
461 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Gui Thread started\n"); | |
462 } | |
463 | |
464 void guiDone(void) | |
465 { | |
466 if(mygui) | |
467 { | |
468 fprintf(stderr, "[GUI] Closed by main mplayer window\n"); | |
469 fflush(stderr); | |
470 mygui->uninit(mygui); | |
471 free(mygui); | |
472 TerminateThread(GuiThread, 0); | |
473 mygui = NULL; | |
474 } | |
475 /* Remove tray icon */ | |
476 Shell_NotifyIcon(NIM_DELETE, &nid); | |
477 cfg_write(); | |
478 } | |
479 | |
480 static void add_vop(char * str) | |
481 { | |
482 mp_msg(MSGT_GPLAYER, MSGL_STATUS, MSGTR_AddingVideoFilter, str); | |
483 if (vo_plugin_args) | |
484 { | |
485 int i = 0; | |
486 while (vo_plugin_args[i].name) | |
487 if (!strcmp(vo_plugin_args[i++].name, str)) | |
488 { | |
489 i = -1; | |
490 break; | |
491 } | |
492 if (i != -1) | |
493 { | |
494 vo_plugin_args = realloc(vo_plugin_args, (i + 2) * sizeof(m_obj_settings_t)); | |
495 vo_plugin_args[i].name = strdup(str); | |
496 vo_plugin_args[i].attribs = NULL; | |
497 vo_plugin_args[i + 1].name = NULL; | |
498 } | |
499 } | |
500 else | |
501 { | |
502 vo_plugin_args = malloc(2 * sizeof(m_obj_settings_t)); | |
503 vo_plugin_args[0].name = strdup(str); | |
504 vo_plugin_args[0].attribs = NULL; | |
505 vo_plugin_args[1].name = NULL; | |
506 } | |
507 } | |
508 | |
509 static void remove_vop(char * str) | |
510 { | |
511 int n = 0; | |
512 if (!vo_plugin_args ) return; | |
513 | |
514 mp_msg(MSGT_GPLAYER,MSGL_STATUS, MSGTR_RemovingVideoFilter, str); | |
515 | |
516 while (vo_plugin_args[n++].name); | |
517 n--; | |
518 if ( n > -1 ) | |
519 { | |
520 int i = 0, m = -1; | |
521 while (vo_plugin_args[i].name) | |
522 if (!strcmp(vo_plugin_args[i++].name, str)) | |
523 { | |
524 m = i - 1; | |
525 break; | |
526 } | |
527 i--; | |
528 if (m > -1) | |
529 { | |
530 if (n == 1) | |
531 { | |
532 free(vo_plugin_args[0].name); | |
533 free(vo_plugin_args[0].attribs); | |
534 free(vo_plugin_args); | |
535 vo_plugin_args=NULL; | |
536 } | |
537 else | |
538 { | |
539 free(vo_plugin_args[i].name); | |
540 free(vo_plugin_args[i].attribs); | |
541 memcpy(&vo_plugin_args[i], &vo_plugin_args[i + 1], (n - i) * sizeof(m_obj_settings_t)); | |
542 } | |
543 } | |
544 } | |
545 } | |
546 | |
547 /* this function gets called by mplayer to update the gui */ | |
548 int guiGetEvent(int type, char *arg) | |
549 { | |
550 if(!mygui || !mygui->skin) return 0; | |
551 | |
552 stream_t *stream = (stream_t *) arg; | |
553 #ifdef USE_DVDREAD | |
554 dvd_priv_t *dvdp = (dvd_priv_t *) arg; | |
555 #endif | |
556 | |
557 switch (type) | |
558 { | |
559 case guiSetFileFormat: | |
560 guiIntfStruct.FileFormat = (int) arg; | |
561 break; | |
562 case guiSetParameters: | |
563 { | |
564 guiGetEvent(guiSetDefaults, NULL); | |
565 guiIntfStruct.DiskChanged = 0; | |
566 guiIntfStruct.FilenameChanged = 0; | |
567 guiIntfStruct.NewPlay = 0; | |
568 switch(guiIntfStruct.StreamType) | |
569 { | |
570 case STREAMTYPE_PLAYLIST: | |
571 break; | |
572 #ifdef USE_DVDREAD | |
573 case STREAMTYPE_DVD: | |
574 { | |
575 char tmp[512]; | |
576 dvd_title = guiIntfStruct.DVD.current_title; | |
577 dvd_chapter = guiIntfStruct.DVD.current_chapter; | |
578 dvd_angle = guiIntfStruct.DVD.current_angle; | |
579 sprintf(tmp,"dvd://%d", guiIntfStruct.Title); | |
580 guiSetFilename(guiIntfStruct.Filename, tmp); | |
581 break; | |
582 } | |
583 #endif | |
584 } | |
585 if(guiIntfStruct.Filename) | |
586 filename = strdup(guiIntfStruct.Filename); | |
587 else if(filename) | |
588 strcpy(guiIntfStruct.Filename, filename); | |
589 break; | |
590 } | |
591 case guiSetAudioOnly: | |
592 { | |
593 guiIntfStruct.AudioOnly = (int) arg; | |
594 if(IsWindowVisible(mygui->subwindow)) | |
595 ShowWindow(mygui->subwindow, SW_HIDE); | |
596 break; | |
597 } | |
598 case guiSetDemuxer: | |
599 guiIntfStruct.demuxer = (void *) arg; | |
600 break; | |
601 case guiSetValues: | |
602 { | |
603 guiIntfStruct.sh_video = arg; | |
604 if (arg) | |
605 { | |
606 sh_video_t *sh = (sh_video_t *)arg; | |
607 codecname = sh->codec->name; | |
608 guiIntfStruct.FPS = sh->fps; | |
609 | |
610 /* we have video, show the subwindow */ | |
611 if(!IsWindowVisible(mygui->subwindow) || IsIconic(mygui->subwindow)) | |
612 ShowWindow(mygui->subwindow, SW_SHOWNORMAL); | |
613 if(WinID == -1) | |
614 update_subwindow(); | |
615 | |
616 } | |
617 break; | |
618 } | |
619 case guiSetShVideo: | |
620 { | |
621 guiIntfStruct.MovieWidth = vo_dwidth; | |
622 guiIntfStruct.MovieHeight = vo_dheight; | |
623 | |
624 sub_aspect = (float)guiIntfStruct.MovieWidth/guiIntfStruct.MovieHeight; | |
625 if(WinID != -1) | |
626 update_subwindow(); | |
627 break; | |
628 } | |
629 case guiSetStream: | |
630 { | |
631 guiIntfStruct.StreamType = stream->type; | |
632 switch(stream->type) | |
633 { | |
634 #ifdef USE_DVDREAD | |
635 case STREAMTYPE_DVD: | |
636 guiGetEvent(guiSetDVD, (char *) stream->priv); | |
637 break; | |
638 #endif | |
639 } | |
640 break; | |
641 } | |
642 #ifdef USE_DVDREAD | |
643 case guiSetDVD: | |
644 { | |
645 guiIntfStruct.DVD.titles = dvdp->vmg_file->tt_srpt->nr_of_srpts; | |
646 guiIntfStruct.DVD.chapters = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts; | |
647 guiIntfStruct.DVD.angles = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; | |
648 guiIntfStruct.DVD.nr_of_audio_channels = dvdp->nr_of_channels; | |
649 memcpy(guiIntfStruct.DVD.audio_streams, dvdp->audio_streams, sizeof(dvdp->audio_streams)); | |
650 guiIntfStruct.DVD.nr_of_subtitles = dvdp->nr_of_subtitles; | |
651 memcpy(guiIntfStruct.DVD.subtitles, dvdp->subtitles, sizeof(dvdp->subtitles)); | |
652 guiIntfStruct.DVD.current_title = dvd_title + 1; | |
653 guiIntfStruct.DVD.current_chapter = dvd_chapter + 1; | |
654 guiIntfStruct.DVD.current_angle = dvd_angle + 1; | |
655 guiIntfStruct.Track = dvd_title + 1; | |
656 break; | |
657 } | |
658 #endif | |
659 case guiReDraw: | |
660 mygui->updatedisplay(mygui, mygui->mainwindow); | |
661 break; | |
662 case guiSetAfilter: | |
663 guiIntfStruct.afilter = (void *) arg; | |
664 break; | |
665 case guiCEvent: | |
666 { | |
667 guiIntfStruct.Playing = (int) arg; | |
668 switch (guiIntfStruct.Playing) | |
669 { | |
670 case guiSetPlay: | |
671 { | |
672 guiIntfStruct.Playing = 1; | |
19245 | 673 if(guiIntfStruct.sh_video && !IsIconic(mygui->subwindow) |
674 && IsWindowVisible(mygui->subwindow) && !fullscreen) | |
675 GetWindowRect(mygui->subwindow, &old_rect); | |
18914 | 676 break; |
677 } | |
678 case guiSetStop: | |
679 { | |
680 guiIntfStruct.Playing = 0; | |
681 if(movie_aspect >= 0) | |
682 movie_aspect = -1; | |
683 update_subwindow(); | |
684 break; | |
685 } | |
686 case guiSetPause: | |
687 guiIntfStruct.Playing = 2; | |
688 break; | |
689 } | |
690 break; | |
691 } | |
692 case guiIEvent: | |
693 { | |
694 mp_msg(MSGT_GPLAYER,MSGL_V, "cmd: %d\n", (int) arg); | |
695 /* MPlayer asks us to quit */ | |
696 switch((int) arg) | |
697 { | |
698 case MP_CMD_GUI_FULLSCREEN: | |
699 { | |
700 if(!guiIntfStruct.sh_video) break; | |
701 | |
19245 | 702 /* FIXME: vo_directx is behaving unexpectedly, this maintains current functionality */ |
703 if(!sub_window || (&video_driver_list && strstr(video_driver_list[0], "directx"))) | |
704 { | |
705 video_out->control(VOCTRL_FULLSCREEN, 0); | |
18914 | 706 break; |
19245 | 707 } |
18914 | 708 |
19245 | 709 if(!fullscreen) |
710 GetWindowRect(mygui->subwindow, &old_rect); | |
711 | |
712 if(fullscreen) | |
18914 | 713 { |
19245 | 714 fullscreen = vo_fs = 0; |
715 vo_dwidth = guiIntfStruct.MovieWidth = old_rect.right-old_rect.left; | |
716 vo_dheight = guiIntfStruct.MovieHeight = old_rect.bottom-old_rect.top; | |
717 vo_dx = old_rect.left; | |
718 vo_dy = old_rect.top; | |
18914 | 719 } else { |
19245 | 720 fullscreen = vo_fs = 1; |
721 vo_dwidth = guiIntfStruct.MovieWidth = vo_screenwidth; | |
722 vo_dheight = guiIntfStruct.MovieHeight = vo_screenheight; | |
723 vo_dx = 0; | |
724 vo_dy = 0; | |
18914 | 725 } |
19245 | 726 mpcodecs_config_vo(guiIntfStruct.sh_video, guiIntfStruct.MovieWidth, |
727 guiIntfStruct.MovieHeight, 0); | |
18914 | 728 break; |
729 } | |
730 case MP_CMD_QUIT: | |
731 { | |
732 mygui->uninit(mygui); | |
733 free(mygui); | |
734 mygui = NULL; | |
735 exit_player("Done"); | |
736 return 0; | |
737 } | |
738 case MP_CMD_GUI_STOP: | |
739 guiGetEvent(guiCEvent, (void *) guiSetStop); | |
740 break; | |
741 case MP_CMD_GUI_PLAY: | |
742 guiGetEvent(guiCEvent, (void *) guiSetPlay); | |
743 break; | |
744 case MP_CMD_GUI_SKINBROWSER: | |
19245 | 745 if(fullscreen) guiSetEvent(evFullScreen); |
18914 | 746 PostMessage(mygui->mainwindow, WM_COMMAND, (WPARAM) ID_SKINBROWSER, 0); |
747 break; | |
748 case MP_CMD_GUI_PLAYLIST: | |
19245 | 749 if(fullscreen) guiSetEvent(evFullScreen); |
18914 | 750 PostMessage(mygui->mainwindow, WM_COMMAND, (WPARAM) ID_PLAYLIST, 0); |
751 break; | |
752 case MP_CMD_GUI_PREFERENCES: | |
19245 | 753 if(fullscreen) guiSetEvent(evFullScreen); |
18914 | 754 PostMessage(mygui->mainwindow, WM_COMMAND, (WPARAM) ID_PREFS, 0); |
755 break; | |
756 case MP_CMD_GUI_LOADFILE: | |
19245 | 757 if(fullscreen) guiSetEvent(evFullScreen); |
18914 | 758 PostMessage(mygui->mainwindow, WM_COMMAND, (WPARAM) IDFILE_OPEN, 0); |
759 break; | |
760 #ifdef USE_SUB | |
761 case MP_CMD_GUI_LOADSUBTITLE: | |
19245 | 762 if(fullscreen) guiSetEvent(evFullScreen); |
18914 | 763 PostMessage(mygui->mainwindow, WM_COMMAND, (WPARAM) IDSUBTITLE_OPEN, 0); |
764 break; | |
765 #endif | |
766 default: | |
767 break; | |
768 } | |
769 break; | |
770 } | |
771 case guiSetFileName: | |
772 if (arg) guiIntfStruct.Filename = (char *) arg; | |
773 break; | |
774 case guiSetDefaults: | |
775 { | |
776 audio_id = -1; | |
777 video_id = -1; | |
778 dvdsub_id = -1; | |
779 vobsub_id = -1; | |
780 stream_cache_size = -1; | |
781 autosync = 0; | |
782 vcd_track = 0; | |
783 dvd_title = 0; | |
784 force_fps = 0; | |
785 if(!mygui->playlist->tracks) return 0; | |
786 filename = guiIntfStruct.Filename = mygui->playlist->tracks[mygui->playlist->current]->filename; | |
787 guiIntfStruct.Track = mygui->playlist->current + 1; | |
788 if(gtkAONorm) greplace(&af_cfg.list, "volnorm", "volnorm"); | |
789 if(gtkAOExtraStereo) | |
790 { | |
791 char *name = malloc(12 + 20 + 1); | |
792 snprintf(name, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul); | |
793 name[12 + 20] = 0; | |
794 greplace(&af_cfg.list, "extrastereo", name); | |
795 free(name); | |
796 } | |
797 if(gtkCacheOn) stream_cache_size = gtkCacheSize; | |
798 if(gtkAutoSyncOn) autosync = gtkAutoSync; | |
799 break; | |
800 } | |
801 case guiSetVolume: | |
802 { | |
803 if(audio_out) | |
804 { | |
805 /* Some audio_out drivers do not support balance e.g. dsound */ | |
806 /* FIXME this algo is not correct */ | |
807 float l, r; | |
808 mixer_getvolume(&mixer, &l, &r); | |
809 guiIntfStruct.Volume = (r > l ? r : l); /* max(r,l) */ | |
810 if (r != l) | |
811 guiIntfStruct.Balance = ((r-l) + 100.0f) * 0.5f; | |
812 else | |
813 guiIntfStruct.Balance = 50.0f; | |
814 } | |
815 break; | |
816 } | |
817 default: | |
818 mp_msg(MSGT_GPLAYER, MSGL_ERR, "[GUI] GOT UNHANDLED EVENT %i\n", type); | |
819 } | |
820 return 0; | |
821 } | |
822 | |
823 /* This function adds/inserts one file into the gui playlist */ | |
824 int import_file_into_gui(char *pathname, int insert) | |
825 { | |
826 char filename[MAX_PATH]; | |
827 char *filepart = filename; | |
828 | |
829 if (strstr(pathname, "://")) | |
830 { | |
831 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding special %s\n", pathname); | |
832 mygui->playlist->add_track(mygui->playlist, pathname, NULL, NULL, 0); | |
833 return 1; | |
834 } | |
835 if (GetFullPathName(pathname, MAX_PATH, filename, &filepart)) | |
836 { | |
837 if (!(GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY)) | |
838 { | |
839 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding filename: %s - fullpath: %s\n", filepart, filename); | |
840 mygui->playlist->add_track(mygui->playlist, filename, NULL, filepart, 0); | |
841 return 1; | |
842 } | |
843 else | |
844 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Cannot add %s\n", filename); | |
845 } | |
846 | |
847 return 0; | |
848 } | |
849 | |
850 /* This function imports the initial playtree (based on cmd-line files) into the gui playlist | |
851 by either: | |
852 - overwriting gui pl (enqueue=0) */ | |
853 | |
854 int import_initial_playtree_into_gui(play_tree_t *my_playtree, m_config_t *config, int enqueue) | |
855 { | |
856 play_tree_iter_t *my_pt_iter = NULL; | |
857 int result = 0; | |
858 | |
859 if(!mygui) guiInit(); | |
860 | |
861 if((my_pt_iter = pt_iter_create(&my_playtree, config))) | |
862 { | |
863 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
864 { | |
865 if (parse_filename(filename, my_playtree, config, 0)) | |
866 result = 1; | |
867 else if (import_file_into_gui(filename, 0)) /* Add it to end of list */ | |
868 result = 1; | |
869 } | |
870 } | |
871 mplGotoTheNext = 1; | |
872 | |
873 if (result) | |
874 { | |
875 mygui->playlist->current = 0; | |
876 filename = mygui->playlist->tracks[0]->filename; | |
877 } | |
878 return result; | |
879 } | |
880 | |
881 /* This function imports and inserts an playtree, that is created "on the fly", for example by | |
882 parsing some MOV-Reference-File; or by loading an playlist with "File Open" | |
883 The file which contained the playlist is thereby replaced with it's contents. */ | |
884 | |
885 int import_playtree_playlist_into_gui(play_tree_t *my_playtree, m_config_t *config) | |
886 { | |
887 play_tree_iter_t *my_pt_iter = NULL; | |
888 int result = 0; | |
889 | |
890 if((my_pt_iter = pt_iter_create(&my_playtree, config))) | |
891 { | |
892 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
893 if (import_file_into_gui(filename, 1)) /* insert it into the list and set plCurrent = new item */ | |
894 result = 1; | |
895 pt_iter_destroy(&my_pt_iter); | |
896 } | |
897 filename = NULL; | |
898 return result; | |
899 } | |
900 | |
901 inline void gtkMessageBox(int type, const char *str) | |
902 { | |
903 if (type & GTK_MB_FATAL) | |
904 MessageBox(NULL, str, "MPlayer GUI for Windows Error", MB_OK | MB_ICONERROR); | |
905 | |
906 fprintf(stderr, "[GUI] MessageBox: %s\n", str); | |
907 fflush(stderr); | |
908 } | |
909 | |
910 void guiMessageBox(int level, char *str) | |
911 { | |
912 switch(level) | |
913 { | |
914 case MSGL_FATAL: | |
915 gtkMessageBox(GTK_MB_FATAL | GTK_MB_SIMPLE, str); | |
916 break; | |
917 case MSGL_ERR: | |
918 gtkMessageBox(GTK_MB_ERROR | GTK_MB_SIMPLE, str); | |
919 break; | |
920 } | |
921 } | |
922 | |
923 static int update_subwindow(void) | |
924 { | |
925 int x,y; | |
926 RECT rd; | |
927 WINDOWPOS wp; | |
928 | |
18947
06ab2099c10e
OpenGL outputs actually support WinID, not to mention that showing the option
reimar
parents:
18914
diff
changeset
|
929 if(!sub_window) |
18914 | 930 { |
931 WinID = -1; // so far only directx supports WinID in windows | |
932 | |
933 if(IsWindowVisible(mygui->subwindow) && guiIntfStruct.sh_video && guiIntfStruct.Playing) | |
934 { | |
935 ShowWindow(mygui->subwindow, SW_HIDE); | |
936 return 0; | |
937 } | |
938 else if(guiIntfStruct.AudioOnly) | |
939 return 0; | |
940 else ShowWindow(mygui->subwindow, SW_SHOW); | |
941 } | |
942 | |
943 /* we've come out of fullscreen at the end of file */ | |
944 if((!IsWindowVisible(mygui->subwindow) || IsIconic(mygui->subwindow)) && !guiIntfStruct.AudioOnly) | |
945 ShowWindow(mygui->subwindow, SW_SHOWNORMAL); | |
946 | |
947 /* get our current window coordinates */ | |
19245 | 948 if(fullscreen) |
949 GetWindowRect(mygui->subwindow, &rd); | |
950 else | |
951 CopyRect(&rd, &old_rect); | |
952 | |
18914 | 953 x = rd.left; |
954 y = rd.top; | |
955 | |
956 if(!guiIntfStruct.Playing) | |
957 { | |
958 window *desc = NULL; | |
959 int i; | |
960 | |
961 for (i=0; i<mygui->skin->windowcount; i++) | |
962 if(mygui->skin->windows[i]->type == wiSub) | |
963 desc = mygui->skin->windows[i]; | |
964 | |
965 rd.right = rd.left+desc->base->bitmap[0]->width; | |
966 rd.bottom = rd.top+desc->base->bitmap[0]->height; | |
967 sub_aspect = (float)(rd.right-rd.left)/(rd.bottom-rd.top); | |
968 } | |
969 else | |
970 { | |
971 rd.right = rd.left+guiIntfStruct.MovieWidth; | |
972 rd.bottom = rd.top+guiIntfStruct.MovieHeight; | |
973 | |
974 if (movie_aspect > 0.0) // forced aspect from the cmdline | |
975 sub_aspect = movie_aspect; | |
976 } | |
977 | |
19245 | 978 |
18914 | 979 AdjustWindowRect(&rd, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, 0); |
19245 | 980 SetWindowPos(mygui->subwindow, 0, x, y, rd.right-rd.left, rd.bottom-rd.top, SWP_NOOWNERZORDER); |
18914 | 981 |
982 wp.hwnd = mygui->subwindow; | |
983 wp.x = rd.left; | |
984 wp.y = rd.top; | |
985 wp.cx = rd.right-rd.left; | |
986 wp.cy = rd.bottom-rd.top; | |
987 wp.flags = SWP_NOOWNERZORDER | SWP_SHOWWINDOW; | |
988 | |
989 /* erase the bitmap image if there's video */ | |
990 if(guiIntfStruct.Playing != 0 && guiIntfStruct.sh_video) | |
991 SendMessage(mygui->subwindow, WM_ERASEBKGND, (WPARAM)GetDC(mygui->subwindow), 0); | |
992 | |
993 /* reset the window aspect */ | |
994 SendMessage(mygui->subwindow, WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp); | |
995 return 0; | |
996 } | |
997 | |
998 void guiEventHandling(void) {} |