[FFmpeg-cvslog] xcbgrab: XCB-based screen capture

compn tempn at mi.rr.com
Tue Oct 28 02:20:09 CET 2014


On Mon, 27 Oct 2014 21:44:59 +0100 (CET)
git at videolan.org (Luca Barbato) wrote:

> ffmpeg | branch: master | Luca Barbato <lu_zero at gentoo.org> | Sun Aug
> 24 14:18:22 2014 +0200| [a6674d2e7771dbf7a4a5556f5e126be83cadac96] |
> committer: Luca Barbato
> 
> xcbgrab: XCB-based screen capture
> 
> Matches the x11grab screen capture by features.

> 100644 --- a/libavdevice/Makefile
> -OBJS-$(CONFIG_X11GRAB_INDEV)             += x11grab.o
> +OBJS-$(CONFIG_X11GRAB_XLIB_INDEV)        += x11grab.o
> +OBJS-$(CONFIG_X11GRAB_XCB_INDEV)         += xcbgrab.o 

so its name is changed in the makefile, but not the device name?

> diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
>      REGISTER_INDEV   (X11GRAB,          x11grab);
> +    REGISTER_INDEV   (X11GRAB_XCB,      x11grab_xcb);

> a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c new file mode 100644
> index 0000000..5055fde
> --- /dev/null
> +++ b/libavdevice/xcbgrab.c
> @@ -0,0 +1,655 @@
> +/*
> + * XCB input grabber
> + * Copyright (C) 2014 Luca Barbato <lu_zero at gentoo.org>
> + *
> + * This file is part of Libav.

> +static const AVOption options[] = {
> +    { "draw_mouse", "Draw the mouse pointer.", OFFSET(draw_mouse),
> AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, D },
> +    { "follow_mouse", "Move the grabbing region when the mouse
> pointer reaches within specified amount of pixels to the edge of
> region.",
> +      OFFSET(follow_mouse), AV_OPT_TYPE_INT, { .i64 = 0 },
> FOLLOW_CENTER, INT_MAX, D, "follow_mouse" },
> +    { "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" },
> +    { "show_region", "Show the grabbing region.",
> OFFSET(show_region), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, D },
> +    { "region_border", "Set the region border thickness.",
> OFFSET(region_border), AV_OPT_TYPE_INT, { .i64 = 3 }, 1, 128, D },
> +    { NULL },

from x11grab.c:

static const AVOption options[] = {
    { "draw_mouse", "draw the mouse pointer", OFFSET(draw_mouse), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, DEC },
    { "follow_mouse", "move the grabbing region when the mouse pointer reaches within specified amount of pixels to the edge of region",
      OFFSET(follow_mouse), AV_OPT_TYPE_INT, {.i64 = 0}, -1, INT_MAX, DEC, "follow_mouse" },
    { "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" },




> +static void wait_frame(AVFormatContext *s, AVPacket *pkt)
> +{
> +    XCBGrabContext *c = s->priv_data;
> +    int64_t curtime, delay;
> +    int64_t frame_time = av_rescale_q(1, c->time_base,
> AV_TIME_BASE_Q); +
> +    c->time_frame += frame_time;
> +
> +    for (;;) {
> +        curtime = av_gettime();
> +        delay   = c->time_frame - curtime;
> +        if (delay <= 0)
> +            break;
> +        av_usleep(delay);
> +    }
> +
> +    pkt->pts = curtime;

is this file based on x11grab.c ? if so , copyrights need to be
modified.

from x11grab.c:
    int64_t curtime, delay;
...
    /* wait based on the frame rate */
    for (;;) {
        curtime = av_gettime();
        delay   = s->time_frame * av_q2d(s->time_base) - curtime;
        if (delay <= 0) {
            if (delay < INT64_C(-1000000) * av_q2d(s->time_base))
                s->time_frame += INT64_C(1000000);
            break;
        }
...
    pkt->pts  = curtime;



> +AVInputFormat ff_x11grab_xcb_demuxer = {
> +    .name           = "x11grab",
> +    .long_name      = NULL_IF_CONFIG_SMALL("X11 screen capture,
> using XCB"),

i've confused myself with x11grab x11grab_xlib and x11grab_xcb , is the name of this demuxer correct?

-compn


More information about the ffmpeg-cvslog mailing list