[ModernStats] Replace uses of std::unique_ptr<> with absl::optional<>.

Optional better describes "optionality" so let's do it for the sake of
style. But a side-effect of switching to optional may be better memory
locality than std::unique_ptr<>. (Anecdotally I saw a pprof suggesting a
significant amount of time being spent allocating/reading these maps.
This CL is unlikely to make the difference but it can't hurt.)

Bug: webrtc:14289
Change-Id: I7dcea9625b95c2f1a23e7d9595d27b58883570e2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/269404
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37624}
diff --git a/pc/track_media_info_map_unittest.cc b/pc/track_media_info_map_unittest.cc
index 0adfbf3..affb363 100644
--- a/pc/track_media_info_map_unittest.cc
+++ b/pc/track_media_info_map_unittest.cc
@@ -33,6 +33,8 @@
 #include "test/gmock.h"
 #include "test/gtest.h"
 
+using ::testing::ElementsAre;
+
 namespace webrtc {
 
 namespace {
@@ -104,9 +106,7 @@
   TrackMediaInfoMapTest() : TrackMediaInfoMapTest(true) {}
 
   explicit TrackMediaInfoMapTest(bool use_real_video_track)
-      : voice_media_info_(new cricket::VoiceMediaInfo()),
-        video_media_info_(new cricket::VideoMediaInfo()),
-        local_audio_track_(AudioTrack::Create("LocalAudioTrack", nullptr)),
+      : local_audio_track_(AudioTrack::Create("LocalAudioTrack", nullptr)),
         remote_audio_track_(AudioTrack::Create("RemoteAudioTrack", nullptr)),
         local_video_track_(use_real_video_track
                                ? CreateVideoTrack("LocalVideoTrack")
@@ -115,15 +115,6 @@
                                 ? CreateVideoTrack("RemoteVideoTrack")
                                 : CreateMockVideoTrack("LocalVideoTrack")) {}
 
-  ~TrackMediaInfoMapTest() {
-    // If we have a map the ownership has been passed to the map, only delete if
-    // `CreateMap` has not been called.
-    if (!map_) {
-      delete voice_media_info_;
-      delete video_media_info_;
-    }
-  }
-
   void AddRtpSenderWithSsrcs(std::initializer_list<uint32_t> ssrcs,
                              MediaStreamTrackInterface* local_track) {
     rtc::scoped_refptr<MockRtpSenderInternal> rtp_sender = CreateMockRtpSender(
@@ -140,7 +131,7 @@
         voice_sender_info.local_stats.push_back(cricket::SsrcSenderInfo());
         voice_sender_info.local_stats[i++].ssrc = ssrc;
       }
-      voice_media_info_->senders.push_back(voice_sender_info);
+      voice_media_info_.senders.push_back(voice_sender_info);
     } else {
       cricket::VideoSenderInfo video_sender_info;
       size_t i = 0;
@@ -148,8 +139,8 @@
         video_sender_info.local_stats.push_back(cricket::SsrcSenderInfo());
         video_sender_info.local_stats[i++].ssrc = ssrc;
       }
-      video_media_info_->senders.push_back(video_sender_info);
-      video_media_info_->aggregated_senders.push_back(video_sender_info);
+      video_media_info_.senders.push_back(video_sender_info);
+      video_media_info_.aggregated_senders.push_back(video_sender_info);
     }
   }
 
@@ -169,7 +160,7 @@
         voice_receiver_info.local_stats.push_back(cricket::SsrcReceiverInfo());
         voice_receiver_info.local_stats[i++].ssrc = ssrc;
       }
-      voice_media_info_->receivers.push_back(voice_receiver_info);
+      voice_media_info_.receivers.push_back(voice_receiver_info);
     } else {
       cricket::VideoReceiverInfo video_receiver_info;
       size_t i = 0;
@@ -177,25 +168,26 @@
         video_receiver_info.local_stats.push_back(cricket::SsrcReceiverInfo());
         video_receiver_info.local_stats[i++].ssrc = ssrc;
       }
-      video_media_info_->receivers.push_back(video_receiver_info);
+      video_media_info_.receivers.push_back(video_receiver_info);
     }
   }
 
