Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: talk/app/webrtc/java/android/org/webrtc/VideoCapturerAndroid.java

Issue 1479523003: Add separate event for camera freeze. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Fix tests Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/app/webrtc/androidtests/src/org/webrtc/VideoCapturerAndroidTestFixtures.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 10 matching lines...) Expand all
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 package org.webrtc; 28 package org.webrtc;
29 29
30 import android.content.Context; 30 import android.content.Context;
31 import android.graphics.SurfaceTexture;
32 import android.os.Handler; 31 import android.os.Handler;
33 import android.os.HandlerThread; 32 import android.os.HandlerThread;
34 import android.os.SystemClock; 33 import android.os.SystemClock;
35 import android.view.Surface; 34 import android.view.Surface;
36 import android.view.WindowManager; 35 import android.view.WindowManager;
37 36
38 import org.json.JSONException; 37 import org.json.JSONException;
39 import org.webrtc.CameraEnumerationAndroid.CaptureFormat; 38 import org.webrtc.CameraEnumerationAndroid.CaptureFormat;
40 import org.webrtc.Logging; 39 import org.webrtc.Logging;
41 40
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 private boolean firstFrameReported; 95 private boolean firstFrameReported;
97 private final boolean isCapturingToTexture; 96 private final boolean isCapturingToTexture;
98 private final SurfaceTextureHelper surfaceHelper; 97 private final SurfaceTextureHelper surfaceHelper;
99 // The camera API can output one old frame after the camera has been switched or the resolution 98 // The camera API can output one old frame after the camera has been switched or the resolution
100 // has been changed. This flag is used for dropping the first frame after came ra restart. 99 // has been changed. This flag is used for dropping the first frame after came ra restart.
101 private boolean dropNextFrame = false; 100 private boolean dropNextFrame = false;
102 // |openCameraOnCodecThreadRunner| is used for retrying to open the camera if it is in use by 101 // |openCameraOnCodecThreadRunner| is used for retrying to open the camera if it is in use by
103 // another application when startCaptureOnCameraThread is called. 102 // another application when startCaptureOnCameraThread is called.
104 private Runnable openCameraOnCodecThreadRunner; 103 private Runnable openCameraOnCodecThreadRunner;
105 private final static int MAX_OPEN_CAMERA_ATTEMPTS = 3; 104 private final static int MAX_OPEN_CAMERA_ATTEMPTS = 3;
106 private final static int OPEN_CAMERA_DELAY_MS = 300; 105 private final static int OPEN_CAMERA_DELAY_MS = 500;
107 private int openCameraAttempts; 106 private int openCameraAttempts;
108 107
109 // Camera error callback. 108 // Camera error callback.
110 private final android.hardware.Camera.ErrorCallback cameraErrorCallback = 109 private final android.hardware.Camera.ErrorCallback cameraErrorCallback =
111 new android.hardware.Camera.ErrorCallback() { 110 new android.hardware.Camera.ErrorCallback() {
112 @Override 111 @Override
113 public void onError(int error, android.hardware.Camera camera) { 112 public void onError(int error, android.hardware.Camera camera) {
114 String errorMessage; 113 String errorMessage;
115 if (error == android.hardware.Camera.CAMERA_ERROR_SERVER_DIED) { 114 if (error == android.hardware.Camera.CAMERA_ERROR_SERVER_DIED) {
116 errorMessage = "Camera server died!"; 115 errorMessage = "Camera server died!";
(...skipping 17 matching lines...) Expand all
134 / CAMERA_OBSERVER_PERIOD_MS; 133 / CAMERA_OBSERVER_PERIOD_MS;
135 134
136 Logging.d(TAG, "Camera fps: " + cameraFps + 135 Logging.d(TAG, "Camera fps: " + cameraFps +
137 ". Pending buffers: " + cameraStatistics.pendingFramesTimeStamps()); 136 ". Pending buffers: " + cameraStatistics.pendingFramesTimeStamps());
138 if (cameraFramesCount == 0) { 137 if (cameraFramesCount == 0) {
139 ++freezePeriodCount; 138 ++freezePeriodCount;
140 if (CAMERA_OBSERVER_PERIOD_MS * freezePeriodCount > CAMERA_FREEZE_REPORT _TIMOUT_MS 139 if (CAMERA_OBSERVER_PERIOD_MS * freezePeriodCount > CAMERA_FREEZE_REPORT _TIMOUT_MS
141 && eventsHandler != null) { 140 && eventsHandler != null) {
142 Logging.e(TAG, "Camera freezed."); 141 Logging.e(TAG, "Camera freezed.");
143 if (cameraStatistics.pendingFramesCount() == cameraStatistics.maxPendi ngFrames) { 142 if (cameraStatistics.pendingFramesCount() == cameraStatistics.maxPendi ngFrames) {
144 eventsHandler.onCameraError("Camera failure. Client must return vide o buffers."); 143 eventsHandler.onCameraFreezed("Camera failure. Client must return vi deo buffers.");
145 } else { 144 } else {
146 eventsHandler.onCameraError("Camera failure."); 145 eventsHandler.onCameraFreezed("Camera failure.");
147 } 146 }
148 return; 147 return;
149 } 148 }
150 } else { 149 } else {
151 freezePeriodCount = 0; 150 freezePeriodCount = 0;
152 } 151 }
153 cameraThreadHandler.postDelayed(this, CAMERA_OBSERVER_PERIOD_MS); 152 cameraThreadHandler.postDelayed(this, CAMERA_OBSERVER_PERIOD_MS);
154 } 153 }
155 }; 154 };
156 155
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 threadChecker.checkIsOnValidThread(); 196 threadChecker.checkIsOnValidThread();
198 List<Long> timeStampsMs = new ArrayList<Long>(); 197 List<Long> timeStampsMs = new ArrayList<Long>();
199 for (long ts : timeStampsNs) { 198 for (long ts : timeStampsNs) {
200 timeStampsMs.add(TimeUnit.NANOSECONDS.toMillis(ts)); 199 timeStampsMs.add(TimeUnit.NANOSECONDS.toMillis(ts));
201 } 200 }
202 return timeStampsMs.toString(); 201 return timeStampsMs.toString();
203 } 202 }
204 } 203 }
205 204
206 public static interface CameraEventsHandler { 205 public static interface CameraEventsHandler {
207 // Camera error handler - invoked when camera stops receiving frames 206 // Camera error handler - invoked when camera can not be opened
208 // or any camera exception happens on camera thread. 207 // or any camera exception happens on camera thread.
209 void onCameraError(String errorDescription); 208 void onCameraError(String errorDescription);
210 209
210 // Invoked when camera stops receiving frames
211 void onCameraFreezed(String errorDescription);
212
211 // Callback invoked when camera is opening. 213 // Callback invoked when camera is opening.
212 void onCameraOpening(int cameraId); 214 void onCameraOpening(int cameraId);
213 215
214 // Callback invoked when first camera frame is available after camera is ope ned. 216 // Callback invoked when first camera frame is available after camera is ope ned.
215 void onFirstFrameAvailable(); 217 void onFirstFrameAvailable();
216 218
217 // Callback invoked when camera closed. 219 // Callback invoked when camera closed.
218 void onCameraClosed(); 220 void onCameraClosed();
219 } 221 }
220 222
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 private native void nativeOnByteBufferFrameCaptured(long nativeCapturer, 940 private native void nativeOnByteBufferFrameCaptured(long nativeCapturer,
939 byte[] data, int length, int width, int height, int rotation, long timeS tamp); 941 byte[] data, int length, int width, int height, int rotation, long timeS tamp);
940 private native void nativeOnTextureFrameCaptured(long nativeCapturer, int wi dth, int height, 942 private native void nativeOnTextureFrameCaptured(long nativeCapturer, int wi dth, int height,
941 int oesTextureId, float[] transformMatrix, long timestamp); 943 int oesTextureId, float[] transformMatrix, long timestamp);
942 private native void nativeOnOutputFormatRequest(long nativeCapturer, 944 private native void nativeOnOutputFormatRequest(long nativeCapturer,
943 int width, int height, int framerate); 945 int width, int height, int framerate);
944 } 946 }
945 947
946 private static native long nativeCreateVideoCapturer(VideoCapturerAndroid vide oCapturer); 948 private static native long nativeCreateVideoCapturer(VideoCapturerAndroid vide oCapturer);
947 } 949 }
OLDNEW
« no previous file with comments | « talk/app/webrtc/androidtests/src/org/webrtc/VideoCapturerAndroidTestFixtures.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698