Index: webrtc/api/java/android/org/webrtc/CameraEnumerator.java |
diff --git a/webrtc/api/java/android/org/webrtc/CameraEnumerator.java b/webrtc/api/java/android/org/webrtc/CameraEnumerator.java |
index 203c1954b744de4ff88bd5942fec1dca6274b7fc..752e10aed2fcfd9872d6df1900139922f07766bc 100644 |
--- a/webrtc/api/java/android/org/webrtc/CameraEnumerator.java |
+++ b/webrtc/api/java/android/org/webrtc/CameraEnumerator.java |
@@ -1,5 +1,5 @@ |
/* |
- * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
+ * Copyright 2016 The WebRTC project authors. All Rights Reserved. |
* |
* Use of this source code is governed by a BSD-style license |
* that can be found in the LICENSE file in the root of the source |
@@ -10,94 +10,11 @@ |
package org.webrtc; |
-import android.os.SystemClock; |
+public interface CameraEnumerator { |
+ public String[] getDeviceNames(); |
+ public boolean isFrontFacing(String deviceName); |
+ public boolean isBackFacing(String deviceName); |
-import org.webrtc.CameraEnumerationAndroid.CaptureFormat; |
-import org.webrtc.Logging; |
- |
-import java.util.ArrayList; |
-import java.util.List; |
- |
-@SuppressWarnings("deprecation") |
-public class CameraEnumerator { |
- private final static String TAG = "CameraEnumerator"; |
- // Each entry contains the supported formats for corresponding camera index. The formats for all |
- // cameras are enumerated on the first call to getSupportedFormats(), and cached for future |
- // reference. |
- private static List<List<CaptureFormat>> cachedSupportedFormats; |
- |
- public static synchronized List<CaptureFormat> getSupportedFormats(int cameraId) { |
- if (cachedSupportedFormats == null) { |
- cachedSupportedFormats = new ArrayList<List<CaptureFormat>>(); |
- for (int i = 0; i < CameraEnumerationAndroid.getDeviceCount(); ++i) { |
- cachedSupportedFormats.add(enumerateFormats(i)); |
- } |
- } |
- return cachedSupportedFormats.get(cameraId); |
- } |
- |
- private static List<CaptureFormat> enumerateFormats(int cameraId) { |
- Logging.d(TAG, "Get supported formats for camera index " + cameraId + "."); |
- final long startTimeMs = SystemClock.elapsedRealtime(); |
- final android.hardware.Camera.Parameters parameters; |
- android.hardware.Camera camera = null; |
- try { |
- Logging.d(TAG, "Opening camera with index " + cameraId); |
- camera = android.hardware.Camera.open(cameraId); |
- parameters = camera.getParameters(); |
- } catch (RuntimeException e) { |
- Logging.e(TAG, "Open camera failed on camera index " + cameraId, e); |
- return new ArrayList<CaptureFormat>(); |
- } finally { |
- if (camera != null) { |
- camera.release(); |
- } |
- } |
- |
- final List<CaptureFormat> formatList = new ArrayList<CaptureFormat>(); |
- try { |
- int minFps = 0; |
- int maxFps = 0; |
- final List<int[]> listFpsRange = parameters.getSupportedPreviewFpsRange(); |
- if (listFpsRange != null) { |
- // getSupportedPreviewFpsRange() returns a sorted list. Take the fps range |
- // corresponding to the highest fps. |
- final int[] range = listFpsRange.get(listFpsRange.size() - 1); |
- minFps = range[android.hardware.Camera.Parameters.PREVIEW_FPS_MIN_INDEX]; |
- maxFps = range[android.hardware.Camera.Parameters.PREVIEW_FPS_MAX_INDEX]; |
- } |
- for (android.hardware.Camera.Size size : parameters.getSupportedPreviewSizes()) { |
- formatList.add(new CaptureFormat(size.width, size.height, minFps, maxFps)); |
- } |
- } catch (Exception e) { |
- Logging.e(TAG, "getSupportedFormats() failed on camera index " + cameraId, e); |
- } |
- |
- final long endTimeMs = SystemClock.elapsedRealtime(); |
- Logging.d(TAG, "Get supported formats for camera index " + cameraId + " done." |
- + " Time spent: " + (endTimeMs - startTimeMs) + " ms."); |
- return formatList; |
- } |
- |
- // Convert from android.hardware.Camera.Size to Size. |
- public static List<Size> convertSizes( |
- List<android.hardware.Camera.Size> cameraSizes) { |
- final List<Size> sizes = new ArrayList<Size>(); |
- for (android.hardware.Camera.Size size : cameraSizes) { |
- sizes.add(new Size(size.width, size.height)); |
- } |
- return sizes; |
- } |
- |
- // Convert from int[2] to CaptureFormat.FramerateRange. |
- public static List<CaptureFormat.FramerateRange> convertFramerates( |
- List<int[]> arrayRanges) { |
- final List<CaptureFormat.FramerateRange> ranges = new ArrayList<CaptureFormat.FramerateRange>(); |
- for (int[] range : arrayRanges) { |
- ranges.add(new CaptureFormat.FramerateRange( |
- range[android.hardware.Camera.Parameters.PREVIEW_FPS_MIN_INDEX], |
- range[android.hardware.Camera.Parameters.PREVIEW_FPS_MAX_INDEX])); |
- } |
- return ranges; |
- } |
+ public CameraVideoCapturer createCapturer(String deviceName, |
+ CameraVideoCapturer.CameraEventsHandler eventsHandler); |
} |