x11grab: Check the XQueryPointer return value
[libav.git] / libavdevice / x11grab.c
1 /*
2 * X11 video grab interface
3 *
4 * This file is part of Libav.
5 *
6 * Libav integration:
7 * Copyright (C) 2006 Clemens Fruhwirth <clemens@endorphin.org>
8 * Edouard Gomez <ed.gomez@free.fr>
9 *
10 * This file contains code from grab.c:
11 * Copyright (c) 2000-2001 Fabrice Bellard
12 *
13 * This file contains code from the xvidcap project:
14 * Copyright (C) 1997-1998 Rasca, Berlin
15 * 2003-2004 Karl H. Beckers, Frankfurt
16 *
17 * Libav is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 *
22 * Libav is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with Libav; if not, write to the Free Software
29 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 */
31
32 /**
33 * @file
34 * X11 frame device demuxer
35 * @author Clemens Fruhwirth <clemens@endorphin.org>
36 * @author Edouard Gomez <ed.gomez@free.fr>
37 */
38
39 #include "config.h"
40
41 #include <time.h>
42 #include <sys/shm.h>
43
44 #include <X11/X.h>
45 #include <X11/Xlib.h>
46 #include <X11/Xlibint.h>
47 #include <X11/Xproto.h>
48 #include <X11/Xutil.h>
49
50 #include <X11/extensions/shape.h>
51 #include <X11/extensions/Xfixes.h>
52 #include <X11/extensions/XShm.h>
53
54 #include "libavutil/log.h"
55 #include "libavutil/opt.h"
56 #include "libavutil/parseutils.h"
57 #include "libavutil/time.h"
58
59 #include "libavformat/avformat.h"
60 #include "libavformat/internal.h"
61
62 /** X11 device demuxer context */
63 typedef struct X11GrabContext {
64 const AVClass *class; /**< Class for private options. */
65 int frame_size; /**< Size in bytes of a grabbed frame */
66 AVRational time_base; /**< Time base */
67 int64_t time_frame; /**< Current time */
68
69 char *video_size; /**< String describing video size, set by a private option. */
70 int height; /**< Height of the grab frame */
71 int width; /**< Width of the grab frame */
72 int x_off; /**< Horizontal top-left corner coordinate */
73 int y_off; /**< Vertical top-left corner coordinate */
74
75 Display *dpy; /**< X11 display from which x11grab grabs frames */
76 XImage *image; /**< X11 image holding the grab */
77 int use_shm; /**< !0 when using XShm extension */
78 XShmSegmentInfo shminfo; /**< When using XShm, keeps track of XShm infos */
79 int draw_mouse; /**< Set by a private option. */
80 int follow_mouse; /**< Set by a private option. */
81 int show_region; /**< set by a private option. */
82 char *framerate; /**< Set by a private option. */
83
84 Window region_win; /**< This is used by show_region option. */
85 } X11GrabContext;
86
87 #define REGION_WIN_BORDER 3
88
89 /**
90 * Draw grabbing region window
91 *
92 * @param s x11grab context
93 */
94 static void x11grab_draw_region_win(X11GrabContext *s)
95 {
96 Display *dpy = s->dpy;
97 Window win = s->region_win;
98 int screen = DefaultScreen(dpy);
99 GC gc = XCreateGC(dpy, win, 0, 0);
100
101 XSetForeground(dpy, gc, WhitePixel(dpy, screen));
102 XSetBackground(dpy, gc, BlackPixel(dpy, screen));
103 XSetLineAttributes(dpy, gc, REGION_WIN_BORDER, LineDoubleDash, 0, 0);
104 XDrawRectangle(dpy, win, gc, 1, 1,
105 (s->width + REGION_WIN_BORDER * 2) - 1 * 2 - 1,
106 (s->height + REGION_WIN_BORDER * 2) - 1 * 2 - 1);
107 XFreeGC(dpy, gc);
108 }
109
110 /**
111 * Initialize grabbing region window
112 *
113 * @param s x11grab context
114 */
115 static void x11grab_region_win_init(X11GrabContext *s)
116 {
117 Display *dpy = s->dpy;
118 XRectangle rect;
119 XSetWindowAttributes attribs = { .override_redirect = True };
120 int screen = DefaultScreen(dpy);
121
122 s->region_win = XCreateWindow(dpy, RootWindow(dpy, screen),
123 s->x_off - REGION_WIN_BORDER,
124 s->y_off - REGION_WIN_BORDER,
125 s->width + REGION_WIN_BORDER * 2,
126 s->height + REGION_WIN_BORDER * 2,
127 0, CopyFromParent,
128 InputOutput, CopyFromParent,
129 CWOverrideRedirect, &attribs);
130 rect.x = 0;
131 rect.y = 0;
132 rect.width = s->width;
133 rect.height = s->height;
134 XShapeCombineRectangles(dpy, s->region_win,
135 ShapeBounding, REGION_WIN_BORDER, REGION_WIN_BORDER,
136 &rect, 1, ShapeSubtract, 0);
137 XMapWindow(dpy, s->region_win);
138 XSelectInput(dpy, s->region_win, ExposureMask | StructureNotifyMask);
139 x11grab_draw_region_win(s);
140 }
141
142 static int setup_shm(AVFormatContext *s, Display *dpy, XImage **image)
143 {
144 X11GrabContext *g = s->priv_data;
145 int scr = XDefaultScreen(dpy);
146 XImage *img = XShmCreateImage(dpy, DefaultVisual(dpy, scr),
147 DefaultDepth(dpy, scr), ZPixmap, NULL,
148 &g->shminfo, g->width, g->height);
149
150 g->shminfo.shmid = shmget(IPC_PRIVATE, img->bytes_per_line * img->height,
151 IPC_CREAT | 0777);
152
153 if (g->shminfo.shmid == -1) {
154 av_log(s, AV_LOG_ERROR, "Cannot get shared memory!\n");
155 return AVERROR(ENOMEM);
156 }
157
158 g->shminfo.shmaddr = img->data = shmat(g->shminfo.shmid, 0, 0);
159 g->shminfo.readOnly = False;
160
161 if (!XShmAttach(dpy, &g->shminfo)) {
162 av_log(s, AV_LOG_ERROR, "Failed to attach shared memory!\n");
163 /* needs some better error subroutine :) */
164 return AVERROR(EIO);
165 }
166
167 *image = img;
168 return 0;
169 }
170
171 static int setup_mouse(Display *dpy, int screen)
172 {
173 int ev_ret, ev_err;
174
175 if (XFixesQueryExtension(dpy, &ev_ret, &ev_err)) {
176 Window root = RootWindow(dpy, screen);
177 XFixesSelectCursorInput(dpy, root, XFixesDisplayCursorNotifyMask);
178 return 0;
179 }
180
181 return AVERROR(ENOSYS);
182 }
183
184 static int pixfmt_from_image(AVFormatContext *s, XImage *image, int *pix_fmt)
185 {
186 av_log(s, AV_LOG_DEBUG,
187 "Image r 0x%.6lx g 0x%.6lx b 0x%.6lx and depth %i\n",
188 image->red_mask,
189 image->green_mask,
190 image->blue_mask,
191 image->bits_per_pixel);
192
193 switch (image->bits_per_pixel) {
194 case 8:
195 *pix_fmt = AV_PIX_FMT_PAL8;
196 break;
197 case 16:
198 if (image->red_mask == 0xf800 &&
199 image->green_mask == 0x07e0 &&
200 image->blue_mask == 0x001f) {
201 *pix_fmt = AV_PIX_FMT_RGB565;
202 } else if (image->red_mask == 0x7c00 &&
203 image->green_mask == 0x03e0 &&
204 image->blue_mask == 0x001f) {
205 *pix_fmt = AV_PIX_FMT_RGB555;
206 }
207 break;
208 case 24:
209 if (image->red_mask == 0xff0000 &&
210 image->green_mask == 0x00ff00 &&
211 image->blue_mask == 0x0000ff) {
212 *pix_fmt = AV_PIX_FMT_BGR24;
213 } else if (image->red_mask == 0x0000ff &&
214 image->green_mask == 0x00ff00 &&
215 image->blue_mask == 0xff0000) {
216 *pix_fmt = AV_PIX_FMT_RGB24;
217 }
218 break;
219 case 32:
220 *pix_fmt = AV_PIX_FMT_RGB32;
221 break;
222 default:
223 av_log(s, AV_LOG_ERROR,
224 "XImages with RGB mask 0x%.6lx 0x%.6lx 0x%.6lx and depth %i "
225 "are currently not supported.\n",
226 image->red_mask,
227 image->green_mask,
228 image->blue_mask,
229 image->bits_per_pixel);
230
231 return AVERROR_PATCHWELCOME;
232 }
233
234 return 0;
235 }
236
237 /**
238 * Initialize the x11 grab device demuxer (public device demuxer API).
239 *
240 * @param s1 Context from avformat core
241 * @return <ul>
242 * <li>AVERROR(ENOMEM) no memory left</li>
243 * <li>AVERROR(EIO) other failure case</li>
244 * <li>0 success</li>
245 * </ul>
246 */
247 static int x11grab_read_header(AVFormatContext *s1)
248 {
249 X11GrabContext *x11grab = s1->priv_data;
250 Display *dpy;
251 AVStream *st = NULL;
252 XImage *image;
253 int x_off = 0, y_off = 0, ret = 0, screen, use_shm;
254 char *param, *offset;
255 AVRational framerate;
256
257 param = av_strdup(s1->filename);
258 if (!param)
259 goto out;
260
261 offset = strchr(param, '+');
262 if (offset) {
263 sscanf(offset, "%d,%d", &x_off, &y_off);
264 x11grab->draw_mouse = !strstr(offset, "nomouse");
265 *offset = 0;
266 }
267
268 ret = av_parse_video_size(&x11grab->width, &x11grab->height,
269 x11grab->video_size);
270 if (ret < 0) {
271 av_log(s1, AV_LOG_ERROR, "Couldn't parse video size.\n");
272 goto out;
273 }
274
275 ret = av_parse_video_rate(&framerate, x11grab->framerate);
276 if (ret < 0) {
277 av_log(s1, AV_LOG_ERROR, "Could not parse framerate: %s.\n",
278 x11grab->framerate);
279 goto out;
280 }
281 av_log(s1, AV_LOG_INFO,
282 "device: %s -> display: %s x: %d y: %d width: %d height: %d\n",
283 s1->filename, param, x_off, y_off, x11grab->width, x11grab->height);
284
285 dpy = XOpenDisplay(param);
286 if (!dpy) {
287 av_log(s1, AV_LOG_ERROR, "Could not open X display.\n");
288 ret = AVERROR(EIO);
289 goto out;
290 }
291
292 st = avformat_new_stream(s1, NULL);
293 if (!st) {
294 ret = AVERROR(ENOMEM);
295 goto out;
296 }
297 avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
298
299 screen = DefaultScreen(dpy);
300
301 if (x11grab->follow_mouse) {
302 int screen_w, screen_h;
303 Window w;
304
305 screen_w = DisplayWidth(dpy, screen);
306 screen_h = DisplayHeight(dpy, screen);
307 XQueryPointer(dpy, RootWindow(dpy, screen), &w, &w, &x_off, &y_off,
308 &ret, &ret, &ret);
309 x_off -= x11grab->width / 2;
310 y_off -= x11grab->height / 2;
311 x_off = FFMIN(FFMAX(x_off, 0), screen_w - x11grab->width);
312 y_off = FFMIN(FFMAX(y_off, 0), screen_h - x11grab->height);
313 av_log(s1, AV_LOG_INFO,
314 "followmouse is enabled, resetting grabbing region to x: %d y: %d\n",
315 x_off, y_off);
316 }
317
318 use_shm = XShmQueryExtension(dpy);
319 av_log(s1, AV_LOG_INFO,
320 "shared memory extension %sfound\n", use_shm ? "" : "not ");
321
322 if (use_shm && setup_shm(s1, dpy, &image) < 0) {
323 av_log(s1, AV_LOG_WARNING, "Falling back to XGetImage\n");
324 use_shm = 0;
325 }
326
327 if (!use_shm) {
328 image = XGetImage(dpy, RootWindow(dpy, screen),
329 x_off, y_off,
330 x11grab->width, x11grab->height,
331 AllPlanes, ZPixmap);
332 }
333
334 if (x11grab->draw_mouse && setup_mouse(dpy, screen) < 0) {
335 av_log(s1, AV_LOG_WARNING,
336 "XFixes not available, cannot draw the mouse cursor\n");
337 x11grab->draw_mouse = 0;
338 }
339
340 x11grab->frame_size = x11grab->width * x11grab->height * image->bits_per_pixel / 8;
341 x11grab->dpy = dpy;
342 x11grab->time_base = (AVRational) { framerate.den, framerate.num };
343 x11grab->time_frame = av_gettime() / av_q2d(x11grab->time_base);
344 x11grab->x_off = x_off;
345 x11grab->y_off = y_off;
346 x11grab->image = image;
347 x11grab->use_shm = use_shm;
348
349 ret = pixfmt_from_image(s1, image, &st->codec->pix_fmt);
350 if (ret < 0)
351 goto out;
352
353 st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
354 st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
355 st->codec->width = x11grab->width;
356 st->codec->height = x11grab->height;
357 st->codec->time_base = x11grab->time_base;
358 st->codec->bit_rate = x11grab->frame_size * 1 / av_q2d(x11grab->time_base) * 8;
359
360 out:
361 av_free(param);
362 return ret;
363 }
364
365 /**
366 * Paint a mouse pointer in an X11 image.
367 *
368 * @param image image to paint the mouse pointer to
369 * @param s context used to retrieve original grabbing rectangle
370 * coordinates
371 */
372 static void paint_mouse_pointer(XImage *image, X11GrabContext *s)
373 {
374 int x_off = s->x_off;
375 int y_off = s->y_off;
376 int width = s->width;
377 int height = s->height;
378 Display *dpy = s->dpy;
379 XFixesCursorImage *xcim;
380 int x, y;
381 int line, column;
382 int to_line, to_column;
383 int pixstride = image->bits_per_pixel >> 3;
384 /* Warning: in its insanity, xlib provides unsigned image data through a
385 * char* pointer, so we have to make it uint8_t to make things not break.
386 * Anyone who performs further investigation of the xlib API likely risks
387 * permanent brain damage. */
388 uint8_t *pix = image->data;
389
390 /* Code doesn't currently support 16-bit or PAL8 */
391 if (image->bits_per_pixel != 24 && image->bits_per_pixel != 32)
392 return;
393
394 xcim = XFixesGetCursorImage(dpy);
395 if (!xcim)
396 return;
397
398 x = xcim->x - xcim->xhot;
399 y = xcim->y - xcim->yhot;
400
401 to_line = FFMIN((y + xcim->height), (height + y_off));
402 to_column = FFMIN((x + xcim->width), (width + x_off));
403
404 for (line = FFMAX(y, y_off); line < to_line; line++) {
405 for (column = FFMAX(x, x_off); column < to_column; column++) {
406 int xcim_addr = (line - y) * xcim->width + column - x;
407 int image_addr = ((line - y_off) * width + column - x_off) * pixstride;
408 int r = (uint8_t)(xcim->pixels[xcim_addr] >> 0);
409 int g = (uint8_t)(xcim->pixels[xcim_addr] >> 8);
410 int b = (uint8_t)(xcim->pixels[xcim_addr] >> 16);
411 int a = (uint8_t)(xcim->pixels[xcim_addr] >> 24);
412
413 if (a == 255) {
414 pix[image_addr + 0] = r;
415 pix[image_addr + 1] = g;
416 pix[image_addr + 2] = b;
417 } else if (a) {
418 /* pixel values from XFixesGetCursorImage come premultiplied by alpha */
419 pix[image_addr + 0] = r + (pix[image_addr + 0] * (255 - a) + 255 / 2) / 255;
420 pix[image_addr + 1] = g + (pix[image_addr + 1] * (255 - a) + 255 / 2) / 255;
421 pix[image_addr + 2] = b + (pix[image_addr + 2] * (255 - a) + 255 / 2) / 255;
422 }
423 }
424 }
425
426 XFree(xcim);
427 xcim = NULL;
428 }
429
430 /**
431 * Read new data in the image structure.
432 *
433 * @param dpy X11 display to grab from
434 * @param d
435 * @param image Image where the grab will be put
436 * @param x Top-Left grabbing rectangle horizontal coordinate
437 * @param y Top-Left grabbing rectangle vertical coordinate
438 * @return 0 if error, !0 if successful
439 */
440 static int xget_zpixmap(Display *dpy, Drawable d, XImage *image, int x, int y)
441 {
442 xGetImageReply rep;
443 xGetImageReq *req;
444 long nbytes;
445
446 if (!image)
447 return 0;
448
449 LockDisplay(dpy);
450 GetReq(GetImage, req);
451
452 /* First set up the standard stuff in the request */
453 req->drawable = d;
454 req->x = x;
455 req->y = y;
456 req->width = image->width;
457 req->height = image->height;
458 req->planeMask = (unsigned int)AllPlanes;
459 req->format = ZPixmap;
460
461 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.length) {
462 UnlockDisplay(dpy);
463 SyncHandle();
464 return 0;
465 }
466
467 nbytes = (long)rep.length << 2;
468 _XReadPad(dpy, image->data, nbytes);
469
470 UnlockDisplay(dpy);
471 SyncHandle();
472 return 1;
473 }
474
475 /**
476 * Grab a frame from x11 (public device demuxer API).
477 *
478 * @param s1 Context from avformat core
479 * @param pkt Packet holding the brabbed frame
480 * @return frame size in bytes
481 */
482 static int x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
483 {
484 X11GrabContext *s = s1->priv_data;
485 Display *dpy = s->dpy;
486 XImage *image = s->image;
487 int x_off = s->x_off;
488 int y_off = s->y_off;
489 int follow_mouse = s->follow_mouse;
490 int screen, pointer_x, pointer_y, _, same_screen = 1;
491 Window w, root;
492 int64_t curtime, delay;
493 struct timespec ts;
494
495 /* Calculate the time of the next frame */
496 s->time_frame += INT64_C(1000000);
497
498 /* wait based on the frame rate */
499 for (;;) {
500 curtime = av_gettime();
501 delay = s->time_frame * av_q2d(s->time_base) - curtime;
502 if (delay <= 0) {
503 if (delay < INT64_C(-1000000) * av_q2d(s->time_base))
504 s->time_frame += INT64_C(1000000);
505 break;
506 }
507 ts.tv_sec = delay / 1000000;
508 ts.tv_nsec = (delay % 1000000) * 1000;
509 nanosleep(&ts, NULL);
510 }
511
512 av_init_packet(pkt);
513 pkt->data = image->data;
514 pkt->size = s->frame_size;
515 pkt->pts = curtime;
516
517 screen = DefaultScreen(dpy);
518 root = RootWindow(dpy, screen);
519
520 if (follow_mouse || s->draw_mouse)
521 same_screen = XQueryPointer(dpy, root, &w, &w,
522 &pointer_x, &pointer_y, &_, &_, &_);
523
524 if (follow_mouse && same_screen) {
525 int screen_w, screen_h;
526
527 screen_w = DisplayWidth(dpy, screen);
528 screen_h = DisplayHeight(dpy, screen);
529 if (follow_mouse == -1) {
530 // follow the mouse, put it at center of grabbing region
531 x_off += pointer_x - s->width / 2 - x_off;
532 y_off += pointer_y - s->height / 2 - y_off;
533 } else {
534 // follow the mouse, but only move the grabbing region when mouse
535 // reaches within certain pixels to the edge.
536 if (pointer_x > x_off + s->width - follow_mouse)
537 x_off += pointer_x - (x_off + s->width - follow_mouse);
538 else if (pointer_x < x_off + follow_mouse)
539 x_off -= (x_off + follow_mouse) - pointer_x;
540 if (pointer_y > y_off + s->height - follow_mouse)
541 y_off += pointer_y - (y_off + s->height - follow_mouse);
542 else if (pointer_y < y_off + follow_mouse)
543 y_off -= (y_off + follow_mouse) - pointer_y;
544 }
545 // adjust grabbing region position if it goes out of screen.
546 s->x_off = x_off = FFMIN(FFMAX(x_off, 0), screen_w - s->width);
547 s->y_off = y_off = FFMIN(FFMAX(y_off, 0), screen_h - s->height);
548
549 if (s->show_region && s->region_win)
550 XMoveWindow(dpy, s->region_win,
551 s->x_off - REGION_WIN_BORDER,
552 s->y_off - REGION_WIN_BORDER);
553 }
554
555 if (s->show_region && same_screen) {
556 if (s->region_win) {
557 XEvent evt = { .type = NoEventMask };
558 // Clean up the events, and do the initial draw or redraw.
559 while (XCheckMaskEvent(dpy, ExposureMask | StructureNotifyMask,
560 &evt))
561 ;
562 if (evt.type)
563 x11grab_draw_region_win(s);
564 } else {
565 x11grab_region_win_init(s);
566 }
567 }
568
569 if (s->use_shm) {
570 if (!XShmGetImage(dpy, root, image, x_off, y_off, AllPlanes))
571 av_log(s1, AV_LOG_INFO, "XShmGetImage() failed\n");
572 } else {
573 if (!xget_zpixmap(dpy, root, image, x_off, y_off))
574 av_log(s1, AV_LOG_INFO, "XGetZPixmap() failed\n");
575 }
576
577 if (s->draw_mouse && same_screen)
578 paint_mouse_pointer(image, s);
579
580 return s->frame_size;
581 }
582
583 /**
584 * Close x11 frame grabber (public device demuxer API).
585 *
586 * @param s1 Context from avformat core
587 * @return 0 success, !0 failure
588 */
589 static int x11grab_read_close(AVFormatContext *s1)
590 {
591 X11GrabContext *x11grab = s1->priv_data;
592
593 /* Detach cleanly from shared mem */
594 if (x11grab->use_shm) {
595 XShmDetach(x11grab->dpy, &x11grab->shminfo);
596 shmdt(x11grab->shminfo.shmaddr);
597 shmctl(x11grab->shminfo.shmid, IPC_RMID, NULL);
598 }
599
600 /* Destroy X11 image */
601 if (x11grab->image) {
602 XDestroyImage(x11grab->image);
603 x11grab->image = NULL;
604 }
605
606 if (x11grab->region_win)
607 XDestroyWindow(x11grab->dpy, x11grab->region_win);
608
609 /* Free X11 display */
610 XCloseDisplay(x11grab->dpy);
611 return 0;
612 }
613
614 #define OFFSET(x) offsetof(X11GrabContext, x)
615 #define DEC AV_OPT_FLAG_DECODING_PARAM
616 static const AVOption options[] = {
617 { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = "vga"}, 0, 0, DEC },
618 { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC },
619 { "draw_mouse", "Draw the mouse pointer.", OFFSET(draw_mouse), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, DEC },
620 { "follow_mouse", "Move the grabbing region when the mouse pointer reaches within specified amount of pixels to the edge of region.",
621 OFFSET(follow_mouse), AV_OPT_TYPE_INT, { .i64 = 0 }, -1, INT_MAX, DEC, "follow_mouse" },
622 { "centered", "Keep the mouse pointer at the center of grabbing region when following.", 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, INT_MIN, INT_MAX, DEC, "follow_mouse" },
623 { "show_region", "Show the grabbing region.", OFFSET(show_region), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, DEC },
624 { NULL },
625 };
626
627 static const AVClass x11_class = {
628 .class_name = "X11grab indev",
629 .item_name = av_default_item_name,
630 .option = options,
631 .version = LIBAVUTIL_VERSION_INT,
632 };
633
634 /** x11 grabber device demuxer declaration */
635 AVInputFormat ff_x11grab_demuxer = {
636 .name = "x11grab",
637 .long_name = NULL_IF_CONFIG_SMALL("X11grab"),
638 .priv_data_size = sizeof(X11GrabContext),
639 .read_header = x11grab_read_header,
640 .read_packet = x11grab_read_packet,
641 .read_close = x11grab_read_close,
642 .flags = AVFMT_NOFILE,
643 .priv_class = &x11_class,
644 };