OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 12 matching lines...) Expand all Loading... |
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 * | 26 * |
27 */ | 27 */ |
28 | 28 |
29 #ifndef TALK_APP_WEBRTC_JAVA_JNI_ANDROIDMEDIACODECCOMMON_H_ | 29 #ifndef TALK_APP_WEBRTC_JAVA_JNI_ANDROIDMEDIACODECCOMMON_H_ |
30 #define TALK_APP_WEBRTC_JAVA_JNI_ANDROIDMEDIACODECCOMMON_H_ | 30 #define TALK_APP_WEBRTC_JAVA_JNI_ANDROIDMEDIACODECCOMMON_H_ |
31 | 31 |
32 #include <android/log.h> | 32 #include <android/log.h> |
| 33 #include <string> |
| 34 |
33 #include "talk/app/webrtc/java/jni/classreferenceholder.h" | 35 #include "talk/app/webrtc/java/jni/classreferenceholder.h" |
| 36 #include "talk/app/webrtc/java/jni/jni_helpers.h" |
34 #include "webrtc/base/thread.h" | 37 #include "webrtc/base/thread.h" |
35 #include "webrtc/base/logging.h" | 38 #include "webrtc/base/logging.h" |
36 #include "webrtc/system_wrappers/include/tick_util.h" | 39 #include "webrtc/system_wrappers/include/tick_util.h" |
37 | 40 |
38 namespace webrtc_jni { | 41 namespace webrtc_jni { |
39 | 42 |
40 // Uncomment this define to enable verbose logging for every encoded/decoded | 43 // Uncomment this define to enable verbose logging for every encoded/decoded |
41 // video frame. | 44 // video frame. |
42 //#define TRACK_BUFFER_TIMING | 45 //#define TRACK_BUFFER_TIMING |
43 | 46 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 81 } |
79 | 82 |
80 static inline void AllowBlockingCalls() { | 83 static inline void AllowBlockingCalls() { |
81 rtc::Thread* current_thread = rtc::Thread::Current(); | 84 rtc::Thread* current_thread = rtc::Thread::Current(); |
82 if (current_thread != NULL) | 85 if (current_thread != NULL) |
83 current_thread->SetAllowBlockingCalls(true); | 86 current_thread->SetAllowBlockingCalls(true); |
84 } | 87 } |
85 | 88 |
86 // Return the (singleton) Java Enum object corresponding to |index|; | 89 // Return the (singleton) Java Enum object corresponding to |index|; |
87 // |state_class_fragment| is something like "MediaSource$State". | 90 // |state_class_fragment| is something like "MediaSource$State". |
88 static inline jobject JavaEnumFromIndex( | 91 static inline jobject JavaEnumFromIndexAndClassName( |
89 JNIEnv* jni, const std::string& state_class_fragment, int index) { | 92 JNIEnv* jni, const std::string& state_class_fragment, int index) { |
90 const std::string state_class = "org/webrtc/" + state_class_fragment; | 93 const std::string state_class = "org/webrtc/" + state_class_fragment; |
91 return JavaEnumFromIndex(jni, FindClass(jni, state_class.c_str()), | 94 return JavaEnumFromIndex(jni, FindClass(jni, state_class.c_str()), |
92 state_class, index); | 95 state_class, index); |
93 } | 96 } |
94 | 97 |
95 // Checks for any Java exception, prints stack backtrace and clears | 98 // Checks for any Java exception, prints stack backtrace and clears |
96 // currently thrown exception. | 99 // currently thrown exception. |
97 static inline bool CheckException(JNIEnv* jni) { | 100 static inline bool CheckException(JNIEnv* jni) { |
98 if (jni->ExceptionCheck()) { | 101 if (jni->ExceptionCheck()) { |
99 LOG_TAG(rtc::LS_ERROR, TAG_COMMON) << "Java JNI exception."; | 102 LOG_TAG(rtc::LS_ERROR, TAG_COMMON) << "Java JNI exception."; |
100 jni->ExceptionDescribe(); | 103 jni->ExceptionDescribe(); |
101 jni->ExceptionClear(); | 104 jni->ExceptionClear(); |
102 return true; | 105 return true; |
103 } | 106 } |
104 return false; | 107 return false; |
105 } | 108 } |
106 | 109 |
107 } // namespace webrtc_jni | 110 } // namespace webrtc_jni |
108 | 111 |
109 #endif // TALK_APP_WEBRTC_JAVA_JNI_ANDROIDMEDIACODECCOMMON_H_ | 112 #endif // TALK_APP_WEBRTC_JAVA_JNI_ANDROIDMEDIACODECCOMMON_H_ |
OLD | NEW |