MixedReality-WebRTC
MixedReality-WebRTC copied to clipboard
Camera2Session: Error: Camera device could not be opened because there are too many other open camera devices.
I am trying to send video feed of the android tablet camera (galaxy tab s6) in which arfoundation is running. In another scene where there is no rtc operation, camera feed is displayed perfectly on the ui. However, when rtc is enabled and communication starts with the peer, then the camera image is complete black on both peers' devices.
I tried to debug the problem using android studio and noticed the below error:
"29959-31814/? E/org.webrtc.Logging: Camera2Session: Error: Camera device could not be opened because there are too many other open camera devices."
As far as I understand, the library is having difficulty sharing camera with arcore, but this is just an assumption.
Is there any way to solve this problem? Thanks in advance.
Have You Ever try to get permission first ? I had this problem for sound and i got permission then it fixed ☻
I acquire all permissions at the start. And as mentioned before, camera feed is actually rendered when rtc is not enabled.
You should force it with java classes. i dont know exactly for camera but i set this for microphone issue.
By the way , do you know anything about multiple connections ? for example three or ten person in a room
I haven't worked in multiple connections use case. But there is an asset other than this called webrtc video chat in assetstore. I guess it supports multi user but has no uwp support.
How did you force getting permissions with java classes inside unity?
private static void RouteToSpeaker(bool speaker)
{
#if UNITY_ANDROID
try
{
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject audioManager = activity.Call<AndroidJavaObject>("getSystemService", "audio");
// bool isSpeakers = audioManager.Call<Boolean>("isSpeakerphoneOn");
audioManager.Call("setSpeakerphoneOn", speaker);
bool res = audioManager.Call<Boolean>("isSpeakerphoneOn");
Debug.Log("Speakers are now set to: " + res);
}
catch (Exception ex)
{
Debug.Log(ex.ToString());
}
#endif
}
Like This