* XCB input grabber
* Copyright (C) 2014 Luca Barbato <lu_zero@gentoo.org>
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdlib.h>
#include <xcb/xcb.h>
-#include <xcb/shape.h>
#if CONFIG_LIBXCB_XFIXES
#include <xcb/xfixes.h>
#include <xcb/shm.h>
#endif
+#if CONFIG_LIBXCB_SHAPE
+#include <xcb/shape.h>
+#endif
+
#include "libavutil/internal.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
+ .category = AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT,
};
static int xcbgrab_reposition(AVFormatContext *s,
switch (depth) {
case 32:
if (fmt->bits_per_pixel == 32)
- *pix_fmt = AV_PIX_FMT_ARGB;
+ *pix_fmt = AV_PIX_FMT_0RGB;
break;
case 24:
if (fmt->bits_per_pixel == 32)
- *pix_fmt = AV_PIX_FMT_RGB32;
+ *pix_fmt = AV_PIX_FMT_0RGB32;
else if (fmt->bits_per_pixel == 24)
*pix_fmt = AV_PIX_FMT_RGB24;
break;
XCB_COPY_FROM_PARENT,
mask, values);
+#if CONFIG_LIBXCB_SHAPE
xcb_shape_rectangles(c->conn, XCB_SHAPE_SO_SUBTRACT,
XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
c->window,
c->region_border, c->region_border,
1, &rect);
+#endif
xcb_map_window(c->conn, c->window);
XCBGrabContext *c = s->priv_data;
int screen_num, ret;
const xcb_setup_t *setup;
- char *host = s->filename[0] ? s->filename : NULL;
- const char *opts = strchr(s->filename, '+');
-
- if (opts) {
- sscanf(opts, "%d,%d", &c->x, &c->y);
- host = av_strdup(s->filename);
- if (!host)
- return AVERROR(ENOMEM);
- host[opts - s->filename] = '\0';
+ char *display_name = av_strdup(s->filename);
+
+ if (!display_name)
+ return AVERROR(ENOMEM);
+
+ if (!sscanf(s->filename, "%[^+]+%d,%d", display_name, &c->x, &c->y)) {
+ *display_name = 0;
+ sscanf(s->filename, "+%d,%d", &c->x, &c->y);
}
- c->conn = xcb_connect(host, &screen_num);
+ c->conn = xcb_connect(display_name[0] ? display_name : NULL, &screen_num);
+ av_freep(&display_name);
if ((ret = xcb_connection_has_error(c->conn))) {
av_log(s, AV_LOG_ERROR, "Cannot open display %s, error %d.\n",
- s->filename[0] ? host : "default", ret);
- if (opts)
- av_freep(&host);
+ s->filename[0] ? s->filename : "default", ret);
return AVERROR(EIO);
}
- if (opts)
- av_freep(&host);
-
setup = xcb_get_setup(c->conn);
c->screen = get_screen(setup, screen_num);