Commit 74ae0f0
Brian Daniels
Refactor emulated_camera to use shared generic implementation with CaptureDeviceFormat trait
Extract `EmulatedCamera` and `EmulatedCameraSession` structs and their
`VirtioMediaDevice` and `VirtioMediaIoctlHandler` implementations into the shared
`vhu_media` library to eliminate duplication.
Introduce the `CaptureDeviceFormat` trait in the shared library to abstract
format-specific differences between `emulated_camera_mplane` and
`emulated_camera_splane`.
Key changes:
- Created `CaptureDeviceFormat` trait in `vhu_media`.
- Moved `Buffer`, `BufferState`, `EmulatedCameraSession`, and `EmulatedCamera`
to `vhu_media`, making the camera and session generic over
`F: CaptureDeviceFormat`.
- Moved and unified `VirtioMediaDevice` and `VirtioMediaIoctlHandler`
implementations to `vhu_media`.
- Refactored `emulated_camera_mplane` and `emulated_camera_splane` to:
- Implement `CaptureDeviceFormat` for `MplaneFormat` and `SplaneFormat` respectively.
- Implement `default_fmt` and `write_pattern` directly within the trait
impl blocks.
- Instantiate the generic `EmulatedCamera` in `main.rs`.
TAG=agy
CONV=b4f9ffcf-c393-4dbc-b8fb-5c38416291c2
Bug: 519646531
Test: cd base/cvd && bazel build cuttlefish/package:cvd
# Repeat with v4l2_emulated_camera_mplane
cvd create -media=type=v4l2_emulated_camera_splane
# Ensure pixel format changes with each type
v4l2-ctl -d1 --all
# Ensure it passes with no failures
v4l2-compliance -d1 -s1 parent 0fce6f1 commit 74ae0f0
5 files changed
Lines changed: 636 additions & 1108 deletions
File tree
- base/cvd/cuttlefish/host/commands/vhost_user_media
- emulated_camera_mplane/src
- emulated_camera_splane/src
- vhu_media/src
0 commit comments