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

Side by Side Diff: webrtc/api/java/jni/surfacetexturehelper_jni.cc

Issue 1988043002: Call java SurfaceTextureHelper.dispose from the corresponding C++ destructor. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Indentation tweak. Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 11
12 #include "webrtc/api/java/jni/surfacetexturehelper_jni.h" 12 #include "webrtc/api/java/jni/surfacetexturehelper_jni.h"
13 13
14 #include "webrtc/api/java/jni/classreferenceholder.h" 14 #include "webrtc/api/java/jni/classreferenceholder.h"
15 #include "webrtc/base/bind.h" 15 #include "webrtc/base/bind.h"
16 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
17 #include "webrtc/base/logging.h"
17 18
18 namespace webrtc_jni { 19 namespace webrtc_jni {
19 20
20 rtc::scoped_refptr<SurfaceTextureHelper> SurfaceTextureHelper::create( 21 rtc::scoped_refptr<SurfaceTextureHelper> SurfaceTextureHelper::create(
21 JNIEnv* jni, 22 JNIEnv* jni,
22 const char* thread_name, 23 const char* thread_name,
23 jobject j_egl_context) { 24 jobject j_egl_context) {
24 jobject j_surface_texture_helper = jni->CallStaticObjectMethod( 25 jobject j_surface_texture_helper = jni->CallStaticObjectMethod(
25 FindClass(jni, "org/webrtc/SurfaceTextureHelper"), 26 FindClass(jni, "org/webrtc/SurfaceTextureHelper"),
26 GetStaticMethodID(jni, FindClass(jni, "org/webrtc/SurfaceTextureHelper"), 27 GetStaticMethodID(jni, FindClass(jni, "org/webrtc/SurfaceTextureHelper"),
(...skipping 14 matching lines...) Expand all
41 : j_surface_texture_helper_(jni, j_surface_texture_helper), 42 : j_surface_texture_helper_(jni, j_surface_texture_helper),
42 j_return_texture_method_( 43 j_return_texture_method_(
43 GetMethodID(jni, 44 GetMethodID(jni,
44 FindClass(jni, "org/webrtc/SurfaceTextureHelper"), 45 FindClass(jni, "org/webrtc/SurfaceTextureHelper"),
45 "returnTextureFrame", 46 "returnTextureFrame",
46 "()V")) { 47 "()V")) {
47 CHECK_EXCEPTION(jni) << "error during initialization of SurfaceTextureHelper"; 48 CHECK_EXCEPTION(jni) << "error during initialization of SurfaceTextureHelper";
48 } 49 }
49 50
50 SurfaceTextureHelper::~SurfaceTextureHelper() { 51 SurfaceTextureHelper::~SurfaceTextureHelper() {
52 LOG(LS_INFO) << "SurfaceTextureHelper dtor";
53 JNIEnv* jni = AttachCurrentThreadIfNeeded();
54 jni->CallVoidMethod(
55 *j_surface_texture_helper_,
56 GetMethodID(jni, FindClass(jni, "org/webrtc/SurfaceTextureHelper"),
57 "dispose", "()V"));
58
59 CHECK_EXCEPTION(jni) << "error during SurfaceTextureHelper.dispose()";
51 } 60 }
52 61
53 jobject SurfaceTextureHelper::GetJavaSurfaceTextureHelper() const { 62 jobject SurfaceTextureHelper::GetJavaSurfaceTextureHelper() const {
54 return *j_surface_texture_helper_; 63 return *j_surface_texture_helper_;
55 } 64 }
56 65
57 void SurfaceTextureHelper::ReturnTextureFrame() const { 66 void SurfaceTextureHelper::ReturnTextureFrame() const {
58 JNIEnv* jni = AttachCurrentThreadIfNeeded(); 67 JNIEnv* jni = AttachCurrentThreadIfNeeded();
59 jni->CallVoidMethod(*j_surface_texture_helper_, j_return_texture_method_); 68 jni->CallVoidMethod(*j_surface_texture_helper_, j_return_texture_method_);
60 69
61 CHECK_EXCEPTION( 70 CHECK_EXCEPTION(
62 jni) << "error during SurfaceTextureHelper.returnTextureFrame"; 71 jni) << "error during SurfaceTextureHelper.returnTextureFrame";
63 } 72 }
64 73
65 rtc::scoped_refptr<webrtc::VideoFrameBuffer> 74 rtc::scoped_refptr<webrtc::VideoFrameBuffer>
66 SurfaceTextureHelper::CreateTextureFrame(int width, int height, 75 SurfaceTextureHelper::CreateTextureFrame(int width, int height,
67 const NativeHandleImpl& native_handle) { 76 const NativeHandleImpl& native_handle) {
68 return new rtc::RefCountedObject<AndroidTextureBuffer>( 77 return new rtc::RefCountedObject<AndroidTextureBuffer>(
69 width, height, native_handle, *j_surface_texture_helper_, 78 width, height, native_handle, *j_surface_texture_helper_,
70 rtc::Bind(&SurfaceTextureHelper::ReturnTextureFrame, this)); 79 rtc::Bind(&SurfaceTextureHelper::ReturnTextureFrame, this));
71 } 80 }
72 81
73 } // namespace webrtc_jni 82 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « webrtc/api/java/jni/surfacetexturehelper_jni.h ('k') | webrtc/api/java/src/org/webrtc/MediaCodecVideoDecoder.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698