diff options
author | perkj <perkj@webrtc.org> | 2015-12-16 02:17:16 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-16 10:17:24 +0000 |
commit | 672aba3f57061e33dd802d9a391c54bdfed952c3 (patch) | |
tree | 4783a2516dde3fe9a35f74ae1b25a642c653646b /talk | |
parent | 66085beef83c790a69666b9be8a74bb2eee44fab (diff) | |
download | webrtc-672aba3f57061e33dd802d9a391c54bdfed952c3.tar.gz |
Fix error prone code in VideoCapturerAndroid
BUG=webrtc:5282
Review URL: https://codereview.webrtc.org/1486423003
Cr-Commit-Position: refs/heads/master@{#11046}
Diffstat (limited to 'talk')
-rw-r--r-- | talk/app/webrtc/java/android/org/webrtc/CameraEnumerationAndroid.java | 13 | ||||
-rw-r--r-- | talk/app/webrtc/java/android/org/webrtc/VideoCapturerAndroid.java | 10 |
2 files changed, 11 insertions, 12 deletions
diff --git a/talk/app/webrtc/java/android/org/webrtc/CameraEnumerationAndroid.java b/talk/app/webrtc/java/android/org/webrtc/CameraEnumerationAndroid.java index 32341a3421..251bcacbf6 100644 --- a/talk/app/webrtc/java/android/org/webrtc/CameraEnumerationAndroid.java +++ b/talk/app/webrtc/java/android/org/webrtc/CameraEnumerationAndroid.java @@ -113,14 +113,12 @@ public class CameraEnumerationAndroid { return width + "x" + height + "@[" + minFramerate + ":" + maxFramerate + "]"; } - @Override - public boolean equals(Object that) { - if (!(that instanceof CaptureFormat)) { + public boolean isSameFormat(final CaptureFormat that) { + if (that == null) { return false; } - final CaptureFormat c = (CaptureFormat) that; - return width == c.width && height == c.height && maxFramerate == c.maxFramerate - && minFramerate == c.minFramerate; + return width == that.width && height == that.height && maxFramerate == that.maxFramerate + && minFramerate == that.minFramerate; } } @@ -203,8 +201,9 @@ public class CameraEnumerationAndroid { return Collections.min(listFpsRange, new ClosestComparator<int[]>() { @Override int diff(int[] range) { + final int maxFpsWeight = 10; return range[android.hardware.Camera.Parameters.PREVIEW_FPS_MIN_INDEX] - + 10 * abs(framerate + + maxFpsWeight * abs(framerate - range[android.hardware.Camera.Parameters.PREVIEW_FPS_MAX_INDEX]); } }); diff --git a/talk/app/webrtc/java/android/org/webrtc/VideoCapturerAndroid.java b/talk/app/webrtc/java/android/org/webrtc/VideoCapturerAndroid.java index d85f2c5588..caeb389137 100644 --- a/talk/app/webrtc/java/android/org/webrtc/VideoCapturerAndroid.java +++ b/talk/app/webrtc/java/android/org/webrtc/VideoCapturerAndroid.java @@ -359,7 +359,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements videoBuffers = new FramePool(cameraThread); isCapturingToTexture = (sharedContext != null); cameraStatistics = - new CameraStatistics(isCapturingToTexture ? 1 : videoBuffers.numCaptureBuffers); + new CameraStatistics(isCapturingToTexture ? 1 : FramePool.NUMBER_OF_CAPTURE_BUFFERS); surfaceHelper = SurfaceTextureHelper.create(sharedContext, cameraThreadHandler); if (isCapturingToTexture) { surfaceHelper.setListener(this); @@ -535,7 +535,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements range[android.hardware.Camera.Parameters.PREVIEW_FPS_MAX_INDEX]); // Check if we are already using this capture format, then we don't need to do anything. - if (captureFormat.equals(this.captureFormat)) { + if (captureFormat.isSameFormat(this.captureFormat)) { return; } @@ -777,7 +777,7 @@ public class VideoCapturerAndroid extends VideoCapturer implements // Arbitrary queue depth. Higher number means more memory allocated & held, // lower number means more sensitivity to processing time in the client (and // potentially stalling the capturer if it runs out of buffers to write to). - public static final int numCaptureBuffers = 3; + public static final int NUMBER_OF_CAPTURE_BUFFERS = 3; // This container tracks the buffers added as camera callback buffers. It is needed for finding // the corresponding ByteBuffer given a byte[]. private final Map<byte[], ByteBuffer> queuedBuffers = new IdentityHashMap<byte[], ByteBuffer>(); @@ -804,12 +804,12 @@ public class VideoCapturerAndroid extends VideoCapturer implements this.frameSize = frameSize; queuedBuffers.clear(); - for (int i = 0; i < numCaptureBuffers; ++i) { + for (int i = 0; i < NUMBER_OF_CAPTURE_BUFFERS; ++i) { final ByteBuffer buffer = ByteBuffer.allocateDirect(frameSize); camera.addCallbackBuffer(buffer.array()); queuedBuffers.put(buffer.array(), buffer); } - Logging.d(TAG, "queueCameraBuffers enqueued " + numCaptureBuffers + Logging.d(TAG, "queueCameraBuffers enqueued " + NUMBER_OF_CAPTURE_BUFFERS + " buffers of size " + frameSize + "."); } |