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.

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