FFmpeg
Data Structures | Macros | Functions | Variables
gdigrab.c File Reference
#include "config.h"
#include "libavformat/demux.h"
#include "libavformat/internal.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/time.h"
#include "libavutil/wchar_filename.h"
#include <windows.h>

Go to the source code of this file.

Data Structures

struct  gdigrab
 GDI Device Demuxer context. More...
 

Macros

#define WIN32_API_ERROR(str)   av_log(s1, AV_LOG_ERROR, str " (error %li)\n", GetLastError())
 
#define REGION_WND_BORDER   3
 
#define CURSOR_ERROR(str)
 
#define OFFSET(x)   offsetof(struct gdigrab, x)
 
#define DEC   AV_OPT_FLAG_DECODING_PARAM
 

Functions

static LRESULT CALLBACK gdigrab_region_wnd_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 Callback to handle Windows messages for the region outline window. More...
 
static int gdigrab_region_wnd_init (AVFormatContext *s1, struct gdigrab *gdigrab)
 Initialize the region outline window. More...
 
static void gdigrab_region_wnd_destroy (AVFormatContext *s1, struct gdigrab *gdigrab)
 Cleanup/free the region outline window. More...
 
static void gdigrab_region_wnd_update (AVFormatContext *s1, struct gdigrab *gdigrab)
 Process the Windows message queue. More...
 
static int gdigrab_read_header (AVFormatContext *s1)
 Initializes the gdi grab device demuxer (public device demuxer API). More...
 
static void paint_mouse_pointer (AVFormatContext *s1, struct gdigrab *gdigrab)
 Paints a mouse pointer in a Win32 image. More...
 
static int gdigrab_read_packet (AVFormatContext *s1, AVPacket *pkt)
 Grabs a frame from gdi (public device demuxer API). More...
 
static int gdigrab_read_close (AVFormatContext *s1)
 Closes gdi frame grabber (public device demuxer API). More...
 

Variables

static const AVOption options []
 
static const AVClass gdigrab_class
 
const FFInputFormat ff_gdigrab_demuxer
 gdi grabber device demuxer declaration More...
 

Detailed Description

GDI frame device demuxer

Author
Calvin Walton calvi.nosp@m.n.wa.nosp@m.lton@.nosp@m.keps.nosp@m.tin.c.nosp@m.a
Christophe Gisquet word1.nosp@m..wor.nosp@m.d2@gm.nosp@m.ail..nosp@m.com

Definition in file gdigrab.c.

Macro Definition Documentation

◆ WIN32_API_ERROR

#define WIN32_API_ERROR (   str)    av_log(s1, AV_LOG_ERROR, str " (error %li)\n", GetLastError())

Definition at line 72 of file gdigrab.c.

◆ REGION_WND_BORDER

#define REGION_WND_BORDER   3

Definition at line 75 of file gdigrab.c.

◆ CURSOR_ERROR

#define CURSOR_ERROR (   str)
Value:
WIN32_API_ERROR(str); \
gdigrab->cursor_error_printed = 1; \
}

◆ OFFSET

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

Definition at line 661 of file gdigrab.c.

◆ DEC

#define DEC   AV_OPT_FLAG_DECODING_PARAM

Definition at line 662 of file gdigrab.c.

Function Documentation

◆ gdigrab_region_wnd_proc()

static LRESULT CALLBACK gdigrab_region_wnd_proc ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Callback to handle Windows messages for the region outline window.

In particular, this handles painting the frame rectangle.

Parameters
hwndThe region outline window handle.
msgThe Windows message.
wparamFirst Windows message parameter.
lparamSecond Windows message parameter.
Returns
0 success, !0 failure

Definition at line 89 of file gdigrab.c.

Referenced by gdigrab_region_wnd_init().

◆ gdigrab_region_wnd_init()

static int gdigrab_region_wnd_init ( AVFormatContext s1,
struct gdigrab gdigrab 
)
static

Initialize the region outline window.

Parameters
s1The format context.
gdigrabgdigrab context.
Returns
0 success, !0 failure

Definition at line 124 of file gdigrab.c.

Referenced by gdigrab_read_header().

◆ gdigrab_region_wnd_destroy()

static void gdigrab_region_wnd_destroy ( AVFormatContext s1,
struct gdigrab gdigrab 
)
static

