OLD | NEW |
---|---|
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 |
(...skipping 16 matching lines...) Expand all Loading... | |
27 // to the error stream. | 27 // to the error stream. |
28 #define CHECK_EXCEPTION(jni) \ | 28 #define CHECK_EXCEPTION(jni) \ |
29 RTC_CHECK(!jni->ExceptionCheck()) \ | 29 RTC_CHECK(!jni->ExceptionCheck()) \ |
30 << (jni->ExceptionDescribe(), jni->ExceptionClear(), "") | 30 << (jni->ExceptionDescribe(), jni->ExceptionClear(), "") |
31 | 31 |
32 // Helper that calls ptr->Release() and aborts the process with a useful | 32 // Helper that calls ptr->Release() and aborts the process with a useful |
33 // message if that didn't actually delete *ptr because of extra refcounts. | 33 // message if that didn't actually delete *ptr because of extra refcounts. |
34 #define CHECK_RELEASE(ptr) \ | 34 #define CHECK_RELEASE(ptr) \ |
35 RTC_CHECK_EQ(0, (ptr)->Release()) << "Unexpected refcount." | 35 RTC_CHECK_EQ(0, (ptr)->Release()) << "Unexpected refcount." |
36 | 36 |
37 // Convenience macro defining JNI-accessible methods in the org.webrtc package. | |
38 // Eliminates unnecessary boilerplate and line-wraps, reducing visual clutter. | |
39 #define JOW(rettype, name) \ | |
magjed_webrtc
2017/08/01 12:52:17
This is unrelated to your CL, but I have been plan
Taylor Brandstetter
2017/08/01 20:53:54
I'm not sure I agree; it may be more transparent,
magjed_webrtc
2017/08/02 14:15:46
So we have three different options. A concrete exa
Taylor Brandstetter
2017/08/02 21:13:49
Since this CL already probably makes more changes
| |
40 extern "C" JNIEXPORT rettype JNICALL Java_org_webrtc_##name | |
41 | |
37 namespace webrtc_jni { | 42 namespace webrtc_jni { |
38 | 43 |
39 jint InitGlobalJniVariables(JavaVM *jvm); | 44 jint InitGlobalJniVariables(JavaVM *jvm); |
40 | 45 |
41 // Return a |JNIEnv*| usable on this thread or NULL if this thread is detached. | 46 // Return a |JNIEnv*| usable on this thread or NULL if this thread is detached. |
42 JNIEnv* GetEnv(); | 47 JNIEnv* GetEnv(); |
43 | 48 |
44 JavaVM *GetJVM(); | 49 JavaVM *GetJVM(); |
45 | 50 |
46 // Return a |JNIEnv*| usable on this thread. Attaches to |g_jvm| if necessary. | 51 // Return a |JNIEnv*| usable on this thread. Attaches to |g_jvm| if necessary. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 // Given a UTF-8 encoded |native| string return a new (UTF-16) jstring. | 95 // Given a UTF-8 encoded |native| string return a new (UTF-16) jstring. |
91 jstring JavaStringFromStdString(JNIEnv* jni, const std::string& native); | 96 jstring JavaStringFromStdString(JNIEnv* jni, const std::string& native); |
92 | 97 |
93 // Given a (UTF-16) jstring return a new UTF-8 native string. | 98 // Given a (UTF-16) jstring return a new UTF-8 native string. |
94 std::string JavaToStdString(JNIEnv* jni, const jstring& j_string); | 99 std::string JavaToStdString(JNIEnv* jni, const jstring& j_string); |
95 | 100 |
96 // Return the (singleton) Java Enum object corresponding to |index|; | 101 // Return the (singleton) Java Enum object corresponding to |index|; |
97 jobject JavaEnumFromIndex(JNIEnv* jni, jclass state_class, | 102 jobject JavaEnumFromIndex(JNIEnv* jni, jclass state_class, |
98 const std::string& state_class_name, int index); | 103 const std::string& state_class_name, int index); |
99 | 104 |
105 // Return the (singleton) Java Enum object corresponding to |index|; | |
106 // |state_class_fragment| is something like "MediaSource$State". | |
107 jobject JavaEnumFromIndexAndClassName(JNIEnv* jni, | |
108 const std::string& state_class_fragment, | |
109 int index); | |
110 | |
100 // Returns the name of a Java enum. | 111 // Returns the name of a Java enum. |
101 std::string GetJavaEnumName(JNIEnv* jni, | 112 std::string GetJavaEnumName(JNIEnv* jni, |
102 const std::string& className, | 113 const std::string& className, |
103 jobject j_enum); | 114 jobject j_enum); |
104 | 115 |
105 jobject NewGlobalRef(JNIEnv* jni, jobject o); | 116 jobject NewGlobalRef(JNIEnv* jni, jobject o); |
106 | 117 |
107 void DeleteGlobalRef(JNIEnv* jni, jobject o); | 118 void DeleteGlobalRef(JNIEnv* jni, jobject o); |
108 | 119 |
109 // Scope Java local references to the lifetime of this object. Use in all C++ | 120 // Scope Java local references to the lifetime of this object. Use in all C++ |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 private: | 200 private: |
190 JNIEnv* jni_; | 201 JNIEnv* jni_; |
191 jobject iterable_; | 202 jobject iterable_; |
192 | 203 |
193 RTC_DISALLOW_COPY_AND_ASSIGN(Iterable); | 204 RTC_DISALLOW_COPY_AND_ASSIGN(Iterable); |
194 }; | 205 }; |
195 | 206 |
196 } // namespace webrtc_jni | 207 } // namespace webrtc_jni |
197 | 208 |
198 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_JNI_HELPERS_H_ | 209 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_JNI_HELPERS_H_ |
OLD | NEW |