From ab961aeb54335fd07c66de2e3b8c3b6af6f89ea2 Mon Sep 17 00:00:00 2001
From: wolfbeast <mcwerewolf@gmail.com>
Date: Mon, 3 Sep 2018 10:11:38 +0200
Subject: Remove all C++ Telemetry Accumulation calls.

This creates a number of stubs and leaves some surrounding code that may be irrelevant (eg. recorded time stamps, status variables).
Stub resolution/removal should be a follow-up to this.
---
 .../signaling/src/media-conduit/AudioConduit.cpp   |   9 --
 .../src/media-conduit/CodecStatistics.cpp          |   8 --
 .../src/peerconnection/PeerConnectionImpl.cpp      | 109 +--------------------
 .../src/peerconnection/WebrtcGlobalInformation.cpp |  16 +--
 4 files changed, 4 insertions(+), 138 deletions(-)

(limited to 'media/webrtc/signaling/src')

diff --git a/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp b/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp
index 2c57431e7..e36b8b6cf 100755
--- a/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp
@@ -706,15 +706,6 @@ WebrtcAudioConduit::GetAudioFrame(int16_t speechData[],
     if (GetAVStats(&jitter_buffer_delay_ms,
                    &playout_buffer_delay_ms,
                    &avsync_offset_ms)) {
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
-      if (avsync_offset_ms < 0) {
-        Telemetry::Accumulate(Telemetry::WEBRTC_AVSYNC_WHEN_VIDEO_LAGS_AUDIO_MS,
-                              -avsync_offset_ms);
-      } else {
-        Telemetry::Accumulate(Telemetry::WEBRTC_AVSYNC_WHEN_AUDIO_LAGS_VIDEO_MS,
-                              avsync_offset_ms);
-      }
-#endif
       CSFLogError(logTag,
                   "A/V sync: sync delta: %dms, audio jitter delay %dms, playout delay %dms",
                   avsync_offset_ms, jitter_buffer_delay_ms, playout_buffer_delay_ms);
diff --git a/media/webrtc/signaling/src/media-conduit/CodecStatistics.cpp b/media/webrtc/signaling/src/media-conduit/CodecStatistics.cpp
index eb03c0bf8..da40a59ea 100644
--- a/media/webrtc/signaling/src/media-conduit/CodecStatistics.cpp
+++ b/media/webrtc/signaling/src/media-conduit/CodecStatistics.cpp
@@ -124,8 +124,6 @@ void VideoCodecStatistics::ReceiveStateChange(const int aChannel,
           TimeDuration timeDelta = TimeStamp::Now() - mReceiveFailureTime;
           CSFLogError(logTag, "Video error duration: %u ms",
                       static_cast<uint32_t>(timeDelta.ToMilliseconds()));
-          Telemetry::Accumulate(Telemetry::WEBRTC_VIDEO_ERROR_RECOVERY_MS,
-                                static_cast<uint32_t>(timeDelta.ToMilliseconds()));
 
           mRecoveredLosses++; // to calculate losses per minute
           mTotalLossTime += timeDelta;  // To calculate % time in recovery
@@ -147,16 +145,10 @@ void VideoCodecStatistics::EndOfCallStats()
     if (callDelta.ToSeconds() != 0) {
       uint32_t recovered_per_min = mRecoveredBeforeLoss/(callDelta.ToSeconds()/60);
       CSFLogError(logTag, "Video recovery before error per min %u", recovered_per_min);
-      Telemetry::Accumulate(Telemetry::WEBRTC_VIDEO_RECOVERY_BEFORE_ERROR_PER_MIN,
-                            recovered_per_min);
       uint32_t err_per_min = mRecoveredLosses/(callDelta.ToSeconds()/60);
       CSFLogError(logTag, "Video recovery after error per min %u", err_per_min);
-      Telemetry::Accumulate(Telemetry::WEBRTC_VIDEO_RECOVERY_AFTER_ERROR_PER_MIN,
-                            err_per_min);
       float percent = (mTotalLossTime.ToSeconds()*100)/callDelta.ToSeconds();
       CSFLogError(logTag, "Video error time percentage %f%%", percent);
-      Telemetry::Accumulate(Telemetry::WEBRTC_VIDEO_DECODE_ERROR_TIME_PERMILLE,
-                            static_cast<uint32_t>(percent*10));
     }
   }
 #endif
diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
index 33422ed7a..43d10ca86 100644
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -2245,22 +2245,6 @@ PeerConnectionImpl::AddIceCandidate(const char* aCandidate, const char* aMid, un
 
   CSFLogDebug(logTag, "AddIceCandidate: %s", aCandidate);
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
-  // When remote candidates are added before our ICE ctx is up and running
-  // (the transition to New is async through STS, so this is not impossible),
-  // we won't record them as trickle candidates. Is this what we want?
-  if(!mIceStartTime.IsNull()) {
-    TimeDuration timeDelta = TimeStamp::Now() - mIceStartTime;
-    if (mIceConnectionState == PCImplIceConnectionState::Failed) {
-      Telemetry::Accumulate(Telemetry::WEBRTC_ICE_LATE_TRICKLE_ARRIVAL_TIME,
-                            timeDelta.ToMilliseconds());
-    } else {
-      Telemetry::Accumulate(Telemetry::WEBRTC_ICE_ON_TIME_TRICKLE_ARRIVAL_TIME,
-                            timeDelta.ToMilliseconds());
-    }
-  }
-#endif
-
   nsresult res = mJsepSession->AddRemoteIceCandidate(aCandidate, aMid, aLevel);
 
   if (NS_SUCCEEDED(res)) {
@@ -3011,49 +2995,7 @@ PeerConnectionImpl::PluginCrash(uint32_t aPluginID,
 void
 PeerConnectionImpl::RecordEndOfCallTelemetry() const
 {
-  if (!mJsepSession) {
-    return;
-  }
-
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
-  // Bitmask used for WEBRTC/LOOP_CALL_TYPE telemetry reporting
-  static const uint32_t kAudioTypeMask = 1;
-  static const uint32_t kVideoTypeMask = 2;
-  static const uint32_t kDataChannelTypeMask = 4;
-
-  // Report end-of-call Telemetry
-  if (mJsepSession->GetNegotiations() > 0) {
-    Telemetry::Accumulate(Telemetry::WEBRTC_RENEGOTIATIONS,
-                          mJsepSession->GetNegotiations()-1);
-  }
-  Telemetry::Accumulate(Telemetry::WEBRTC_MAX_VIDEO_SEND_TRACK,
-                        mMaxSending[SdpMediaSection::MediaType::kVideo]);
-  Telemetry::Accumulate(Telemetry::WEBRTC_MAX_VIDEO_RECEIVE_TRACK,
-                        mMaxReceiving[SdpMediaSection::MediaType::kVideo]);
-  Telemetry::Accumulate(Telemetry::WEBRTC_MAX_AUDIO_SEND_TRACK,
-                        mMaxSending[SdpMediaSection::MediaType::kAudio]);
-  Telemetry::Accumulate(Telemetry::WEBRTC_MAX_AUDIO_RECEIVE_TRACK,
-                        mMaxReceiving[SdpMediaSection::MediaType::kAudio]);
-  // DataChannels appear in both Sending and Receiving
-  Telemetry::Accumulate(Telemetry::WEBRTC_DATACHANNEL_NEGOTIATED,
-                        mMaxSending[SdpMediaSection::MediaType::kApplication]);
-  // Enumerated/bitmask: 1 = Audio, 2 = Video, 4 = DataChannel
-  // A/V = 3, A/V/D = 7, etc
-  uint32_t type = 0;
-  if (mMaxSending[SdpMediaSection::MediaType::kAudio] ||
-      mMaxReceiving[SdpMediaSection::MediaType::kAudio]) {
-    type = kAudioTypeMask;
-  }
-  if (mMaxSending[SdpMediaSection::MediaType::kVideo] ||
-      mMaxReceiving[SdpMediaSection::MediaType::kVideo]) {
-    type |= kVideoTypeMask;
-  }
-  if (mMaxSending[SdpMediaSection::MediaType::kApplication]) {
-    type |= kDataChannelTypeMask;
-  }
-  Telemetry::Accumulate(Telemetry::WEBRTC_CALL_TYPE,
-                        type);
-#endif
+  /* STUB */
 }
 
 nsresult
@@ -3109,13 +3051,6 @@ PeerConnectionImpl::ShutdownMedia()
       pair.second->RemovePrincipalChangeObserver(this);
     }
   }
-
-  // End of call to be recorded in Telemetry
-  if (!mStartTime.IsNull()){
-    TimeDuration timeDelta = TimeStamp::Now() - mStartTime;
-    Telemetry::Accumulate(Telemetry::WEBRTC_CALL_DURATION,
-                          timeDelta.ToSeconds());
-  }
 #endif
 
   // Forget the reference so that we can transfer it to
@@ -3423,33 +3358,6 @@ void PeerConnectionImpl::IceConnectionStateChange(
     return;
   }
 
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
-  if (!isDone(mIceConnectionState) && isDone(domState)) {
-    // mIceStartTime can be null if going directly from New to Closed, in which
-    // case we don't count it as a success or a failure.
-    if (!mIceStartTime.IsNull()){
-      TimeDuration timeDelta = TimeStamp::Now() - mIceStartTime;
-      if (isSucceeded(domState)) {
-        Telemetry::Accumulate(Telemetry::WEBRTC_ICE_SUCCESS_TIME,
-                              timeDelta.ToMilliseconds());
-      } else if (isFailed(domState)) {
-        Telemetry::Accumulate(Telemetry::WEBRTC_ICE_FAILURE_TIME,
-                              timeDelta.ToMilliseconds());
-      }
-    }
-
-    if (isSucceeded(domState)) {
-      Telemetry::Accumulate(
-          Telemetry::WEBRTC_ICE_ADD_CANDIDATE_ERRORS_GIVEN_SUCCESS,
-          mAddCandidateErrorCount);
-    } else if (isFailed(domState)) {
-      Telemetry::Accumulate(
-          Telemetry::WEBRTC_ICE_ADD_CANDIDATE_ERRORS_GIVEN_FAILURE,
-          mAddCandidateErrorCount);
-    }
-  }
-#endif
-
   mIceConnectionState = domState;
 
   if (mIceConnectionState == PCImplIceConnectionState::Connected ||
@@ -3467,10 +3375,6 @@ void PeerConnectionImpl::IceConnectionStateChange(
       STAMP_TIMECARD(mTimeCard, "Ice state: new");
       break;
     case PCImplIceConnectionState::Checking:
-#if !defined(MOZILLA_EXTERNAL_LINKAGE)
-      // For telemetry
-      mIceStartTime = TimeStamp::Now();
-#endif
       STAMP_TIMECARD(mTimeCard, "Ice state: checking");
       break;
     case PCImplIceConnectionState::Connected:
@@ -4067,16 +3971,7 @@ PeerConnectionImpl::IceStreamReady(NrIceMediaStream *aStream)
 //Telemetry for when calls start
 void
 PeerConnectionImpl::startCallTelem() {
-  if (!mStartTime.IsNull()) {
-    return;
-  }
-
-  // Start time for calls
-  mStartTime = TimeStamp::Now();
-
-  // Increment session call counter
-  // If we want to track Loop calls independently here, we need two histograms.
-  Telemetry::Accumulate(Telemetry::WEBRTC_CALL_COUNT_2, 1);
+  /* STUB */
 }
 #endif
 
diff --git a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp
index 96bdd5b70..f283d6111 100644
--- a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp
+++ b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp
@@ -1194,18 +1194,8 @@ static void GetStatsForLongTermStorage_s(
     rate_limit_bit_pattern |= 2;
   }
 
-  if (query->failed) {
-    Telemetry::Accumulate(
-        Telemetry::WEBRTC_STUN_RATE_LIMIT_EXCEEDED_BY_TYPE_GIVEN_FAILURE,
-        rate_limit_bit_pattern);
-  } else {
-    Telemetry::Accumulate(
-        Telemetry::WEBRTC_STUN_RATE_LIMIT_EXCEEDED_BY_TYPE_GIVEN_SUCCESS,
-        rate_limit_bit_pattern);
-  }
-
-  // Even if Telemetry::Accumulate is threadsafe, we still need to send the
-  // query back to main, since that is where it must be destroyed.
+  // We still need to send the query back to main, since that is where
+  // it must be destroyed.
   NS_DispatchToMainThread(
       WrapRunnableNM(
           &StoreLongTermICEStatisticsImpl_m,
@@ -1216,8 +1206,6 @@ static void GetStatsForLongTermStorage_s(
 
 void WebrtcGlobalInformation::StoreLongTermICEStatistics(
     PeerConnectionImpl& aPc) {
-  Telemetry::Accumulate(Telemetry::WEBRTC_ICE_FINAL_CONNECTION_STATE,
-                        static_cast<uint32_t>(aPc.IceConnectionState()));
 
   if (aPc.IceConnectionState() == PCImplIceConnectionState::New) {
     // ICE has not started; we won't have any remote candidates, so recording
-- 
cgit v1.2.3