x11grab.c File Reference

X11 frame device demuxer. More...

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

Go to the source code of this file.

Data Structures

struct  x11_grab
 X11 Device Demuxer context. More...

Macros

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

Functions

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

Variables

static const AVOption options []
static const AVClass x11_class
AVInputFormat ff_x11_grab_device_demuxer
 x11 grabber device demuxer declaration

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 DEC   AV_OPT_FLAG_DECODING_PARAM

Definition at line 583 of file x11grab.c.

#define OFFSET (   x)    offsetof(struct x11_grab, x)

Definition at line 582 of file x11grab.c.

#define REGION_WIN_BORDER   3

Definition at line 84 of file x11grab.c.

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


Function Documentation

static void paint_mouse_pointer ( XImage *  image,
struct x11_grab s 
)
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 334 of file x11grab.c.

Referenced by x11grab_read_packet().

static void x11grab_draw_region_win ( struct x11_grab s)
static

Draw grabbing region window.

Parameters:
sx11_grab context

Definition at line 91 of file x11grab.c.

Referenced by x11grab_read_packet(), and x11grab_region_win_init().

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 556 of file x11grab.c.

static int x11grab_read_header ( AVFormatContext s1,
AVFormatParameters ap 
)
static

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

Parameters:
s1Context from avformat core
apParameters from avformat core
Returns:

Definition at line 157 of file x11grab.c.

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 446 of file x11grab.c.

static void x11grab_region_win_init ( struct x11_grab s)
static

Initialize grabbing region window.

Parameters:
sx11_grab context

Definition at line 116 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 402 of file x11grab.c.

Referenced by x11grab_read_packet().


Variable Documentation

AVInputFormat ff_x11_grab_device_demuxer
Initial value:
{
.name = "x11grab",
.long_name = NULL_IF_CONFIG_SMALL("X11grab"),
.priv_data_size = sizeof(struct x11_grab),
.read_packet = x11grab_read_packet,
.read_close = x11grab_read_close,
.flags = AVFMT_NOFILE,
.priv_class = &x11_class,
}

x11 grabber device demuxer declaration

Definition at line 603 of file x11grab.c.

const AVOption options[]
static
Initial value:
{
{ "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = "vga"}, 0, 0, DEC },
{ "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC },
{ "draw_mouse", "Draw the mouse pointer.", OFFSET(draw_mouse), AV_OPT_TYPE_INT, { 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, { 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, { -1 }, INT_MIN, INT_MAX, DEC, "follow_mouse" },
{ "show_region", "Show the grabbing region.", OFFSET(show_region), AV_OPT_TYPE_INT, { 0 }, 0, 1, DEC },
{ NULL },
}

Definition at line 584 of file x11grab.c.

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

Definition at line 595 of file x11grab.c.