Bug 1408371: report AEC log dir through getter. r?ng,smaug
MozReview-Commit-ID: 1Tb8nwYzMFt
--- a/dom/webidl/WebrtcGlobalInformation.webidl
+++ b/dom/webidl/WebrtcGlobalInformation.webidl
@@ -31,9 +31,11 @@ interface WebrtcGlobalInformation {
// 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;
+
+ static readonly attribute DOMString aecDebugLogDir;
};
--- a/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp
+++ b/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp
@@ -252,45 +252,50 @@ void StopWebRtcLog()
webrtc::Trace::SetTraceCallback(nullptr);
webrtc::Trace::SetTraceFile(nullptr);
if (sSink) {
rtc::LogMessage::RemoveLogToStream(sSink);
sSink = nullptr;
}
}
-void ConfigAecLog() {
+nsCString ConfigAecLog() {
+ nsCString aecLogDir;
if (webrtc::Trace::aec_debug()) {
- return;
+ return EmptyCString();
}
- nsCString aAECLogDir;
#if defined(ANDROID)
- aAECLogDir.Assign(default_tmp_dir);
+ aecLogDir.Assign(default_tmp_dir);
#else
nsCOMPtr<nsIFile> tempDir;
nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tempDir));
if (NS_SUCCEEDED(rv)) {
- tempDir->GetNativePath(aAECLogDir);
+ tempDir->GetNativePath(aecLogDir);
}
#endif
- webrtc::Trace::set_aec_debug_filename(aAECLogDir.get());
+ webrtc::Trace::set_aec_debug_filename(aecLogDir.get());
+
+ return aecLogDir;
}
-void StartAecLog()
+nsCString StartAecLog()
{
+ nsCString aecLogDir;
if (webrtc::Trace::aec_debug()) {
- return;
+ return EmptyCString();
}
uint32_t trace_mask = 0;
bool multi_log = false;
nsAutoCString log_file;
GetWebRtcLogPrefs(&trace_mask, log_file, &multi_log);
CheckOverrides(&trace_mask, &log_file, &multi_log);
- ConfigAecLog();
+ aecLogDir = ConfigAecLog();
webrtc::Trace::set_aec_debug(true);
+
+ return aecLogDir;
}
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,15 +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();
+nsCString 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
@@ -661,16 +661,17 @@ WebrtcGlobalInformation::GetLogging(
LogRequest::Delete(request->mRequestId);
}
aRv = rv;
}
static int32_t sLastSetLevel = 0;
static bool sLastAECDebug = false;
+static Maybe<nsCString> sAecDebugLogDir;
void
WebrtcGlobalInformation::SetDebugLevel(const GlobalObject& aGlobal, int32_t aLevel)
{
if (aLevel) {
StartWebRtcLog(webrtc::TraceLevel(aLevel));
} else {
StopWebRtcLog();
@@ -687,17 +688,17 @@ WebrtcGlobalInformation::DebugLevel(cons
{
return sLastSetLevel;
}
void
WebrtcGlobalInformation::SetAecDebug(const GlobalObject& aGlobal, bool aEnable)
{
if (aEnable) {
- StartAecLog();
+ sAecDebugLogDir.emplace(StartAecLog());
} else {
StopAecLog();
}
sLastAECDebug = aEnable;
for (auto& cp : WebrtcContentParents::GetAll()){
Unused << cp->SendSetAecLogging(aEnable);
@@ -705,16 +706,22 @@ WebrtcGlobalInformation::SetAecDebug(con
}
bool
WebrtcGlobalInformation::AecDebug(const GlobalObject& aGlobal)
{
return sLastAECDebug;
}
+void
+WebrtcGlobalInformation::GetAecDebugLogDir(const GlobalObject& aGlobal, nsAString& aDir)
+{
+ aDir = NS_ConvertASCIItoUTF16(sAecDebugLogDir.valueOr(EmptyCString()));
+}
+
mozilla::ipc::IPCResult
WebrtcGlobalParent::RecvGetStatsResult(const int& aRequestId,
nsTArray<RTCStatsReportInternal>&& Stats)
{
MOZ_ASSERT(NS_IsMainThread());
nsresult rv = NS_OK;
StatsRequest* request = StatsRequest::Get(aRequestId);
--- a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.h
+++ b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.h
@@ -35,16 +35,17 @@ public:
static void ClearLogging(const GlobalObject& aGlobal);
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 GetAecDebugLogDir(const GlobalObject& aGlobal, nsAString& aDir);
static void StoreLongTermICEStatistics(PeerConnectionImpl& aPc);
private:
WebrtcGlobalInformation() = delete;
WebrtcGlobalInformation(const WebrtcGlobalInformation& aOrig) = delete;
WebrtcGlobalInformation& operator=(
const WebrtcGlobalInformation& aRhs) = delete;
--- a/toolkit/content/aboutwebrtc/aboutWebrtc.js
+++ b/toolkit/content/aboutwebrtc/aboutWebrtc.js
@@ -257,17 +257,17 @@ function AecLogging() {
}
AecLogging.prototype = Object.create(Control.prototype);
AecLogging.prototype.constructor = AecLogging;
AecLogging.prototype.offState = function() {
this._label = getString("aec_logging_off_state_label");
try {
- let file = Services.prefs.getCharPref("media.webrtc.debug.aec_log_dir");
+ let file = WebrtcGlobalInformation.aecDebugLogDir;
this._message = formatString("aec_logging_off_state_msg", [file], 1);
} catch (e) {
this._message = null;
}
};
AecLogging.prototype.onState = function() {
this._label = getString("aec_logging_on_state_label");