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

Unified Diff: talk/app/webrtc/java/android/org/webrtc/VideoCapturerAndroid.java

Issue 1377783002: Revert of Android VideoCapturer: Send ByteBuffer instead of byte[] (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: talk/app/webrtc/java/android/org/webrtc/VideoCapturerAndroid.java
diff --git a/talk/app/webrtc/java/android/org/webrtc/VideoCapturerAndroid.java b/talk/app/webrtc/java/android/org/webrtc/VideoCapturerAndroid.java
index 72b62c3f9fbdf376e1be8628c7379691fb1b43fa..ee01eede9e6e87f63929b4956143fae2b02f79fd 100644
--- a/talk/app/webrtc/java/android/org/webrtc/VideoCapturerAndroid.java
+++ b/talk/app/webrtc/java/android/org/webrtc/VideoCapturerAndroid.java
@@ -569,11 +569,12 @@
}
rotation = (info.orientation + rotation) % 360;
// Mark the frame owning |data| as used.
- final ByteBuffer buffer = videoBuffers.reserveByteBuffer(data, captureTimeNs);
- if (buffer != null) {
+ // Note that since data is directBuffer,
+ // data.length >= videoBuffers.frameSize.
+ if (videoBuffers.reserveByteBuffer(data, captureTimeNs)) {
cameraFramesCount++;
- frameObserver.OnFrameCaptured(buffer, captureFormat.width, captureFormat.height,
- rotation, captureTimeNs);
+ frameObserver.OnFrameCaptured(data, videoBuffers.frameSize, captureFormat.width,
+ captureFormat.height, rotation, captureTimeNs);
} else {
Logging.w(TAG, "reserveByteBuffer failed - dropping frame.");
}
@@ -655,8 +656,7 @@
: " Pending buffers: " + pendingFramesTimeStamps() + "."));
}
- // Returns the reserved byte buffer, or null on failure.
- public ByteBuffer reserveByteBuffer(byte[] data, long timeStamp) {
+ public boolean reserveByteBuffer(byte[] data, long timeStamp) {
checkIsOnValidThread();
final ByteBuffer buffer = queuedBuffers.remove(data);
if (buffer == null) {
@@ -664,21 +664,21 @@
// capture format in |startPreviewOnCameraThread|. Drop these old frames.
Logging.w(TAG, "Received callback buffer from previous configuration with length: "
+ (data == null ? "null" : data.length));
- return null;
+ return false;
}
if (buffer.capacity() != frameSize) {
throw new IllegalStateException("Callback buffer has unexpected frame size");
}
if (pendingBuffers.containsKey(timeStamp)) {
Logging.e(TAG, "Timestamp already present in pending buffers - they need to be unique");
- return null;
+ return false;
}
pendingBuffers.put(timeStamp, buffer);
if (queuedBuffers.isEmpty()) {
Logging.v(TAG, "Camera is running out of capture buffers."
+ " Pending buffers: " + pendingFramesTimeStamps());
}
- return buffer;
+ return true;
}
public void returnBuffer(long timeStamp) {
@@ -722,8 +722,8 @@
// Delivers a captured frame. Called on a Java thread owned by
// VideoCapturerAndroid.
- abstract void OnFrameCaptured(ByteBuffer buffer, int width, int height, int rotation,
- long timeStamp);
+ abstract void OnFrameCaptured(byte[] data, int length, int width, int height,
+ int rotation, long timeStamp);
// Requests an output format from the video capturer. Captured frames
// by the camera will be scaled/or dropped by the video capturer.
@@ -746,9 +746,9 @@
}
@Override
- public void OnFrameCaptured(ByteBuffer buffer, int width, int height, int rotation,
- long timeStamp) {
- nativeOnFrameCaptured(nativeCapturer, buffer, width, height, rotation, timeStamp);
+ public void OnFrameCaptured(byte[] data, int length, int width, int height,
+ int rotation, long timeStamp) {
+ nativeOnFrameCaptured(nativeCapturer, data, length, width, height, rotation, timeStamp);
}
@Override
@@ -759,7 +759,7 @@
private native void nativeCapturerStarted(long nativeCapturer,
boolean success);
private native void nativeOnFrameCaptured(long nativeCapturer,
- ByteBuffer buffer, int width, int height, int rotation, long timeStamp);
+ byte[] data, int length, int width, int height, int rotation, long timeStamp);
private native void nativeOnOutputFormatRequest(long nativeCapturer,
int width, int height, int fps);
}

Powered by Google App Engine
This is Rietveld 408576698