@@ -86,91 +86,6 @@ fn list_cameras() -> Result<()> {
8686 Ok ( ( ) )
8787}
8888
89- /// Check if the V4L2 M2M H.264 hardware encoder is available (Pi 4, Rockchip, etc.).
90- /// Probes /dev/video* devices using v4l2-ctl (if available) or a simple device existence check.
91- /// The actual V4L2 M2M probing is done by the C++ V4L2VideoEncoderFactory::IsSupported() at
92- /// WebRTC encoder creation time; this is a best-effort early diagnostic for the user.
93- #[ cfg( target_os = "linux" ) ]
94- fn check_v4l2_hw_encoder ( ) {
95- use std:: process:: Command ;
96-
97- info ! ( "Probing for V4L2 M2M H.264 hardware encoder..." ) ;
98-
99- // Try v4l2-ctl --list-devices to enumerate video devices
100- match Command :: new ( "v4l2-ctl" ) . arg ( "--list-devices" ) . output ( ) {
101- Ok ( output) => {
102- let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
103- let stderr = String :: from_utf8_lossy ( & output. stderr ) ;
104- if output. status . success ( ) {
105- info ! ( "V4L2 devices:\n {}" , stdout. trim( ) ) ;
106-
107- // Look for bcm2835-codec (Pi 4) or similar M2M encoder indicators
108- let has_encoder = stdout. contains ( "bcm2835-codec" )
109- || stdout. contains ( "encoder" )
110- || stdout. contains ( "m2m" ) ;
111- if has_encoder {
112- info ! ( "V4L2 M2M encoder device detected in device list" ) ;
113- }
114- } else {
115- debug ! ( "v4l2-ctl --list-devices failed: {}" , stderr. trim( ) ) ;
116- }
117- }
118- Err ( _) => {
119- debug ! ( "v4l2-ctl not found; skipping device enumeration" ) ;
120- }
121- }
122-
123- // Check the well-known Pi 4 encoder device path
124- let encoder_paths = [ "/dev/video11" , "/dev/video10" ] ;
125- for path in & encoder_paths {
126- if std:: path:: Path :: new ( path) . exists ( ) {
127- // Try to query its capabilities
128- match Command :: new ( "v4l2-ctl" )
129- . args ( [ "--device" , path, "--all" ] )
130- . output ( )
131- {
132- Ok ( output) => {
133- let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
134- if stdout. contains ( "H.264" ) || stdout. contains ( "H264" ) || stdout. contains ( "h264" ) {
135- info ! ( "V4L2 HW H.264 encoder confirmed at {}" , path) ;
136- // Print capabilities for diagnostics
137- for line in stdout. lines ( ) {
138- if line. contains ( "Driver" )
139- || line. contains ( "Card" )
140- || line. contains ( "H264" )
141- || line. contains ( "H.264" )
142- || line. contains ( "Video Capture" )
143- || line. contains ( "Video Output" )
144- || line. contains ( "m2m" )
145- {
146- info ! ( " {}" , line. trim( ) ) ;
147- }
148- }
149- return ;
150- }
151- }
152- Err ( _) => {
153- info ! ( "V4L2 device {} exists (v4l2-ctl not available for detailed check)" , path) ;
154- }
155- }
156- }
157- }
158-
159- // The C++ V4L2VideoEncoderFactory::IsSupported() will do the definitive check
160- // at encoder creation time by probing all /dev/video* with proper ioctls.
161- warn ! (
162- "Could not confirm V4L2 M2M H.264 hardware encoder via v4l2-ctl. \
163- The WebRTC encoder factory will probe at runtime. \
164- If encoding fails, ensure your user is in the 'video' group: \
165- sudo usermod -aG video $USER"
166- ) ;
167- }
168-
169- #[ cfg( not( target_os = "linux" ) ) ]
170- fn check_v4l2_hw_encoder ( ) {
171- debug ! ( "V4L2 hardware encoder check skipped (not Linux)" ) ;
172- }
173-
17489/// Try to open a camera with the given format, returning the Camera and the format name on success.
17590fn try_open_camera (
17691 index : & CameraIndex ,
@@ -288,9 +203,6 @@ async fn run(args: Args, ctrl_c_received: Arc<AtomicBool>) -> Result<()> {
288203 return list_cameras ( ) ;
289204 }
290205
291- // Probe for V4L2 M2M hardware encoder (Pi 4, Rockchip, etc.)
292- check_v4l2_hw_encoder ( ) ;
293-
294206 // LiveKit connection details
295207 let url = args
296208 . url
0 commit comments