-  void CreateMap() {
-    RTC_DCHECK(!map_);
-    map_.reset(new TrackMediaInfoMap(
-        std::unique_ptr<cricket::VoiceMediaInfo>(voice_media_info_),
-        std::unique_ptr<cricket::VideoMediaInfo>(video_media_info_),
-        rtp_senders_, rtp_receivers_));
+  // Copies the current state of `voice_media_info_` and `video_media_info_`
+  // into the map.
+  void InitializeMap() {
+    map_.Initialize(voice_media_info_, video_media_info_, rtp_senders_,
+                    rtp_receivers_);
   }
 
- protected:
+ private:
   rtc::AutoThread main_thread_;
-  cricket::VoiceMediaInfo* voice_media_info_;
-  cricket::VideoMediaInfo* video_media_info_;
+  cricket::VoiceMediaInfo voice_media_info_;
+  cricket::VideoMediaInfo video_media_info_;
+
+ protected:
   std::vector<rtc::scoped_refptr<RtpSenderInternal>> rtp_senders_;
   std::vector<rtc::scoped_refptr<RtpReceiverInternal>> rtp_receivers_;
-  std::unique_ptr<TrackMediaInfoMap> map_;
+  TrackMediaInfoMap map_;
   rtc::scoped_refptr<AudioTrack> local_audio_track_;
   rtc::scoped_refptr<AudioTrack> remote_audio_track_;
   rtc::scoped_refptr<VideoTrackInterface> local_video_track_;
@@ -209,34 +201,32 @@
   AddRtpReceiverWithSsrcs({2}, remote_audio_track_.get());
   AddRtpSenderWithSsrcs({3}, local_video_track_.get());
   AddRtpReceiverWithSsrcs({4}, remote_video_track_.get());
-  CreateMap();
+  InitializeMap();
 
   // Local audio track <-> RTP audio sender
-  ASSERT_TRUE(map_->GetVoiceSenderInfos(*local_audio_track_));
-  EXPECT_EQ(
-      *map_->GetVoiceSenderInfos(*local_audio_track_),
-      std::vector<cricket::VoiceSenderInfo*>({&voice_media_info_->senders[0]}));
-  EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[0]),
+  ASSERT_TRUE(map_.GetVoiceSenderInfos(*local_audio_track_));
+  EXPECT_THAT(*map_.GetVoiceSenderInfos(*local_audio_track_),
+              ElementsAre(&map_.voice_media_info()->senders[0]));
+  EXPECT_EQ(map_.GetAudioTrack(map_.voice_media_info()->senders[0]),
             local_audio_track_.get());
 
   // Remote audio track <-> RTP audio receiver
-  EXPECT_EQ(map_->GetVoiceReceiverInfo(*remote_audio_track_),
-            &voice_media_info_->receivers[0]);
-  EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->receivers[0]),
+  EXPECT_EQ(map_.GetVoiceReceiverInfo(*remote_audio_track_),
+            &map_.voice_media_info()->receivers[0]);
+  EXPECT_EQ(map_.GetAudioTrack(map_.voice_media_info()->receivers[0]),
             remote_audio_track_.get());
 
   // Local video track <-> RTP video sender
-  ASSERT_TRUE(map_->GetVideoSenderInfos(*local_video_track_));
-  EXPECT_EQ(
-      *map_->GetVideoSenderInfos(*local_video_track_),
-      std::vector<cricket::VideoSenderInfo*>({&video_media_info_->senders[0]}));
-  EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[0]),
+  ASSERT_TRUE(map_.GetVideoSenderInfos(*local_video_track_));
+  EXPECT_THAT(*map_.GetVideoSenderInfos(*local_video_track_),
+              ElementsAre(&map_.video_media_info()->senders[0]));
+  EXPECT_EQ(map_.GetVideoTrack(map_.video_media_info()->senders[0]),
             local_video_track_.get());
 
   // Remote video track <-> RTP video receiver
-  EXPECT_EQ(map_->GetVideoReceiverInfo(*remote_video_track_),
-            &video_media_info_->receivers[0]);
-  EXPECT_EQ(map_->GetVideoTrack(video_media_info_->receivers[0]),
+  EXPECT_EQ(map_.GetVideoReceiverInfo(*remote_video_track_),
+            &map_.video_media_info()->receivers[0]);
+  EXPECT_EQ(map_.GetVideoTrack(map_.video_media_info()->receivers[0]),
             remote_video_track_.get());
 }
 
