Skip to content

Add new virtio-media V4l2 stream virtual device - #2935

Open
bridadan wants to merge 2 commits into
google:mainfrom
bridadan:v4l2_stream
Open

Add new virtio-media V4l2 stream virtual device#2935
bridadan wants to merge 2 commits into
google:mainfrom
bridadan:v4l2_stream

Conversation

@bridadan

Copy link
Copy Markdown
Collaborator

This PR introduces the v4l2_stream device, a vhost-user-media backend that enables streaming video from a host-side source (via a FIFO/named pipe) into a guest VM using the virtio-media protocol.

It allows video data generated on the host (e.g., from a video file, synthetic test source, or any other producer of raw video frames) to be streamed directly into the guest VM's V4L2 framework.

The first commit copies over the emulated_camera_mplane crate into the new v4l2_stream crate, and includes minimal changes to get it building and launchable. The second commit modifies the new crate with the new functionality.

b/472497998

@bridadan
bridadan requested a review from ser-io July 30, 2026 20:39

@ser-io ser-io left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's avoid forking emulated_camera_mplane as the first commit, it makes the second commit very hard to review. Feel free to introduce the new device in the first commit.

Comment thread base/cvd/cuttlefish/host/commands/vhost_user_media/v4l2_stream/src/main.rs Outdated
Comment thread base/cvd/cuttlefish/host/libs/config/media.h Outdated
Comment thread base/cvd/cuttlefish/host/commands/vhost_user_media/v4l2_stream/test_stream.sh Outdated
This adds the implementation of the v4l2_stream_proxy device,
which reads from a FIFO and behaves as a virtio-media device.
It also adds the necessary configuration and flags to support
custom stream parameters (width, height, fps, source).

worker_thread_loop in v4l2_stream_proxy uses nix::poll and
nix::sys::eventfd to wait for both FIFO data and control signals
(Stop/BufferQueued) without busy looping or sleeping.

Bug: 472497998
Adds TestV4l2StreamProxyCompliance to e2e tests, which:
1. Creates a FIFO on the host.
2. Starts a goroutine to write dummy YUV420M frames to the FIFO.
3. Launches CVD with v4l2_stream_proxy pointing to the FIFO.
4. Finds the video node in the guest.
5. Runs v4l2-compliance on the guest.

Bug: 472497998
@@ -0,0 +1,1152 @@
// Copyright 2026, The Android Open Source Project

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similiar to f62529f. Let's have the first commit with the code of new Rust binary only.

The vhost user binaries could be attached to any crosvm VM instance, so it's ok to have the first commit only with code related to the vhost user binary.

Then, we can have the next commit integrating "cvd" with the new v4l2_stream_proxy binary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants