redroid-doc icon indicating copy to clipboard operation
redroid-doc copied to clipboard

v4l2loopback can't get video

Open ArtBreguez opened this issue 2 years ago • 3 comments

I'm trying to stream into redroid my desktop, I implemented de v4l2 Hal in redroid and got the USB Camera working through and 3-part-apk, now I need to use the default camera (back) as a webcam or streaming from my desktop.

I'm testing streaming my desktop through v4l2loopback into redroid with --device=/dev/video1:/dev/video1 when i run the container, got the video working on my host, when i run ls /dev/video* inside redroid it returns me /dev/video1, but when I try to open the camera it fails and when i plug my Webcam in my host it shows the camera image (not desktop), not sure what's going on here.

here some logs: Captura de Tela 2022-06-21 às 10 05 10

ps: Here's the issue (closed) when I implemented v4l2 Hal https://github.com/remote-android/redroid-doc/issues/174

ArtBreguez avatar Jun 21 '22 13:06 ArtBreguez

@zhouziyang, I managed to configure the external camera by usb using v4l2, but i have this err:

E CameraService: cameraIdIntToStrLocked: input id 0 invalid: valid range  (0, 0)
E CameraService: shouldRejectSystemCameraConnection: Invalid camera id , 
W CameraService: Attempting to connect to system-only camera id , connection rejected
W CameraBase: An error occurred while connecting to camera 0: Status(-8, EX_SERVICE_SPECIFIC): '4: validateClientPermissionsLocked:1158: No camera device with ID "" isavailable'

How do I create a rule for this file_contexts in redroid? /dev/video([0-9])+ u:object_r:camera_device:s0 it is possible to create it in init.redroid.rc ? how to start the device according to the link https://source.android.com/security/selinux/device-policy

$ ps -Z | grep init | grep cam

system_u:system_r:initrc_t:s0  cameraserver    139      1   57636  22316 binder_thread_read  0 S cameraserver
system_u:system_r:initrc_t:s0  u0_a118        1332    137 13098508 126472 ep_poll            0 S com.shenyaocn.android.usbcamera
system_u:system_r:initrc_t:s0  u0_a116       14504    137 13281192 298020 ep_poll            0 S com.jacksoftw.webcam

$ dumpsys media.camera

== Service global info: ==

Number of camera devices: 0
Number of normal camera devices: 0
Number of public camera devices visible to API1: 0
Active Camera Clients:
[]
Allowed user IDs: 0

== Camera service events log (most recent at top): ==
  06-21 13:08:37 : REJECT device  client for package net.sourceforge.opencamera (PID 4908), reason: (Status(-8, EX_SERVICE_SPECIFIC): '4: validateClientPermissionsLocked:1158: No camera device with ID "" isavailable')
  06-21 12:52:59 : REJECT device  client for package net.sourceforge.opencamera (PID 4908), reason: (Status(-8, EX_SERVICE_SPECIFIC): '4: validateClientPermissionsLocked:1158: No camera device with ID "" isavailable')
  06-21 12:52:41 : REJECT device  client for package net.sourceforge.opencamera (PID 4908), reason: (Status(-8, EX_SERVICE_SPECIFIC): '4: validateClientPermissionsLocked:1158: No camera device with ID "" isavailable')
  06-21 12:49:33 : REJECT device  client for package net.sourceforge.opencamera (PID 1654), reason: (Status(-8, EX_SERVICE_SPECIFIC): '4: validateClientPermissionsLocked:1158: No camera device with ID "" isavailable')
  06-21 12:49:15 : USER_SWITCH previous allowed user IDs: <None>, current allowed user IDs: 0


== Vendor tags: ==


== Camera error traces (0): ==
  No camera traces collected.

$ cat /lib/modules/$(uname -r)/build/.config | grep CONFIG_USB_VIDEO_CLASS

CONFIG_USB_VIDEO_CLASS=m
CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y
...
CONFIG_ANDROID_BINDER_IPC=m
CONFIG_ANDROID_BINDERFS=m
CONFIG_ANDROID_BINDER_DEVICES=""

help me too, how to set into kernell to CONFIG_USB_VIDEO_CLASS=y?

diggleweb avatar Jun 21 '22 21:06 diggleweb

@ArtBreguez for v4l2loopback streaming, possible need V4L2 Camera HAL (https://cs.android.com/android/platform/superproject/+/android-12.0.0_r1:hardware/libhardware/modules/camera/3_4/;bpv=1;bpt=0)

you need claim new HIDLs in manifext.xml; and better to claim camera features to system (frameworks/native/data/etc/android.hardware.camera...)

zhouziyang avatar Jun 22 '22 02:06 zhouziyang

@diggleweb selinux is ignored (hook in libselinux.so), and should not care about the se rules. CONFIG_USB_VIDEO_CLASS is the config of your Host kernel. since build as a module (CONFIG_USB_VIDEO_CLASS=m), I think you can load via modprobe

zhouziyang avatar Jun 22 '22 02:06 zhouziyang