@@ -245,12 +235,12 @@
   AddRtpSenderWithSsrcs({}, local_video_track_.get());
   AddRtpReceiverWithSsrcs({}, remote_audio_track_.get());
   AddRtpReceiverWithSsrcs({}, remote_video_track_.get());
-  CreateMap();
+  InitializeMap();
 
-  EXPECT_FALSE(map_->GetVoiceSenderInfos(*local_audio_track_));
-  EXPECT_FALSE(map_->GetVideoSenderInfos(*local_video_track_));
-  EXPECT_FALSE(map_->GetVoiceReceiverInfo(*remote_audio_track_));
-  EXPECT_FALSE(map_->GetVideoReceiverInfo(*remote_video_track_));
+  EXPECT_FALSE(map_.GetVoiceSenderInfos(*local_audio_track_));
+  EXPECT_FALSE(map_.GetVideoSenderInfos(*local_video_track_));
+  EXPECT_FALSE(map_.GetVoiceReceiverInfo(*remote_audio_track_));
+  EXPECT_FALSE(map_.GetVideoReceiverInfo(*remote_video_track_));
 }
 
 TEST_F(TrackMediaInfoMapTest,
@@ -259,56 +249,52 @@
   AddRtpReceiverWithSsrcs({2}, remote_audio_track_.get());
   AddRtpSenderWithSsrcs({1}, local_video_track_.get());
   AddRtpReceiverWithSsrcs({2}, remote_video_track_.get());
-  CreateMap();
+  InitializeMap();
 
   // Local audio track <-> RTP audio sender
-  ASSERT_TRUE(map_->GetVoiceSenderInfos(*local_audio_track_));
-  EXPECT_EQ(
-      *map_->GetVoiceSenderInfos(*local_audio_track_),
-      std::vector<cricket::VoiceSenderInfo*>({&voice_media_info_->senders[0]}));
-  EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[0]),
+  ASSERT_TRUE(map_.GetVoiceSenderInfos(*local_audio_track_));
+  EXPECT_THAT(*map_.GetVoiceSenderInfos(*local_audio_track_),
+              ElementsAre(&map_.voice_media_info()->senders[0]));
+  EXPECT_EQ(map_.GetAudioTrack(map_.voice_media_info()->senders[0]),
             local_audio_track_.get());
 
   // Remote audio track <-> RTP audio receiver
-  EXPECT_EQ(map_->GetVoiceReceiverInfo(*remote_audio_track_),
-            &voice_media_info_->receivers[0]);
-  EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->receivers[0]),
+  EXPECT_EQ(map_.GetVoiceReceiverInfo(*remote_audio_track_),
+            &map_.voice_media_info()->receivers[0]);
+  EXPECT_EQ(map_.GetAudioTrack(map_.voice_media_info()->receivers[0]),
             remote_audio_track_.get());
 
   // Local video track <-> RTP video sender
-  ASSERT_TRUE(map_->GetVideoSenderInfos(*local_video_track_));
-  EXPECT_EQ(
-      *map_->GetVideoSenderInfos(*local_video_track_),
-      std::vector<cricket::VideoSenderInfo*>({&video_media_info_->senders[0]}));
-  EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[0]),
+  ASSERT_TRUE(map_.GetVideoSenderInfos(*local_video_track_));
+  EXPECT_THAT(*map_.GetVideoSenderInfos(*local_video_track_),
+              ElementsAre(&map_.video_media_info()->senders[0]));
+  EXPECT_EQ(map_.GetVideoTrack(map_.video_media_info()->senders[0]),
             local_video_track_.get());
 
   // Remote video track <-> RTP video receiver
