FFmpeg
Data Structures | Macros | Functions | Variables
kmsgrab.c File Reference
#include <fcntl.h>
#include <unistd.h>
#include <drm.h>
#include <drm_fourcc.h>
#include <drm_mode.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_drm.h"
#include "libavutil/internal.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixfmt.h"
#include "libavutil/pixdesc.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  KMSGrabContext
 

Macros

#define DRM_FORMAT_MOD_INVALID   ((1ULL << 56) - 1)
 
#define OFFSET(x)   offsetof(KMSGrabContext, x)
 
#define FLAGS   AV_OPT_FLAG_DECODING_PARAM
 

Functions

static void kmsgrab_free_desc (void *opaque, uint8_t *data)
 
static void kmsgrab_free_frame (void *opaque, uint8_t *data)
 
static int kmsgrab_get_fb (AVFormatContext *avctx, drmModePlane *plane, AVDRMFrameDescriptor *desc)
 
static int kmsgrab_read_packet (AVFormatContext *avctx, AVPacket *pkt)
 
static av_cold int kmsgrab_read_header (AVFormatContext *avctx)
 
static av_cold int kmsgrab_read_close (AVFormatContext *avctx)
 

Variables

struct {
   enum AVPixelFormat   pixfmt
 
   uint32_t   drm_format
 
kmsgrab_formats []
 
static const AVOption options []
 
static const AVClass kmsgrab_class
 
const FFInputFormat ff_kmsgrab_demuxer
 

Macro Definition Documentation

◆ DRM_FORMAT_MOD_INVALID

#define DRM_FORMAT_MOD_INVALID   ((1ULL << 56) - 1)

Definition at line 32 of file kmsgrab.c.

◆ OFFSET

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

Definition at line 681 of file kmsgrab.c.

◆ FLAGS

#define FLAGS   AV_OPT_FLAG_DECODING_PARAM

Definition at line 682 of file kmsgrab.c.

Function Documentation

◆ kmsgrab_free_desc()

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

Definition at line 76 of file kmsgrab.c.

Referenced by kmsgrab_read_packet().

◆ kmsgrab_free_frame()

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

Definition at line 87 of file kmsgrab.c.

Referenced by kmsgrab_read_packet().

◆ kmsgrab_get_fb()

static int kmsgrab_get_fb ( AVFormatContext avctx,
drmModePlane *  plane,
AVDRMFrameDescriptor desc 
)
static

Definition at line 94 of file kmsgrab.c.

Referenced by kmsgrab_read_packet().

◆ kmsgrab_read_packet()

static int kmsgrab_read_packet ( AVFormatContext avctx,
AVPacket pkt 
)
static

Definition at line 264 of file kmsgrab.c.

◆ kmsgrab_read_header()

static av_cold int kmsgrab_read_header ( AVFormatContext avctx)
static

Definition at line 410 of file kmsgrab.c.

◆ kmsgrab_read_close()

static av_cold int kmsgrab_read_close ( AVFormatContext avctx)
static

Definition at line 671 of file kmsgrab.c.

Variable Documentation

◆ pixfmt

enum AVPixelFormat pixfmt

◆ drm_format

uint32_t drm_format

Definition at line 368 of file kmsgrab.c.

Referenced by kmsgrab_read_header().

◆ kmsgrab_formats

const { ... } kmsgrab_formats[]

Referenced by kmsgrab_read_header().

◆ options

const AVOption options[]
static
Initial value:
= {
{ "device", "DRM device path",
OFFSET(device_path), AV_OPT_TYPE_STRING,
{ .str = "/dev/dri/card0" }, 0, 0, FLAGS },
{ "format", "Pixel format for framebuffer",
{ .i64 = AV_PIX_FMT_NONE }, -1, INT32_MAX, FLAGS },
{ "format_modifier", "DRM format modifier for framebuffer",
OFFSET(drm_format_modifier), AV_OPT_TYPE_INT64,
{ .i64 = DRM_FORMAT_MOD_INVALID }, 0, INT64_MAX, FLAGS },
{ "crtc_id", "CRTC ID to define capture source",
OFFSET(source_crtc), AV_OPT_TYPE_INT64,
{ .i64 = 0 }, 0, UINT32_MAX, FLAGS },
{ "plane_id", "Plane ID to define capture source",
OFFSET(source_plane), AV_OPT_TYPE_INT64,
{ .i64 = 0 }, 0, UINT32_MAX, FLAGS },
{ "framerate", "Framerate to capture at",
{ .dbl = 30.0 }, 0, 1000, FLAGS },
{ NULL },
}

Definition at line 683 of file kmsgrab.c.

◆ kmsgrab_class

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

Definition at line 705 of file kmsgrab.c.

◆ ff_kmsgrab_demuxer

const FFInputFormat ff_kmsgrab_demuxer
Initial value:
= {
.p.name = "kmsgrab",
.p.long_name = NULL_IF_CONFIG_SMALL("KMS screen capture"),
.p.flags = AVFMT_NOFILE,
.p.priv_class = &kmsgrab_class,
.priv_data_size = sizeof(KMSGrabContext),
}

Definition at line 713 of file kmsgrab.c.

AV_OPT_TYPE_RATIONAL
@ AV_OPT_TYPE_RATIONAL
Underlying C type is AVRational.
Definition: opt.h:280
kmsgrab_read_close
static av_cold int kmsgrab_read_close(AVFormatContext *avctx)
Definition: kmsgrab.c:671
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
kmsgrab_read_packet
static int kmsgrab_read_packet(AVFormatContext *avctx, AVPacket *pkt)
Definition: kmsgrab.c:264
format
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
DRM_FORMAT_MOD_INVALID
#define DRM_FORMAT_MOD_INVALID
Definition: kmsgrab.c:32
AV_OPT_TYPE_INT64
@ AV_OPT_TYPE_INT64
Underlying C type is int64_t.
Definition: opt.h:263
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_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
KMSGrabContext
Definition: kmsgrab.c:49
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
OFFSET
#define OFFSET(x)
Definition: kmsgrab.c:681
AVFMT_NOFILE
#define AVFMT_NOFILE
Demuxer will use avio_open, no opened file should be provided by the caller.
Definition: avformat.h:468
kmsgrab_read_header
static av_cold int kmsgrab_read_header(AVFormatContext *avctx)
Definition: kmsgrab.c:410
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
options
static const AVOption options[]
Definition: kmsgrab.c:683
AV_OPT_TYPE_PIXEL_FMT
@ AV_OPT_TYPE_PIXEL_FMT
Underlying C type is enum AVPixelFormat.
Definition: opt.h:307
kmsgrab_class
static const AVClass kmsgrab_class
Definition: kmsgrab.c:705
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
FLAGS
#define FLAGS
Definition: kmsgrab.c:682