From 77405b279485b1583212cc4bea5081d00fbaa24a Mon Sep 17 00:00:00 2001 From: magjed Date: Thu, 26 May 2016 08:34:40 -0700 Subject: [PATCH] Android: Fix frame dropping for texture frames A bug was introduced in https://codereview.webrtc.org/1973873003 that doesn't return texture frames when they are dropped. BUG=webrtc:5682 Review-Url: https://codereview.webrtc.org/2012773004 Cr-Commit-Position: refs/heads/master@{#12922} --- webrtc/api/java/jni/androidvideocapturer_jni.cc | 1 + webrtc/api/java/jni/surfacetexturehelper_jni.h | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/webrtc/api/java/jni/androidvideocapturer_jni.cc b/webrtc/api/java/jni/androidvideocapturer_jni.cc index 0e8e8677ab..bc85cc4146 100644 --- a/webrtc/api/java/jni/androidvideocapturer_jni.cc +++ b/webrtc/api/java/jni/androidvideocapturer_jni.cc @@ -264,6 +264,7 @@ void AndroidVideoCapturerJni::OnTextureFrame(int width, if (!capturer_->AdaptFrame(width, height, timestamp_ns, &adapted_width, &adapted_height, &crop_width, &crop_height, &crop_x, &crop_y)) { + surface_texture_helper_->ReturnTextureFrame(); return; } diff --git a/webrtc/api/java/jni/surfacetexturehelper_jni.h b/webrtc/api/java/jni/surfacetexturehelper_jni.h index d7a9a7707a..6bee728d31 100644 --- a/webrtc/api/java/jni/surfacetexturehelper_jni.h +++ b/webrtc/api/java/jni/surfacetexturehelper_jni.h @@ -49,14 +49,14 @@ class SurfaceTextureHelper : public rtc::RefCountInterface { int height, const NativeHandleImpl& native_handle); + // May be called on arbitrary thread. + void ReturnTextureFrame() const; + protected: ~SurfaceTextureHelper(); SurfaceTextureHelper(JNIEnv* jni, jobject j_surface_texture_helper); private: - // May be called on arbitrary thread. - void ReturnTextureFrame() const; - const ScopedGlobalRef j_surface_texture_helper_; const jmethodID j_return_texture_method_; };