-  EXPECT_EQ(map_->GetVideoReceiverInfo(*remote_video_track_),
-            &video_media_info_->receivers[0]);
-  EXPECT_EQ(map_->GetVideoTrack(video_media_info_->receivers[0]),
+  EXPECT_EQ(map_.GetVideoReceiverInfo(*remote_video_track_),
+            &map_.video_media_info()->receivers[0]);
+  EXPECT_EQ(map_.GetVideoTrack(map_.video_media_info()->receivers[0]),
             remote_video_track_.get());
 }
 
 TEST_F(TrackMediaInfoMapTest, SingleMultiSsrcSenderPerTrack) {
   AddRtpSenderWithSsrcs({1, 2}, local_audio_track_.get());
   AddRtpSenderWithSsrcs({3, 4}, local_video_track_.get());
-  CreateMap();
+  InitializeMap();
 
   // Local audio track <-> RTP audio senders
-  ASSERT_TRUE(map_->GetVoiceSenderInfos(*local_audio_track_));
-  EXPECT_EQ(
-      *map_->GetVoiceSenderInfos(*local_audio_track_),
-      std::vector<cricket::VoiceSenderInfo*>({&voice_media_info_->senders[0]}));
-  EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[0]),
+  ASSERT_TRUE(map_.GetVoiceSenderInfos(*local_audio_track_));
+  EXPECT_THAT(*map_.GetVoiceSenderInfos(*local_audio_track_),
+              ElementsAre(&map_.voice_media_info()->senders[0]));
+  EXPECT_EQ(map_.GetAudioTrack(map_.voice_media_info()->senders[0]),
             local_audio_track_.get());
 
   // Local video track <-> RTP video senders
-  ASSERT_TRUE(map_->GetVideoSenderInfos(*local_video_track_));
-  EXPECT_EQ(
-      *map_->GetVideoSenderInfos(*local_video_track_),
-      std::vector<cricket::VideoSenderInfo*>({&video_media_info_->senders[0]}));
-  EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[0]),
+  ASSERT_TRUE(map_.GetVideoSenderInfos(*local_video_track_));
+  EXPECT_THAT(*map_.GetVideoSenderInfos(*local_video_track_),
+              ElementsAre(&map_.video_media_info()->senders[0]));
+  EXPECT_EQ(map_.GetVideoTrack(map_.video_media_info()->senders[0]),
             local_video_track_.get());
 }
 
@@ -317,28 +303,26 @@
   AddRtpSenderWithSsrcs({2}, local_audio_track_.get());
   AddRtpSenderWithSsrcs({3}, local_video_track_.get());
   AddRtpSenderWithSsrcs({4}, local_video_track_.get());
-  CreateMap();
+  InitializeMap();
 
   // Local audio track <-> RTP audio senders
-  ASSERT_TRUE(map_->GetVoiceSenderInfos(*local_audio_track_));
-  EXPECT_EQ(
-      *map_->GetVoiceSenderInfos(*local_audio_track_),
-      std::vector<cricket::VoiceSenderInfo*>(
-          {&voice_media_info_->senders[0], &voice_media_info_->senders[1]}));
-  EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[0]),
+  ASSERT_TRUE(map_.GetVoiceSenderInfos(*local_audio_track_));
+  EXPECT_THAT(*map_.GetVoiceSenderInfos(*local_audio_track_),
+              ElementsAre(&map_.voice_media_info()->senders[0],
+                          &map_.voice_media_info()->senders[1]));
+  EXPECT_EQ(map_.GetAudioTrack(map_.voice_media_info()->senders[0]),
             local_audio_track_.get());
-  EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[1]),
+  EXPECT_EQ(map_.GetAudioTrack(map_.voice_media_info()->senders[1]),
             local_audio_track_.get());
 
   // Local video track <-> RTP video senders
-  ASSERT_TRUE(map_->GetVideoSenderInfos(*local_video_track_));
-  EXPECT_EQ(
-      *map_->GetVideoSenderInfos(*local_video_track_),
-      std::vector<cricket::VideoSenderInfo*>(
-          {&video_media_info_->senders[0], &video_media_info_->senders[1]}));
-  EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[0]),
+  ASSERT_TRUE(map_.GetVideoSenderInfos(*local_video_track_));
+  EXPECT_THAT(*map_.GetVideoSenderInfos(*local_video_track_),
+              ElementsAre(&map_.video_media_info()->senders[0],
+                          &map_.video_media_info()->senders[1]));
+  EXPECT_EQ(map_.GetVideoTrack(map_.video_media_info()->senders[0]),
             local_video_track_.get());
-  EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[1]),
+  EXPECT_EQ(map_.GetVideoTrack(map_.video_media_info()->senders[1]),
             local_video_track_.get());
 }
 
