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.

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