53 #include <sys/ioctl.h>
59 #if defined(HAVE_VIDEO_CONSOLE)
68 struct grab_x11_desc {
76 static void *grab_x11_close(
void *
desc);
81 static void *grab_x11_open(
const char *
name,
struct fbuf_t *geom,
int fps)
85 struct grab_x11_desc *v;
89 if (strncasecmp(name,
"X11", 3))
96 v->dpy = XOpenDisplay(NULL);
105 screen_num = DefaultScreen(v->dpy);
106 v->screen_width = DisplayWidth(v->dpy, screen_num);
107 v->screen_height = DisplayHeight(v->dpy, screen_num);
109 v->image = im = XGetImage(v->dpy,
110 RootWindow(v->dpy, DefaultScreen(v->dpy)),
111 b->
x, b->
y, b->
w, b->
h, AllPlanes, ZPixmap);
112 if (v->image == NULL) {
116 switch (im->bits_per_pixel) {
121 b->
pix_fmt = (im->green_mask == 0x7e0) ? PIX_FMT_RGB565 : PIX_FMT_RGB555;
129 im->red_mask, im->green_mask, im->blue_mask);
132 b->
data = (uint8_t *)im->data;
136 return grab_x11_close(v);
139 static struct fbuf_t *grab_x11_read(
void *
desc)
142 struct grab_x11_desc *v =
desc;
146 RootWindow(v->dpy, DefaultScreen(v->dpy)),
147 b->
x, b->
y, b->
w, b->
h, AllPlanes, ZPixmap, v->image, 0, 0);
149 b->
data = (uint8_t *)v->image->data;
153 static int boundary_checks(
int x,
int limit)
155 return (x <= 0) ? 0 : (x > limit ? limit :
x);
161 static void grab_x11_move(
void *desc,
int dx,
int dy)
163 struct grab_x11_desc *v =
desc;
165 v->b.x = boundary_checks(v->b.x + dx, v->screen_width - v->b.w);
166 v->b.y = boundary_checks(v->b.y + dy, v->screen_height - v->b.h);
170 static void *grab_x11_close(
void *desc)
172 struct grab_x11_desc *v =
desc;
175 XCloseDisplay(v->dpy);
182 static struct grab_desc grab_x11_desc = {
184 .open = grab_x11_open,
185 .read = grab_x11_read,
186 .move = grab_x11_move,
187 .close = grab_x11_close,
191 #ifdef HAVE_VIDEODEV_H
192 #include <linux/videodev.h>
194 struct grab_v4l1_desc {
203 static void *grab_v4l1_open(
const char *dev,
struct fbuf_t *geom,
int fps)
205 struct video_window vw = { 0 };
206 struct video_picture vp;
208 struct grab_v4l1_desc *v;
212 if (strncmp(dev,
"/dev/", 5))
214 fd = open(dev, O_RDONLY | O_NONBLOCK);
230 i = fcntl(fd, F_GETFL);
231 if (-1 == fcntl(fd, F_SETFL, i | O_NONBLOCK)) {
234 dev, strerror(
errno));
242 vw.flags = fps << 16;
243 if (ioctl(fd, VIDIOCSWIN, &vw) == -1) {
245 dev, strerror(
errno));
248 if (ioctl(fd, VIDIOCGPICT, &vp) == -1) {
253 "contrast %d bright %d colour %d hue %d white %d palette %d\n",
254 vp.contrast, vp.brightness,
256 vp.whiteness, vp.palette);
262 vp.palette = VIDEO_PALETTE_YUV420P;
263 if (ioctl(v->fd, VIDIOCSPICT, &vp) == -1) {
272 b->
size = (b->
w * b->
h * 3)/2;
274 dev, b->
w, b->
h, b->
size);
295 static struct fbuf_t *grab_v4l1_read(
void *desc)
297 struct grab_v4l1_desc *v =
desc;
301 r = read(v->fd, b->
data + b->
used, l);
316 static void *grab_v4l1_close(
void *desc)
318 struct grab_v4l1_desc *v =
desc;
328 static struct grab_desc grab_v4l1_desc = {
330 .open = grab_v4l1_open,
331 .read = grab_v4l1_read,
332 .close = grab_v4l1_close,
346 #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[]
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.