@@ -347,28 +331,26 @@
   AddRtpSenderWithSsrcs({3, 4}, local_audio_track_.get());
   AddRtpSenderWithSsrcs({5, 6}, local_video_track_.get());
   AddRtpSenderWithSsrcs({7, 8}, local_video_track_.get());
-  CreateMap();
+  InitializeMap();
 
   // Local audio track <-> RTP audio senders
-  ASSERT_TRUE(map_->GetVoiceSenderInfos(*local_audio_track_));
-  EXPECT_EQ(
-      *map_->GetVoiceSenderInfos(*local_audio_track_),
-      std::vector<cricket::VoiceSenderInfo*>(
-          {&voice_media_info_->senders[0], &voice_media_info_->senders[1]}));
-  EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[0]),
+  ASSERT_TRUE(map_.GetVoiceSenderInfos(*local_audio_track_));
+  EXPECT_THAT(*map_.GetVoiceSenderInfos(*local_audio_track_),
+              ElementsAre(&map_.voice_media_info()->senders[0],
+                          &map_.voice_media_info()->senders[1]));
+  EXPECT_EQ(map_.GetAudioTrack(map_.voice_media_info()->senders[0]),
             local_audio_track_.get());
-  EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[1]),
+  EXPECT_EQ(map_.GetAudioTrack(map_.voice_media_info()->senders[1]),
             local_audio_track_.get());
 
   // Local video track <-> RTP video senders
-  ASSERT_TRUE(map_->GetVideoSenderInfos(*local_video_track_));
-  EXPECT_EQ(
-      *map_->GetVideoSenderInfos(*local_video_track_),
-      std::vector<cricket::VideoSenderInfo*>(
-          {&video_media_info_->senders[0], &video_media_info_->senders[1]}));
-  EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[0]),
+  ASSERT_TRUE(map_.GetVideoSenderInfos(*local_video_track_));
+  EXPECT_THAT(*map_.GetVideoSenderInfos(*local_video_track_),
+              ElementsAre(&map_.video_media_info()->senders[0],
+                          &map_.video_media_info()->senders[1]));
+  EXPECT_EQ(map_.GetVideoTrack(map_.video_media_info()->senders[0]),
             local_video_track_.get());
-  EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[1]),
+  EXPECT_EQ(map_.GetVideoTrack(map_.video_media_info()->senders[1]),
             local_video_track_.get());
 }
 
@@ -378,34 +360,32 @@
   AddRtpReceiverWithSsrcs({1}, remote_audio_track_.get());
   AddRtpSenderWithSsrcs({2}, local_video_track_.get());
   AddRtpReceiverWithSsrcs({2}, remote_video_track_.get());
-  CreateMap();
+  InitializeMap();
 
   // Local audio track <-> RTP audio senders
-  ASSERT_TRUE(map_->GetVoiceSenderInfos(*local_audio_track_));
-  EXPECT_EQ(
-      *map_->GetVoiceSenderInfos(*local_audio_track_),
-      std::vector<cricket::VoiceSenderInfo*>({&voice_media_info_->senders[0]}));
-  EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[0]),
+  ASSERT_TRUE(map_.GetVoiceSenderInfos(*local_audio_track_));
+  EXPECT_THAT(*map_.GetVoiceSenderInfos(*local_audio_track_),
+              ElementsAre(&map_.voice_media_info()->senders[0]));
+  EXPECT_EQ(map_.GetAudioTrack(map_.voice_media_info()->senders[0]),
             local_audio_track_.get());
 
   // Remote audio track <-> RTP audio receiver
-  EXPECT_EQ(map_->GetVoiceReceiverInfo(*remote_audio_track_),
-            &voice_media_info_->receivers[0]);
-  EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->receivers[0]),
+  EXPECT_EQ(map_.GetVoiceReceiverInfo(*remote_audio_track_),
+            &map_.voice_media_info()->receivers[0]);
+  EXPECT_EQ(map_.GetAudioTrack(map_.voice_media_info()->receivers[0]),
             remote_audio_track_.get());
 
   // Local video track <-> RTP video senders
