diff options
Diffstat (limited to 'libavdevice/xcbgrab.c')
-rw-r--r-- | libavdevice/xcbgrab.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c index 5055fde..2fdb992 100644 --- a/libavdevice/xcbgrab.c +++ b/libavdevice/xcbgrab.c @@ -2,20 +2,20 @@ * 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 */ @@ -47,7 +47,9 @@ typedef struct XCBGrabContext { xcb_connection_t *conn; xcb_screen_t *screen; xcb_window_t window; +#if CONFIG_LIBXCB_SHM xcb_shm_seg_t segment; +#endif int64_t time_frame; AVRational time_base; @@ -92,6 +94,7 @@ static const AVClass xcbgrab_class = { .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, @@ -488,7 +491,6 @@ static int create_stream(AVFormatContext *s) { XCBGrabContext *c = s->priv_data; AVStream *st = avformat_new_stream(s, NULL); - const char *opts = strchr(s->filename, '+'); xcb_get_geometry_cookie_t gc; xcb_get_geometry_reply_t *geo; int ret; @@ -504,9 +506,6 @@ static int create_stream(AVFormatContext *s) if (ret < 0) return ret; - if (opts) - sscanf(opts, "%d,%d", &c->x, &c->y); - avpriv_set_pts_info(st, 64, 1, 1000000); gc = xcb_get_geometry(c->conn, c->screen->root); @@ -577,11 +576,13 @@ static void setup_window(AVFormatContext *s) XCB_COPY_FROM_PARENT, mask, values); +#if XCB_SHAPE_RECTANGLES 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); @@ -593,8 +594,20 @@ static av_cold int xcbgrab_read_header(AVFormatContext *s) XCBGrabContext *c = s->priv_data; int screen_num, ret; const xcb_setup_t *setup; + char *display_name = av_strdup(s->filename); + + if (s->filename) { + if (!display_name) + return AVERROR(ENOMEM); - c->conn = xcb_connect(s->filename, &screen_num); + 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(display_name, &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 ? s->filename : "default", ret); @@ -610,7 +623,9 @@ static av_cold int xcbgrab_read_header(AVFormatContext *s) return AVERROR(EIO); } +#if CONFIG_LIBXCB_SHM c->segment = xcb_generate_id(c->conn); +#endif ret = create_stream(s); |