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

Side by Side Diff: webrtc/sdk/android/src/jni/jni_helpers.h

Issue 2989323002: Revert of Break peerconnection_jni.cc into multiple files, in "pc" directory. (Closed)
Patch Set: Created 3 years, 4 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
(...skipping 16 matching lines...) Expand all
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 //
40 // TODO(deadbeef): Rename this macro to something like
41 // "JNI_FUNCTION_DECLARATION", and use variable length arguments, such that you
42 // can write:
43 //
44 // JNI_FUNCTION_DECLARATION(void, nativeFoo, Type arg1, Type arg2) { ...
45 //
46 // Instead of:
47 //
48 // JNI_FUNCTION_DECLARATION(void, nativeFoo)(Type arg1, Type arg2) { ...
49 //
50 // The latter gets handled poorly by autoformatting tools.
51 #define JOW(rettype, name) \
52 extern "C" JNIEXPORT rettype JNICALL Java_org_webrtc_##name
53
54 namespace webrtc_jni { 37 namespace webrtc_jni {
55 38
56 jint InitGlobalJniVariables(JavaVM *jvm); 39 jint InitGlobalJniVariables(JavaVM *jvm);
57 40
58 // Return a |JNIEnv*| usable on this thread or NULL if this thread is detached. 41 // Return a |JNIEnv*| usable on this thread or NULL if this thread is detached.
59 JNIEnv* GetEnv(); 42 JNIEnv* GetEnv();
60 43
61 JavaVM *GetJVM(); 44 JavaVM *GetJVM();
62 45
63 // Return a |JNIEnv*| usable on this thread. Attaches to |g_jvm| if necessary. 46 // 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
107 // Given a UTF-8 encoded |native| string return a new (UTF-16) jstring. 90 // Given a UTF-8 encoded |native| string return a new (UTF-16) jstring.
108 jstring JavaStringFromStdString(JNIEnv* jni, const std::string& native); 91 jstring JavaStringFromStdString(JNIEnv* jni, const std::string& native);
109 92
110 // Given a (UTF-16) jstring return a new UTF-8 native string. 93 // Given a (UTF-16) jstring return a new UTF-8 native string.
111 std::string JavaToStdString(JNIEnv* jni, const jstring& j_string); 94 std::string JavaToStdString(JNIEnv* jni, const jstring& j_string);
112 95
113 // Return the (singleton) Java Enum object corresponding to |index|; 96 // Return the (singleton) Java Enum object corresponding to |index|;
114 jobject JavaEnumFromIndex(JNIEnv* jni, jclass state_class, 97 jobject JavaEnumFromIndex(JNIEnv* jni, jclass state_class,
115 const std::string& state_class_name, int index); 98 const std::string& state_class_name, int index);
116 99
117 // Return the (singleton) Java Enum object corresponding to |index|;
118 // |state_class_fragment| is something like "MediaSource$State".
119 jobject JavaEnumFromIndexAndClassName(JNIEnv* jni,
120 const std::string& state_class_fragment,
121 int index);
122
123 // Returns the name of a Java enum. 100 // Returns the name of a Java enum.
124 std::string GetJavaEnumName(JNIEnv* jni, 101 std::string GetJavaEnumName(JNIEnv* jni,
125 const std::string& className, 102 const std::string& className,
126 jobject j_enum); 103 jobject j_enum);
127 104
128 jobject NewGlobalRef(JNIEnv* jni, jobject o); 105 jobject NewGlobalRef(JNIEnv* jni, jobject o);
129 106
130 void DeleteGlobalRef(JNIEnv* jni, jobject o); 107 void DeleteGlobalRef(JNIEnv* jni, jobject o);
131 108
132 // Scope Java local references to the lifetime of this object. Use in all C++ 109 // 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
212 private: 189 private:
213 JNIEnv* jni_; 190 JNIEnv* jni_;
214 jobject iterable_; 191 jobject iterable_;
215 192
216 RTC_DISALLOW_COPY_AND_ASSIGN(Iterable); 193 RTC_DISALLOW_COPY_AND_ASSIGN(Iterable);
217 }; 194 };
218 195
219 } // namespace webrtc_jni 196 } // namespace webrtc_jni
220 197
221 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_JNI_HELPERS_H_ 198 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_JNI_HELPERS_H_
OLDNEW
« no previous file with comments | « webrtc/sdk/android/src/jni/classreferenceholder.h ('k') | webrtc/sdk/android/src/jni/jni_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698