Index: webrtc/sdk/android/src/jni/pc/logging_jni.cc |
diff --git a/webrtc/sdk/android/src/jni/ownedfactoryandthreads.cc b/webrtc/sdk/android/src/jni/pc/logging_jni.cc |
similarity index 23% |
copy from webrtc/sdk/android/src/jni/ownedfactoryandthreads.cc |
copy to webrtc/sdk/android/src/jni/pc/logging_jni.cc |
index a3aa45c4bead267acec36c6862cae84a9790d792..d2ccb560f73c685114bb07fc7e5b4be7e811f3d0 100644 |
--- a/webrtc/sdk/android/src/jni/ownedfactoryandthreads.cc |
+++ b/webrtc/sdk/android/src/jni/pc/logging_jni.cc |
@@ -8,57 +8,53 @@ |
* be found in the AUTHORS file in the root of the source tree. |
*/ |
-#include "webrtc/sdk/android/src/jni/ownedfactoryandthreads.h" |
+#include <memory> |
#include "webrtc/rtc_base/logging.h" |
-#include "webrtc/sdk/android/src/jni/classreferenceholder.h" |
#include "webrtc/sdk/android/src/jni/jni_helpers.h" |
+#include "webrtc/system_wrappers/include/logcat_trace_context.h" |
+#include "webrtc/system_wrappers/include/trace.h" |
namespace webrtc_jni { |
-PeerConnectionFactoryInterface* factoryFromJava(jlong j_p) { |
- return reinterpret_cast<OwnedFactoryAndThreads*>(j_p)->factory(); |
+JOW(void, Logging_nativeEnableTracing) |
+(JNIEnv* jni, jclass, jstring j_path, jint nativeLevels) { |
+ std::string path = JavaToStdString(jni, j_path); |
+ if (nativeLevels != webrtc::kTraceNone) { |
+ webrtc::Trace::set_level_filter(nativeLevels); |
+ if (path != "logcat:") { |
+ RTC_CHECK_EQ(0, webrtc::Trace::SetTraceFile(path.c_str(), false)) |
+ << "SetTraceFile failed"; |
+ } else { |
+ // Intentionally leak this to avoid needing to reason about its lifecycle. |
+ // It keeps no state and functions only as a dispatch point. |
+ static webrtc::LogcatTraceContext* g_trace_callback = |
+ new webrtc::LogcatTraceContext(); |
+ } |
+ } |
} |
-OwnedFactoryAndThreads::~OwnedFactoryAndThreads() { |
- CHECK_RELEASE(factory_); |
- if (network_monitor_factory_ != nullptr) { |
- rtc::NetworkMonitorFactory::ReleaseFactory(network_monitor_factory_); |
+JOW(void, Logging_nativeEnableLogToDebugOutput) |
+(JNIEnv* jni, jclass, jint nativeSeverity) { |
+ if (nativeSeverity >= rtc::LS_SENSITIVE && nativeSeverity <= rtc::LS_NONE) { |
+ rtc::LogMessage::LogToDebug( |
+ static_cast<rtc::LoggingSeverity>(nativeSeverity)); |
} |
} |
-void OwnedFactoryAndThreads::JavaCallbackOnFactoryThreads() { |
- JNIEnv* jni = AttachCurrentThreadIfNeeded(); |
- ScopedLocalRefFrame local_ref_frame(jni); |
- jclass j_factory_class = FindClass(jni, "org/webrtc/PeerConnectionFactory"); |
- jmethodID m = nullptr; |
- if (network_thread_->IsCurrent()) { |
- LOG(LS_INFO) << "Network thread JavaCallback"; |
- m = GetStaticMethodID(jni, j_factory_class, "onNetworkThreadReady", "()V"); |
- } |
- if (worker_thread_->IsCurrent()) { |
- LOG(LS_INFO) << "Worker thread JavaCallback"; |
- m = GetStaticMethodID(jni, j_factory_class, "onWorkerThreadReady", "()V"); |
- } |
- if (signaling_thread_->IsCurrent()) { |
- LOG(LS_INFO) << "Signaling thread JavaCallback"; |
- m = GetStaticMethodID(jni, j_factory_class, "onSignalingThreadReady", |
- "()V"); |
- } |
- if (m != nullptr) { |
- jni->CallStaticVoidMethod(j_factory_class, m); |
- CHECK_EXCEPTION(jni) << "error during JavaCallback::CallStaticVoidMethod"; |
- } |
+JOW(void, Logging_nativeEnableLogThreads)(JNIEnv* jni, jclass) { |
+ rtc::LogMessage::LogThreads(true); |
+} |
+ |
+JOW(void, Logging_nativeEnableLogTimeStamps)(JNIEnv* jni, jclass) { |
+ rtc::LogMessage::LogTimestamps(true); |
} |
-void OwnedFactoryAndThreads::InvokeJavaCallbacksOnFactoryThreads() { |
- LOG(LS_INFO) << "InvokeJavaCallbacksOnFactoryThreads."; |
- network_thread_->Invoke<void>(RTC_FROM_HERE, |
- [this] { JavaCallbackOnFactoryThreads(); }); |
- worker_thread_->Invoke<void>(RTC_FROM_HERE, |
- [this] { JavaCallbackOnFactoryThreads(); }); |
- signaling_thread_->Invoke<void>(RTC_FROM_HERE, |
- [this] { JavaCallbackOnFactoryThreads(); }); |
+JOW(void, Logging_nativeLog) |
+(JNIEnv* jni, jclass, jint j_severity, jstring j_tag, jstring j_message) { |
+ std::string message = JavaToStdString(jni, j_message); |
+ std::string tag = JavaToStdString(jni, j_tag); |
+ LOG_TAG(static_cast<rtc::LoggingSeverity>(j_severity), tag) << message; |
} |
} // namespace webrtc_jni |