Cleanup/free the region outline window.

Parameters
s1The format context.
gdigrabgdigrab context.

Definition at line 190 of file gdigrab.c.

Referenced by gdigrab_read_close().

◆ gdigrab_region_wnd_update()

static void gdigrab_region_wnd_update ( AVFormatContext s1,
struct gdigrab gdigrab 
)
static

Process the Windows message queue.

This is important to prevent Windows from thinking the window has become unresponsive. As well, things like WM_PAINT (to actually draw the window contents) are handled from the message queue context.

Parameters
s1The format context.
gdigrabgdigrab context.

Definition at line 208 of file gdigrab.c.

Referenced by gdigrab_read_packet().

◆ gdigrab_read_header()

static int gdigrab_read_header ( AVFormatContext s1)
static

Initializes the gdi grab device demuxer (public device demuxer API).

Parameters
s1Context from avformat core
Returns
AVERROR_IO error, 0 success

Definition at line 225 of file gdigrab.c.

◆ paint_mouse_pointer()

static void paint_mouse_pointer ( AVFormatContext s1,
struct gdigrab gdigrab 
)
static

Paints a mouse pointer in a Win32 image.

Parameters
s1Context of the log information
sCurrent grad structure

Definition at line 470 of file gdigrab.c.

Referenced by gdigrab_read_packet().

◆ gdigrab_read_packet()

static int gdigrab_read_packet ( AVFormatContext s1,
AVPacket pkt 
)
static

Grabs a frame from gdi (public device demuxer API).

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

Definition at line 558 of file gdigrab.c.

◆ gdigrab_read_close()

static int gdigrab_read_close ( AVFormatContext s1)
static

Closes gdi frame grabber (public device demuxer API).

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

Definition at line 642 of file gdigrab.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "draw_mouse", "draw the mouse pointer", OFFSET(draw_mouse), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, DEC },
{ "show_region", "draw border around capture area", OFFSET(show_region), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DEC },
{ "framerate", "set video frame rate", OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, {.str = "ntsc"}, 0, INT_MAX, DEC },
{ "video_size", "set video frame size", OFFSET(width), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, DEC },
{ "offset_x", "capture area x offset", OFFSET(offset_x), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC },
{ "offset_y", "capture area y offset", OFFSET(offset_y), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC },
{ NULL },
}

Definition at line 663 of file gdigrab.c.

◆ gdigrab_class

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

Definition at line 673 of file gdigrab.c.

◆ ff_gdigrab_demuxer

const FFInputFormat ff_gdigrab_demuxer
Initial value:
= {
.p.name = "gdigrab",
.p.long_name = NULL_IF_CONFIG_SMALL("GDI API Windows frame grabber"),
.p.flags = AVFMT_NOFILE,
.p.priv_class = &gdigrab_class,
.priv_data_size = sizeof(struct gdigrab),
.read_packet = gdigrab_read_packet,
.read_close = gdigrab_read_close,
}

gdi grabber device demuxer declaration

Definition at line 682 of file gdigrab.c.

gdigrab_read_packet
static int gdigrab_read_packet(AVFormatContext *s1, AVPacket *pkt)
Grabs a frame from gdi (public device demuxer API).
Definition: gdigrab.c:558
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
Definition: opt.h:315
OFFSET
#define OFFSET(x)
Definition: gdigrab.c:661
gdigrab::cursor_error_printed
int cursor_error_printed
Definition: gdigrab.c:69
DEC
#define DEC
Definition: gdigrab.c:662
gdigrab_read_close
static int gdigrab_read_close(AVFormatContext *s1)
Closes gdi frame grabber (public device demuxer API).
Definition: gdigrab.c:642
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
gdigrab_read_header
static int gdigrab_read_header(AVFormatContext *s1)
Initializes the gdi grab device demuxer (public device demuxer API).
Definition: gdigrab.c:225
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
gdigrab_class
static const AVClass gdigrab_class
Definition: gdigrab.c:673
AVFMT_NOFILE
#define AVFMT_NOFILE
Demuxer will use avio_open, no opened file should be provided by the caller.
Definition: avformat.h:468
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
gdigrab
GDI Device Demuxer context.
Definition: gdigrab.c:43
options
static const AVOption options[]
Definition: gdigrab.c:663
width
#define width
Definition: dsp.h:85