1 /*
2  *  display.h
3  *
4  *     Copyright (C) Charles 'Buck' Krasic - April 2000
5  *     Copyright (C) Erik Walthinsen - April 2000
6  *
7  *  This file is part of libdv, a free DV (IEC 61834/SMPTE 314M)
8  *  codec.
9  *
10  *  libdv is free software; you can redistribute it and/or modify it
11  *  under the terms of the GNU Lesser Public License as published by
12  *  the Free Software Foundation; either version 2.1, or (at your
13  *  option) any later version.
14  *
15  *  libdv is distributed in the hope that it will be useful, but
16  *  WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  *  Lesser Public License for more details.
19  *
20  *  You should have received a copy of the GNU Lesser Public License
21  *  along with libdv; see the file COPYING.  If not, write to
22  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23  *
24  *  The libdv homepage is http://libdv.sourceforge.net/.
25  */
26 
27 #ifndef DV_DISPLAY_H
28 #define DV_DISPLAY_H
29 
30 #if HAVE_CONFIG_H
31 # include <config.h>
32 #endif
33 
34 #include "libdv/dv_types.h"
35 #include <gtk/gtk.h>
36 
37 #if HAVE_LIBXV
38 #include <X11/Xlib.h>
39 #include <X11/Xutil.h>
40 #include <X11/keysym.h>
41 #include <X11/extensions/XShm.h>
42 #include <X11/extensions/Xvlib.h>
43 #endif // HAVE_LIBXV
44 
45 #if HAVE_SDL
46 #include <SDL/SDL.h>
47 #include <SDL/SDL_syswm.h>
48 #endif // HAVE_SDL
49 
50 #if HAVE_GTK
51 #include <gtk/gtk.h>
52 #endif // HAVE_GTK
53 
54 #define DV_FOURCC_YV12  0x32315659	/* 4:2:0 Planar mode: Y + V + U  (3 planes) */
55 #define DV_FOURCC_YUY2  0x32595559	/* 4:2:2 Packed mode: Y0+U0+Y1+V0 (1 plane) */
56 
57 #if HAVE_LIBXV
58 #define DV_DISPLAY_OPT_METHOD   0
59 #define DV_DISPLAY_OPT_ASPECT	1
60 #define DV_DISPLAY_OPT_SIZE	2
61 #define DV_DISPLAY_OPT_CALLBACK 3
62 #define DV_DISPLAY_OPT_XV_PORT  4
63 #define DV_DISPLAY_NUM_OPTS     5
64 #else
65 #define DV_DISPLAY_OPT_METHOD   0
66 #define DV_DISPLAY_OPT_CALLBACK 1
67 #define DV_DISPLAY_NUM_OPTS     2
68 #endif /* HAVE_LIBXV */
69 
70 typedef enum dv_dpy_lib_e {
71   e_dv_dpy_Xv,
72   e_dv_dpy_SDL,
73   e_dv_dpy_gtk,
74   e_dv_dpy_XShm,
75 } dv_dpy_lib_t;
76 
77 typedef struct {
78   dv_color_space_t color_space;
79   gint		    width, height;
80   guchar           *pixels[3];
81   gint              pitches[3];
82 
83   /* Begin Private */
84   dv_dpy_lib_t      lib;
85   guint32           len;
86   guint32           format;   /* fourcc code for YUV modes */
87 
88 #if HAVE_LIBXV
89   /* -----------------------------------------------------------
90    * Xv specific members
91    */
92   Display          *dpy;
93   Screen           *scn;
94   Window            rwin, win;
95   gint		    dwidth, dheight,
96 		    swidth, sheight,
97 		    lwidth, lheight,
98 		    lxoff, lyoff,
99 		    flags,
100 		    pic_format;
101   GC                gc;
102   XEvent            event;
103   XvPortID	    port;
104   XShmSegmentInfo   shminfo;
105   XvImage          *xv_image;
106 #endif // HAVE_LIBXV
107 
108 #if HAVE_GTK
109   /* -----------------------------------------------------------
110    * GDK specific members
111    */
112   GtkWidget	   *window, *image;
113 #endif
114 
115 #if HAVE_SDL
116   SDL_Surface* sdl_screen;
117   SDL_Overlay *overlay;
118   SDL_Rect rect;
119 #endif
120 
121   gint 			arg_display,
122 			arg_aspect_val,
123 			arg_size_val,
124 			arg_xv_port;
125   gchar			*arg_aspect_string;
126 
127 #if HAVE_LIBPOPT
128   struct poptOption	option_table[DV_DISPLAY_NUM_OPTS+1];
129 #endif // HAVE_LIBPOPT
130 } dv_display_t;
131 
132 #ifdef __cplusplus
133 extern "C" {
134 #endif
135 
136 extern dv_display_t *dv_display_new(void);
137 extern gboolean      dv_display_init(dv_display_t *dpy,
138 				     int *argc, char ***argv,
139 				     int width, int height,
140 				     dv_sample_t sampling,
141 				     char *w_name, char *i_name); // dv_display_init
142 
143 extern void dv_display_show(dv_display_t *dv_dpy);
144 extern void dv_display_exit(dv_display_t *dv_dpy);
145 extern void dv_display_set_norm (dv_display_t *dv_dpy, dv_system_t norm);
146 extern void dv_display_check_format(dv_display_t *dv_dpy, int pic_format);
147 
148 #ifdef __cplusplus
149 }
150 #endif
151 
152 #endif // DV_DISPLAY_H
153 
154