FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
x11grab.c File Reference

X11 frame device demuxer. More...

#include "config.h"
#include <time.h>
#include <sys/shm.h>
#include <X11/cursorfont.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xlibint.h>
#include <X11/Xproto.h>
#include <X11/Xutil.h>
#include <X11/extensions/shape.h>
#include <X11/extensions/Xfixes.h>
#include <X11/extensions/XShm.h>
#include "libavutil/internal.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "libavformat/internal.h"
#include "avdevice.h"

Go to the source code of this file.

Data Structures

struct  X11GrabContext
 X11 device demuxer context. More...
 

Macros

#define REGION_WIN_BORDER   3
 
#define OFFSET(x)   offsetof(X11GrabContext, x)
 
#define DEC   AV_OPT_FLAG_DECODING_PARAM
 

Functions

static void x11grab_draw_region_win (X11GrabContext *s)
 Draw grabbing region window. More...
 
static void x11grab_region_win_init (X11GrabContext *s)
 Initialize grabbing region window. More...
 
static int setup_shm (AVFormatContext *s, Display *dpy, XImage **image)
 
static int setup_mouse (Display *dpy, int screen)
 
static int pixfmt_from_image (AVFormatContext *s, XImage *image, int *pix_fmt)
 
static int x11grab_read_header (AVFormatContext *s1)
 Initialize the x11 grab device demuxer (public device demuxer API). More...
 
static void paint_mouse_pointer (XImage *image, AVFormatContext *s1)
 Paint a mouse pointer in an X11 image. More...
 
static int xget_zpixmap (Display *dpy, Drawable d, XImage *image, int x, int y)
 Read new data in the image structure. More...
 
static int x11grab_read_packet (AVFormatContext *s1, AVPacket *pkt)
 Grab a frame from x11 (public device demuxer API). More...
 
static int x11grab_read_close (AVFormatContext *s1)
 Close x11 frame grabber (public device demuxer API). More...
 

Variables

static const AVOption options []
 
static const AVClass x11_class
 
AVInputFormat ff_x11grab_demuxer
 x11 grabber device demuxer declaration More...
 

Detailed Description

X11 frame device demuxer.

Author
Clemens Fruhwirth cleme.nosp@m.ns@e.nosp@m.ndorp.nosp@m.hin..nosp@m.org
Edouard Gomez ed.go.nosp@m.mez@.nosp@m.free..nosp@m.fr

Definition in file x11grab.c.

Macro Definition Documentation

#define REGION_WIN_BORDER   3

Definition at line 92 of file x11grab.c.

Referenced by x11grab_draw_region_win(), x11grab_read_packet(), and x11grab_region_win_init().

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

Definition at line 659 of file x11grab.c.

#define DEC   AV_OPT_FLAG_DECODING_PARAM

Definition at line 660 of file x11grab.c.

Function Documentation

static void x11grab_draw_region_win ( X11GrabContext s)
static

Draw grabbing region window.

Parameters
sx11grab context

Definition at line 99 of file x11grab.c.

Referenced by x11grab_read_packet(), and x11grab_region_win_init().

static void x11grab_region_win_init ( X11GrabContext s)
static

Initialize grabbing region window.

Parameters
sx11grab context

Definition at line 120 of file x11grab.c.

Referenced by x11grab_read_packet().

static int setup_shm ( AVFormatContext s,
Display *  dpy,
XImage **  image 
)
static

Definition at line 147 of file x11grab.c.

Referenced by x11grab_read_header().

static int setup_mouse ( Display *  dpy,
int  screen 
)
static

Definition at line 176 of file x11grab.c.

Referenced by x11grab_read_header().

static int pixfmt_from_image ( AVFormatContext s,
XImage *  image,
int *  pix_fmt 
)
static

Definition at line 189 of file x11grab.c.

Referenced by x11grab_read_header().

static int x11grab_read_header ( AVFormatContext s1)
static

