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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 enum { kMaxDecodedLogFrames = 10 }; | 63 enum { kMaxDecodedLogFrames = 10 }; |
64 // Maximum amount of encoded frames for which per-frame logging is enabled. | 64 // Maximum amount of encoded frames for which per-frame logging is enabled. |
65 enum { kMaxEncodedLogFrames = 10 }; | 65 enum { kMaxEncodedLogFrames = 10 }; |
66 | 66 |
67 static inline void AllowBlockingCalls() { | 67 static inline void AllowBlockingCalls() { |
68 rtc::Thread* current_thread = rtc::Thread::Current(); | 68 rtc::Thread* current_thread = rtc::Thread::Current(); |
69 if (current_thread != NULL) | 69 if (current_thread != NULL) |
70 current_thread->SetAllowBlockingCalls(true); | 70 current_thread->SetAllowBlockingCalls(true); |
71 } | 71 } |
72 | 72 |
| 73 // Return the (singleton) Java Enum object corresponding to |index|; |
| 74 // |state_class_fragment| is something like "MediaSource$State". |
| 75 static inline jobject JavaEnumFromIndexAndClassName( |
| 76 JNIEnv* jni, const std::string& state_class_fragment, int index) { |
| 77 const std::string state_class = "org/webrtc/" + state_class_fragment; |
| 78 return JavaEnumFromIndex(jni, FindClass(jni, state_class.c_str()), |
| 79 state_class, index); |
| 80 } |
| 81 |
73 // Checks for any Java exception, prints stack backtrace and clears | 82 // Checks for any Java exception, prints stack backtrace and clears |
74 // currently thrown exception. | 83 // currently thrown exception. |
75 static inline bool CheckException(JNIEnv* jni) { | 84 static inline bool CheckException(JNIEnv* jni) { |
76 if (jni->ExceptionCheck()) { | 85 if (jni->ExceptionCheck()) { |
77 LOG_TAG(rtc::LS_ERROR, TAG_COMMON) << "Java JNI exception."; | 86 LOG_TAG(rtc::LS_ERROR, TAG_COMMON) << "Java JNI exception."; |
78 jni->ExceptionDescribe(); | 87 jni->ExceptionDescribe(); |
79 jni->ExceptionClear(); | 88 jni->ExceptionClear(); |
80 return true; | 89 return true; |
81 } | 90 } |
82 return false; | 91 return false; |
83 } | 92 } |
84 | 93 |
85 } // namespace webrtc_jni | 94 } // namespace webrtc_jni |
86 | 95 |
87 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_ANDROIDMEDIACODECCOMMON_H_ | 96 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_ANDROIDMEDIACODECCOMMON_H_ |
OLD | NEW |