diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp index e0e079999dd9..dfaad58935d7 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp @@ -36,6 +36,8 @@ #include "nsDOMDataChannelDeclarations.h" #ifdef MOZILLA_INTERNAL_API +#include "mozilla/TimeStamp.h" +#include "mozilla/Telemetry.h" #include "nsDOMJSUtils.h" #include "nsIDocument.h" #include "nsIScriptError.h" @@ -245,6 +247,9 @@ public: // providing non-fatal warnings. mPC->ClearSdpParseErrorMessages(); mObserver->OnSetRemoteDescriptionSuccess(); +#ifdef MOZILLA_INTERNAL_API + mPC->setStartTime(); +#endif break; case SETLOCALDESCERROR: @@ -1326,6 +1331,14 @@ PeerConnectionImpl::ShutdownMedia() if (!mMedia) return; +#ifdef MOZILLA_INTERNAL_API + // End of call to be recorded in Telemetry + if (!mStartTime.IsNull()){ + mozilla::TimeDuration timeDelta = mozilla::TimeStamp::Now() - mStartTime; + Telemetry::Accumulate(Telemetry::WEBRTC_CALL_DURATION, timeDelta.ToSeconds()); + } +#endif + // Forget the reference so that we can transfer it to // SelfDestruct(). mMedia.forget().get()->SelfDestruct(); @@ -1543,6 +1556,13 @@ PeerConnectionImpl::GetSdpParseErrors() { return mSDPParseErrorMessages; } +#ifdef MOZILLA_INTERNAL_API +//Telemetry set start time +void +PeerConnectionImpl::setStartTime() { + mStartTime = mozilla::TimeStamp::Now(); +} +#endif #ifdef MOZILLA_INTERNAL_API static nsresult diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h index 49a6f5aea442..d2126cda1189 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h @@ -29,6 +29,7 @@ #include "PeerConnectionMedia.h" #ifdef MOZILLA_INTERNAL_API +#include "mozilla/TimeStamp.h" #include "mozilla/net/DataChannel.h" #include "VideoUtils.h" #include "VideoSegment.h" @@ -281,6 +282,11 @@ public: // Sets the RTC Signaling State void SetSignalingState_m(SignalingState aSignalingState); +#ifdef MOZILLA_INTERNAL_API + // Set start time for Telemetry + void setStartTime(); +#endif + private: PeerConnectionImpl(const PeerConnectionImpl&rhs); PeerConnectionImpl& operator=(PeerConnectionImpl); @@ -366,6 +372,11 @@ private: nsRefPtr mMedia; +#ifdef MOZILLA_INTERNAL_API + // Start time of call used for Telemetry + mozilla::TimeStamp mStartTime; +#endif + // Temporary: used to prevent multiple audio streams or multiple video streams // in a single PC. This is tied up in the IETF discussion around proper // representation of multiple streams in SDP, and strongly related to diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 420d1f05c7e1..3d231cede6af 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -3502,6 +3502,12 @@ "kind": "boolean", "description": "The number of failed ICE Connections (0) vs. number of successful ICE connections (1)." }, + "WEBRTC_CALL_DURATION":{ + "kind": "exponential", + "high": "10000", + "n_buckets": "1000", + "description": "The length of time (in seconds) that a call lasted." + }, "DEVTOOLS_DEBUGGER_RDP_LOCAL_TRACERDETACH_MS": { "kind": "exponential", "high": "10000",