[Stats] Make simulcastIndex 0 in the event of singlecast.

The WG decided we should add this to the web. The PR was updated to
return 0 in singlecast instead of missing value, so let's make our C++
implementation match as well.

Bug: chromium:404853839, chromium:406922375
Change-Id: I247555559d00138ab78d7e2df23629787fcab723
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/383500
Auto-Submit: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#44258}
diff --git a/api/stats/rtcstats_objects.h b/api/stats/rtcstats_objects.h
index c4f15a3..82acb45 100644
--- a/api/stats/rtcstats_objects.h
+++ b/api/stats/rtcstats_objects.h
@@ -332,9 +332,6 @@
   std::optional<std::string> remote_id;
   std::optional<std::string> mid;
   std::optional<std::string> rid;
-  // C++-only metric. Useful for apps that don't use RIDs and need to know which
-  // SSRC belong to which encoding, or stats processing which does not know the
-  // app-specific RID-to-index mapping (e.g. chrome://webrtc-internals/).
   std::optional<uint32_t> encoding_index;
   std::optional<uint64_t> retransmitted_packets_sent;
   std::optional<uint64_t> header_bytes_sent;
diff --git a/media/engine/webrtc_video_engine.cc b/media/engine/webrtc_video_engine.cc
index 6ba1023..906ef01 100644
--- a/media/engine/webrtc_video_engine.cc
+++ b/media/engine/webrtc_video_engine.cc
@@ -2550,8 +2550,7 @@
     uint32_t ssrc = pair.first;
     info.add_ssrc(ssrc);
     info.rid = parameters_.config.rtp.GetRidForSsrc(ssrc);
-    if (outbound_rtp_substreams.size() > 1 &&
-        encoding_index_by_ssrc.find(ssrc) != encoding_index_by_ssrc.end()) {
+    if (encoding_index_by_ssrc.find(ssrc) != encoding_index_by_ssrc.end()) {
       info.encoding_index = encoding_index_by_ssrc[ssrc];
     }
     info.active = IsActiveFromEncodings(
diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc
index 1da0c89..96f8f98 100644
--- a/pc/rtc_stats_integrationtest.cc
+++ b/pc/rtc_stats_integrationtest.cc
@@ -841,9 +841,12 @@
           outbound_stream.frames_sent);
       verifier.TestAttributeIsNonNegative<uint32_t>(
           outbound_stream.huge_frames_sent);
-      // RID and simulcast index are N/A because this test uses singlecast.
+      // RID is N/A because this test uses singlecast.
       verifier.TestAttributeIsUndefined(outbound_stream.rid);
-      verifier.TestAttributeIsUndefined(outbound_stream.encoding_index);
+      // In singlecast, the only encoding that exists has index 0.
+      verifier.TestAttributeIsDefined(outbound_stream.encoding_index);
+      EXPECT_TRUE(outbound_stream.encoding_index.has_value() &&
+                  outbound_stream.encoding_index.value() == 0);
       verifier.TestAttributeIsDefined(outbound_stream.scalability_mode);
       verifier.TestAttributeIsNonNegative<uint32_t>(outbound_stream.rtx_ssrc);
     } else {