Mercurial > mplayer.hg
annotate Gui/interface.c @ 6687:b5cd3ce87bfb
very simple script to generate png images from an video with all -sws methods
author | michael |
---|---|
date | Tue, 09 Jul 2002 21:53:29 +0000 |
parents | 8f49c75a2824 |
children | cc917a581b6e |
rev | line source |
---|---|
6280 | 1 |
4845 | 2 #include <inttypes.h> |
3 #include <stdlib.h> | |
4 #include <stdio.h> | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
5 #include <string.h> |
4798 | 6 |
7 #include "ws.h" | |
8 #include "mplayer/play.h" | |
9 #include "interface.h" | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
10 #include "skin/skin.h" |
6627 | 11 #include "mplayer/gtk/eq.h" |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
12 |
4798 | 13 #include "../mplayer.h" |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
14 #include "mplayer/widgets.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
15 #include "mplayer/mplayer.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
16 #include "app.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
17 #include "../libvo/x11_common.h" |
5789 | 18 #include "../libvo/video_out.h" |
4858 | 19 #include "../input/input.h" |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
20 #include "../libao2/audio_out.h" |
6627 | 21 #include "../mixer.h" |
22 #include "../libao2/audio_plugin.h" | |
23 #include "../libao2/eq.h" | |
5789 | 24 |
6280 | 25 #include <inttypes.h> |
26 #include <sys/types.h> | |
27 | |
5665 | 28 #include "../libmpdemux/stream.h" |
5789 | 29 #include "../libmpdemux/demuxer.h" |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
30 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
31 guiInterface_t guiIntfStruct; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
32 |
6627 | 33 char * gstrcat( char ** dest,char * src ) |
34 { | |
35 char * tmp = NULL; | |
36 | |
37 if ( !src ) return NULL; | |
38 | |
39 if ( *dest ) | |
40 { | |
41 tmp=malloc( strlen( *dest ) + strlen( src ) + 1 ); | |
42 strcpy( tmp,*dest ); strcat( tmp,src ); free( *dest ); | |
43 } | |
44 else | |
45 { tmp=malloc( strlen( src ) + 1 ); strcpy( tmp,src ); } | |
46 *dest=tmp; | |
47 return tmp; | |
48 } | |
49 | |
6218 | 50 void guiInit( void ) |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
51 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
52 memset( &guiIntfStruct,0,sizeof( guiIntfStruct ) ); |
6627 | 53 memset( >kEquChannels,0,sizeof( gtkEquChannels ) ); |
6218 | 54 appInit( (void*)mDisplay ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
55 } |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
56 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
57 void guiDone( void ) |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
58 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
59 mp_msg( MSGT_GPLAYER,MSGL_V,"[mplayer] exit.\n" ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
60 mplStop(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
61 gtkDone(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
62 wsXDone(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
63 } |
4798 | 64 |
4858 | 65 int guiCMDArray[] = |
66 { | |
67 evLoad, | |
68 evLoadSubtitle, | |
69 evAbout, | |
70 evPlay, | |
71 evStop, | |
72 evPlayList, | |
73 evPreferences, | |
74 evFullScreen, | |
75 evSkinBrowser | |
76 }; | |
77 | |
5789 | 78 typedef struct |
79 { | |
80 demux_stream_t *ds; | |
81 unsigned int format; | |
82 struct codecs_st *codec; | |
83 int inited; | |
84 // output format: | |
85 float timer; | |
86 float fps; | |
87 float frametime; | |
88 int i_bps; | |
89 int disp_w,disp_h; | |
90 } tmp_sh_video_t; | |
91 | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
92 extern ao_functions_t * audio_out; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
93 |
4798 | 94 void guiGetEvent( int type,char * arg ) |
95 { | |
6280 | 96 stream_t * stream = (stream_t *) arg; |
5672
1f8b34f1e7c0
ifdef reading dvd args, without it non-dvd compilation fails.
eyck
parents:
5665
diff
changeset
|
97 #ifdef USE_DVDREAD |
5665 | 98 dvd_priv_t * dvdp = (dvd_priv_t *) arg; |
5672
1f8b34f1e7c0
ifdef reading dvd args, without it non-dvd compilation fails.
eyck
parents:
5665
diff
changeset
|
99 #endif |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
100 |
4798 | 101 switch ( type ) |
102 { | |
103 case guiXEvent: | |
104 wsEvents( wsDisplay,(XEvent *)arg,NULL ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
105 gtkEventHandling(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
106 break; |
4798 | 107 case guiCEvent: |
4963 | 108 switch ( (int)arg ) |
109 { | |
110 case guiSetPlay: guiIntfStruct.Playing=1; mplState(); break; | |
111 case guiSetStop: guiIntfStruct.Playing=0; mplState(); break; | |
112 case guiSetPause: guiIntfStruct.Playing=2; mplState(); break; | |
113 } | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
114 break; |
5665 | 115 case guiSetState: |
116 mplState(); | |
117 break; | |
118 case guiSetFileName: | |
119 if ( arg ) guiSetFilename( guiIntfStruct.Filename,arg ); | |
120 break; | |
5789 | 121 case guiSetAudioOnly: |
122 guiIntfStruct.AudioOnly=(int)arg; | |
123 if ( (int)arg ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); | |
124 else wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); | |
125 break; | |
126 case guiReDrawSubWindow: | |
127 wsPostRedisplay( &appMPlayer.subWindow ); | |
5956 | 128 if ( guiIntfStruct.Playing == 1 ) wsSetBackgroundRGB( &appMPlayer.subWindow,0,0,0 ); |
5789 | 129 break; |
130 case guiSetShVideo: | |
131 { | |
5986 | 132 if ( !appMPlayer.subWindow.isFullScreen ) |
133 { | |
134 wsResizeWindow( &appMPlayer.subWindow,vo_dwidth,vo_dheight ); | |
135 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); | |
136 } | |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
137 guiIntfStruct.MovieWidth=vo_dwidth; |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
138 guiIntfStruct.MovieHeight=vo_dheight; |
5789 | 139 } |
140 break; | |
5665 | 141 #ifdef USE_DVDREAD |
142 case guiSetDVD: | |
143 guiIntfStruct.DVD.titles=dvdp->vmg_file->tt_srpt->nr_of_srpts; | |
144 guiIntfStruct.DVD.chapters=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts; | |
145 guiIntfStruct.DVD.angles=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; | |
146 guiIntfStruct.DVD.nr_of_audio_channels=dvdp->nr_of_channels; | |
147 memcpy( guiIntfStruct.DVD.audio_streams,dvdp->audio_streams,sizeof( dvdp->audio_streams ) ); | |
148 guiIntfStruct.DVD.nr_of_subtitles=dvdp->nr_of_subtitles; | |
149 memcpy( guiIntfStruct.DVD.subtitles,dvdp->subtitles,sizeof( dvdp->subtitles ) ); | |
150 guiIntfStruct.DVD.current_title=dvd_title + 1; | |
151 guiIntfStruct.DVD.current_chapter=dvd_chapter + 1; | |
152 guiIntfStruct.DVD.current_angle=dvd_angle + 1; | |
153 guiIntfStruct.Track=dvd_title + 1; | |
154 break; | |
155 #endif | |
6280 | 156 case guiSetStream: |
157 guiIntfStruct.StreamType=stream->type; | |
158 switch( stream->type ) | |
159 { | |
160 case STREAMTYPE_DVD: | |
161 guiGetEvent( guiSetDVD,(char *)stream->priv ); | |
162 break; | |
163 #ifdef HAVE_VCD | |
164 case STREAMTYPE_VCD: | |
165 { | |
166 int i; | |
167 for ( i=1;i < 100;i++ ) | |
168 if ( vcd_seek_to_track( stream->fd,i ) < 0 ) break; | |
169 vcd_seek_to_track( stream->fd,vcd_track ); | |
170 guiIntfStruct.VCDTracks=--i; | |
171 mp_msg( MSGT_GPLAYER,MSGL_INFO,"[interface] vcd tracks: %d\n",guiIntfStruct.VCDTracks ); | |
172 guiIntfStruct.Track=vcd_track; | |
173 break; | |
174 } | |
175 #endif | |
176 } | |
177 break; | |
5120 | 178 #ifdef HAVE_NEW_INPUT |
4858 | 179 case guiIEvent: |
180 printf( "cmd: %d\n",(int)arg ); | |
181 switch( (int)arg ) | |
182 { | |
183 case MP_CMD_QUIT: | |
184 mplEventHandling( evExit,0 ); | |
185 break; | |
186 case MP_CMD_VO_FULLSCREEN: | |
187 mplEventHandling( evFullScreen,0 ); | |
188 break; | |
189 default: | |
190 mplEventHandling( guiCMDArray[ (int)arg - MP_CMD_GUI_EVENTS - 1 ],0 ); | |
191 } | |
192 break; | |
5120 | 193 #endif |
6280 | 194 case guiClearStruct: |
195 #ifdef USE_DVDREAD | |
196 if ( (unsigned int)arg & guiDVD ) memset( &guiIntfStruct.DVD,0,sizeof( guiDVDStruct ) ); | |
197 #endif | |
198 #ifdef HAVE_VCD | |
199 if ( (unsigned int)arg & guiVCD ) guiIntfStruct.VCDTracks=0; | |
200 #endif | |
201 break; | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
202 case guiReDraw: |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
203 mplEventHandling( evRedraw,0 ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
204 break; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
205 case guiSetVolume: |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
206 if ( audio_out ) |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
207 { |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
208 float l,r; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
209 mixer_getvolume( &l,&r ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
210 guiIntfStruct.Volume=(r>l?r:l); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
211 if ( r != l ) guiIntfStruct.Balance=( ( r - l ) + 100 ) * 0.5f; |
6627 | 212 else guiIntfStruct.Balance=50.0f; |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
213 btnModify( evSetVolume,guiIntfStruct.Volume ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
214 btnModify( evSetBalance,guiIntfStruct.Balance ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
215 } |
6627 | 216 |
217 if ( gtkEnableVideoEqualizer ) | |
218 { | |
219 gtkSet( gtkSetContrast,gtkContrast,NULL ); | |
220 gtkSet( gtkSetBrightness,gtkBrightness,NULL ); | |
221 gtkSet( gtkSetHue,gtkHue,NULL ); | |
222 gtkSet( gtkSetSaturation,gtkSaturation,NULL ); | |
223 } | |
224 if ( gtkEnableAudioEqualizer ) | |
225 { | |
226 equalizer_t eq; | |
227 int i,j; | |
228 for ( i=0;i<6;i++ ) | |
229 for ( j=0;j<10;j++ ) | |
230 { | |
231 eq.channel=i; eq.band=j; eq.gain=gtkEquChannels[i][j]; | |
232 gtkSet( gtkSetEqualizer,0,&eq ); | |
233 } | |
234 } | |
235 break; | |
236 case guiSetDefaults: | |
237 #if defined( HAVE_VCD ) || defined( USE_DVDREAD ) | |
238 if ( guiIntfStruct.DiskChanged ) | |
239 { | |
6651 | 240 /* |
6627 | 241 #ifdef USE_DVDREAD |
242 switch ( guiIntfStruct.StreamType ) | |
243 { | |
244 case STREAMTYPE_DVD: filename=DEFAULT_DVD_DEVICE; break; | |
245 } | |
246 #endif | |
6651 | 247 */ |
6627 | 248 guiIntfStruct.DiskChanged=0; |
249 guiGetEvent( guiCEvent,(char *)guiSetPlay ); | |
250 } | |
251 #endif | |
252 | |
253 #ifdef USE_SUB | |
254 if ( guiIntfStruct.SubtitleChanged || !guiIntfStruct.FilenameChanged ) | |
255 { | |
256 if ( ( guiIntfStruct.Subtitlename )&&( guiIntfStruct.Subtitlename[0] != 0 ) ) sub_name=guiIntfStruct.Subtitlename; | |
257 guiIntfStruct.SubtitleChanged=0; | |
258 } | |
259 #endif | |
260 | |
261 if ( guiIntfStruct.AudioFile ) audio_stream=guiIntfStruct.AudioFile; | |
262 else if ( guiIntfStruct.FilenameChanged ) audio_stream=NULL; | |
263 | |
264 if ( gtkEnableAudioEqualizer ) | |
265 { | |
266 if ( ao_plugin_cfg.plugin_list ) { if ( !strstr( ao_plugin_cfg.plugin_list,"eq" ) ) gstrcat( &ao_plugin_cfg.plugin_list,"," ); } | |
267 else gstrcat( &ao_plugin_cfg.plugin_list,"eq" ); | |
268 } | |
269 | |
270 break; | |
4798 | 271 } |
272 } | |
273 | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
274 extern unsigned int GetTimerMS( void ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
275 extern int mplTimer; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
276 |
4798 | 277 void guiEventHandling( void ) |
278 { | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
279 if ( !guiIntfStruct.Playing || guiIntfStruct.AudioOnly ) wsHandleEvents(); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
280 gtkEventHandling(); |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
281 mplTimer=GetTimerMS() / 20; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
282 // if ( !( GetTimerMS()%2 ) ) |
4798 | 283 } |
6627 | 284 |
285 // --- | |
286 | |
287 float gtkContrast = 0.0f; | |
288 float gtkBrightness = 0.0f; | |
289 float gtkHue = 0.0f; | |
290 float gtkSaturation = 0.0f; | |
291 | |
292 float gtkEquChannels[6][10]; | |
293 | |
294 void gtkSet( int cmd,float fparam, void * vparam ) | |
295 { | |
296 mp_cmd_t * mp_cmd = (mp_cmd_t *)calloc( 1,sizeof( *mp_cmd ) ); | |
297 equalizer_t * eq = (equalizer_t *)vparam; | |
298 | |
299 switch ( cmd ) | |
300 { | |
301 case gtkSetContrast: | |
302 mp_cmd->id=MP_CMD_CONTRAST; mp_cmd->name=strdup( "contrast" ); | |
303 gtkContrast=fparam; | |
304 break; | |
305 case gtkSetBrightness: | |
306 mp_cmd->id=MP_CMD_BRIGHTNESS; mp_cmd->name=strdup( "brightness" ); | |
307 gtkBrightness=fparam; | |
308 break; | |
309 case gtkSetHue: | |
310 mp_cmd->id=MP_CMD_HUE; mp_cmd->name=strdup( "hue" ); | |
311 gtkHue=fparam; | |
312 break; | |
313 case gtkSetSaturation: | |
314 mp_cmd->id=MP_CMD_SATURATION; mp_cmd->name=strdup( "saturation" ); | |
315 gtkSaturation=fparam; | |
316 break; | |
317 case gtkSetEqualizer: | |
318 if ( eq ) | |
319 { | |
320 gtkEquChannels[eq->channel][eq->band]=eq->gain; | |
321 audio_plugin_eq.control( AOCONTROL_PLUGIN_EQ_SET_GAIN,(int)eq ); | |
322 } | |
323 else | |
324 { | |
325 int i,j; equalizer_t tmp; tmp.gain=0.0f; | |
326 memset( gtkEquChannels,0,sizeof( gtkEquChannels ) ); | |
327 for ( i=0;i<6;i++ ) | |
328 for ( j=0;j<10;j++ ) | |
329 { tmp.channel=i; tmp.band=j; audio_plugin_eq.control( AOCONTROL_PLUGIN_EQ_SET_GAIN,(int)&tmp ); } | |
330 } | |
331 return; | |
332 default: free( mp_cmd ); return; | |
333 } | |
334 mp_cmd->args[0].v.i=(int)fparam; | |
335 mp_cmd->args[1].v.i=1; | |
336 mp_input_queue_cmd( mp_cmd ); | |
337 } |