Initialize the x11 grab device demuxer (public device demuxer API).

Parameters
s1Context from avformat core
Returns

Definition at line 259 of file x11grab.c.

static void paint_mouse_pointer ( XImage *  image,
AVFormatContext s1 
)
static

Paint a mouse pointer in an X11 image.

Parameters
imageimage to paint the mouse pointer to
scontext used to retrieve original grabbing rectangle coordinates

Definition at line 395 of file x11grab.c.

Referenced by x11grab_read_packet().

static int xget_zpixmap ( Display *  dpy,
Drawable  d,
XImage *  image,
int  x,
int  y 
)
static

Read new data in the image structure.

Parameters
dpyX11 display to grab from
d
imageImage where the grab will be put
xTop-Left grabbing rectangle horizontal coordinate
yTop-Left grabbing rectangle vertical coordinate
Returns
0 if error, !0 if successful

Definition at line 475 of file x11grab.c.

Referenced by x11grab_read_packet().

static int x11grab_read_packet ( AVFormatContext s1,
AVPacket pkt 
)
static

Grab a frame from x11 (public device demuxer API).

Parameters
s1Context from avformat core
pktPacket holding the brabbed frame
Returns
frame size in bytes

Definition at line 517 of file x11grab.c.

static int x11grab_read_close ( AVFormatContext s1)
static

Close x11 frame grabber (public device demuxer API).

Parameters
s1Context from avformat core
Returns
0 success, !0 failure

Definition at line 634 of file x11grab.c.

Variable Documentation

const AVOption options[]
static
Initial value:
= {
{ "grab_x", "Initial x coordinate.", OFFSET(x_off), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, DEC },
{ "grab_y", "Initial y coordinate.", OFFSET(y_off), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, DEC },
{ "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" },
{ "framerate", "set video frame rate", OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, {.str = "ntsc"}, 0, INT_MAX, DEC },
{ "show_region", "show the grabbing region", OFFSET(show_region), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DEC },
{ "video_size", "set video frame size", OFFSET(width), AV_OPT_TYPE_IMAGE_SIZE, {.str = "vga"}, 0, 0, DEC },
{ "use_shm", "use MIT-SHM extension", OFFSET(use_shm), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, DEC },
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define OFFSET(x)
Definition: x11grab.c:659
#define DEC
Definition: x11grab.c:660
#define width
offset must point to AVRational
Definition: opt.h:235
offset must point to two consecutive integers
Definition: opt.h:232
char * framerate
Set by a private option.
Definition: vfwcap.c:51

Definition at line 661 of file x11grab.c.

const AVClass x11_class
static
Initial value:
= {
.class_name = "X11grab indev",
.item_name = av_default_item_name,
.option = options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:70
static const AVOption options[]
Definition: x11grab.c:661
av_default_item_name

Definition at line 678 of file x11grab.c.

AVInputFormat ff_x11grab_demuxer
Initial value:
= {
.name = "x11grab",
.long_name = NULL_IF_CONFIG_SMALL("X11grab"),
.priv_data_size = sizeof(X11GrabContext),
.priv_class = &x11_class,
}
static int x11grab_read_header(AVFormatContext *s1)
Initialize the x11 grab device demuxer (public device demuxer API).
Definition: x11grab.c:259
static int x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
Grab a frame from x11 (public device demuxer API).
Definition: x11grab.c:517
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:145
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
static const AVClass x11_class
Definition: x11grab.c:678
static int x11grab_read_close(AVFormatContext *s1)
Close x11 frame grabber (public device demuxer API).
Definition: x11grab.c:634
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:638
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42
X11 device demuxer context.
Definition: x11grab.c:66
static int flags
Definition: cpu.c:47
#define AVFMT_NOFILE
Demuxer will use avio_open, no opened file should be provided by the caller.
Definition: avformat.h:476

x11 grabber device demuxer declaration

Definition at line 687 of file x11grab.c.