You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

673 lines
19KB

  1. /*
  2. * XCB input grabber
  3. * Copyright (C) 2014 Luca Barbato <lu_zero@gentoo.org>
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "config.h"
  22. #include <stdlib.h>
  23. #include <xcb/xcb.h>
  24. #if CONFIG_LIBXCB_XFIXES
  25. #include <xcb/xfixes.h>
  26. #endif
  27. #if CONFIG_LIBXCB_SHM
  28. #include <sys/shm.h>
  29. #include <xcb/shm.h>
  30. #endif
  31. #if CONFIG_LIBXCB_SHAPE
  32. #include <xcb/shape.h>
  33. #endif
  34. #include "libavformat/avformat.h"
  35. #include "libavformat/internal.h"
  36. #include "libavutil/mathematics.h"
  37. #include "libavutil/opt.h"
  38. #include "libavutil/parseutils.h"
  39. #include "libavutil/time.h"
  40. typedef struct XCBGrabContext {
  41. const AVClass *class;
  42. xcb_connection_t *conn;
  43. xcb_screen_t *screen;
  44. xcb_window_t window;
  45. #if CONFIG_LIBXCB_SHM
  46. xcb_shm_seg_t segment;
  47. #endif
  48. int64_t time_frame;
  49. AVRational time_base;
  50. int x, y;
  51. int width, height;
  52. int frame_size;
  53. int bpp;
  54. int draw_mouse;
  55. int follow_mouse;
  56. int show_region;
  57. int region_border;
  58. int centered;
  59. const char *video_size;
  60. const char *framerate;
  61. int has_shm;
  62. } XCBGrabContext;
  63. #define FOLLOW_CENTER -1
  64. #define OFFSET(x) offsetof(XCBGrabContext, x)
  65. #define D AV_OPT_FLAG_DECODING_PARAM
  66. static const AVOption options[] = {
  67. { "x", "Initial x coordinate.", OFFSET(x), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, D },
  68. { "y", "Initial y coordinate.", OFFSET(y), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, D },
  69. { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = "vga" }, 0, 0, D },
  70. { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "ntsc" }, 0, 0, D },
  71. { "draw_mouse", "Draw the mouse pointer.", OFFSET(draw_mouse), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, D },
  72. { "follow_mouse", "Move the grabbing region when the mouse pointer reaches within specified amount of pixels to the edge of region.",
  73. OFFSET(follow_mouse), AV_OPT_TYPE_INT, { .i64 = 0 }, FOLLOW_CENTER, INT_MAX, D, "follow_mouse" },
  74. { "centered", "Keep the mouse pointer at the center of grabbing region when following.", 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, INT_MIN, INT_MAX, D, "follow_mouse" },
  75. { "show_region", "Show the grabbing region.", OFFSET(show_region), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, D },
  76. { "region_border", "Set the region border thickness.", OFFSET(region_border), AV_OPT_TYPE_INT, { .i64 = 3 }, 1, 128, D },
  77. { NULL },
  78. };
  79. static const AVClass xcbgrab_class = {
  80. .class_name = "xcbgrab indev",
  81. .item_name = av_default_item_name,
  82. .option = options,
  83. .version = LIBAVUTIL_VERSION_INT,
  84. .category = AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT,
  85. };
  86. static int xcbgrab_reposition(AVFormatContext *s,
  87. xcb_query_pointer_reply_t *p,
  88. xcb_get_geometry_reply_t *geo)
  89. {
  90. XCBGrabContext *c = s->priv_data;
  91. int x = c->x, y = c->y;
  92. int w = c->width, h = c->height, f = c->follow_mouse;
  93. int p_x, p_y;
  94. if (!p || !geo)
  95. return AVERROR(EIO);
  96. p_x = p->win_x;
  97. p_y = p->win_y;
  98. if (f == FOLLOW_CENTER) {
  99. x = p_x - w / 2;
  100. y = p_y - h / 2;
  101. } else {
  102. int left = x + f;
  103. int right = x + w - f;
  104. int top = y + f;
  105. int bottom = y + h + f;
  106. if (p_x > right) {
  107. x += p_x - right;
  108. } else if (p_x < left) {
  109. x -= left - p_x;
  110. }
  111. if (p_y > bottom) {
  112. y += p_y - bottom;
  113. } else if (p_y < top) {
  114. y -= top - p_y;
  115. }
  116. }
  117. c->x = FFMIN(FFMAX(0, x), geo->width - w);
  118. c->y = FFMIN(FFMAX(0, y), geo->height - h);
  119. return 0;
  120. }
  121. static int xcbgrab_frame(AVFormatContext *s, AVPacket *pkt)
  122. {
  123. XCBGrabContext *c = s->priv_data;
  124. xcb_get_image_cookie_t iq;
  125. xcb_get_image_reply_t *img;
  126. xcb_drawable_t drawable = c->screen->root;
  127. uint8_t *data;
  128. int length, ret;
  129. iq = xcb_get_image(c->conn, XCB_IMAGE_FORMAT_Z_PIXMAP, drawable,
  130. c->x, c->y, c->width, c->height, ~0);
  131. img = xcb_get_image_reply(c->conn, iq, NULL);
  132. if (!img)
  133. return AVERROR(EAGAIN);
  134. data = xcb_get_image_data(img);
  135. length = xcb_get_image_data_length(img);
  136. ret = av_new_packet(pkt, length);
  137. if (!ret)
  138. memcpy(pkt->data, data, length);
  139. free(img);
  140. return ret;
  141. }
  142. static void wait_frame(AVFormatContext *s, AVPacket *pkt)
  143. {
  144. XCBGrabContext *c = s->priv_data;
  145. int64_t curtime, delay;
  146. int64_t frame_time = av_rescale_q(1, c->time_base, AV_TIME_BASE_Q);
  147. c->time_frame += frame_time;
  148. for (;;) {
  149. curtime = av_gettime();
  150. delay = c->time_frame - curtime;
  151. if (delay <= 0)
  152. break;
  153. av_usleep(delay);
  154. }
  155. pkt->pts = curtime;
  156. }
  157. #if CONFIG_LIBXCB_SHM
  158. static int check_shm(xcb_connection_t *conn)
  159. {
  160. xcb_shm_query_version_cookie_t cookie = xcb_shm_query_version(conn);
  161. xcb_shm_query_version_reply_t *reply;
  162. reply = xcb_shm_query_version_reply(conn, cookie, NULL);
  163. if (reply) {
  164. free(reply);
  165. return 1;
  166. }
  167. return 0;
  168. }
  169. static void dealloc_shm(void *unused, uint8_t *data)
  170. {
  171. shmdt(data);
  172. }
  173. static int xcbgrab_frame_shm(AVFormatContext *s, AVPacket *pkt)
  174. {
  175. XCBGrabContext *c = s->priv_data;
  176. xcb_shm_get_image_cookie_t iq;
  177. xcb_shm_get_image_reply_t *img;
  178. xcb_drawable_t drawable = c->screen->root;
  179. uint8_t *data;
  180. int size = c->frame_size + FF_INPUT_BUFFER_PADDING_SIZE;
  181. int id = shmget(IPC_PRIVATE, size, IPC_CREAT | 0777);
  182. xcb_generic_error_t *e = NULL;
  183. if (id == -1) {
  184. char errbuf[1024];
  185. int err = AVERROR(errno);
  186. av_strerror(err, errbuf, sizeof(errbuf));
  187. av_log(s, AV_LOG_ERROR, "Cannot get %d bytes of shared memory: %s.\n",
  188. size, errbuf);
  189. return err;
  190. }
  191. xcb_shm_attach(c->conn, c->segment, id, 0);
  192. iq = xcb_shm_get_image(c->conn, drawable,
  193. c->x, c->y, c->width, c->height, ~0,
  194. XCB_IMAGE_FORMAT_Z_PIXMAP, c->segment, 0);
  195. xcb_shm_detach(c->conn, c->segment);
  196. img = xcb_shm_get_image_reply(c->conn, iq, &e);
  197. xcb_flush(c->conn);
  198. if (e) {
  199. av_log(s, AV_LOG_ERROR,
  200. "Cannot get the image data "
  201. "event_error: response_type:%u error_code:%u "
  202. "sequence:%u resource_id:%u minor_code:%u major_code:%u.\n",
  203. e->response_type, e->error_code,
  204. e->sequence, e->resource_id, e->minor_code, e->major_code);
  205. shmctl(id, IPC_RMID, 0);
  206. return AVERROR(EACCES);
  207. }
  208. free(img);
  209. data = shmat(id, NULL, 0);
  210. shmctl(id, IPC_RMID, 0);
  211. if ((intptr_t)data == -1)
  212. return AVERROR(errno);
  213. pkt->buf = av_buffer_create(data, size, dealloc_shm, NULL, 0);
  214. if (!pkt->buf) {
  215. shmdt(data);
  216. return AVERROR(ENOMEM);
  217. }
  218. pkt->data = pkt->buf->data;
  219. pkt->size = c->frame_size;
  220. return 0;
  221. }
  222. #endif /* CONFIG_LIBXCB_SHM */
  223. #if CONFIG_LIBXCB_XFIXES
  224. static int check_xfixes(xcb_connection_t *conn)
  225. {
  226. xcb_xfixes_query_version_cookie_t cookie;
  227. xcb_xfixes_query_version_reply_t *reply;
  228. cookie = xcb_xfixes_query_version(conn, XCB_XFIXES_MAJOR_VERSION,
  229. XCB_XFIXES_MINOR_VERSION);
  230. reply = xcb_xfixes_query_version_reply(conn, cookie, NULL);
  231. if (reply) {
  232. free(reply);
  233. return 1;
  234. }
  235. return 0;
  236. }
  237. #define BLEND(target, source, alpha) \
  238. (target) + ((source) * (255 - (alpha)) + 255 / 2) / 255
  239. static void xcbgrab_draw_mouse(AVFormatContext *s, AVPacket *pkt,
  240. xcb_query_pointer_reply_t *p,
  241. xcb_get_geometry_reply_t *geo)
  242. {
  243. XCBGrabContext *gr = s->priv_data;
  244. uint32_t *cursor;
  245. uint8_t *image = pkt->data;
  246. int stride = gr->bpp / 8;
  247. xcb_xfixes_get_cursor_image_cookie_t cc;
  248. xcb_xfixes_get_cursor_image_reply_t *ci;
  249. int cx, cy, x, y, w, h, c_off, i_off;
  250. cc = xcb_xfixes_get_cursor_image(gr->conn);
  251. ci = xcb_xfixes_get_cursor_image_reply(gr->conn, cc, NULL);
  252. if (!ci)
  253. return;
  254. cursor = xcb_xfixes_get_cursor_image_cursor_image(ci);
  255. if (!cursor)
  256. return;
  257. cx = ci->x - ci->xhot;
  258. cy = ci->y - ci->yhot;
  259. x = FFMAX(cx, gr->x);
  260. y = FFMAX(cy, gr->y);
  261. w = FFMIN(cx + ci->width, gr->x + gr->width) - x;
  262. h = FFMIN(cy + ci->height, gr->y + gr->height) - y;
  263. c_off = x - cx;
  264. i_off = x - gr->x;
  265. cursor += (y - cy) * ci->width;
  266. image += (y - gr->y) * gr->width * stride;
  267. for (y = 0; y < h; y++) {
  268. cursor += c_off;
  269. image += i_off * stride;
  270. for (x = 0; x < w; x++, cursor++, image += stride) {
  271. int r, g, b, a;
  272. r = *cursor & 0xff;
  273. g = (*cursor >> 8) & 0xff;
  274. b = (*cursor >> 16) & 0xff;
  275. a = (*cursor >> 24) & 0xff;
  276. if (!a)
  277. continue;
  278. if (a == 255) {
  279. image[0] = r;
  280. image[1] = g;
  281. image[2] = b;
  282. } else {
  283. image[0] = BLEND(r, image[0], a);
  284. image[1] = BLEND(g, image[1], a);
  285. image[2] = BLEND(b, image[2], a);
  286. }
  287. }
  288. cursor += ci->width - w - c_off;
  289. image += (gr->width - w - i_off) * stride;
  290. }
  291. free(ci);
  292. }
  293. #endif /* CONFIG_LIBXCB_XFIXES */
  294. static void xcbgrab_update_region(AVFormatContext *s)
  295. {
  296. XCBGrabContext *c = s->priv_data;
  297. const uint32_t args[] = { c->x - c->region_border,
  298. c->y - c->region_border };
  299. xcb_configure_window(c->conn,
  300. c->window,
  301. XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y,
  302. args);
  303. }
  304. static int xcbgrab_read_packet(AVFormatContext *s, AVPacket *pkt)
  305. {
  306. XCBGrabContext *c = s->priv_data;
  307. xcb_query_pointer_cookie_t pc;
  308. xcb_get_geometry_cookie_t gc;
  309. xcb_query_pointer_reply_t *p = NULL;
  310. xcb_get_geometry_reply_t *geo = NULL;
  311. int ret = 0;
  312. wait_frame(s, pkt);
  313. if (c->follow_mouse || c->draw_mouse) {
  314. pc = xcb_query_pointer(c->conn, c->screen->root);
  315. gc = xcb_get_geometry(c->conn, c->screen->root);
  316. p = xcb_query_pointer_reply(c->conn, pc, NULL);
  317. geo = xcb_get_geometry_reply(c->conn, gc, NULL);
  318. }
  319. if (c->follow_mouse && p->same_screen)
  320. xcbgrab_reposition(s, p, geo);
  321. if (c->show_region)
  322. xcbgrab_update_region(s);
  323. #if CONFIG_LIBXCB_SHM
  324. if (c->has_shm && xcbgrab_frame_shm(s, pkt) < 0)
  325. c->has_shm = 0;
  326. #endif
  327. if (!c->has_shm)
  328. ret = xcbgrab_frame(s, pkt);
  329. #if CONFIG_LIBXCB_XFIXES
  330. if (c->draw_mouse && p->same_screen)
  331. xcbgrab_draw_mouse(s, pkt, p, geo);
  332. #endif
  333. free(p);
  334. free(geo);
  335. return ret;
  336. }
  337. static av_cold int xcbgrab_read_close(AVFormatContext *s)
  338. {
  339. XCBGrabContext *ctx = s->priv_data;
  340. xcb_disconnect(ctx->conn);
  341. return 0;
  342. }
  343. static xcb_screen_t *get_screen(const xcb_setup_t *setup, int screen_num)
  344. {
  345. xcb_screen_iterator_t it = xcb_setup_roots_iterator(setup);
  346. xcb_screen_t *screen = NULL;
  347. for (; it.rem > 0; xcb_screen_next (&it)) {
  348. if (!screen_num) {
  349. screen = it.data;
  350. break;
  351. }
  352. screen_num--;
  353. }
  354. return screen;
  355. }
  356. static int pixfmt_from_pixmap_format(AVFormatContext *s, int depth,
  357. int *pix_fmt)
  358. {
  359. XCBGrabContext *c = s->priv_data;
  360. const xcb_setup_t *setup = xcb_get_setup(c->conn);
  361. const xcb_format_t *fmt = xcb_setup_pixmap_formats(setup);
  362. int length = xcb_setup_pixmap_formats_length(setup);
  363. *pix_fmt = 0;
  364. while (length--) {
  365. if (fmt->depth == depth) {
  366. switch (depth) {
  367. case 32:
  368. if (fmt->bits_per_pixel == 32)
  369. *pix_fmt = AV_PIX_FMT_0RGB;
  370. break;
  371. case 24:
  372. if (fmt->bits_per_pixel == 32)
  373. *pix_fmt = AV_PIX_FMT_0RGB32;
  374. else if (fmt->bits_per_pixel == 24)
  375. *pix_fmt = AV_PIX_FMT_RGB24;
  376. break;
  377. case 16:
  378. if (fmt->bits_per_pixel == 16)
  379. *pix_fmt = AV_PIX_FMT_RGB565;
  380. break;
  381. case 15:
  382. if (fmt->bits_per_pixel == 16)
  383. *pix_fmt = AV_PIX_FMT_RGB555;
  384. break;
  385. case 8:
  386. if (fmt->bits_per_pixel == 8)
  387. *pix_fmt = AV_PIX_FMT_RGB8;
  388. break;
  389. }
  390. }
  391. if (*pix_fmt) {
  392. c->bpp = fmt->bits_per_pixel;
  393. c->frame_size = c->width * c->height * fmt->bits_per_pixel / 8;
  394. return 0;
  395. }
  396. fmt++;
  397. }
  398. av_log(s, AV_LOG_ERROR, "Pixmap format not mappable.\n");
  399. return AVERROR_PATCHWELCOME;
  400. }
  401. static int create_stream(AVFormatContext *s)
  402. {
  403. XCBGrabContext *c = s->priv_data;
  404. AVStream *st = avformat_new_stream(s, NULL);
  405. xcb_get_geometry_cookie_t gc;
  406. xcb_get_geometry_reply_t *geo;
  407. int ret;
  408. if (!st)
  409. return AVERROR(ENOMEM);
  410. ret = av_parse_video_size(&c->width, &c->height, c->video_size);
  411. if (ret < 0)
  412. return ret;
  413. ret = av_parse_video_rate(&st->avg_frame_rate, c->framerate);
  414. if (ret < 0)
  415. return ret;
  416. avpriv_set_pts_info(st, 64, 1, 1000000);
  417. gc = xcb_get_geometry(c->conn, c->screen->root);
  418. geo = xcb_get_geometry_reply(c->conn, gc, NULL);
  419. c->width = FFMIN(geo->width, c->width);
  420. c->height = FFMIN(geo->height, c->height);
  421. c->time_base = (AVRational){ st->avg_frame_rate.den,
  422. st->avg_frame_rate.num };
  423. c->time_frame = av_gettime();
  424. st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
  425. st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
  426. st->codec->width = c->width;
  427. st->codec->height = c->height;
  428. st->codec->time_base = c->time_base;
  429. ret = pixfmt_from_pixmap_format(s, geo->depth, &st->codec->pix_fmt);
  430. free(geo);
  431. return ret;
  432. }
  433. static void draw_rectangle(AVFormatContext *s)
  434. {
  435. XCBGrabContext *c = s->priv_data;
  436. xcb_gcontext_t gc = xcb_generate_id(c->conn);
  437. uint32_t mask = XCB_GC_FOREGROUND |
  438. XCB_GC_BACKGROUND |
  439. XCB_GC_LINE_WIDTH |
  440. XCB_GC_LINE_STYLE |
  441. XCB_GC_FILL_STYLE;
  442. uint32_t values[] = { c->screen->black_pixel,
  443. c->screen->white_pixel,
  444. c->region_border,
  445. XCB_LINE_STYLE_DOUBLE_DASH,
  446. XCB_FILL_STYLE_SOLID };
  447. xcb_rectangle_t r = { 1, 1,
  448. c->width + c->region_border * 2 - 3,
  449. c->height + c->region_border * 2 - 3 };
  450. xcb_create_gc(c->conn, gc, c->window, mask, values);
  451. xcb_poly_rectangle(c->conn, c->window, gc, 1, &r);
  452. }
  453. static void setup_window(AVFormatContext *s)
  454. {
  455. XCBGrabContext *c = s->priv_data;
  456. uint32_t mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK;
  457. uint32_t values[] = { 1,
  458. XCB_EVENT_MASK_EXPOSURE |
  459. XCB_EVENT_MASK_STRUCTURE_NOTIFY };
  460. xcb_rectangle_t rect = { 0, 0, c->width, c->height };
  461. c->window = xcb_generate_id(c->conn);
  462. xcb_create_window(c->conn, XCB_COPY_FROM_PARENT,
  463. c->window,
  464. c->screen->root,
  465. c->x - c->region_border,
  466. c->y - c->region_border,
  467. c->width + c->region_border * 2,
  468. c->height + c->region_border * 2,
  469. 0,
  470. XCB_WINDOW_CLASS_INPUT_OUTPUT,
  471. XCB_COPY_FROM_PARENT,
  472. mask, values);
  473. #if CONFIG_LIBXCB_SHAPE
  474. xcb_shape_rectangles(c->conn, XCB_SHAPE_SO_SUBTRACT,
  475. XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
  476. c->window,
  477. c->region_border, c->region_border,
  478. 1, &rect);
  479. #endif
  480. xcb_map_window(c->conn, c->window);
  481. draw_rectangle(s);
  482. }
  483. static av_cold int xcbgrab_read_header(AVFormatContext *s)
  484. {
  485. XCBGrabContext *c = s->priv_data;
  486. int screen_num, ret;
  487. const xcb_setup_t *setup;
  488. char *display_name = av_strdup(s->filename);
  489. if (!display_name)
  490. return AVERROR(ENOMEM);
  491. if (!sscanf(s->filename, "%[^+]+%d,%d", display_name, &c->x, &c->y)) {
  492. *display_name = 0;
  493. sscanf(s->filename, "+%d,%d", &c->x, &c->y);
  494. }
  495. c->conn = xcb_connect(display_name[0] ? display_name : NULL, &screen_num);
  496. av_freep(&display_name);
  497. if ((ret = xcb_connection_has_error(c->conn))) {
  498. av_log(s, AV_LOG_ERROR, "Cannot open display %s, error %d.\n",
  499. s->filename[0] ? s->filename : "default", ret);
  500. return AVERROR(EIO);
  501. }
  502. setup = xcb_get_setup(c->conn);
  503. c->screen = get_screen(setup, screen_num);
  504. if (!c->screen) {
  505. av_log(s, AV_LOG_ERROR, "The screen %d does not exist.\n",
  506. screen_num);
  507. xcbgrab_read_close(s);
  508. return AVERROR(EIO);
  509. }
  510. ret = create_stream(s);
  511. if (ret < 0) {
  512. xcbgrab_read_close(s);
  513. return ret;
  514. }
  515. #if CONFIG_LIBXCB_SHM
  516. if ((c->has_shm = check_shm(c->conn)))
  517. c->segment = xcb_generate_id(c->conn);
  518. #endif
  519. #if CONFIG_LIBXCB_XFIXES
  520. if (c->draw_mouse) {
  521. if (!(c->draw_mouse = check_xfixes(c->conn))) {
  522. av_log(s, AV_LOG_WARNING,
  523. "XFixes not available, cannot draw the mouse.\n");
  524. }
  525. if (c->bpp < 24) {
  526. avpriv_report_missing_feature(s, "%d bits per pixel screen",
  527. c->bpp);
  528. c->draw_mouse = 0;
  529. }
  530. }
  531. #endif
  532. if (c->show_region)
  533. setup_window(s);
  534. return 0;
  535. }
  536. AVInputFormat ff_x11grab_xcb_demuxer = {
  537. .name = "x11grab",
  538. .long_name = NULL_IF_CONFIG_SMALL("X11 screen capture, using XCB"),
  539. .priv_data_size = sizeof(XCBGrabContext),
  540. .read_header = xcbgrab_read_header,
  541. .read_packet = xcbgrab_read_packet,
  542. .read_close = xcbgrab_read_close,
  543. .flags = AVFMT_NOFILE,
  544. .priv_class = &xcbgrab_class,
  545. };