Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: llyyr <llyyr.public@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [RFC PATCH 1/2] libavdevice/pipewiregrab: add pipewire based grab
Date: Fri, 22 Sep 2023 17:07:20 +0530
Message-ID: <ff795246-7e19-4ad4-92f0-ef4acdc92824@gmail.com> (raw)
In-Reply-To: <20230920184058.1263793-1-abhishek.ojha@savoirfairelinux.com>

On 9/21/23 00:10, Abhishek Ojha wrote:
> This is an proof of concept for pipewire grab to enable screen capture
> on wayland. Add a new Linux capture based on [1] PipeWire and the
> [2] Desktop portal.
> This new capture starts by asking the Desktop portal for a screencapture
> session.There are quite a few D-Bus calls involved in this, but the key
> points are:
> 
> 1. A connection to org.freedesktop.portal.ScreenCast is estabilished,
>     and the available cursor modes are updated. Currently only embedded
>     and hidden currsor mode enabled.
> 
> 2. Call CreateSession via dbus call. This is the first step of the
>     communication. Response callback return the status of created
>     session.
> 
> 3. Call SelectSources . This is when a system dialog pops up asking
>     the user to either select a monitor (desktop capture).Only monitor
>     capture is enabled in current implementation.
> 
> 4. Call Start . This signals the compositor that it can setup a PipeWire
>     stream, and start sending buffers.
> 
> Above flow is implemented as per the [2] xdg-desktop-portal. Once flow
> is completed, pipewire fd is received and using this pipewire stream is
> created and receive buffer from the created stream.
> 
> For cursor implementation, embedded cursor mode is enabled that means
> cursor metadata is not handled in current implementation and has no
> control over the cursor bitmap.
> 
> gdbus/pipewire logic, this is based on obs-xdg, gstpipewire and
> pipewire examples, and initial pipewire grab logic, this is based on
> libavdevice/xcbgrab and libavdevice/v4l2
> 
> This implementation shows the skeleton implementation and enables basic
> functionality. I'd like to hear opinions and suggestions to improve and
> properly use this.
> 
> [1] https://pipewire.org/
> [2] https://github.com/flatpak/xdg-desktop-portal/
> 
> Below are the arguments for pipewiregrab.
> ffplay -f pipewiregrab -draw_mouse 1 -i :0.0
> 
> Signed-off-by: Abhishek Ojha <abhishek.ojha@savoirfairelinux.com>
> ---
>   configure                  |    9 +
>   libavdevice/Makefile       |    1 +
>   libavdevice/alldevices.c   |    1 +
>   libavdevice/pipewiregrab.c | 1836 ++++++++++++++++++++++++++++++++++++
>   4 files changed, 1847 insertions(+)
>   create mode 100644 libavdevice/pipewiregrab.c
> 
> diff --git a/configure b/configure
> index e40dcce09e..325b10484f 100755
> --- a/configure
> +++ b/configure
> @@ -299,6 +299,7 @@ External library support:
>     --enable-libxcb-shm      enable X11 grabbing shm communication [autodetect]
>     --enable-libxcb-xfixes   enable X11 grabbing mouse rendering [autodetect]
>     --enable-libxcb-shape    enable X11 grabbing shape rendering [autodetect]
> +  --enable-libpipewire     enable screen grabbing using pipewire [autodetect]
>     --enable-libxvid         enable Xvid encoding via xvidcore,
>                              native MPEG-4/Xvid encoder exists [no]
>     --enable-libxml2         enable XML parsing using the C library libxml2, needed
> @@ -1788,6 +1789,8 @@ EXTERNAL_AUTODETECT_LIBRARY_LIST="
>       libxcb_shm
>       libxcb_shape
>       libxcb_xfixes
> +    libpipewire
> +    libgio_unix
>       lzma
>       mediafoundation
>       metal
> @@ -3621,6 +3624,7 @@ v4l2_outdev_suggest="libv4l2"
>   vfwcap_indev_deps="vfw32 vfwcap_defines"
>   xcbgrab_indev_deps="libxcb"
>   xcbgrab_indev_suggest="libxcb_shm libxcb_shape libxcb_xfixes"
> +pipewiregrab_indev_deps="libpipewire libgio_unix pthreads"
>   xv_outdev_deps="xlib_xv xlib_x11 xlib_xext"
>   
>   # protocols
> @@ -7041,6 +7045,11 @@ if enabled libxcb; then
>       enabled libxcb_xfixes && check_pkg_config libxcb_xfixes xcb-xfixes xcb/xfixes.h xcb_xfixes_get_cursor_image
>   fi
>   
> +enabled libpipewire && check_pkg_config libpipewire "libpipewire-0.3 >= 0.3.40" pipewire/pipewire.h pw_init
> +if enabled libpipewire; then
> +    enabled libgio_unix && check_pkg_config libgio_unix gio-unix-2.0 gio/gio.h g_main_loop_new
> +fi
> +
I just tried this and it failed to build due to missing locale_t and 
other locale related issues in pipewire's spa library. Upon further 
inspection, it seems Pipewire wants _XOPEN_SOURCE=700 but ffmpeg's 
configure sets _XOPEN_SOURCE=600. Not sure who's at fault here but I was 
able to get it to build after explicitly setting that.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

      parent reply	other threads:[~2023-09-22 11:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-20 18:40 Abhishek Ojha
2023-09-20 18:40 ` [FFmpeg-devel] [RFC PATCH 2/2] configure: disable locale use in spa plugin Abhishek Ojha
2023-09-20 22:25 ` [FFmpeg-devel] [RFC PATCH 1/2] libavdevice/pipewiregrab: add pipewire based grab Leo Izen
2023-09-21 10:39 ` Paul B Mahol
2023-09-22 11:37 ` llyyr [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ff795246-7e19-4ad4-92f0-ef4acdc92824@gmail.com \
    --to=llyyr.public@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git