OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 CHECK(0, msg); \ | 44 CHECK(0, msg); \ |
45 } \ | 45 } \ |
46 } | 46 } |
47 | 47 |
48 // JNIEnv-helper methods that CHECK success: no Java exception thrown and found | 48 // JNIEnv-helper methods that CHECK success: no Java exception thrown and found |
49 // object/class/method/field is non-null. | 49 // object/class/method/field is non-null. |
50 jmethodID GetMethodID(JNIEnv* jni, jclass c, const std::string& name, | 50 jmethodID GetMethodID(JNIEnv* jni, jclass c, const std::string& name, |
51 const char* signature); | 51 const char* signature); |
52 | 52 |
53 // Return a |jlong| that will automatically convert back to |ptr| when assigned | 53 // Return a |jlong| that will automatically convert back to |ptr| when assigned |
54 // to a |uint64| | 54 // to a |uint64_t| |
55 jlong jlongFromPointer(void* ptr); | 55 jlong jlongFromPointer(void* ptr); |
56 | 56 |
57 // Given a (UTF-16) jstring return a new UTF-8 native string. | 57 // Given a (UTF-16) jstring return a new UTF-8 native string. |
58 std::string JavaToStdString(JNIEnv* jni, const jstring& j_string); | 58 std::string JavaToStdString(JNIEnv* jni, const jstring& j_string); |
59 | 59 |
60 // Android's FindClass() is trickier than usual because the app-specific | 60 // Android's FindClass() is trickier than usual because the app-specific |
61 // ClassLoader is not consulted when there is no app-specific frame on the | 61 // ClassLoader is not consulted when there is no app-specific frame on the |
62 // stack. Consequently, we only look up classes once in JNI_OnLoad. | 62 // stack. Consequently, we only look up classes once in JNI_OnLoad. |
63 // http://developer.android.com/training/articles/perf-jni.html#faq_FindClass | 63 // http://developer.android.com/training/articles/perf-jni.html#faq_FindClass |
64 class ClassReferenceHolder { | 64 class ClassReferenceHolder { |
65 public: | 65 public: |
66 ClassReferenceHolder(JNIEnv* jni, const char** classes, int size); | 66 ClassReferenceHolder(JNIEnv* jni, const char** classes, int size); |
67 ~ClassReferenceHolder(); | 67 ~ClassReferenceHolder(); |
68 | 68 |
69 void FreeReferences(JNIEnv* jni); | 69 void FreeReferences(JNIEnv* jni); |
70 | 70 |
71 jclass GetClass(const std::string& name); | 71 jclass GetClass(const std::string& name); |
72 | 72 |
73 private: | 73 private: |
74 void LoadClass(JNIEnv* jni, const std::string& name); | 74 void LoadClass(JNIEnv* jni, const std::string& name); |
75 | 75 |
76 std::map<std::string, jclass> classes_; | 76 std::map<std::string, jclass> classes_; |
77 }; | 77 }; |
78 | 78 |
79 #endif // WEBRTC_EXAMPLES_ANDROID_MEDIA_DEMO_JNI_JNI_HELPERS_H_ | 79 #endif // WEBRTC_EXAMPLES_ANDROID_MEDIA_DEMO_JNI_JNI_HELPERS_H_ |
OLD | NEW |