FFmpeg
Data Structures | Macros | Functions | Variables
xcbgrab.c File Reference
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <xcb/xcb.h>
#include "libavutil/internal.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "libavutil/time.h"
#include "libavformat/avformat.h"
#include "libavformat/demux.h"
#include "libavformat/internal.h"

Go to the source code of this file.

Data Structures

struct  XCBGrabContext
 

Macros

#define FOLLOW_CENTER   -1
 
#define OFFSET(x)   offsetof(XCBGrabContext, x)
 
#define D   AV_OPT_FLAG_DECODING_PARAM
 
#define CROSSHAIR_CURSOR   34
 

Functions

static int xcbgrab_reposition (AVFormatContext *s, xcb_query_pointer_reply_t *p, xcb_get_geometry_reply_t *geo)
 
static void xcbgrab_image_reply_free (void *opaque, uint8_t *data)
 
static int xcbgrab_frame (AVFormatContext *s, AVPacket *pkt)
 
static int64_t wait_frame (AVFormatContext *s, AVPacket *pkt)
 
static void xcbgrab_update_region (AVFormatContext *s, int win_x, int win_y)
 
static int xcbgrab_read_packet (AVFormatContext *s, AVPacket *pkt)
 
static av_cold int xcbgrab_read_close (AVFormatContext *s)
 
static xcb_screen_t * get_screen (const xcb_setup_t *setup, int screen_num)
 
static int pixfmt_from_pixmap_format (AVFormatContext *s, int depth, int *pix_fmt, int *bpp)
 
static int create_stream (AVFormatContext *s)
 
static void draw_rectangle (AVFormatContext *s)
 
static void setup_window (AVFormatContext *s)
 
static xcb_rectangle_t rectangle_from_corners (xcb_point_t *corner_a, xcb_point_t *corner_b)
 
static int select_region (AVFormatContext *s)
 
static av_cold int xcbgrab_read_header (AVFormatContext *s)
 

Variables

static const AVOption options []
 
static const AVClass xcbgrab_class
 
const FFInputFormat ff_xcbgrab_demuxer
 

Macro Definition Documentation

◆ FOLLOW_CENTER

#define FOLLOW_CENTER   -1

Definition at line 83 of file xcbgrab.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(XCBGrabContext, x)

Definition at line 85 of file xcbgrab.c.

◆ D

Definition at line 86 of file xcbgrab.c.

◆ CROSSHAIR_CURSOR

#define CROSSHAIR_CURSOR   34

Definition at line 708 of file xcbgrab.c.

Function Documentation

◆ xcbgrab_reposition()

static int xcbgrab_reposition ( AVFormatContext s,
xcb_query_pointer_reply_t *  p,
xcb_get_geometry_reply_t *  geo 
)
static

Definition at line 113 of file xcbgrab.c.

Referenced by xcbgrab_read_packet().

◆ xcbgrab_image_reply_free()

static void xcbgrab_image_reply_free ( void *  opaque,
uint8_t *  data 
)
static

Definition at line 154 of file xcbgrab.c.

Referenced by xcbgrab_frame().

◆ xcbgrab_frame()

static int xcbgrab_frame ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 159 of file xcbgrab.c.

Referenced by xcbgrab_read_packet().

◆ wait_frame()

static int64_t wait_frame ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 203 of file xcbgrab.c.

Referenced by xcbgrab_read_packet().

◆ xcbgrab_update_region()

static void xcbgrab_update_region ( AVFormatContext s,
int  win_x,
int  win_y 
)
static

Definition at line 404 of file xcbgrab.c.

Referenced by xcbgrab_read_packet().

◆ xcbgrab_read_packet()

static int xcbgrab_read_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 416 of file xcbgrab.c.

◆ xcbgrab_read_close()

static av_cold int xcbgrab_read_close ( AVFormatContext s)
static

Definition at line 489 of file xcbgrab.c.

Referenced by xcbgrab_read_header().

◆ get_screen()

static xcb_screen_t* get_screen ( const xcb_setup_t *  setup,
int  screen_num 
)
static

Definition at line 502 of file xcbgrab.c.

Referenced by xcbgrab_read_header().

◆ pixfmt_from_pixmap_format()

