| 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 |
| 11 // This file contain convenience functions and classes for JNI. | 11 // This file contain convenience functions and classes for JNI. |
| 12 // Before using any of the methods, InitGlobalJniVariables must be called. | 12 // Before using any of the methods, InitGlobalJniVariables must be called. |
| 13 | 13 |
| 14 #ifndef WEBRTC_SDK_ANDROID_SRC_JNI_JNI_HELPERS_H_ | 14 #ifndef WEBRTC_SDK_ANDROID_SRC_JNI_JNI_HELPERS_H_ |
| 15 #define WEBRTC_SDK_ANDROID_SRC_JNI_JNI_HELPERS_H_ | 15 #define WEBRTC_SDK_ANDROID_SRC_JNI_JNI_HELPERS_H_ |
| 16 | 16 |
| 17 #include <jni.h> | 17 #include <jni.h> |
| 18 #include <map> |
| 18 #include <string> | 19 #include <string> |
| 19 #include <vector> | 20 #include <vector> |
| 20 | 21 |
| 21 #include "webrtc/rtc_base/checks.h" | 22 #include "webrtc/rtc_base/checks.h" |
| 22 #include "webrtc/rtc_base/constructormagic.h" | 23 #include "webrtc/rtc_base/constructormagic.h" |
| 23 #include "webrtc/rtc_base/thread_checker.h" | 24 #include "webrtc/rtc_base/thread_checker.h" |
| 24 | 25 |
| 25 // Abort the process if |jni| has a Java exception pending. | 26 // Abort the process if |jni| has a Java exception pending. |
| 26 // This macros uses the comma operator to execute ExceptionDescribe | 27 // This macros uses the comma operator to execute ExceptionDescribe |
| 27 // and ExceptionClear ignoring their return values and sending "" | 28 // and ExceptionClear ignoring their return values and sending "" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // Return the (singleton) Java Enum object corresponding to |index|; | 108 // Return the (singleton) Java Enum object corresponding to |index|; |
| 108 jobject JavaEnumFromIndex(JNIEnv* jni, jclass state_class, | 109 jobject JavaEnumFromIndex(JNIEnv* jni, jclass state_class, |
| 109 const std::string& state_class_name, int index); | 110 const std::string& state_class_name, int index); |
| 110 | 111 |
| 111 // Return the (singleton) Java Enum object corresponding to |index|; | 112 // Return the (singleton) Java Enum object corresponding to |index|; |
| 112 // |state_class_fragment| is something like "MediaSource$State". | 113 // |state_class_fragment| is something like "MediaSource$State". |
| 113 jobject JavaEnumFromIndexAndClassName(JNIEnv* jni, | 114 jobject JavaEnumFromIndexAndClassName(JNIEnv* jni, |
| 114 const std::string& state_class_fragment, | 115 const std::string& state_class_fragment, |
| 115 int index); | 116 int index); |
| 116 | 117 |
| 118 // Parses Map<String, String> to std::map<std::string, std::string>. |
| 119 std::map<std::string, std::string> JavaToStdMapStrings(JNIEnv* jni, |
| 120 jobject j_map); |
| 121 |
| 117 // Returns the name of a Java enum. | 122 // Returns the name of a Java enum. |
| 118 std::string GetJavaEnumName(JNIEnv* jni, | 123 std::string GetJavaEnumName(JNIEnv* jni, |
| 119 const std::string& className, | 124 const std::string& className, |
| 120 jobject j_enum); | 125 jobject j_enum); |
| 121 | 126 |
| 122 jobject NewGlobalRef(JNIEnv* jni, jobject o); | 127 jobject NewGlobalRef(JNIEnv* jni, jobject o); |
| 123 | 128 |
| 124 void DeleteGlobalRef(JNIEnv* jni, jobject o); | 129 void DeleteGlobalRef(JNIEnv* jni, jobject o); |
| 125 | 130 |
| 126 // Scope Java local references to the lifetime of this object. Use in all C++ | 131 // Scope Java local references to the lifetime of this object. Use in all C++ |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 220 |
| 216 // TODO(magjed): Remove once external clients are updated. | 221 // TODO(magjed): Remove once external clients are updated. |
| 217 namespace webrtc_jni { | 222 namespace webrtc_jni { |
| 218 | 223 |
| 219 using webrtc::jni::AttachCurrentThreadIfNeeded; | 224 using webrtc::jni::AttachCurrentThreadIfNeeded; |
| 220 using webrtc::jni::InitGlobalJniVariables; | 225 using webrtc::jni::InitGlobalJniVariables; |
| 221 | 226 |
| 222 } // namespace webrtc_jni | 227 } // namespace webrtc_jni |
| 223 | 228 |
| 224 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_JNI_HELPERS_H_ | 229 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_JNI_HELPERS_H_ |
| OLD | NEW |