Call java SurfaceTextureHelper.dispose from the corresponding C++ destructor.
This makes it clearer that the C++ SurfaceTextureHelper owns its associated java object it. In addition, arrange so that the SurfaceTextureHelper.stopListening method (in java) can be called from any thread. BUG= Review-Url: https://codereview.webrtc.org/1988043002 Cr-Commit-Position: refs/heads/master@{#12941}
This commit is contained in:
@ -53,13 +53,6 @@ AndroidVideoCapturerJni::~AndroidVideoCapturerJni() {
|
||||
*j_video_capturer_,
|
||||
GetMethodID(jni(), *j_video_capturer_class_, "dispose", "()V"));
|
||||
CHECK_EXCEPTION(jni()) << "error during VideoCapturer.dispose()";
|
||||
if (surface_texture_helper_) {
|
||||
jni()->CallVoidMethod(
|
||||
surface_texture_helper_->GetJavaSurfaceTextureHelper(),
|
||||
GetMethodID(jni(), FindClass(jni(), "org/webrtc/SurfaceTextureHelper"),
|
||||
"dispose", "()V"));
|
||||
}
|
||||
CHECK_EXCEPTION(jni()) << "error during SurfaceTextureHelper.dispose()";
|
||||
}
|
||||
|
||||
void AndroidVideoCapturerJni::Start(int width, int height, int framerate,
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include "webrtc/api/java/jni/classreferenceholder.h"
|
||||
#include "webrtc/base/bind.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
|
||||
namespace webrtc_jni {
|
||||
|
||||
@ -48,6 +49,14 @@ SurfaceTextureHelper::SurfaceTextureHelper(JNIEnv* jni,
|
||||
}
|
||||
|
||||
SurfaceTextureHelper::~SurfaceTextureHelper() {
|
||||
LOG(LS_INFO) << "SurfaceTextureHelper dtor";
|
||||
JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
||||
jni->CallVoidMethod(
|
||||
*j_surface_texture_helper_,
|
||||
GetMethodID(jni, FindClass(jni, "org/webrtc/SurfaceTextureHelper"),
|
||||
"dispose", "()V"));
|
||||
|
||||
CHECK_EXCEPTION(jni) << "error during SurfaceTextureHelper.dispose()";
|
||||
}
|
||||
|
||||
jobject SurfaceTextureHelper::GetJavaSurfaceTextureHelper() const {
|
||||
|
||||
@ -30,6 +30,8 @@ namespace webrtc_jni {
|
||||
// SurfaceTextureHelper is reference counted to make sure that it is not
|
||||
// destroyed while a VideoFrameBuffer is in use.
|
||||
// This class is the C++ counterpart of the java class SurfaceTextureHelper.
|
||||
// It owns the corresponding java object, and calls the java dispose
|
||||
// method when destroyed.
|
||||
// Usage:
|
||||
// 1. Create an instance of this class.
|
||||
// 2. Get the Java SurfaceTextureHelper with GetJavaSurfaceTextureHelper().
|
||||
|
||||
Reference in New Issue
Block a user