Bug 1024288: Add a button to about:webrtc to turn on/off AEC logging r=jib,smaug,unfocused a=lmandel
authorRandell Jesup <rjesup@jesup.org>
Thu, 12 Jun 2014 12:21:38 -0400
changeset 207568 1f0efff0f0751ca88f946d69bd64b451a9a4974e
parent 207567 af4b196d4a6a430fc118fb4ebbe1334af6cebe11
child 207569 5ddb3118d9ae531b2b6d784dd829a88dd5daea66
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib, smaug, unfocused, lmandel
bugs1024288
milestone32.0a2
Bug 1024288: Add a button to about:webrtc to turn on/off AEC logging r=jib,smaug,unfocused a=lmandel
dom/webidl/WebrtcGlobalInformation.webidl
media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp
media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp
media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.h
modules/libpref/src/init/all.js
toolkit/content/aboutWebrtc.xhtml
--- a/dom/webidl/WebrtcGlobalInformation.webidl
+++ b/dom/webidl/WebrtcGlobalInformation.webidl
@@ -24,11 +24,14 @@ interface WebrtcGlobalInformation {
 
   // NSPR WebRTC Trace debug level (0 - 65535)
   //
   // Notes:
   // - Setting a non-zero debug level turns on gathering of log for file output.
   // - Subsequently setting a zero debug level writes that log to disk.
 
   static attribute long debugLevel;
+
+  // WebRTC AEC debugging enable
+  static attribute boolean aecDebug;
 };
 
 
--- a/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp
+++ b/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp
@@ -23,16 +23,25 @@ static PRLogModuleInfo* GetWebRtcTraceLo
 {
   static PRLogModuleInfo *sLog;
   if (!sLog) {
     sLog = PR_NewLogModule("webrtc_trace");
   }
   return sLog;
 }
 
