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

Side by Side Diff: webrtc/api/android/java/src/org/webrtc/Camera2Capturer.java

Issue 2168623002: Refactor stopCapture to be asynchronous in VideoCapturerAndroid. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@androidvideotracksource
Patch Set: Synchronized. Created 4 years, 5 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/api/android/java/src/org/webrtc/VideoCapturer.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 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 770
771 @Override 771 @Override
772 public List<CaptureFormat> getSupportedFormats() { 772 public List<CaptureFormat> getSupportedFormats() {
773 synchronized (cameraState) { 773 synchronized (cameraState) {
774 return Camera2Enumerator.getSupportedFormats(this.cameraManager, cameraNam e); 774 return Camera2Enumerator.getSupportedFormats(this.cameraManager, cameraNam e);
775 } 775 }
776 } 776 }
777 777
778 @Override 778 @Override
779 public void dispose() { 779 public void dispose() {
780 stopCapture();
781
780 synchronized (cameraStateLock) { 782 synchronized (cameraStateLock) {
781 waitForCameraToStopIfStopping(); 783 waitForCameraToStopIfStopping();
782 784
783 if (cameraState != CameraState.IDLE) { 785 if (cameraState != CameraState.IDLE) {
784 throw new IllegalStateException("Unexpected camera state for dispose: " + cameraState); 786 throw new IllegalStateException("Unexpected camera state for dispose: " + cameraState);
785 } 787 }
786 } 788 }
787 } 789 }
788 790
789 // Blocks until camera is known to be stopped. 791 // Blocks until camera is known to be stopped.
790 @Override 792 @Override
791 public void stopCapture() { 793 public void stopCapture() {
792 final CountDownLatch cameraStoppingLatch = new CountDownLatch(1); 794 final CountDownLatch cameraStoppingLatch = new CountDownLatch(1);
793 795
794 Logging.d(TAG, "stopCapture"); 796 Logging.d(TAG, "stopCapture");
795 checkNotOnCameraThread(); 797 checkNotOnCameraThread();
796 798
797 synchronized (cameraStateLock) { 799 synchronized (cameraStateLock) {
798 waitForCameraToStartIfStarting(); 800 waitForCameraToStartIfStarting();
799 801
800 if (cameraState != CameraState.RUNNING) { 802 if (cameraState != CameraState.RUNNING) {
801 Logging.w(TAG, "stopCapture called for already stopped camera."); 803 Logging.d(TAG, "stopCapture called for already stopped camera.");
802 return; 804 return;
803 } 805 }
804 806
805 postOnCameraThread(new Runnable() { 807 postOnCameraThread(new Runnable() {
806 @Override 808 @Override
807 public void run() { 809 public void run() {
808 Logging.d(TAG, "stopCaptureOnCameraThread"); 810 Logging.d(TAG, "stopCaptureOnCameraThread");
809 811
810 // Stop capture. 812 // Stop capture.
811 closeAndRelease(); 813 closeAndRelease();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 rotation = (360 + rotation % 360) % 360; 883 rotation = (360 + rotation % 360) % 360;
882 884
883 // Undo camera orientation - we report it as rotation instead. 885 // Undo camera orientation - we report it as rotation instead.
884 transformMatrix = RendererCommon.rotateTextureMatrix(transformMatrix, -camer aOrientation); 886 transformMatrix = RendererCommon.rotateTextureMatrix(transformMatrix, -camer aOrientation);
885 887
886 cameraStatistics.addFrame(); 888 cameraStatistics.addFrame();
887 capturerObserver.onTextureFrameCaptured(captureFormat.width, captureFormat.h eight, oesTextureId, 889 capturerObserver.onTextureFrameCaptured(captureFormat.width, captureFormat.h eight, oesTextureId,
888 transformMatrix, rotation, timestampNs); 890 transformMatrix, rotation, timestampNs);
889 } 891 }
890 } 892 }
OLDNEW
« no previous file with comments | « no previous file | webrtc/api/android/java/src/org/webrtc/VideoCapturer.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698