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

Unified Diff: talk/app/webrtc/java/jni/androidvideocapturer_jni.cc

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
« no previous file with comments | « talk/app/webrtc/java/jni/androidvideocapturer_jni.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/app/webrtc/java/jni/androidvideocapturer_jni.cc
diff --git a/talk/app/webrtc/java/jni/androidvideocapturer_jni.cc b/talk/app/webrtc/java/jni/androidvideocapturer_jni.cc
index eae87bd8ce2894b1a7598701550eaf208f67c3e1..74a9372d866e1d8042f478bedc46aeacf4f50814 100644
--- a/talk/app/webrtc/java/jni/androidvideocapturer_jni.cc
+++ b/talk/app/webrtc/java/jni/androidvideocapturer_jni.cc
@@ -176,13 +176,13 @@
success);
}
-void AndroidVideoCapturerJni::OnIncomingFrame(const uint8_t* video_frame,
+void AndroidVideoCapturerJni::OnIncomingFrame(void* video_frame,
int length,
int width,
int height,
int rotation,
int64 time_stamp) {
- const uint8_t* y_plane = video_frame;
+ const uint8_t* y_plane = static_cast<uint8_t*>(video_frame);
// Android guarantees that the stride is a multiple of 16.
// http://developer.android.com/reference/android/hardware/Camera.Parameters.html#setPreviewFormat%28int%29
int y_stride;
@@ -215,14 +215,20 @@
JNIEnv* AndroidVideoCapturerJni::jni() { return AttachCurrentThreadIfNeeded(); }
JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeOnFrameCaptured)
- (JNIEnv* jni, jclass, jlong j_capturer, jobject j_byte_buffer,
+ (JNIEnv* jni, jclass, jlong j_capturer, jbyteArray j_frame, jint length,
jint width, jint height, jint rotation, jlong ts) {
- const uint8_t* bytes =
- static_cast<uint8_t*>(jni->GetDirectBufferAddress(j_byte_buffer));
- const int length = jni->GetDirectBufferCapacity(j_byte_buffer);
- RTC_CHECK(bytes != nullptr && length != -1) << "ByteBuffer is not direct";
+ jboolean is_copy = true;
+ jbyte* bytes = jni->GetByteArrayElements(j_frame, &is_copy);
+ // If this is a copy of the original frame, it means that the memory
+ // is not direct memory and thus VideoCapturerAndroid does not guarantee
+ // that the memory is valid when we have released |j_frame|.
+ // TODO(magjed): Move ReleaseByteArrayElements() into ReturnBuffer() and
+ // remove this check.
+ RTC_CHECK(!is_copy)
+ << "NativeObserver_nativeOnFrameCaptured: frame is a copy";
reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)
->OnIncomingFrame(bytes, length, width, height, rotation, ts);
+ jni->ReleaseByteArrayElements(j_frame, bytes, JNI_ABORT);
}
JOW(void, VideoCapturerAndroid_00024NativeObserver_nativeCapturerStarted)
« no previous file with comments | « talk/app/webrtc/java/jni/androidvideocapturer_jni.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698