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 * Media recorder handler - one of these functions are invoked with the result of switchCamera(). | |
magjed_webrtc
2017/04/21 10:45:16
nit: not switchCamera(), but addMediaRecorderToCam
AlexG
2017/04/21 19:38:11
Done.
| |
66 * The callback may be called on an arbitrary thread. | |
67 */ | |
68 public interface MediaRecorderHandler { | |
69 // Invoked on success. | |
70 void onMediaRecorderSuccess(); | |
71 | |
72 // Invoked on failure, e.g. camera is stopped or any exception happens. | |
73 void onMediaRecorderError(String errorDescription); | |
74 } | |
75 | |
76 /** | |
77 * Add MediaRecorder to camera pipeline. This can only be called while the cam era is running. | |
78 * This function can be called from any thread. | |
79 */ | |
80 void addMediaRecorderToCamera(MediaRecorder mediaRecorder, MediaRecorderHandle r resultHandler); | |
81 | |
82 /** | |
83 * Remove MediaRecorder from camera pipeline. This can only be called while th e camera is running. | |
84 * This function can be called from any thread. | |
85 */ | |
86 void removeMediaRecorderFromCamera(MediaRecorderHandler resultHandler); | |
87 | |
88 /** | |
63 * Helper class to log framerate and detect if the camera freezes. It will run periodic callbacks | 89 * 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 | 90 * on the SurfaceTextureHelper thread passed in the ctor, and should only be o perated from that |
65 * thread. | 91 * thread. |
66 */ | 92 */ |
67 public static class CameraStatistics { | 93 public static class CameraStatistics { |
68 private final static String TAG = "CameraStatistics"; | 94 private final static String TAG = "CameraStatistics"; |
69 private final static int CAMERA_OBSERVER_PERIOD_MS = 2000; | 95 private final static int CAMERA_OBSERVER_PERIOD_MS = 2000; |
70 private final static int CAMERA_FREEZE_REPORT_TIMOUT_MS = 4000; | 96 private final static int CAMERA_FREEZE_REPORT_TIMOUT_MS = 4000; |
71 | 97 |
72 private final SurfaceTextureHelper surfaceTextureHelper; | 98 private final SurfaceTextureHelper surfaceTextureHelper; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 public void addFrame() { | 147 public void addFrame() { |
122 checkThread(); | 148 checkThread(); |
123 ++frameCount; | 149 ++frameCount; |
124 } | 150 } |
125 | 151 |
126 public void release() { | 152 public void release() { |
127 surfaceTextureHelper.getHandler().removeCallbacks(cameraObserver); | 153 surfaceTextureHelper.getHandler().removeCallbacks(cameraObserver); |
128 } | 154 } |
129 } | 155 } |
130 } | 156 } |
OLD | NEW |