[FFmpeg-devel] [PATCH] avdevice: add dxgigrab

Timo Rothenpieler timo at rothenpieler.org
Thu Feb 9 17:58:46 EET 2023


On 09.02.2023 15:22, aline.gondimsantos at savoirfairelinux.com wrote:
> From: Aline Gondim Santos <aline.gondimsantos at savoirfairelinux.com>
> 
> A dxgi grab device may be either a display or a window.
> Differently from the existing gdigrab, this new device does
> not make the mouse to flick and also allows proper grabbing of
> accelerated windows, such as chrome or visual studio code.

How do you get access to the d3d hwdevice, given this lives in lavd, 
which has no provisions for that?
This looks much more like it'd fit in with the desktop duplication 
capture, which ended up being a vsrc filter for that reason.

> Signed-off-by: Aline Gondim Santos <aline.gondimsantos at savoirfairelinux.com>
> ---
>   configure                        |   1 +
>   libavdevice/Makefile             |   4 +
>   libavdevice/alldevices.c         |   1 +
>   libavdevice/d3dHelpers.h         |  59 ++++++++
>   libavdevice/direct3d11.interop.h |  51 +++++++
>   libavdevice/dxgigrab.cpp         | 225 +++++++++++++++++++++++++++++++
>   libavdevice/dxgigrab.h           |  83 ++++++++++++
>   libavdevice/dxgigrab_c.c         |  59 ++++++++
>   libavdevice/dxgigrab_c.h         |  98 ++++++++++++++
>   libavdevice/windows_capture.cpp  | 184 +++++++++++++++++++++++++
>   libavdevice/windows_capture.h    |  82 +++++++++++

The name of these files seem way too generic to just sit there like this 
in the top level.

>   11 files changed, 847 insertions(+)
>   create mode 100644 libavdevice/d3dHelpers.h
>   create mode 100644 libavdevice/direct3d11.interop.h
>   create mode 100644 libavdevice/dxgigrab.cpp
>   create mode 100644 libavdevice/dxgigrab.h
>   create mode 100644 libavdevice/dxgigrab_c.c
>   create mode 100644 libavdevice/dxgigrab_c.h
>   create mode 100644 libavdevice/windows_capture.cpp
>   create mode 100644 libavdevice/windows_capture.h
> 
> diff --git a/configure b/configure
> index 12184c7f26..c9cbee0c09 100755
> --- a/configure
> +++ b/configure
> @@ -3529,6 +3529,7 @@ fbdev_outdev_deps="linux_fb_h"
>   gdigrab_indev_deps="CreateDIBSection"
>   gdigrab_indev_extralibs="-lgdi32"
>   gdigrab_indev_select="bmp_decoder"
> +dxgigrab_indev_extralibs="-ldxgi -ld3d11"
>   iec61883_indev_deps="libiec61883"
>   iec61883_indev_select="dv_demuxer"
>   jack_indev_deps="libjack"
> diff --git a/libavdevice/Makefile b/libavdevice/Makefile
> index 8a62822b69..6740012000 100644
> --- a/libavdevice/Makefile
> +++ b/libavdevice/Makefile
> @@ -30,6 +30,7 @@ OBJS-$(CONFIG_FBDEV_INDEV)               += fbdev_dec.o \
>   OBJS-$(CONFIG_FBDEV_OUTDEV)              += fbdev_enc.o \
>                                               fbdev_common.o
>   OBJS-$(CONFIG_GDIGRAB_INDEV)             += gdigrab.o
> +OBJS-$(CONFIG_DXGIGRAB_INDEV)            += windows_capture.o dxgigrab.o dxgigrab_c.o
>   OBJS-$(CONFIG_IEC61883_INDEV)            += iec61883.o
>   OBJS-$(CONFIG_JACK_INDEV)                += jack.o timefilter.o
>   OBJS-$(CONFIG_KMSGRAB_INDEV)             += kmsgrab.o
> @@ -72,5 +73,8 @@ SKIPHEADERS-$(CONFIG_V4L2_INDEV)         += v4l2-common.h
>   SKIPHEADERS-$(CONFIG_V4L2_OUTDEV)        += v4l2-common.h
>   SKIPHEADERS-$(CONFIG_ALSA)               += alsa.h
>   SKIPHEADERS-$(CONFIG_SNDIO)              += sndio.h
> +SKIPHEADERS-$(CONFIG_DXGIGRAB_INDEV)     += dxgigrab.h \
> +                                            windows_capture.h \
> +                                            dxgigrab_c.h
>   
>   TESTPROGS-$(CONFIG_JACK_INDEV)           += timefilter
> diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
> index 22323a0a44..fb0a37513b 100644
> --- a/libavdevice/alldevices.c
> +++ b/libavdevice/alldevices.c
> @@ -35,6 +35,7 @@ extern const AVInputFormat  ff_dshow_demuxer;
>   extern const AVInputFormat  ff_fbdev_demuxer;
>   extern const AVOutputFormat ff_fbdev_muxer;
>   extern const AVInputFormat  ff_gdigrab_demuxer;
> +extern const AVInputFormat  ff_dxgigrab_demuxer;
>   extern const AVInputFormat  ff_iec61883_demuxer;
>   extern const AVInputFormat  ff_jack_demuxer;
>   extern const AVInputFormat  ff_kmsgrab_demuxer;
> diff --git a/libavdevice/d3dHelpers.h b/libavdevice/d3dHelpers.h
> new file mode 100644
> index 0000000000..d8d2c003ec
> --- /dev/null
> +++ b/libavdevice/d3dHelpers.h
> @@ -0,0 +1,59 @@
> +/*
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public License
> + * as published by the Free Software Foundation; either version 2.1
> + * of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#pragma once
> +
> +#include <winrt/Windows.UI.Composition.h>
> +#include <windows.ui.composition.interop.h>
> +#include <d2d1_1.h>

Are these headers parts of any normal windows SDK?
I don't see them in anything mingw has.
Does this break cross compiling from Linux, or with anything that's not 
MSVC?

And given it's winrt... does this work on normal Desktop Windows?


More information about the ffmpeg-devel mailing list