OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2016 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 android.media.MediaRecorder; |
| 14 |
13 /** | 15 /** |
14 * Base interface for camera1 and camera2 implementations. Extends VideoCapturer
with a | 16 * Base interface for camera1 and camera2 implementations. Extends VideoCapturer
with a |
15 * switchCamera() function. Also provides subinterfaces for handling camera even
ts, and a helper | 17 * switchCamera() function. Also provides subinterfaces for handling camera even
ts, and a helper |
16 * class for detecting camera freezes. | 18 * class for detecting camera freezes. |
17 */ | 19 */ |
18 public interface CameraVideoCapturer extends VideoCapturer { | 20 public interface CameraVideoCapturer extends VideoCapturer { |
19 /** | 21 /** |
20 * Camera events handler - can be used to be notifed about camera events. The
callbacks are | 22 * Camera events handler - can be used to be notifed about camera events. The
callbacks are |
21 * executed from an arbitrary thread. | 23 * executed from an arbitrary thread. |
22 */ | 24 */ |
(...skipping 30 matching lines...) Expand all Loading... |
53 void onCameraSwitchError(String errorDescription); | 55 void onCameraSwitchError(String errorDescription); |
54 } | 56 } |
55 | 57 |
56 /** | 58 /** |
57 * Switch camera to the next valid camera id. This can only be called while th
e camera is running. | 59 * Switch camera to the next valid camera id. This can only be called while th
e camera is running. |
58 * This function can be called from any thread. | 60 * This function can be called from any thread. |
59 */ | 61 */ |
60 void switchCamera(CameraSwitchHandler switchEventsHandler); | 62 void switchCamera(CameraSwitchHandler switchEventsHandler); |
61 | 63 |
62 /** | 64 /** |
| 65 * MediaRecorder add/remove handler - one of these functions are invoked with
the result of |
| 66 * addMediaRecorderToCamera() or removeMediaRecorderFromCamera calls. |
| 67 * The callback may be called on an arbitrary thread. |
| 68 */ |
| 69 public interface MediaRecorderHandler { |
| 70 // Invoked on success. |
| 71 void onMediaRecorderSuccess(); |
| 72 |
| 73 // Invoked on failure, e.g. camera is stopped or any exception happens. |
| 74 void onMediaRecorderError(String errorDescription); |
| 75 } |
| 76 |
| 77 /** |
| 78 * Add MediaRecorder to camera pipeline. This can only be called while the cam
era is running. |
| 79 * Once MediaRecorder is added to camera pipeline camera switch is not allowed
. |
| 80 * This function can be called from any thread. |
| 81 */ |
| 82 void addMediaRecorderToCamera(MediaRecorder mediaRecorder, MediaRecorderHandle
r resultHandler); |
| 83 |
| 84 /** |
| 85 * Remove MediaRecorder from camera pipeline. This can only be called while th
e camera is running. |
| 86 * This function can be called from any thread. |
| 87 */ |
| 88 void removeMediaRecorderFromCamera(MediaRecorderHandler resultHandler); |
| 89 |
| 90 /** |
63 * Helper class to log framerate and detect if the camera freezes. It will run
periodic callbacks | 91 * Helper class to log framerate and detect if the camera freezes. It will run
periodic callbacks |
64 * on the SurfaceTextureHelper thread passed in the ctor, and should only be o
perated from that | 92 * on the SurfaceTextureHelper thread passed in the ctor, and should only be o
perated from that |
65 * thread. | 93 * thread. |
66 */ | 94 */ |
67 public static class CameraStatistics { | 95 public static class CameraStatistics { |
68 private final static String TAG = "CameraStatistics"; | 96 private final static String TAG = "CameraStatistics"; |
69 private final static int CAMERA_OBSERVER_PERIOD_MS = 2000; | 97 private final static int CAMERA_OBSERVER_PERIOD_MS = 2000; |
70 private final static int CAMERA_FREEZE_REPORT_TIMOUT_MS = 4000; | 98 private final static int CAMERA_FREEZE_REPORT_TIMOUT_MS = 4000; |
71 | 99 |
72 private final SurfaceTextureHelper surfaceTextureHelper; | 100 private final SurfaceTextureHelper surfaceTextureHelper; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 public void addFrame() { | 149 public void addFrame() { |
122 checkThread(); | 150 checkThread(); |
123 ++frameCount; | 151 ++frameCount; |
124 } | 152 } |
125 | 153 |
126 public void release() { | 154 public void release() { |
127 surfaceTextureHelper.getHandler().removeCallbacks(cameraObserver); | 155 surfaceTextureHelper.getHandler().removeCallbacks(cameraObserver); |
128 } | 156 } |
129 } | 157 } |
130 } | 158 } |
OLD | NEW |