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