Reputation: 10641
I am tinkering with Android Things v1.0 and am trying to get WebRTC working using WebView on RaspberryPi 3. Which in theory should be possible.
I understand it's possible that the camera HAL pipeline only supports 1 stream on RPi 3, which might be part of the problem. But, unless getUserMedia() is trying to grab more than the single stream, and I don't think it is, it should just return the local video stream:
navigator.mediaDevices.getUserMedia({
audio: false,
video: true
})
.then(
gotUserMedia,
didntGetUserMedia
);
gotUserMedia
is never called, only didntGetUserMedia
is called. Furthermore:
If the browser cannot find all media tracks with the specified types that meet the
constraints given, then the returned promise is rejected with NotFoundError.
Which is not the error thrown:
object NavigatorUserMediaError
I am doing all this with a working WebRTC web application that works with Chrome browser on Mac, Windows, and Ubuntu. The problem appears to be around the RPi. If I load a Raspbian OS and use Chromium (which supports WebRTC), it still does not get the local video stream. Perhaps the issues are related?
The camera works if I open it with native app on Raspbian
, and it also works in Android Things
if i simply preview it using a textureView
from within the same Android app that the Webview is in - but not at the same time.
The permissions granted have been done so manually, and are declared in the Manifest:
adb shell pm grant com.rpi.garagetinker android.permission.CAMERA
adb shell pm grant com.rpi.garagetinker android.permission.INTERNET
adb shell pm grant com.rpi.garagetinker android.permission.WRITE_EXTERNAL_STORAGE
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I have not dug into the errors on Chromium, but the logcat for Android Things RPi and Webview shows a permissions issue, which may be related to the problem (given the getUserMedia() error above):
12-31 18:00:07.491 772-772/? E//system/bin/webview_zygote32: Failed to make and chown /acct/uid_99000: Permission denied
12-31 18:00:07.491 299-310/? I/ActivityManager: Start proc 772:com.android.webview:sandboxed_process0/u0i0 for webview_service com.rpi.garagetinker/org.chromium.content.app.SandboxedProcessService0
I don't know if this is the problem, and am uncertain how to fix if it is. I really think this is a permissions issue, but what other permissions might I grant? Any guidance is appreciated.
Notes:
There is only ONE WebView in use, and this is the only app installed on new Android Things image.
Posts solving issue when multiple browsers are involved like this are not directly helpful, but suggest that something else might be consuming the media handle.
Also, also, Chromium on Raspbian does not prompt for access to video (audio which is not present) like it does on Chrome other OS's.
WebRTC is now working on Raspbian with Chromium.
Upvotes: 2
Views: 1188
Reputation: 63303
I'm not intimately familiar with how the WebRTC API interacts with the native layer, but you may need additional permissions for the call to succeed. For example, the Android WebRTC sample also requests permissions for audio access (among other things):
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
I might also recommend reviewing the Android Things video call sample, which showcases the native WebRTC SDK on Android Things instead of piping it all through WebView.
Finally, one clarification…
Note: Android Things grants permissions at startup, so the Pi has been rebooted many times.
This is not correct; this behavior was removed from the developer preview. Dangerous permissions have to be explicitly granted by either the Android Things console or the developer tools. For example, when Android Studio deploys an APK to the device, it does so using adb install -g <apk-file>
to explicitly grant all requested permissions.
Upvotes: 1