Skip to content

Commit 3ba52ec

Browse files
author
Brian Daniels
committed
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 `video_capture_device` 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 `video_capture_device`. - Moved `Buffer`, `BufferState`, `EmulatedCameraSession`, and `EmulatedCamera` to `video_capture_device`, making the camera and session generic over `F: CaptureDeviceFormat`. - Moved and unified `VirtioMediaDevice` and `VirtioMediaIoctlHandler` implementations to `video_capture_device`. - 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 -s
1 parent 0e662a9 commit 3ba52ec

5 files changed

Lines changed: 603 additions & 1052 deletions

File tree

0 commit comments

Comments
 (0)