1
|
1 /*
|
|
2 * video_out.c,
|
|
3 *
|
|
4 * Copyright (C) Aaron Holtzman - June 2000
|
|
5 *
|
|
6 * mpeg2dec is free software; you can redistribute it and/or modify
|
|
7 * it under the terms of the GNU General Public License as published by
|
|
8 * the Free Software Foundation; either version 2, or (at your option)
|
|
9 * any later version.
|
|
10 *
|
|
11 * mpeg2dec is distributed in the hope that it will be useful,
|
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 * GNU General Public License for more details.
|
|
15 *
|
|
16 * You should have received a copy of the GNU General Public License
|
|
17 * along with GNU Make; see the file COPYING. If not, write to
|
|
18 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
19 *
|
|
20 */
|
|
21
|
|
22 #include <stdio.h>
|
|
23 #include <stdlib.h>
|
|
24 #include <string.h>
|
|
25
|
|
26 #include <unistd.h>
|
|
27 #include <sys/mman.h>
|
|
28
|
|
29 #include "config.h"
|
|
30 #include "video_out.h"
|
|
31
|
|
32 #include "../linux/shmem.h"
|
|
33
|
|
34 //
|
|
35 // Externally visible list of all vo drivers
|
|
36 //
|
|
37
|
|
38 extern vo_functions_t video_out_mga;
|
|
39 extern vo_functions_t video_out_xmga;
|
|
40 extern vo_functions_t video_out_x11;
|
|
41 extern vo_functions_t video_out_xv;
|
|
42 extern vo_functions_t video_out_gl;
|
12
|
43 extern vo_functions_t video_out_dga;
|
1
|
44 extern vo_functions_t video_out_sdl;
|
|
45 extern vo_functions_t video_out_3dfx;
|
|
46 extern vo_functions_t video_out_null;
|
|
47 extern vo_functions_t video_out_odivx;
|
|
48 extern vo_functions_t video_out_pgm;
|
|
49 extern vo_functions_t video_out_md5;
|
|
50 extern vo_functions_t video_out_syncfb;
|
|
51
|
|
52 vo_functions_t* video_out_drivers[] =
|
|
53 {
|
|
54 #ifdef HAVE_MGA
|
|
55 #ifdef HAVE_X11
|
|
56 &video_out_xmga,
|
|
57 #endif
|
|
58 &video_out_mga,
|
|
59 #endif
|
|
60 #ifdef HAVE_SYNCFB
|
|
61 &video_out_syncfb,
|
|
62 #endif
|
|
63 #ifdef HAVE_3DFX
|
|
64 &video_out_3dfx,
|
|
65 #endif
|
|
66 #ifdef HAVE_XV
|
|
67 &video_out_xv,
|
|
68 #endif
|
|
69 #ifdef HAVE_X11
|
|
70 &video_out_x11,
|
|
71 #endif
|
|
72 #ifdef HAVE_GL
|
|
73 &video_out_gl,
|
|
74 #endif
|
12
|
75 #ifdef HAVE_DGA
|
|
76 &video_out_dga,
|
|
77 #endif
|
1
|
78 #ifdef HAVE_SDL
|
|
79 &video_out_sdl,
|
|
80 #endif
|
|
81 &video_out_null,
|
|
82 &video_out_odivx,
|
|
83 &video_out_pgm,
|
|
84 &video_out_md5,
|
|
85 NULL
|
|
86 };
|
|
87
|
|
88 #ifdef X11_FULLSCREEN
|
|
89
|
|
90 #include <X11/Xlib.h>
|
|
91 #include <X11/Xutil.h>
|
|
92 #include <X11/Xatom.h>
|
|
93
|
|
94 int vo_depthonscreen=0;
|
|
95 int vo_screenwidth=0;
|
|
96 int vo_screenheight=0;
|
|
97
|
|
98 int vo_init( void )
|
|
99 {
|
|
100 int CompletionType = -1;
|
|
101 int mScreen;
|
|
102 int bpp;
|
|
103 char * DisplayName = ":0.0";
|
|
104 Display * mDisplay;
|
|
105 XImage * mXImage;
|
|
106 Window mRootWin;
|
|
107 static XWindowAttributes attribs;
|
|
108
|
|
109 if(vo_depthonscreen) return 1; // already called
|
|
110
|
|
111 if ( getenv( "DISPLAY" ) ) DisplayName=getenv( "DISPLAY" );
|
|
112 mDisplay=XOpenDisplay( DisplayName );
|
|
113 if ( !mDisplay )
|
|
114 {
|
|
115 fprintf( stderr,"vo: couldn't open the X11 display!\n" );
|
|
116 return 0;
|
|
117 }
|
|
118 mScreen=DefaultScreen( mDisplay ); // Screen ID.
|
|
119 mRootWin=RootWindow( mDisplay,mScreen );// Root window ID.
|
|
120 vo_screenwidth=DisplayWidth( mDisplay,mScreen );
|
|
121 vo_screenheight=DisplayHeight( mDisplay,mScreen );
|
|
122 // get color depth:
|
|
123 // XGetWindowAttributes(mydisplay, DefaultRootWindow(mDisplay), &attribs);
|
|
124 XGetWindowAttributes(mDisplay, mRootWin, &attribs);
|
|
125 vo_depthonscreen=attribs.depth;
|
|
126 // get bits/pixel:
|
|
127 mXImage=XGetImage( mDisplay,mRootWin,0,0,1,1,AllPlanes,ZPixmap );
|
|
128 bpp=mXImage->bits_per_pixel;
|
|
129 XDestroyImage( mXImage );
|
|
130 if((vo_depthonscreen+7)/8 != (bpp+7)/8) vo_depthonscreen=bpp; // by A'rpi
|
|
131 XCloseDisplay( mDisplay );
|
|
132 printf("X11 running at %dx%d depth: %d\n",vo_screenwidth,vo_screenheight,vo_depthonscreen);
|
|
133 return 1;
|
|
134 }
|
|
135
|
|
136 #include "../linux/keycodes.h"
|
|
137 extern void mplayer_put_key(int code);
|
|
138
|
|
139 void vo_keyboard( int key )
|
|
140 {
|
|
141 switch ( key )
|
|
142 {
|
|
143 case wsLeft: mplayer_put_key(KEY_LEFT); break;
|
|
144 case wsRight: mplayer_put_key(KEY_RIGHT); break;
|
|
145 case wsUp: mplayer_put_key(KEY_UP); break;
|
|
146 case wsDown: mplayer_put_key(KEY_DOWN); break;
|
|
147 case wsSpace: mplayer_put_key(' '); break;
|
|
148 case wsEscape: mplayer_put_key(KEY_ESC); break;
|
|
149 case wsEnter: mplayer_put_key(KEY_ENTER); break;
|
|
150 case wsq:
|
|
151 case wsQ: mplayer_put_key('q'); break;
|
|
152 case wsp:
|
|
153 case wsP: mplayer_put_key('p'); break;
|
|
154 case wsMinus:
|
|
155 case wsGrayMinus: mplayer_put_key('-'); break;
|
|
156 case wsPlus:
|
|
157 case wsGrayPlus: mplayer_put_key('+'); break;
|
|
158 }
|
|
159 }
|
|
160
|
|
161
|
|
162 // ----- Motif header: -------
|
|
163
|
|
164 #define MWM_HINTS_DECORATIONS 2
|
|
165
|
|
166 typedef struct
|
|
167 {
|
|
168 long flags;
|
|
169 long functions;
|
|
170 long decorations;
|
|
171 long input_mode;
|
|
172 } MotifWmHints;
|
|
173
|
|
174 extern MotifWmHints vo_MotifWmHints;
|
|
175 extern Atom vo_MotifHints;
|
|
176 extern int vo_depthonscreen;
|
|
177 extern int vo_screenwidth;
|
|
178 extern int vo_screenheight;
|
|
179
|
|
180 static MotifWmHints vo_MotifWmHints;
|
|
181 static Atom vo_MotifHints = None;
|
|
182
|
|
183 void vo_decoration( Display * vo_Display,Window w,int d )
|
|
184 {
|
|
185 vo_MotifHints=XInternAtom( vo_Display,"_MOTIF_WM_HINTS",0 );
|
|
186 if ( vo_MotifHints != None )
|
|
187 {
|
|
188 vo_MotifWmHints.flags=2;
|
|
189 vo_MotifWmHints.decorations=d;
|
|
190 XChangeProperty( vo_Display,w,vo_MotifHints,vo_MotifHints,32,
|
|
191 PropModeReplace,(unsigned char *)&vo_MotifWmHints,4 );
|
|
192 }
|
|
193 }
|
|
194
|
|
195 #include <signal.h>
|
|
196
|
|
197 int vo_eventhandler_pid=-1;
|
|
198
|
|
199 void vo_kill_eventhandler(){
|
|
200 if(vo_eventhandler_pid!=-1) kill(vo_eventhandler_pid,SIGTERM);
|
|
201
|
|
202 }
|
|
203
|
|
204 #endif
|
|
205
|