+static PRLogModuleInfo* GetWebRtcAECLog()
+{
+  static PRLogModuleInfo *sLog;
+  if (!sLog) {
+    sLog = PR_NewLogModule("AEC");
+  }
+  return sLog;
+}
+
 class WebRtcTraceCallback: public webrtc::TraceCallback
 {
 public:
   void Print(webrtc::TraceLevel level, const char* message, int length)
   {
     PRLogModuleInfo *log = GetWebRtcTraceLog();
     PR_LOG(log, PR_LOG_DEBUG, ("%s", message));
     return;
@@ -42,16 +51,17 @@ public:
 static WebRtcTraceCallback gWebRtcCallback;
 
 #ifdef MOZILLA_INTERNAL_API
 void GetWebRtcLogPrefs(uint32_t *aTraceMask, nsACString* aLogFile, bool *aMultiLog)
 {
   *aMultiLog = mozilla::Preferences::GetBool("media.webrtc.debug.multi_log");
   *aTraceMask = mozilla::Preferences::GetUint("media.webrtc.debug.trace_mask");
   mozilla::Preferences::GetCString("media.webrtc.debug.log_file", aLogFile);
+  webrtc::Trace::set_aec_debug_size(mozilla::Preferences::GetUint("media.webrtc.debug.aec_dump_max_size"));
 }
 #endif
 
 void CheckOverrides(uint32_t *aTraceMask, nsACString *aLogFile, bool *aMultiLog)
 {
   if (!aTraceMask || !aLogFile || !aMultiLog) {
     return;
   }
@@ -64,16 +74,21 @@ void CheckOverrides(uint32_t *aTraceMask
      be reliably used to turn off the trace and override a log level from about:config as
      there is no way to differentiate between NSPR_LOG_MODULES=webrtc_trace:0 and the complete
      absense of the webrtc_trace in the environment string at all.
   */
   if (log_info && (log_info->level != 0)) {
     *aTraceMask = log_info->level;
   }
 
+  log_info = GetWebRtcAECLog();
+  if (log_info && (log_info->level != 0)) {
+    webrtc::Trace::set_aec_debug(true);
+  }
+
   const char *file_name = PR_GetEnv("WEBRTC_TRACE_FILE");
   if (file_name) {
     aLogFile->Assign(file_name);
   }
 }
 
 void ConfigWebRtcLog(uint32_t trace_mask, nsCString &aLogFile, bool multi_log)
 {
--- a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp
+++ b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp
@@ -18,16 +18,17 @@
 #include "mozilla/Vector.h"
 #include "nsProxyRelease.h"
 #include "mozilla/Telemetry.h"
 
 #include "rlogringbuffer.h"
 #include "runnable_utils.h"
 #include "PeerConnectionCtx.h"
 #include "PeerConnectionImpl.h"
+#include "webrtc/system_wrappers/interface/trace.h"
 
 using sipcc::PeerConnectionImpl;
 using sipcc::PeerConnectionCtx;
 using sipcc::RTCStatsQuery;
 
 static const char* logTag = "WebrtcGlobalInformation";
 
 namespace mozilla {
@@ -228,30 +229,45 @@ WebrtcGlobalInformation::GetLogging(
   if (NS_FAILED(rv)) {
     aLoggingCallback.Release();
   }
 
   aRv = rv;
 }
 
 static int32_t sLastSetLevel = 0;
+static bool sLastAECDebug = false;
 
 void
 WebrtcGlobalInformation::SetDebugLevel(const GlobalObject& aGlobal, int32_t aLevel)
 {
   StartWebRtcLog(webrtc::TraceLevel(aLevel));
   sLastSetLevel = aLevel;
 }
 
 int32_t
 WebrtcGlobalInformation::DebugLevel(const GlobalObject& aGlobal)
 {
   return sLastSetLevel;
 }
 
+void
+WebrtcGlobalInformation::SetAecDebug(const GlobalObject& aGlobal, bool aEnable)
+{
+  webrtc::Trace::set_aec_debug(aEnable);
+  sLastAECDebug = aEnable;
+}
+
+bool
+WebrtcGlobalInformation::AecDebug(const GlobalObject& aGlobal)
+{
+  return sLastAECDebug;
+}
+
+
 struct StreamResult {
   StreamResult() : candidateTypeBitpattern(0), streamSucceeded(false) {}
   uint8_t candidateTypeBitpattern;
   bool streamSucceeded;
 };
 
 static void StoreLongTermICEStatisticsImpl_m(
     nsresult result,
--- a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.h
+++ b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.h
@@ -31,16 +31,19 @@ public:
   static void GetLogging(const GlobalObject& aGlobal,
                          const nsAString& aPattern,
                          WebrtcGlobalLoggingCallback& aLoggingCallback,
                          ErrorResult& aRv);
 
   static void SetDebugLevel(const GlobalObject& aGlobal, int32_t aLevel);
   static int32_t DebugLevel(const GlobalObject& aGlobal);
 
+  static void SetAecDebug(const GlobalObject& aGlobal, bool aEnable);
+  static bool AecDebug(const GlobalObject& aGlobal);
+
   static void StoreLongTermICEStatistics(sipcc::PeerConnectionImpl& aPc);
 
 private:
   WebrtcGlobalInformation() MOZ_DELETE;
   WebrtcGlobalInformation(const WebrtcGlobalInformation& aOrig) MOZ_DELETE;
   WebrtcGlobalInformation& operator=(
     const WebrtcGlobalInformation& aRhs) MOZ_DELETE;
 };
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -260,16 +260,17 @@ pref("media.navigator.video.default_minf
 
 pref("media.webrtc.debug.trace_mask", 0);
 pref("media.webrtc.debug.multi_log", false);
 #if defined(ANDROID) || defined(XP_WIN)
 pref("media.webrtc.debug.log_file", "");
 #else
 pref("media.webrtc.debug.log_file", "/tmp/WebRTC.log");
 #endif
+pref("media.webrtc.debug.aec_dump_max_size", 4194304); // 4MB
 
 #ifdef MOZ_WIDGET_GONK
 pref("media.navigator.video.default_width",320);
 pref("media.navigator.video.default_height",240);
 pref("media.peerconnection.enabled", true);
 pref("media.peerconnection.video.enabled", true);
 pref("media.navigator.video.max_fs", 1200); // 640x480 == 1200mb
 pref("media.navigator.video.max_fr", 30);
--- a/toolkit/content/aboutWebrtc.xhtml
+++ b/toolkit/content/aboutWebrtc.xhtml
@@ -386,16 +386,21 @@ function displayStats(globalReport) {
 
 function onLoad() {
   WebrtcGlobalInformation.getAllStats(displayStats);
   if (WebrtcGlobalInformation.debugLevel) {
     setDebugButton(true);
   } else {
     setDebugButton(false);
   }
+  if (WebrtcGlobalInformation.aecDebug) {
+    setAECDebugButton(true);
+  } else {
+    setAECDebugButton(false);
+  }
 }
 
 function startDebugMode() {
   WebrtcGlobalInformation.debugLevel = 65535;
   setDebugButton(true);
 }
 
 function stopDebugMode() {
@@ -404,25 +409,46 @@ function stopDebugMode() {
 }
 
 function setDebugButton(on) {
   var button = document.getElementById("debug-toggle-button");
   button.innerHTML = on ? "Stop debug mode" : "Start debug mode";
   button.onclick = on ? stopDebugMode : startDebugMode;
 }
 
+function startAECDebugMode() {
+  WebrtcGlobalInformation.aecDebug = true;
+  setAECDebugButton(true);
+}
+
+function stopAECDebugMode() {
+  WebrtcGlobalInformation.aecDebug = false;
+  setAECDebugButton(false);
+}
+
+function setAECDebugButton(on) {
+  var button = document.getElementById("aec-debug-toggle-button");
+  button.innerHTML = on ? "Stop AEC logging" : "Start AEC logging";
+  button.onclick = on ? stopAECDebugMode : startAECDebugMode;
+}
+
+
+
   </script>
 
   <body id="body" onload="onLoad()">
     <div id="stats">
     </div>
     <button onclick="WebrtcGlobalInformation.getLogging('', displayLogs)">
       Connection log
     </button>
     <button id="debug-toggle-button" onclick="startDebugMode()">
       Start debug mode
     </button>
+    <button id="aec-debug-toggle-button" onclick="startAECDebugMode()">
+      Start AEC logging
+    </button>
     <div id="logs">
     </div>
   </body>
 </html>
 <!-- vim: softtabstop=2:shiftwidth=2:expandtab
 -->