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

Side by Side Diff: webrtc/sdk/android/src/jni/pc/peerconnection_jni.cc

Issue 3003213002: Android: Add common function for adding/releasing native reference (Closed)
Patch Set: Created 3 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2013 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
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 static rtc::scoped_refptr<webrtc::PeerConnectionInterface> ExtractNativePC( 50 static rtc::scoped_refptr<webrtc::PeerConnectionInterface> ExtractNativePC(
51 JNIEnv* jni, 51 JNIEnv* jni,
52 jobject j_pc) { 52 jobject j_pc) {
53 jfieldID native_pc_id = 53 jfieldID native_pc_id =
54 GetFieldID(jni, GetObjectClass(jni, j_pc), "nativePeerConnection", "J"); 54 GetFieldID(jni, GetObjectClass(jni, j_pc), "nativePeerConnection", "J");
55 jlong j_p = GetLongField(jni, j_pc, native_pc_id); 55 jlong j_p = GetLongField(jni, j_pc, native_pc_id);
56 return rtc::scoped_refptr<webrtc::PeerConnectionInterface>( 56 return rtc::scoped_refptr<webrtc::PeerConnectionInterface>(
57 reinterpret_cast<webrtc::PeerConnectionInterface*>(j_p)); 57 reinterpret_cast<webrtc::PeerConnectionInterface*>(j_p));
58 } 58 }
59 59
60 JOW(void, PeerConnection_freePeerConnection)(JNIEnv*, jclass, jlong j_p) {
61 CHECK_RELEASE(reinterpret_cast<webrtc::PeerConnectionInterface*>(j_p));
62 }
63
64 JOW(void, PeerConnection_freeObserver)(JNIEnv*, jclass, jlong j_p) { 60 JOW(void, PeerConnection_freeObserver)(JNIEnv*, jclass, jlong j_p) {
65 PeerConnectionObserverJni* p = 61 PeerConnectionObserverJni* p =
66 reinterpret_cast<PeerConnectionObserverJni*>(j_p); 62 reinterpret_cast<PeerConnectionObserverJni*>(j_p);
67 delete p; 63 delete p;
68 } 64 }
69 65
70 JOW(jobject, PeerConnection_getLocalDescription)(JNIEnv* jni, jobject j_pc) { 66 JOW(jobject, PeerConnection_getLocalDescription)(JNIEnv* jni, jobject j_pc) {
71 const webrtc::SessionDescriptionInterface* sdp = 67 const webrtc::SessionDescriptionInterface* sdp =
72 ExtractNativePC(jni, j_pc)->local_description(); 68 ExtractNativePC(jni, j_pc)->local_description();
73 return sdp ? NativeToJavaSessionDescription(jni, sdp) : NULL; 69 return sdp ? NativeToJavaSessionDescription(jni, sdp) : NULL;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 return JavaEnumFromIndexAndClassName(jni, "PeerConnection$IceGatheringState", 332 return JavaEnumFromIndexAndClassName(jni, "PeerConnection$IceGatheringState",
337 state); 333 state);
338 } 334 }
339 335
340 JOW(void, PeerConnection_close)(JNIEnv* jni, jobject j_pc) { 336 JOW(void, PeerConnection_close)(JNIEnv* jni, jobject j_pc) {
341 ExtractNativePC(jni, j_pc)->Close(); 337 ExtractNativePC(jni, j_pc)->Close();
342 return; 338 return;
343 } 339 }
344 340
345 } // namespace webrtc_jni 341 } // namespace webrtc_jni
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698