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

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

Issue 2127893002: AndroidVideoTrackSource implementation (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@magjed-init
Patch Set: Fix cpplint errors. 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
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 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 org.webrtc.CameraEnumerationAndroid.CaptureFormat; 13 import org.webrtc.CameraEnumerationAndroid.CaptureFormat;
14 14
15 import android.content.Context; 15 import android.content.Context;
16 import android.os.Handler; 16 import android.os.Handler;
17 import android.os.SystemClock; 17 import android.os.SystemClock;
18 import android.view.Surface; 18 import android.view.Surface;
19 import android.view.WindowManager; 19 import android.view.WindowManager;
20 20
21 import java.io.IOException; 21 import java.io.IOException;
22 import java.nio.ByteBuffer; 22 import java.nio.ByteBuffer;
23 import java.util.HashSet; 23 import java.util.HashSet;
24 import java.util.List; 24 import java.util.List;
25 import java.util.Set; 25 import java.util.Set;
26 import java.util.concurrent.atomic.AtomicBoolean;
27 import java.util.concurrent.CountDownLatch; 26 import java.util.concurrent.CountDownLatch;
28 import java.util.concurrent.TimeUnit; 27 import java.util.concurrent.TimeUnit;
28 import java.util.concurrent.atomic.AtomicBoolean;
29 29
30 // Android specific implementation of VideoCapturer. 30 // Android specific implementation of VideoCapturer.
31 // An instance of this class can be created by an application using 31 // An instance of this class can be created by an application using
32 // VideoCapturerAndroid.create(); 32 // VideoCapturerAndroid.create();
33 // This class extends VideoCapturer with a method to easily switch between the 33 // This class extends VideoCapturer with a method to easily switch between the
34 // front and back camera. It also provides methods for enumerating valid device 34 // front and back camera. It also provides methods for enumerating valid device
35 // names. 35 // names.
36 // 36 //
37 // Threading notes: this class is called from C++ code, Android Camera callbacks , and possibly 37 // Threading notes: this class is called from C++ code, Android Camera callbacks , and possibly
38 // arbitrary Java threads. All public entry points are thread safe, and delegate the work to the 38 // arbitrary Java threads. All public entry points are thread safe, and delegate the work to the
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 Logging.e(TAG, "Calling stopCapture() for already stopped camera."); 477 Logging.e(TAG, "Calling stopCapture() for already stopped camera.");
478 return; 478 return;
479 } 479 }
480 if (!barrier.await(CAMERA_STOP_TIMEOUT_MS, TimeUnit.MILLISECONDS)) { 480 if (!barrier.await(CAMERA_STOP_TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
481 Logging.e(TAG, "Camera stop timeout"); 481 Logging.e(TAG, "Camera stop timeout");
482 printStackTrace(); 482 printStackTrace();
483 if (eventsHandler != null) { 483 if (eventsHandler != null) {
484 eventsHandler.onCameraError("Camera stop timeout"); 484 eventsHandler.onCameraError("Camera stop timeout");
485 } 485 }
486 } 486 }
487 frameObserver.onCapturerStopped();
487 Logging.d(TAG, "stopCapture done"); 488 Logging.d(TAG, "stopCapture done");
488 } 489 }
489 490
490 private void stopCaptureOnCameraThread(boolean stopHandler) { 491 private void stopCaptureOnCameraThread(boolean stopHandler) {
491 checkIsOnCameraThread(); 492 checkIsOnCameraThread();
492 Logging.d(TAG, "stopCaptureOnCameraThread"); 493 Logging.d(TAG, "stopCaptureOnCameraThread");
493 // Note that the camera might still not be started here if startCaptureOnCam eraThread failed 494 // Note that the camera might still not be started here if startCaptureOnCam eraThread failed
494 // and we posted a retry. 495 // and we posted a retry.
495 496
496 // Make sure onTextureFrameAvailable() is not called anymore. 497 // Make sure onTextureFrameAvailable() is not called anymore.
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 // Undo the mirror that the OS "helps" us with. 634 // Undo the mirror that the OS "helps" us with.
634 // http://developer.android.com/reference/android/hardware/Camera.html#set DisplayOrientation(int) 635 // http://developer.android.com/reference/android/hardware/Camera.html#set DisplayOrientation(int)
635 transformMatrix = 636 transformMatrix =
636 RendererCommon.multiplyMatrices(transformMatrix, RendererCommon.horizo ntalFlipMatrix()); 637 RendererCommon.multiplyMatrices(transformMatrix, RendererCommon.horizo ntalFlipMatrix());
637 } 638 }
638 cameraStatistics.addFrame(); 639 cameraStatistics.addFrame();
639 frameObserver.onTextureFrameCaptured(captureFormat.width, captureFormat.heig ht, oesTextureId, 640 frameObserver.onTextureFrameCaptured(captureFormat.width, captureFormat.heig ht, oesTextureId,
640 transformMatrix, rotation, timestampNs); 641 transformMatrix, rotation, timestampNs);
641 } 642 }
642 } 643 }
OLDNEW
« no previous file with comments | « webrtc/api/android/java/src/org/webrtc/VideoCapturer.java ('k') | webrtc/api/android/java/src/org/webrtc/VideoSource.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698