OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 package org.webrtc; | 11 package org.webrtc; |
12 | 12 |
13 import org.webrtc.CameraEnumerationAndroid.CaptureFormat; | 13 import org.webrtc.CameraEnumerationAndroid.CaptureFormat; |
14 | 14 |
15 import android.os.SystemClock; | 15 import android.os.SystemClock; |
16 | 16 |
17 import java.util.ArrayList; | 17 import java.util.ArrayList; |
18 import java.util.List; | 18 import java.util.List; |
19 | 19 |
20 @SuppressWarnings("deprecation") | 20 @SuppressWarnings("deprecation") |
21 public class Camera1Enumerator implements CameraEnumerator { | 21 public class Camera1Enumerator implements CameraEnumerator { |
22 private final static String TAG = "Camera1Enumerator"; | 22 private final static String TAG = "Camera1Enumerator"; |
23 // Each entry contains the supported formats for corresponding camera index. T
he formats for all | 23 // Each entry contains the supported formats for corresponding camera index. T
he formats for all |
24 // cameras are enumerated on the first call to getSupportedFormats(), and cach
ed for future | 24 // cameras are enumerated on the first call to getSupportedFormats(), and cach
ed for future |
25 // reference. | 25 // reference. |
26 private static List<List<CaptureFormat>> cachedSupportedFormats; | 26 private static List<List<CaptureFormat>> cachedSupportedFormats; |
27 | 27 |
| 28 private final boolean captureToTexture; |
| 29 |
| 30 Camera1Enumerator() { |
| 31 this(true /* captureToTexture */); |
| 32 } |
| 33 |
| 34 Camera1Enumerator(boolean captureToTexture) { |
| 35 this.captureToTexture = captureToTexture; |
| 36 } |
28 | 37 |
29 public boolean isFrontFacing(String deviceName) { | 38 public boolean isFrontFacing(String deviceName) { |
30 android.hardware.Camera.CameraInfo info = getCameraInfo(getCameraIndex(devic
eName)); | 39 android.hardware.Camera.CameraInfo info = getCameraInfo(getCameraIndex(devic
eName)); |
31 return info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT
; | 40 return info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT
; |
32 } | 41 } |
33 | 42 |
34 public boolean isBackFacing(String deviceName) { | 43 public boolean isBackFacing(String deviceName) { |
35 android.hardware.Camera.CameraInfo info = getCameraInfo(getCameraIndex(devic
eName)); | 44 android.hardware.Camera.CameraInfo info = getCameraInfo(getCameraIndex(devic
eName)); |
36 return info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK; | 45 return info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK; |
37 } | 46 } |
38 | 47 |
39 public CameraVideoCapturer createCapturer(String deviceName, | 48 public CameraVideoCapturer createCapturer(String deviceName, |
40 CameraVideoCapturer.CameraEventsHandler eventsHandler) { | 49 CameraVideoCapturer.CameraEventsHandler eventsHandler) { |
41 return new VideoCapturerAndroid(deviceName, eventsHandler, true); | 50 return new VideoCapturerAndroid(deviceName, eventsHandler, captureToTexture)
; |
42 } | 51 } |
43 | 52 |
44 private static android.hardware.Camera.CameraInfo getCameraInfo(int index) { | 53 private static android.hardware.Camera.CameraInfo getCameraInfo(int index) { |
45 android.hardware.Camera.CameraInfo info = new android.hardware.Camera.Camera
Info(); | 54 android.hardware.Camera.CameraInfo info = new android.hardware.Camera.Camera
Info(); |
46 try { | 55 try { |
47 android.hardware.Camera.getCameraInfo(index, info); | 56 android.hardware.Camera.getCameraInfo(index, info); |
48 } catch (Exception e) { | 57 } catch (Exception e) { |
49 Logging.e(TAG, "getCameraInfo failed on index " + index,e); | 58 Logging.e(TAG, "getCameraInfo failed on index " + index,e); |
50 return null; | 59 return null; |
51 } | 60 } |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 // camera can not be used. | 159 // camera can not be used. |
151 static String getDeviceName(int index) { | 160 static String getDeviceName(int index) { |
152 android.hardware.Camera.CameraInfo info = getCameraInfo(index); | 161 android.hardware.Camera.CameraInfo info = getCameraInfo(index); |
153 | 162 |
154 String facing = | 163 String facing = |
155 (info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT)
? "front" : "back"; | 164 (info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT)
? "front" : "back"; |
156 return "Camera " + index + ", Facing " + facing | 165 return "Camera " + index + ", Facing " + facing |
157 + ", Orientation " + info.orientation; | 166 + ", Orientation " + info.orientation; |
158 } | 167 } |
159 } | 168 } |
OLD | NEW |