From bbbc6476fd8b3573158e3addabe03fbaa2f92dda Mon Sep 17 00:00:00 2001 From: Randell Jesup Date: Tue, 29 Mar 2016 11:32:54 -0400 Subject: [PATCH] Bug 1256430: start AEC log independently of webrtc TRACE r=jesup,pkerr --- .../src/common/browser_logging/WebRtcLog.cpp | 88 ++++++++++++++----- .../src/common/browser_logging/WebRtcLog.h | 2 + .../WebrtcGlobalInformation.cpp | 15 +++- 3 files changed, 78 insertions(+), 27 deletions(-) diff --git a/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp b/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp index 6a0c27d2d85a..45c1ad3276ca 100644 --- a/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp +++ b/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp @@ -113,30 +113,9 @@ void ConfigWebRtcLog(uint32_t trace_mask, nsCString &aLogFile, nsCString &aAECLo #if defined(ANDROID) // Special case: use callback to pipe to NSPR logging. aLogFile.Assign(default_log_name); - // For AEC, do not use a default value: force the user to specify a directory. - if (aAECLogDir.IsEmpty()) { - aAECLogDir.Assign(default_tmp_dir); - } #else - if (aLogFile.IsEmpty() || aAECLogDir.IsEmpty()) { - nsCOMPtr tempDir; - nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tempDir)); - - if (NS_SUCCEEDED(rv)) { - if (aAECLogDir.IsEmpty()) { - tempDir->GetNativePath(aAECLogDir); - } - - if (aLogFile.IsEmpty()) { - tempDir->AppendNative(default_log_name); - tempDir->GetNativePath(aLogFile); - } - } - } -#endif webrtc::Trace::set_level_filter(trace_mask); - webrtc::Trace::set_aec_debug_filename(aAECLogDir.get()); if (trace_mask != 0) { if (aLogFile.EqualsLiteral("nspr")) { @@ -145,11 +124,21 @@ void ConfigWebRtcLog(uint32_t trace_mask, nsCString &aLogFile, nsCString &aAECLo webrtc::Trace::SetTraceFile(aLogFile.get(), multi_log); } } + + if (aLogFile.IsEmpty()) { + nsCOMPtr tempDir; + nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tempDir)); + if (NS_SUCCEEDED(rv)) { + tempDir->AppendNative(default_log_name); + tempDir->GetNativePath(aLogFile); + } + } +#endif + #if !defined(MOZILLA_EXTERNAL_LINKAGE) if (XRE_IsParentProcess()) { - // Capture the final choices for the trace settings. + // Capture the final choice for the trace setting. mozilla::Preferences::SetCString("media.webrtc.debug.log_file", aLogFile); - mozilla::Preferences::SetCString("media.webrtc.debug.aec_log_dir", aAECLogDir); } #endif return; @@ -211,3 +200,56 @@ void StopWebRtcLog() { webrtc::Trace::SetTraceFile(nullptr); } + +void ConfigAecLog(nsCString &aAECLogDir) { + if (webrtc::Trace::aec_debug()) { + return; + } +#if defined(ANDROID) + // For AEC, do not use a default value: force the user to specify a directory. + if (aAECLogDir.IsEmpty()) { + aAECLogDir.Assign(default_tmp_dir); + } +#else + if (aAECLogDir.IsEmpty()) { + nsCOMPtr tempDir; + nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tempDir)); + if (NS_SUCCEEDED(rv)) { + if (aAECLogDir.IsEmpty()) { + tempDir->GetNativePath(aAECLogDir); + } + } + } +#endif + webrtc::Trace::set_aec_debug_filename(aAECLogDir.get()); +#if !defined(MOZILLA_EXTERNAL_LINKAGE) + if (XRE_IsParentProcess()) { + // Capture the final choice for the aec_log_dir setting. + mozilla::Preferences::SetCString("media.webrtc.debug.aec_log_dir", aAECLogDir); + } +#endif +} + +void StartAecLog() +{ + if (webrtc::Trace::aec_debug()) { + return; + } + uint32_t trace_mask = 0; + bool multi_log = false; + nsAutoCString log_file; + nsAutoCString aec_log_dir; + +#ifdef MOZILLA_INTERNAL_API + GetWebRtcLogPrefs(&trace_mask, &log_file, &aec_log_dir, &multi_log); +#endif + CheckOverrides(&trace_mask, &log_file, &multi_log); + ConfigAecLog(aec_log_dir); + + webrtc::Trace::set_aec_debug(true); +} + +void StopAecLog() +{ + webrtc::Trace::set_aec_debug(false); +} diff --git a/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.h b/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.h index dc304081716e..58a824bee041 100644 --- a/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.h +++ b/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.h @@ -7,6 +7,8 @@ #include "webrtc/common_types.h" +void StartAecLog(); +void StopAecLog(); void StartWebRtcLog(uint32_t log_level = webrtc::kTraceDefault); void EnableWebRtcLog(); void StopWebRtcLog(); diff --git a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp index 9cc9b15bf51f..b2149cc4efc3 100644 --- a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp +++ b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp @@ -681,8 +681,12 @@ WebrtcGlobalInformation::DebugLevel(const GlobalObject& aGlobal) void WebrtcGlobalInformation::SetAecDebug(const GlobalObject& aGlobal, bool aEnable) { - StartWebRtcLog(sLastSetLevel); // to make it read the aec path - webrtc::Trace::set_aec_debug(aEnable); + if (aEnable) { + StartAecLog(); + } else { + StopAecLog(); + } + sLastAECDebug = aEnable; for (auto& cp : WebrtcContentParents::GetAll()){ @@ -881,8 +885,11 @@ bool WebrtcGlobalChild::RecvSetAecLogging(const bool& aEnable) { if (!mShutdown) { - StartWebRtcLog(sLastSetLevel); // to make it read the aec path - webrtc::Trace::set_aec_debug(aEnable); + if (aEnable) { + StartAecLog(); + } else { + StopAecLog(); + } } return true; }