static av_cold int xcbgrab_read_header(AVFormatContext *s)

{

    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);

        host[opts - s->filename] = '\0';

    }



    c->conn = xcb_connect(host, &screen_num);



    if (opts)

        av_free(host);



    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);

        return AVERROR(EIO);

    }

    setup = xcb_get_setup(c->conn);



    c->screen = get_screen(setup, screen_num);

    if (!c->screen) {

        av_log(s, AV_LOG_ERROR, "The screen %d does not exist.\n",

               screen_num);

        xcbgrab_read_close(s);

        return AVERROR(EIO);

    }



    ret = create_stream(s);



    if (ret < 0) {

        xcbgrab_read_close(s);

        return ret;

    }



#if CONFIG_LIBXCB_SHM

    if ((c->has_shm = check_shm(c->conn)))

        c->segment = xcb_generate_id(c->conn);

#endif



#if CONFIG_LIBXCB_XFIXES

    if (c->draw_mouse) {

        if (!(c->draw_mouse = check_xfixes(c->conn))) {

            av_log(s, AV_LOG_WARNING,

                   "XFixes not available, cannot draw the mouse.\n");

        }

        if (c->bpp < 24) {

            avpriv_report_missing_feature(s, "%d bits per pixel screen",

                                          c->bpp);

            c->draw_mouse = 0;

        }

    }

#endif



    if (c->show_region)

        setup_window(s);



    return 0;

}

static av_cold int xcbgrab_read_header(AVFormatContext *s)

{

    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);

        host[opts - s->filename] = '\0';

    }



    c->conn = xcb_connect(host, &screen_num);



    if (opts)

        av_free(host);



    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);

        return AVERROR(EIO);

    }

    setup = xcb_get_setup(c->conn);



    c->screen = get_screen(setup, screen_num);

    if (!c->screen) {

        av_log(s, AV_LOG_ERROR, "The screen %d does not exist.\n",

               screen_num);

        xcbgrab_read_close(s);

        return AVERROR(EIO);

    }



    ret = create_stream(s);



    if (ret < 0) {

        xcbgrab_read_close(s);

        return ret;

    }



#if CONFIG_LIBXCB_SHM

    if ((c->has_shm = check_shm(c->conn)))

        c->segment = xcb_generate_id(c->conn);

#endif



#if CONFIG_LIBXCB_XFIXES

    if (c->draw_mouse) {

        if (!(c->draw_mouse = check_xfixes(c->conn))) {

            av_log(s, AV_LOG_WARNING,

                   "XFixes not available, cannot draw the mouse.\n");

        }

        if (c->bpp < 24) {

            avpriv_report_missing_feature(s, "%d bits per pixel screen",

                                          c->bpp);

            c->draw_mouse = 0;

        }

    }

#endif



    if (c->show_region)

        setup_window(s);



    return 0;

}

    if (opts)         av_free(host);
static av_cold int FUNC_0(AVFormatContext *s)

{

    XCBGrabContext *c = s->priv_data;

    int VAR_0, VAR_1;

    const xcb_setup_t *VAR_2;

    char *VAR_3        = s->filename[0] ? s->filename : NULL;

    const char *VAR_4  = strchr(s->filename, '+');



    if (VAR_4) {

        sscanf(VAR_4, "%d,%d", &c->x, &c->y);

        VAR_3 = av_strdup(s->filename);

        VAR_3[VAR_4 - s->filename] = '\0';

    }



    c->conn = xcb_connect(VAR_3, &VAR_0);



    if (VAR_4)

        av_free(VAR_3);



    if ((VAR_1 = xcb_connection_has_error(c->conn))) {

        av_log(s, AV_LOG_ERROR, "Cannot open display %s, error %d.\n",

               s->filename[0] ? VAR_3 : "default", VAR_1);

        return AVERROR(EIO);

    }

    VAR_2 = xcb_get_setup(c->conn);



    c->screen = get_screen(VAR_2, VAR_0);

    if (!c->screen) {

        av_log(s, AV_LOG_ERROR, "The screen %d does not exist.\n",

               VAR_0);

        xcbgrab_read_close(s);

        return AVERROR(EIO);

    }



    VAR_1 = create_stream(s);



    if (VAR_1 < 0) {

        xcbgrab_read_close(s);

        return VAR_1;

    }



#if CONFIG_LIBXCB_SHM

    if ((c->has_shm = check_shm(c->conn)))

        c->segment = xcb_generate_id(c->conn);

#endif



#if CONFIG_LIBXCB_XFIXES

    if (c->draw_mouse) {

        if (!(c->draw_mouse = check_xfixes(c->conn))) {

            av_log(s, AV_LOG_WARNING,

                   "XFixes not available, cannot draw the mouse.\n");

        }

        if (c->bpp < 24) {

            avpriv_report_missing_feature(s, "%d bits per pixel screen",

                                          c->bpp);

            c->draw_mouse = 0;

        }

    }

#endif



    if (c->show_region)

        setup_window(s);



    return 0;

}

static av_cold int FUNC_0(AVFormatContext *s)
{ XCBGrabContext *c = s->priv_data; int VAR_0, VAR_1; const xcb_setup_t *VAR_2; char *VAR_3        = s->filename[0] ? s->filename : NULL; const char *VAR_4  = strchr(s->filename, '+'); if (VAR_4) { sscanf(VAR_4, "%d,%d", &c->x, &c->y); VAR_3 = av_strdup(s->filename); VAR_3[VAR_4 - s->filename] = '\0'; } c->conn = xcb_connect(VAR_3, &VAR_0); if (VAR_4)
av_free(VAR_3); if ((VAR_1 = xcb_connection_has_error(c->conn))) { av_log(s, AV_LOG_ERROR, "Cannot open display %s, error %d.\n",
s->filename[0] ? VAR_3 : "default", VAR_1); return AVERROR(EIO); } VAR_2 = xcb_get_setup(c->conn); c->screen = get_screen(VAR_2, VAR_0); if (!c->screen) { av_log(s, AV_LOG_ERROR, "The screen %d does not exist.\n",
VAR_0); xcbgrab_read_close(s); return AVERROR(EIO); } VAR_1 = create_stream(s); if (VAR_1 < 0) { xcbgrab_read_close(s); return VAR_1; } #if CONFIG_LIBXCB_SHM
if ((c->has_shm = check_shm(c->conn)))
c->segment = xcb_generate_id(c->conn); #endif
#if CONFIG_LIBXCB_XFIXES
if (c->draw_mouse) { if (!(c->draw_mouse = check_xfixes(c->conn))) { av_log(s, AV_LOG_WARNING,
"XFixes not available, cannot draw the mouse.\n"); } if (c->bpp < 24) { avpriv_report_missing_feature(s, "%d bits per pixel screen",
c->bpp); c->draw_mouse = 0; } } #endif
if (c->show_region)
setup_window(s); return 0; }