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.

670 lines
19KB

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