-  ASSERT_TRUE(map_->GetVideoSenderInfos(*local_video_track_));
-  EXPECT_EQ(
-      *map_->GetVideoSenderInfos(*local_video_track_),
-      std::vector<cricket::VideoSenderInfo*>({&video_media_info_->senders[0]}));
-  EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[0]),
+  ASSERT_TRUE(map_.GetVideoSenderInfos(*local_video_track_));
+  EXPECT_THAT(*map_.GetVideoSenderInfos(*local_video_track_),
+              ElementsAre(&map_.video_media_info()->senders[0]));
+  EXPECT_EQ(map_.GetVideoTrack(map_.video_media_info()->senders[0]),
             local_video_track_.get());
 
   // Remote video track <-> RTP video receiver
-  EXPECT_EQ(map_->GetVideoReceiverInfo(*remote_video_track_),
-            &video_media_info_->receivers[0]);
-  EXPECT_EQ(map_->GetVideoTrack(video_media_info_->receivers[0]),
+  EXPECT_EQ(map_.GetVideoReceiverInfo(*remote_video_track_),
+            &map_.video_media_info()->receivers[0]);
+  EXPECT_EQ(map_.GetVideoTrack(map_.video_media_info()->receivers[0]),
             remote_video_track_.get());
 }
 
@@ -414,22 +394,22 @@
   AddRtpReceiverWithSsrcs({2}, remote_audio_track_.get());
   AddRtpSenderWithSsrcs({3}, local_video_track_.get());
   AddRtpReceiverWithSsrcs({4}, remote_video_track_.get());
-  CreateMap();
-  EXPECT_TRUE(map_->GetVoiceSenderInfoBySsrc(1));
-  EXPECT_TRUE(map_->GetVoiceReceiverInfoBySsrc(2));
-  EXPECT_TRUE(map_->GetVideoSenderInfoBySsrc(3));
-  EXPECT_TRUE(map_->GetVideoReceiverInfoBySsrc(4));
-  EXPECT_FALSE(map_->GetVoiceSenderInfoBySsrc(2));
-  EXPECT_FALSE(map_->GetVoiceSenderInfoBySsrc(1024));
+  InitializeMap();
+  EXPECT_TRUE(map_.GetVoiceSenderInfoBySsrc(1));
+  EXPECT_TRUE(map_.GetVoiceReceiverInfoBySsrc(2));
+  EXPECT_TRUE(map_.GetVideoSenderInfoBySsrc(3));
+  EXPECT_TRUE(map_.GetVideoReceiverInfoBySsrc(4));
+  EXPECT_FALSE(map_.GetVoiceSenderInfoBySsrc(2));
+  EXPECT_FALSE(map_.GetVoiceSenderInfoBySsrc(1024));
 }
 
 TEST_F(TrackMediaInfoMapTest, GetAttachmentIdByTrack) {
   AddRtpSenderWithSsrcs({1}, local_audio_track_.get());
-  CreateMap();
+  InitializeMap();
   EXPECT_EQ(rtp_senders_[0]->AttachmentId(),
-            map_->GetAttachmentIdByTrack(local_audio_track_.get()));
+            map_.GetAttachmentIdByTrack(local_audio_track_.get()));
   EXPECT_EQ(absl::nullopt,
-            map_->GetAttachmentIdByTrack(local_video_track_.get()));
+            map_.GetAttachmentIdByTrack(local_video_track_.get()));
 }
 
 // Death tests.
@@ -447,7 +427,7 @@
   AddRtpReceiverWithSsrcs({2}, remote_audio_track_.get());
   AddRtpReceiverWithSsrcs({3}, remote_video_track_.get());
   AddRtpReceiverWithSsrcs({4}, remote_video_track_.get());
-  EXPECT_DEATH(CreateMap(), "");
+  EXPECT_DEATH(InitializeMap(), "");
 }
 
 TEST_F(TrackMediaInfoMapDeathTest, MultipleMultiSsrcReceiversPerTrack) {
@@ -455,7 +435,7 @@
   AddRtpReceiverWithSsrcs({3, 4}, remote_audio_track_.get());
   AddRtpReceiverWithSsrcs({5, 6}, remote_video_track_.get());
   AddRtpReceiverWithSsrcs({7, 8}, remote_video_track_.get());
-  EXPECT_DEATH(CreateMap(), "");
+  EXPECT_DEATH(InitializeMap(), "");
 }
 
 #endif  // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)