We're hiring!
*

Integrating libcamera into PipeWire

Raghavendra Rao avatar

Raghavendra Rao
September 11, 2020

Share this post:

Earlier this year, my colleagues Julian Bouzas and George Kiagiadakis wrote about PipeWire and Wireplumber, the PipeWire session manager. Since then, PipeWire has continued to evolve with the recent integration of libcamera, a library to support complex cameras. In this blog post, I'll explain why libcamera exists, what it does, and how we integrated it in PipeWire.

libcamera

Cameras are complex devices which require heavy hardware image processing. The complexity in the userspace camera application development originates with the evolution of complex hardware. libcamera addresses this problem and offers ease of camera application development. libcamera can be described as a full camera stack library in the userspace to provide the feature that do not belong in the kernel.

The core of libcamera framework exposes kernel driver APIs to userspace while the libcamera application layer abstracts the developer from complex hardware usage. libcamera supports multiple video streams from a single device. In real time use cases such as video conferencing, we may need to preview streams with different resolutions than what we tend to stream over the network. It is natural that we would like to display the live streaming simaultaneously while we capture the video with different resolutions. libcamera offers a perfect solution to fulfill these requirements.

Having said that, what if we'd like to stream a camera device data using different applications simaultaneously? Well, PipeWire answers this question. Besides acting as an interface between hardware devices and applications, PipeWire eases the sharing of hardware devices between applications. Moreover, integration of libcamera into PipeWire brings all the abilities offered by libcamera into PipeWire. With this, PipeWire can become a first class user of modern cameras.

PipeWire-libcamera interworking

As camera application development through v4l becomes more and more complex, Collabora decided to tackle this by integrating libcamera into PipeWire to offer all the evolutions coming from both the frameworks.

The integration work has been merged into PipeWire master.

Give it a try!

Please follow the steps below to try libcamera in PipeWire.

  1. Make sure that the linux kernel version is 5.0.0 or above.
  2. Make sure that the system user is added to video group to access /dev/media*. You can run the command sudo adduser `whoami` video and restart the session.
  3. Make sure that meson build package is installed in your system.
  4. Make sure that sdl2 package is installed in your system.
  5. Make sure that libdrm package is installed in your system.
  6. Follow Getting libcamera to obtain the source and install it. You can also use the commands below to build and install.
    meson --prefix <path/to/install dir> --buildtype=plain build
    cd build
    ninja -C . install
    
  7. Follow Getting PipeWire to obtain the source. Configure with meson and install it. Use the following commands:
    meson --prefix <path/to/install dir> -Dlibcamera=true build
    cd build
    ninja -C . install
    
  8. Now you can test libcamera spa plugin. Run the command "./build/spa/examples/local-libcamera" from the PipeWire directory. You should be able to see the camera captured data being rendered.

We will be blogging more about this integration work and improvements to be made in the future, explaining the motivation and further progress we make. Stay tuned!

Comments (2)

  1. Rogan Dawes:
    Sep 14, 2020 at 05:04 PM

    Is this something that could easily be exported as a remote desktop using VNC? Given the availability of cheap HDMI input dongles that appear as a UVC camera, it would be neat to be able to expose them using a regular "remote desktop" protocol. I guess an input filter would be required to receive the keystrokes and mouse movements, of course. Those could then be emitted using a HID Gadget and ConfigFS or similar.
    I did look at doing this with Xvncserver, but the rawfb support was a bit tricky to figure out, and I never got that working.

    Reply to this comment

    Reply to this comment

    1. Raghavendra:
      Sep 15, 2020 at 06:57 PM

      Hello Rogan Dawes,

      Thank you for your response.

      The idea behind the integration of libcamera was to ease the Camera application development with modern cameras and bring all the capabilities of libcamera to PipeWire.

      It is interesting to note that PipeWire already supports remote desktop sharing with wayland, gnome-remote-desktop and browsers such as firefox, chrome etc. PipeWire acts as interface between the Application and hardware to share the media via "dmabuf" buffers. Applications such as VNC/RDP can connect to PipeWire creating sink nodes to consume the Video frames captured by source nodes such as libcamera node, in this case.

      gnome-remote-desktop daemon enables GNOME to offer remote desktop sharing using VNC with PipeWire. This daemon supports GNOME on X as well as GNOME on Wayland. If you have got ubuntu installed then you may want to recompile mutter with remote desktop option enabled to make it work on ubuntu.

      Thanks,
      Raghavendra

      Reply to this comment

      Reply to this comment


Add a Comment






Allowed tags: <b><i><br>Add a new comment:


Search the newsroom

Latest Blog Posts

Open Source meets Super Resolution, part 1

21/09/2020

Introducing an accurate and light-weight deep network for video super-resolution upscaling, running on a completely open source software…

Integrating libcamera into PipeWire

11/09/2020

PipeWire continues to evolve with the recent integration of libcamera, a library to support complex cameras. In this blog post, I'll explain…

Pushing pixels to your Chromebook

31/08/2020

A high-level introduction of the Linux graphics stack, how it is used within ChromeOS, and the work done to improve software rendering (while…

Using the Linux kernel's Case-insensitive feature in Ext4

27/08/2020

Last year, a (controversial) feature was added to the Linux kernel to support optimized case-insensitive file name lookups in the Ext4 filesystem.…

Panfrost performance counters with Perfetto

21/08/2020

We have now integrated Mali GPU hardware counters supported by Panfrost with Perfetto's tracing SDK, unlocking all-in-one graphics-aware…

Paving the way for high bitrate video streaming with GStreamer's RTP elements

20/08/2020

Key performance improvements and fixes to GStreamer's RTP stack have landed in GStreamer 1.18, due in the coming months. The latest enhancements…

Open Since 2005 logo

We use cookies on this website to ensure that you get the best experience. By continuing to use this website you are consenting to the use of these cookies. To find out more please follow this link.

Collabora Ltd © 2005-2020. All rights reserved. Privacy Notice. Sitemap.