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

Side by Side Diff: webrtc/sdk/android/api/org/webrtc/Camera1Session.java

Issue 2642703002: Add failure type parameter to onFailure callback. (Closed)
Patch Set: Correctly handle failure type. Created 3 years, 11 months 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 | « no previous file | webrtc/sdk/android/api/org/webrtc/Camera2Session.java » ('j') | 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 * 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
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 final SurfaceTextureHelper surfaceTextureHelper, final int cameraId, final int width, 58 final SurfaceTextureHelper surfaceTextureHelper, final int cameraId, final int width,
59 final int height, final int framerate) { 59 final int height, final int framerate) {
60 final long constructionTimeNs = System.nanoTime(); 60 final long constructionTimeNs = System.nanoTime();
61 Logging.d(TAG, "Open camera " + cameraId); 61 Logging.d(TAG, "Open camera " + cameraId);
62 events.onCameraOpening(); 62 events.onCameraOpening();
63 63
64 final android.hardware.Camera camera; 64 final android.hardware.Camera camera;
65 try { 65 try {
66 camera = android.hardware.Camera.open(cameraId); 66 camera = android.hardware.Camera.open(cameraId);
67 } catch (RuntimeException e) { 67 } catch (RuntimeException e) {
68 callback.onFailure(e.getMessage()); 68 callback.onFailure(FailureType.ERROR, e.getMessage());
69 return; 69 return;
70 } 70 }
71 71
72 try { 72 try {
73 camera.setPreviewTexture(surfaceTextureHelper.getSurfaceTexture()); 73 camera.setPreviewTexture(surfaceTextureHelper.getSurfaceTexture());
74 } catch (IOException e) { 74 } catch (IOException e) {
75 camera.release(); 75 camera.release();
76 callback.onFailure(e.getMessage()); 76 callback.onFailure(FailureType.ERROR, e.getMessage());
77 return; 77 return;
78 } 78 }
79 79
80 final android.hardware.Camera.CameraInfo info = new android.hardware.Camera. CameraInfo(); 80 final android.hardware.Camera.CameraInfo info = new android.hardware.Camera. CameraInfo();
81 android.hardware.Camera.getCameraInfo(cameraId, info); 81 android.hardware.Camera.getCameraInfo(cameraId, info);
82 82
83 final android.hardware.Camera.Parameters parameters = camera.getParameters() ; 83 final android.hardware.Camera.Parameters parameters = camera.getParameters() ;
84 final CaptureFormat captureFormat = 84 final CaptureFormat captureFormat =
85 findClosestCaptureFormat(parameters, width, height, framerate); 85 findClosestCaptureFormat(parameters, width, height, framerate);
86 final Size pictureSize = findClosestPictureSize(parameters, width, height); 86 final Size pictureSize = findClosestPictureSize(parameters, width, height);
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } 334 }
335 return (info.orientation + rotation) % 360; 335 return (info.orientation + rotation) % 360;
336 } 336 }
337 337
338 private void checkIsOnCameraThread() { 338 private void checkIsOnCameraThread() {
339 if (Thread.currentThread() != cameraThreadHandler.getLooper().getThread()) { 339 if (Thread.currentThread() != cameraThreadHandler.getLooper().getThread()) {
340 throw new IllegalStateException("Wrong thread"); 340 throw new IllegalStateException("Wrong thread");
341 } 341 }
342 } 342 }
343 } 343 }
OLDNEW
« no previous file with comments | « no previous file | webrtc/sdk/android/api/org/webrtc/Camera2Session.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698