static int pixfmt_from_pixmap_format ( AVFormatContext s,
int  depth,
int *  pix_fmt,
int *  bpp 
)
static

Definition at line 519 of file xcbgrab.c.

Referenced by create_stream().

◆ create_stream()

static int create_stream ( AVFormatContext s)
static

Definition at line 574 of file xcbgrab.c.

Referenced by xcbgrab_read_header().

◆ draw_rectangle()

static void draw_rectangle ( AVFormatContext s)
static

Definition at line 649 of file xcbgrab.c.

Referenced by setup_window().

◆ setup_window()

static void setup_window ( AVFormatContext s)
static

Definition at line 672 of file xcbgrab.c.

Referenced by xcbgrab_read_header().

◆ rectangle_from_corners()

static xcb_rectangle_t rectangle_from_corners ( xcb_point_t *  corner_a,
xcb_point_t *  corner_b 
)
static

Definition at line 710 of file xcbgrab.c.

Referenced by select_region().

◆ select_region()

static int select_region ( AVFormatContext s)
static

Definition at line 721 of file xcbgrab.c.

Referenced by xcbgrab_read_header().

◆ xcbgrab_read_header()

static av_cold int xcbgrab_read_header ( AVFormatContext s)
static

Definition at line 819 of file xcbgrab.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "window_id", "Window to capture.", OFFSET(window_id), AV_OPT_TYPE_INT, { .i64 = XCB_NONE }, 0, UINT32_MAX, D },
{ "x", "Initial x coordinate.", OFFSET(x), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, D },
{ "y", "Initial y coordinate.", OFFSET(y), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, D },
{ "grab_x", "Initial x coordinate.", OFFSET(x), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, D },
{ "grab_y", "Initial y coordinate.", OFFSET(y), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, D },
{ "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(width), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL }, 0, 0, D },
{ "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "ntsc" }, 0, 0, D },
{ "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, .unit = "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, .unit = "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 },
{ "select_region", "Select the grabbing region graphically using the pointer.", OFFSET(select_region), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, D },
{ NULL },
}

Definition at line 87 of file xcbgrab.c.

◆ xcbgrab_class

const AVClass xcbgrab_class
static
Initial value:
= {
.class_name = "xcbgrab indev",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 105 of file xcbgrab.c.

◆ ff_xcbgrab_demuxer

const FFInputFormat ff_xcbgrab_demuxer
Initial value:
= {
.p.name = "x11grab",
.p.long_name = NULL_IF_CONFIG_SMALL("X11 screen capture, using XCB"),
.p.flags = AVFMT_NOFILE,
.p.priv_class = &xcbgrab_class,
.priv_data_size = sizeof(XCBGrabContext),
}

Definition at line 908 of file xcbgrab.c.

FOLLOW_CENTER
#define FOLLOW_CENTER
Definition: xcbgrab.c:83
xcbgrab_class
static const AVClass xcbgrab_class
Definition: xcbgrab.c:105
read_close
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:143
read_packet
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_read_callback.c:42
options
static const AVOption options[]
Definition: xcbgrab.c:87
framerate
float framerate
Definition: av1_levels.c:29
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
read_header
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:540
NULL
#define NULL
Definition: coverity.c:32
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition: opt.h:303
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT
@ AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT
Definition: log.h:41
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
AVFMT_NOFILE
#define AVFMT_NOFILE
Demuxer will use avio_open, no opened file should be provided by the caller.
Definition: avformat.h:468
D
#define D
Definition: xcbgrab.c:86
xcbgrab_read_close
static av_cold int xcbgrab_read_close(AVFormatContext *s)
Definition: xcbgrab.c:489
xcbgrab_read_packet
static int xcbgrab_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: xcbgrab.c:416
select_region
static int select_region(AVFormatContext *s)
Definition: xcbgrab.c:721
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
xcbgrab_read_header
static av_cold int xcbgrab_read_header(AVFormatContext *s)
Definition: xcbgrab.c:819
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
OFFSET
#define OFFSET(x)
Definition: xcbgrab.c:85
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:276
width
#define width
Definition: dsp.h:85
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
XCBGrabContext
Definition: xcbgrab.c:52