Add UMA counters for type of SDP semantic in use.

We count a) what semantics are asked for explicitly (if any),
and b) what semantics are reflected in the successfully
processed answer, as indicated by presence of msid lines
of type Unified Plan vs Plan B.

This gives an indication of usage in sessions initiated by
the browser. It does not indicate usage in sessions where the
browser is the answerer.

Bug: chromium:811683
Change-Id: I2e28a6a83df1664e1aa1e17cd4ff2921de1fba7e
Reviewed-on: https://webrtc-review.googlesource.com/52101
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22008}
diff --git a/pc/peerconnection_rtp_unittest.cc b/pc/peerconnection_rtp_unittest.cc
index 023ce92..2f20261 100644
--- a/pc/peerconnection_rtp_unittest.cc
+++ b/pc/peerconnection_rtp_unittest.cc
@@ -13,6 +13,7 @@
 
 #include "api/audio_codecs/builtin_audio_decoder_factory.h"
 #include "api/audio_codecs/builtin_audio_encoder_factory.h"
+#include "api/fakemetricsobserver.h"
 #include "api/jsep.h"
 #include "api/mediastreaminterface.h"
 #include "api/peerconnectioninterface.h"
@@ -889,6 +890,9 @@
   caller->AddAudioTrack("caller_audio");
   auto callee = CreatePeerConnectionWithUnifiedPlan();
   callee->AddAudioTrack("callee_audio");
+  auto caller_observer =
+      new rtc::RefCountedObject<webrtc::FakeMetricsObserver>();
+  caller->pc()->RegisterUMAObserver(caller_observer);
 
   ASSERT_TRUE(caller->ExchangeOfferAnswerWith(callee.get()));
 
@@ -902,6 +906,19 @@
   auto* answer = caller->pc()->remote_description();
   EXPECT_EQ(cricket::kMsidSignalingMediaSection,
             answer->description()->msid_signaling());
+  // Check that this is counted correctly
+  EXPECT_EQ(1, caller_observer->GetEnumCounter(
+                   webrtc::kEnumCounterSdpSemanticNegotiated,
+                   webrtc::kSdpSemanticNegotiatedUnifiedPlan));
+  EXPECT_EQ(0, caller_observer->GetEnumCounter(
+                   webrtc::kEnumCounterSdpSemanticNegotiated,
+                   webrtc::kSdpSemanticNegotiatedNone));
+  EXPECT_EQ(0, caller_observer->GetEnumCounter(
+                   webrtc::kEnumCounterSdpSemanticNegotiated,
+                   webrtc::kSdpSemanticNegotiatedPlanB));
+  EXPECT_EQ(0, caller_observer->GetEnumCounter(
+                   webrtc::kEnumCounterSdpSemanticNegotiated,
+                   webrtc::kSdpSemanticNegotiatedMixed));
 }
 
 TEST_F(PeerConnectionMsidSignalingTest, PlanBOfferToUnifiedPlanAnswer) {