Skip to content

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

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

Add new virtio-media V4l2 stream virtual device#2935
bridadan wants to merge 4 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
@bridadan
bridadan force-pushed the v4l2_stream branch 3 times, most recently from 0d284fd to 752ec67 Compare July 31, 2026 19:48
The previous implementation of the send_events function used all but one
descriptor because the iterator was advanced through the entire
collection of descriptors. Then only one descriptor is released back.
This limits the throughput for devices and makes them more susceptible
to jitter due to system load.

This implementation only advances the descriptor iterator by one,
leaving the rest unused.

Bug: 472497998
Assisted-by: Jetski:Gemini 3.5 Flash
@bridadan
bridadan force-pushed the v4l2_stream branch 2 times, most recently from fc32f68 to 4bdd8f5 Compare August 3, 2026 16:53
@bridadan
bridadan requested a review from ser-io August 3, 2026 16:54
Comment thread base/cvd/cuttlefish/host/libs/config/media.h Outdated
Comment thread e2etests/cvd/media_tests/v4l2compliance/main_test.go Outdated
Brian Daniels added 3 commits August 4, 2026 11:32
This adds the implementation of the v4l2_stream_proxy device,
which reads from a FIFO and behaves as a virtio-media device.

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
Assisted-by: Jetski:Gemini 3.5 Flash
This adds all of the necessary flags and configuration to launch the
v4l2_stream_proxy virtual device from the cvd cli.

Bug: 472497998
Assisted-by: Jetski:Gemini 3.5 Flash
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
Assisted-by: Jetski:Gemini 3.5 Flash
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