Webrtc支持Android 5.0

时间:2017-04-27 02:56:29

标签: android webrtc

我正在开发一个webrtc应用程序。我发现webrtc不支持android 5.0(api level 21)。这是我从webrtc库(libjingle)获得的代码:

  /**
   * Checks if API is supported and all cameras have better than legacy support.
   */
    public static boolean isSupported(Context context) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            return false;
        }

        CameraManager cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
        try {
            String[] cameraIds = cameraManager.getCameraIdList();
            for (String id : cameraIds) {
                CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(id);
                if (characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL)
        == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY) {
                    return false;
                }
             }
             // On Android OS pre 4.4.2, a class will not load because of VerifyError     if it contains a
             // catch statement with an Exception from a newer API, even if the code is never executed.
             // https://code.google.com/p/android/issues/detail?id=209129
         } catch (/* CameraAccessException */ AndroidException e) {
             Logging.e(TAG, "Camera access exception: " + e);
             return false;
         }
        return true;
    }

它总是返回false,因为Android 5.0的INFO_SUPPORTED_HARDWARE_LEVEL是INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY。所以我不能使用相机来捕捉本地媒体流。

有人帮助我吗?

1 个答案:

答案 0 :(得分:1)

我已经实现了webRTC for android及其对棒棒糖和棉花糖的支持,请查看link