Bug 964127 - Add a/v sync telemetry. r=bwc
authorJan-Ivar Bruaroey <jib@mozilla.com>
Fri, 14 Mar 2014 16:46:31 -0400
changeset 173797 5eacab1442af
parent 173796 c41d3898b1c3
child 173798 e182de48f628
push id26420
push userkhuey@mozilla.com
push date2014-03-16 00:40 +0000
treeherdermozilla-central@e182de48f628 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc
bugs964127
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 964127 - Add a/v sync telemetry. r=bwc
media/webrtc/signaling/src/media-conduit/AudioConduit.cpp
toolkit/components/telemetry/Histograms.json
--- a/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp
@@ -15,16 +15,17 @@
 #include "nsCOMPtr.h"
 #include "mozilla/Services.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsThreadUtils.h"
 #ifdef MOZILLA_INTERNAL_API
 #include "Latency.h"
+#include "mozilla/Telemetry.h"
 #endif
 
 #include "webrtc/voice_engine/include/voe_errors.h"
 #include "webrtc/system_wrappers/interface/clock.h"
 
 #ifdef MOZ_WIDGET_ANDROID
 #include "AndroidJNIWrapper.h"
 #endif
@@ -686,25 +687,37 @@ WebrtcAudioConduit::GetAudioFrame(int16_
       return kMediaConduitPlayoutError;
     }
     return kMediaConduitUnknownError;
   }
 
   // Not #ifdef DEBUG or on a log module so we can use it for about:webrtc/etc
   mSamples += lengthSamples;
   if (mSamples >= mLastSyncLog + samplingFreqHz) {
-    int jitter_buffer_delay_ms = 0;
-    int playout_buffer_delay_ms = 0;
-    int avsync_offset_ms = 0;
-    GetAVStats(&jitter_buffer_delay_ms,
-               &playout_buffer_delay_ms,
-               &avsync_offset_ms); // ignore errors
-    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);
+    int jitter_buffer_delay_ms;
+    int playout_buffer_delay_ms;
+    int avsync_offset_ms;
+    if (GetAVStats(&jitter_buffer_delay_ms,
+                   &playout_buffer_delay_ms,
+                   &avsync_offset_ms)) {
+#ifdef MOZILLA_INTERNAL_API
+      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);
+    } else {
+      CSFLogError(logTag, "A/V sync: GetAVStats failed");
+    }
     mLastSyncLog = mSamples;
   }
 
 #ifdef MOZILLA_INTERNAL_API
   if (PR_LOG_TEST(GetLatencyLog(), PR_LOG_DEBUG)) {
     if (mProcessing.Length() > 0) {
       unsigned int now;
       mPtrVoEVideoSync->GetPlayoutTimestamp(mChannel, now);
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -4971,16 +4971,30 @@
     "n_buckets": "1000",
     "description": "The time (in milliseconds) that it took a 'reconfigure thread' request to go round trip."
   },
   "WEBRTC_ICE_SUCCESS_RATE": {
     "expires_in_version": "never",
     "kind": "boolean",
     "description": "The number of failed ICE Connections (0) vs. number of successful ICE connections (1)."
   },
+  "WEBRTC_AVSYNC_WHEN_AUDIO_LAGS_VIDEO_MS": {
+    "expires_in_version": "never",
+    "kind": "exponential",
+    "high": 60000,
+    "n_buckets": 1000,
+    "description": "The delay (in milliseconds) when audio is behind video. Zero delay is counted. Measured every second of a call."
+  },
+  "WEBRTC_AVSYNC_WHEN_VIDEO_LAGS_AUDIO_MS": {
+    "expires_in_version": "never",
+    "kind": "exponential",
+    "high": 60000,
+    "n_buckets": 1000,
+    "description": "The delay (in milliseconds) when video is behind audio. Zero delay is not counted. Measured every second of a call."
+  },
   "WEBRTC_CALL_DURATION": {
     "expires_in_version": "never",
     "kind": "exponential",
     "high": "10000",
     "n_buckets": "1000",
     "description": "The length of time (in seconds) that a call lasted."
   },
   "WEBRTC_CALL_COUNT": {