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.

622 lines
21KB

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