52 #include <sys/ioctl.h> 58 #if defined(HAVE_VIDEO_CONSOLE) 67 struct grab_x11_desc {
75 static void *grab_x11_close(
void *
desc);
80 static void *grab_x11_open(
const char *
name,
struct fbuf_t *geom,
int fps)
84 struct grab_x11_desc *v;
88 if (strncasecmp(name,
"X11", 3))
95 v->dpy = XOpenDisplay(
NULL);
104 screen_num = DefaultScreen(v->dpy);
105 v->screen_width = DisplayWidth(v->dpy, screen_num);
106 v->screen_height = DisplayHeight(v->dpy, screen_num);
108 v->image = im = XGetImage(v->dpy,
109 RootWindow(v->dpy, DefaultScreen(v->dpy)),
110 b->
x, b->
y, b->
w, b->
h, AllPlanes, ZPixmap);
111 if (v->image ==
NULL) {
115 switch (im->bits_per_pixel) {
120 b->
pix_fmt = (im->green_mask == 0x7e0) ? PIX_FMT_RGB565 : PIX_FMT_RGB555;
128 im->red_mask, im->green_mask, im->blue_mask);
131 b->
data = (uint8_t *)im->data;
135 return grab_x11_close(v);
138 static struct fbuf_t *grab_x11_read(
void *
desc)
141 struct grab_x11_desc *v =
desc;
145 RootWindow(v->dpy, DefaultScreen(v->dpy)),
146 b->
x, b->
y, b->
w, b->
h, AllPlanes, ZPixmap, v->image, 0, 0);
148 b->
data = (uint8_t *)v->image->data;
152 static int boundary_checks(
int x,
int limit)
154 return (x <= 0) ? 0 : (x > limit ? limit :
x);
160 static void grab_x11_move(
void *desc,
int dx,
int dy)
162 struct grab_x11_desc *v =
desc;
164 v->b.x = boundary_checks(v->b.x + dx, v->screen_width - v->b.w);
165 v->b.y = boundary_checks(v->b.y + dy, v->screen_height - v->b.h);
169 static void *grab_x11_close(
void *desc)
171 struct grab_x11_desc *v =
desc;
174 XCloseDisplay(v->dpy);
181 static struct grab_desc grab_x11_desc = {
183 .open = grab_x11_open,
184 .read = grab_x11_read,
185 .move = grab_x11_move,
186 .close = grab_x11_close,
190 #ifdef HAVE_VIDEODEV_H 191 #include <linux/videodev.h> 193 struct grab_v4l1_desc {
202 static void *grab_v4l1_open(
const char *dev,
struct fbuf_t *geom,
int fps)
204 struct video_window vw = { 0 };
205 struct video_picture vp;
207 struct grab_v4l1_desc *v;
211 if (strncmp(dev,
"/dev/", 5))
213 fd = open(dev, O_RDONLY | O_NONBLOCK);
237 vw.flags = fps << 16;
238 if (ioctl(fd, VIDIOCSWIN, &vw) == -1) {
240 dev, strerror(
errno));
243 if (ioctl(fd, VIDIOCGPICT, &vp) == -1) {
248 "contrast %d bright %d colour %d hue %d white %d palette %d\n",
249 vp.contrast, vp.brightness,
251 vp.whiteness, vp.palette);
257 vp.palette = VIDEO_PALETTE_YUV420P;
258 if (ioctl(v->fd, VIDIOCSPICT, &vp) == -1) {
267 b->
size = (b->
w * b->
h * 3)/2;
269 dev, b->
w, b->
h, b->
size);
290 static struct fbuf_t *grab_v4l1_read(
void *desc)
292 struct grab_v4l1_desc *v =
desc;
296 r = read(v->fd, b->
data + b->
used, l);
311 static void *grab_v4l1_close(
void *desc)
313 struct grab_v4l1_desc *v =
desc;
323 static struct grab_desc grab_v4l1_desc = {
325 .open = grab_v4l1_open,
326 .read = grab_v4l1_read,
327 .close = grab_v4l1_close,
341 #ifdef HAVE_VIDEODEV_H
Asterisk main include file. File version handling, generic pbx functions.
void fbuf_free(struct fbuf_t *)
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
struct grab_desc * console_grabbers[]
#define ast_fd_set_flags(fd, flags)
Set flags on the given file descriptor.
#define ast_calloc(num, len)
A wrapper for calloc()
int error(const char *format,...)