Bug 1256430: start AEC log independently of webrtc TRACE r=jesup,pkerr
authorRandell Jesup <rjesup@jesup.org>
Tue, 29 Mar 2016 11:32:54 -0400
changeset 290944 0ff7a5a4b24f76859762f1e93ad9c617b8f3c643
parent 290943 98818a65c221dc220432d1c3da491f3aa97c1a81
child 290945 de7e03fdff65b86744f8ce59b036ea86caf6df8d
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, pkerr
bugs1256430
milestone48.0a1
Bug 1256430: start AEC log independently of webrtc TRACE r=jesup,pkerr
media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp
media/webrtc/signaling/src/common/browser_logging/WebRtcLog.h
media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp
--- a/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp
+++ b/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp
@@ -108,53 +108,42 @@ void ConfigWebRtcLog(uint32_t trace_mask
 {
   if (gWebRtcTraceLoggingOn) {
     return;
   }
 
 #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<nsIFile> 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")) {
       webrtc::Trace::SetTraceCallback(&gWebRtcCallback);
     } else {
       webrtc::Trace::SetTraceFile(aLogFile.get(), multi_log);
     }
   }
+
+  if (aLogFile.IsEmpty()) {
+    nsCOMPtr<nsIFile> 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;
 }
 
 void StartWebRtcLog(uint32_t log_level)
 {
   if (gWebRtcTraceLoggingOn && log_level != 0) {
@@ -206,8 +195,61 @@ void EnableWebRtcLog()
   ConfigWebRtcLog(trace_mask, log_file, aec_log_dir, multi_log);
   return;
 }
 
 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<nsIFile> 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);
+}
--- a/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.h
+++ b/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.h
@@ -2,13 +2,15 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef WEBRTCLOG_H_
 #define WEBRTCLOG_H_
 
 #include "webrtc/common_types.h"
 
+void StartAecLog();
+void StopAecLog();
 void StartWebRtcLog(uint32_t log_level = webrtc::kTraceDefault);
 void EnableWebRtcLog();
 void StopWebRtcLog();
 
 #endif
--- a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp
+++ b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp
@@ -676,18 +676,22 @@ int32_t
 WebrtcGlobalInformation::DebugLevel(const GlobalObject& aGlobal)
 {
   return sLastSetLevel;
 }
 
 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()){
     Unused << cp->SendSetAecLogging(aEnable);
   }
 }
 
 bool
@@ -876,18 +880,21 @@ WebrtcGlobalChild::RecvClearLogRequest()
   RunLogClear();
   return true;
 }
 
 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;
 }
 
 bool
 WebrtcGlobalChild::RecvSetDebugMode(const int& aLevel)
 {
   if (!mShutdown) {