Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: webrtc/pc/trackmediainfomap_unittest.cc

Issue 2690793003: Move trackmediainfomap files from api/ to pc/. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/pc/trackmediainfomap.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/api/trackmediainfomap.h" 11 #include "webrtc/pc/trackmediainfomap.h"
12 12
13 #include <initializer_list> 13 #include <initializer_list>
14 #include <memory> 14 #include <memory>
15 #include <utility> 15 #include <utility>
16 #include <vector> 16 #include <vector>
17 17
18 #include "webrtc/api/audiotrack.h"
19 #include "webrtc/api/rtpreceiverinterface.h" 18 #include "webrtc/api/rtpreceiverinterface.h"
20 #include "webrtc/api/rtpsenderinterface.h" 19 #include "webrtc/api/rtpsenderinterface.h"
21 #include "webrtc/api/test/mock_rtpreceiver.h" 20 #include "webrtc/api/test/mock_rtpreceiver.h"
22 #include "webrtc/api/test/mock_rtpsender.h" 21 #include "webrtc/api/test/mock_rtpsender.h"
23 #include "webrtc/api/test/fakevideotracksource.h"
24 #include "webrtc/api/videotrack.h"
25 #include "webrtc/base/refcount.h" 22 #include "webrtc/base/refcount.h"
26 #include "webrtc/media/base/mediachannel.h" 23 #include "webrtc/media/base/mediachannel.h"
24 #include "webrtc/pc/audiotrack.h"
25 #include "webrtc/pc/test/fakevideotracksource.h"
26 #include "webrtc/pc/videotrack.h"
27 #include "webrtc/test/gtest.h" 27 #include "webrtc/test/gtest.h"
28 28
29 namespace webrtc { 29 namespace webrtc {
30 30
31 namespace { 31 namespace {
32 32
33 RtpParameters CreateRtpParametersWithSsrcs( 33 RtpParameters CreateRtpParametersWithSsrcs(
34 std::initializer_list<uint32_t> ssrcs) { 34 std::initializer_list<uint32_t> ssrcs) {
35 RtpParameters params; 35 RtpParameters params;
36 for (uint32_t ssrc : ssrcs) { 36 for (uint32_t ssrc : ssrcs) {
37 RtpEncodingParameters encoding_params; 37 RtpEncodingParameters encoding_params;
38 encoding_params.ssrc = rtc::Optional<uint32_t>(ssrc); 38 encoding_params.ssrc = rtc::Optional<uint32_t>(ssrc);
39 params.encodings.push_back(encoding_params); 39 params.encodings.push_back(encoding_params);
40 } 40 }
41 return params; 41 return params;
42 } 42 }
43 43
44 rtc::scoped_refptr<MockRtpSender> CreateMockRtpSender( 44 rtc::scoped_refptr<MockRtpSender> CreateMockRtpSender(
45 cricket::MediaType media_type, std::initializer_list<uint32_t> ssrcs, 45 cricket::MediaType media_type,
46 std::initializer_list<uint32_t> ssrcs,
46 rtc::scoped_refptr<MediaStreamTrackInterface> track) { 47 rtc::scoped_refptr<MediaStreamTrackInterface> track) {
47 uint32_t first_ssrc; 48 uint32_t first_ssrc;
48 if (ssrcs.size()) { 49 if (ssrcs.size()) {
49 first_ssrc = *ssrcs.begin(); 50 first_ssrc = *ssrcs.begin();
50 } else { 51 } else {
51 first_ssrc = 0; 52 first_ssrc = 0;
52 } 53 }
53 rtc::scoped_refptr<MockRtpSender> sender( 54 rtc::scoped_refptr<MockRtpSender> sender(
54 new rtc::RefCountedObject<MockRtpSender>()); 55 new rtc::RefCountedObject<MockRtpSender>());
55 EXPECT_CALL(*sender, track()).WillRepeatedly(testing::Return(track)); 56 EXPECT_CALL(*sender, track()).WillRepeatedly(testing::Return(track));
56 EXPECT_CALL(*sender, ssrc()).WillRepeatedly(testing::Return(first_ssrc)); 57 EXPECT_CALL(*sender, ssrc()).WillRepeatedly(testing::Return(first_ssrc));
57 EXPECT_CALL(*sender, media_type()).WillRepeatedly(testing::Return( 58 EXPECT_CALL(*sender, media_type())
58 media_type)); 59 .WillRepeatedly(testing::Return(media_type));
59 EXPECT_CALL(*sender, GetParameters()).WillRepeatedly(testing::Return( 60 EXPECT_CALL(*sender, GetParameters())
60 CreateRtpParametersWithSsrcs(ssrcs))); 61 .WillRepeatedly(testing::Return(CreateRtpParametersWithSsrcs(ssrcs)));
61 return sender; 62 return sender;
62 } 63 }
63 64
64 rtc::scoped_refptr<MockRtpReceiver> CreateMockRtpReceiver( 65 rtc::scoped_refptr<MockRtpReceiver> CreateMockRtpReceiver(
65 cricket::MediaType media_type, std::initializer_list<uint32_t> ssrcs, 66 cricket::MediaType media_type,
67 std::initializer_list<uint32_t> ssrcs,
66 rtc::scoped_refptr<MediaStreamTrackInterface> track) { 68 rtc::scoped_refptr<MediaStreamTrackInterface> track) {
67 rtc::scoped_refptr<MockRtpReceiver> receiver( 69 rtc::scoped_refptr<MockRtpReceiver> receiver(
68 new rtc::RefCountedObject<MockRtpReceiver>()); 70 new rtc::RefCountedObject<MockRtpReceiver>());
69 EXPECT_CALL(*receiver, track()).WillRepeatedly(testing::Return(track)); 71 EXPECT_CALL(*receiver, track()).WillRepeatedly(testing::Return(track));
70 EXPECT_CALL(*receiver, media_type()).WillRepeatedly(testing::Return( 72 EXPECT_CALL(*receiver, media_type())
71 media_type)); 73 .WillRepeatedly(testing::Return(media_type));
72 EXPECT_CALL(*receiver, GetParameters()).WillRepeatedly(testing::Return( 74 EXPECT_CALL(*receiver, GetParameters())
73 CreateRtpParametersWithSsrcs(ssrcs))); 75 .WillRepeatedly(testing::Return(CreateRtpParametersWithSsrcs(ssrcs)));
74 return receiver; 76 return receiver;
75 } 77 }
76 78
77 class TrackMediaInfoMapTest : public testing::Test { 79 class TrackMediaInfoMapTest : public testing::Test {
78 public: 80 public:
79 TrackMediaInfoMapTest() 81 TrackMediaInfoMapTest()
80 : voice_media_info_(new cricket::VoiceMediaInfo()), 82 : voice_media_info_(new cricket::VoiceMediaInfo()),
81 video_media_info_(new cricket::VideoMediaInfo()), 83 video_media_info_(new cricket::VideoMediaInfo()),
82 local_audio_track_(AudioTrack::Create("LocalAudioTrack", nullptr)), 84 local_audio_track_(AudioTrack::Create("LocalAudioTrack", nullptr)),
83 remote_audio_track_(AudioTrack::Create("RemoteAudioTrack", nullptr)), 85 remote_audio_track_(AudioTrack::Create("RemoteAudioTrack", nullptr)),
84 local_video_track_( 86 local_video_track_(
85 VideoTrack::Create("LocalVideoTrack", 87 VideoTrack::Create("LocalVideoTrack",
86 FakeVideoTrackSource::Create(false))), 88 FakeVideoTrackSource::Create(false))),
87 remote_video_track_( 89 remote_video_track_(
88 VideoTrack::Create("RemoteVideoTrack", 90 VideoTrack::Create("RemoteVideoTrack",
89 FakeVideoTrackSource::Create(false))) { 91 FakeVideoTrackSource::Create(false))) {}
90 }
91 92
92 ~TrackMediaInfoMapTest() { 93 ~TrackMediaInfoMapTest() {
93 // If we have a map the ownership has been passed to the map, only delete if 94 // If we have a map the ownership has been passed to the map, only delete if
94 // |CreateMap| has not been called. 95 // |CreateMap| has not been called.
95 if (!map_) { 96 if (!map_) {
96 delete voice_media_info_; 97 delete voice_media_info_;
97 delete video_media_info_; 98 delete video_media_info_;
98 } 99 }
99 } 100 }
100 101
101 void AddRtpSenderWithSsrcs(std::initializer_list<uint32_t> ssrcs, 102 void AddRtpSenderWithSsrcs(std::initializer_list<uint32_t> ssrcs,
102 MediaStreamTrackInterface* local_track) { 103 MediaStreamTrackInterface* local_track) {
103 rtc::scoped_refptr<MockRtpSender> rtp_sender = CreateMockRtpSender( 104 rtc::scoped_refptr<MockRtpSender> rtp_sender = CreateMockRtpSender(
104 local_track->kind() == MediaStreamTrackInterface::kAudioKind ? 105 local_track->kind() == MediaStreamTrackInterface::kAudioKind
105 cricket::MEDIA_TYPE_AUDIO : cricket::MEDIA_TYPE_VIDEO, 106 ? cricket::MEDIA_TYPE_AUDIO
107 : cricket::MEDIA_TYPE_VIDEO,
106 ssrcs, local_track); 108 ssrcs, local_track);
107 rtp_senders_.push_back(rtp_sender); 109 rtp_senders_.push_back(rtp_sender);
108 110
109 if (local_track->kind() == MediaStreamTrackInterface::kAudioKind) { 111 if (local_track->kind() == MediaStreamTrackInterface::kAudioKind) {
110 cricket::VoiceSenderInfo voice_sender_info; 112 cricket::VoiceSenderInfo voice_sender_info;
111 size_t i = 0; 113 size_t i = 0;
112 for (uint32_t ssrc : ssrcs) { 114 for (uint32_t ssrc : ssrcs) {
113 voice_sender_info.local_stats.push_back(cricket::SsrcSenderInfo()); 115 voice_sender_info.local_stats.push_back(cricket::SsrcSenderInfo());
114 voice_sender_info.local_stats[i++].ssrc = ssrc; 116 voice_sender_info.local_stats[i++].ssrc = ssrc;
115 } 117 }
116 voice_media_info_->senders.push_back(voice_sender_info); 118 voice_media_info_->senders.push_back(voice_sender_info);
117 } else { 119 } else {
118 cricket::VideoSenderInfo video_sender_info; 120 cricket::VideoSenderInfo video_sender_info;
119 size_t i = 0; 121 size_t i = 0;
120 for (uint32_t ssrc : ssrcs) { 122 for (uint32_t ssrc : ssrcs) {
121 video_sender_info.local_stats.push_back(cricket::SsrcSenderInfo()); 123 video_sender_info.local_stats.push_back(cricket::SsrcSenderInfo());
122 video_sender_info.local_stats[i++].ssrc = ssrc; 124 video_sender_info.local_stats[i++].ssrc = ssrc;
123 } 125 }
124 video_media_info_->senders.push_back(video_sender_info); 126 video_media_info_->senders.push_back(video_sender_info);
125 } 127 }
126 } 128 }
127 129
128 void AddRtpReceiverWithSsrcs(std::initializer_list<uint32_t> ssrcs, 130 void AddRtpReceiverWithSsrcs(std::initializer_list<uint32_t> ssrcs,
129 MediaStreamTrackInterface* remote_track) { 131 MediaStreamTrackInterface* remote_track) {
130 rtc::scoped_refptr<MockRtpReceiver> rtp_receiver = CreateMockRtpReceiver( 132 rtc::scoped_refptr<MockRtpReceiver> rtp_receiver = CreateMockRtpReceiver(
131 remote_track->kind() == MediaStreamTrackInterface::kAudioKind ? 133 remote_track->kind() == MediaStreamTrackInterface::kAudioKind
132 cricket::MEDIA_TYPE_AUDIO : cricket::MEDIA_TYPE_VIDEO, 134 ? cricket::MEDIA_TYPE_AUDIO
135 : cricket::MEDIA_TYPE_VIDEO,
133 ssrcs, remote_track); 136 ssrcs, remote_track);
134 rtp_receivers_.push_back(rtp_receiver); 137 rtp_receivers_.push_back(rtp_receiver);
135 138
136 if (remote_track->kind() == MediaStreamTrackInterface::kAudioKind) { 139 if (remote_track->kind() == MediaStreamTrackInterface::kAudioKind) {
137 cricket::VoiceReceiverInfo voice_receiver_info; 140 cricket::VoiceReceiverInfo voice_receiver_info;
138 size_t i = 0; 141 size_t i = 0;
139 for (uint32_t ssrc : ssrcs) { 142 for (uint32_t ssrc : ssrcs) {
140 voice_receiver_info.local_stats.push_back(cricket::SsrcReceiverInfo()); 143 voice_receiver_info.local_stats.push_back(cricket::SsrcReceiverInfo());
141 voice_receiver_info.local_stats[i++].ssrc = ssrc; 144 voice_receiver_info.local_stats[i++].ssrc = ssrc;
142 } 145 }
143 voice_media_info_->receivers.push_back(voice_receiver_info); 146 voice_media_info_->receivers.push_back(voice_receiver_info);
144 } else { 147 } else {
145 cricket::VideoReceiverInfo video_receiver_info; 148 cricket::VideoReceiverInfo video_receiver_info;
146 size_t i = 0; 149 size_t i = 0;
147 for (uint32_t ssrc : ssrcs) { 150 for (uint32_t ssrc : ssrcs) {
148 video_receiver_info.local_stats.push_back(cricket::SsrcReceiverInfo()); 151 video_receiver_info.local_stats.push_back(cricket::SsrcReceiverInfo());
149 video_receiver_info.local_stats[i++].ssrc = ssrc; 152 video_receiver_info.local_stats[i++].ssrc = ssrc;
150 } 153 }
151 video_media_info_->receivers.push_back(video_receiver_info); 154 video_media_info_->receivers.push_back(video_receiver_info);
152 } 155 }
153 } 156 }
154 157
155 void CreateMap() { 158 void CreateMap() {
156 RTC_DCHECK(!map_); 159 RTC_DCHECK(!map_);
157 map_.reset(new TrackMediaInfoMap( 160 map_.reset(new TrackMediaInfoMap(
158 std::unique_ptr<cricket::VoiceMediaInfo>(voice_media_info_), 161 std::unique_ptr<cricket::VoiceMediaInfo>(voice_media_info_),
159 std::unique_ptr<cricket::VideoMediaInfo>(video_media_info_), 162 std::unique_ptr<cricket::VideoMediaInfo>(video_media_info_),
160 rtp_senders_, 163 rtp_senders_, rtp_receivers_));
161 rtp_receivers_));
162 } 164 }
163 165
164 protected: 166 protected:
165 cricket::VoiceMediaInfo* voice_media_info_; 167 cricket::VoiceMediaInfo* voice_media_info_;
166 cricket::VideoMediaInfo* video_media_info_; 168 cricket::VideoMediaInfo* video_media_info_;
167 std::vector<rtc::scoped_refptr<RtpSenderInterface>> rtp_senders_; 169 std::vector<rtc::scoped_refptr<RtpSenderInterface>> rtp_senders_;
168 std::vector<rtc::scoped_refptr<RtpReceiverInterface>> rtp_receivers_; 170 std::vector<rtc::scoped_refptr<RtpReceiverInterface>> rtp_receivers_;
169 std::unique_ptr<TrackMediaInfoMap> map_; 171 std::unique_ptr<TrackMediaInfoMap> map_;
170 rtc::scoped_refptr<AudioTrack> local_audio_track_; 172 rtc::scoped_refptr<AudioTrack> local_audio_track_;
171 rtc::scoped_refptr<AudioTrack> remote_audio_track_; 173 rtc::scoped_refptr<AudioTrack> remote_audio_track_;
172 rtc::scoped_refptr<VideoTrack> local_video_track_; 174 rtc::scoped_refptr<VideoTrack> local_video_track_;
173 rtc::scoped_refptr<VideoTrack> remote_video_track_; 175 rtc::scoped_refptr<VideoTrack> remote_video_track_;
174 }; 176 };
175 177
176 } // namespace 178 } // namespace
177 179
178 TEST_F(TrackMediaInfoMapTest, SingleSenderReceiverPerTrackWithOneSsrc) { 180 TEST_F(TrackMediaInfoMapTest, SingleSenderReceiverPerTrackWithOneSsrc) {
179 AddRtpSenderWithSsrcs({ 1 }, local_audio_track_); 181 AddRtpSenderWithSsrcs({1}, local_audio_track_);
180 AddRtpReceiverWithSsrcs({ 2 }, remote_audio_track_); 182 AddRtpReceiverWithSsrcs({2}, remote_audio_track_);
181 AddRtpSenderWithSsrcs({ 3 }, local_video_track_); 183 AddRtpSenderWithSsrcs({3}, local_video_track_);
182 AddRtpReceiverWithSsrcs({ 4 }, remote_video_track_); 184 AddRtpReceiverWithSsrcs({4}, remote_video_track_);
183 CreateMap(); 185 CreateMap();
184 186
185 // Local audio track <-> RTP audio sender 187 // Local audio track <-> RTP audio sender
186 ASSERT_TRUE(map_->GetVoiceSenderInfos(*local_audio_track_)); 188 ASSERT_TRUE(map_->GetVoiceSenderInfos(*local_audio_track_));
187 EXPECT_EQ(*map_->GetVoiceSenderInfos(*local_audio_track_), 189 EXPECT_EQ(
188 std::vector<cricket::VoiceSenderInfo*>({ 190 *map_->GetVoiceSenderInfos(*local_audio_track_),
189 &voice_media_info_->senders[0] })); 191 std::vector<cricket::VoiceSenderInfo*>({&voice_media_info_->senders[0]}));
190 EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[0]), 192 EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[0]),
191 local_audio_track_.get()); 193 local_audio_track_.get());
192 194
193 // Remote audio track <-> RTP audio receiver 195 // Remote audio track <-> RTP audio receiver
194 EXPECT_EQ(map_->GetVoiceReceiverInfo(*remote_audio_track_), 196 EXPECT_EQ(map_->GetVoiceReceiverInfo(*remote_audio_track_),
195 &voice_media_info_->receivers[0]); 197 &voice_media_info_->receivers[0]);
196 EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->receivers[0]), 198 EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->receivers[0]),
197 remote_audio_track_.get()); 199 remote_audio_track_.get());
198 200
199 // Local video track <-> RTP video sender 201 // Local video track <-> RTP video sender
200 ASSERT_TRUE(map_->GetVideoSenderInfos(*local_video_track_)); 202 ASSERT_TRUE(map_->GetVideoSenderInfos(*local_video_track_));
201 EXPECT_EQ(*map_->GetVideoSenderInfos(*local_video_track_), 203 EXPECT_EQ(
202 std::vector<cricket::VideoSenderInfo*>({ 204 *map_->GetVideoSenderInfos(*local_video_track_),
203 &video_media_info_->senders[0] })); 205 std::vector<cricket::VideoSenderInfo*>({&video_media_info_->senders[0]}));
204 EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[0]), 206 EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[0]),
205 local_video_track_.get()); 207 local_video_track_.get());
206 208
207 // Remote video track <-> RTP video receiver 209 // Remote video track <-> RTP video receiver
208 EXPECT_EQ(map_->GetVideoReceiverInfo(*remote_video_track_), 210 EXPECT_EQ(map_->GetVideoReceiverInfo(*remote_video_track_),
209 &video_media_info_->receivers[0]); 211 &video_media_info_->receivers[0]);
210 EXPECT_EQ(map_->GetVideoTrack(video_media_info_->receivers[0]), 212 EXPECT_EQ(map_->GetVideoTrack(video_media_info_->receivers[0]),
211 remote_video_track_.get()); 213 remote_video_track_.get());
212 } 214 }
213 215
214 TEST_F(TrackMediaInfoMapTest, SingleSenderReceiverPerTrackWithMissingSsrc) { 216 TEST_F(TrackMediaInfoMapTest, SingleSenderReceiverPerTrackWithMissingSsrc) {
215 AddRtpSenderWithSsrcs({}, local_audio_track_); 217 AddRtpSenderWithSsrcs({}, local_audio_track_);
216 AddRtpSenderWithSsrcs({}, local_video_track_); 218 AddRtpSenderWithSsrcs({}, local_video_track_);
217 AddRtpReceiverWithSsrcs({}, remote_audio_track_); 219 AddRtpReceiverWithSsrcs({}, remote_audio_track_);
218 AddRtpReceiverWithSsrcs({}, remote_video_track_); 220 AddRtpReceiverWithSsrcs({}, remote_video_track_);
219 CreateMap(); 221 CreateMap();
220 222
221 EXPECT_FALSE(map_->GetVoiceSenderInfos(*local_audio_track_)); 223 EXPECT_FALSE(map_->GetVoiceSenderInfos(*local_audio_track_));
222 EXPECT_FALSE(map_->GetVideoSenderInfos(*local_video_track_)); 224 EXPECT_FALSE(map_->GetVideoSenderInfos(*local_video_track_));
223 EXPECT_FALSE(map_->GetVoiceReceiverInfo(*remote_audio_track_)); 225 EXPECT_FALSE(map_->GetVoiceReceiverInfo(*remote_audio_track_));
224 EXPECT_FALSE(map_->GetVideoReceiverInfo(*remote_video_track_)); 226 EXPECT_FALSE(map_->GetVideoReceiverInfo(*remote_video_track_));
225 } 227 }
226 228
227 TEST_F(TrackMediaInfoMapTest, 229 TEST_F(TrackMediaInfoMapTest,
228 SingleSenderReceiverPerTrackWithAudioAndVideoUseSameSsrc) { 230 SingleSenderReceiverPerTrackWithAudioAndVideoUseSameSsrc) {
229 AddRtpSenderWithSsrcs({ 1 }, local_audio_track_); 231 AddRtpSenderWithSsrcs({1}, local_audio_track_);
230 AddRtpReceiverWithSsrcs({ 2 }, remote_audio_track_); 232 AddRtpReceiverWithSsrcs({2}, remote_audio_track_);
231 AddRtpSenderWithSsrcs({ 1 }, local_video_track_); 233 AddRtpSenderWithSsrcs({1}, local_video_track_);
232 AddRtpReceiverWithSsrcs({ 2 }, remote_video_track_); 234 AddRtpReceiverWithSsrcs({2}, remote_video_track_);
233 CreateMap(); 235 CreateMap();
234 236
235 // Local audio track <-> RTP audio sender 237 // Local audio track <-> RTP audio sender
236 ASSERT_TRUE(map_->GetVoiceSenderInfos(*local_audio_track_)); 238 ASSERT_TRUE(map_->GetVoiceSenderInfos(*local_audio_track_));
237 EXPECT_EQ(*map_->GetVoiceSenderInfos(*local_audio_track_), 239 EXPECT_EQ(
238 std::vector<cricket::VoiceSenderInfo*>({ 240 *map_->GetVoiceSenderInfos(*local_audio_track_),
239 &voice_media_info_->senders[0] })); 241 std::vector<cricket::VoiceSenderInfo*>({&voice_media_info_->senders[0]}));
240 EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[0]), 242 EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[0]),
241 local_audio_track_.get()); 243 local_audio_track_.get());
242 244
243 // Remote audio track <-> RTP audio receiver 245 // Remote audio track <-> RTP audio receiver
244 EXPECT_EQ(map_->GetVoiceReceiverInfo(*remote_audio_track_), 246 EXPECT_EQ(map_->GetVoiceReceiverInfo(*remote_audio_track_),
245 &voice_media_info_->receivers[0]); 247 &voice_media_info_->receivers[0]);
246 EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->receivers[0]), 248 EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->receivers[0]),
247 remote_audio_track_.get()); 249 remote_audio_track_.get());
248 250
249 // Local video track <-> RTP video sender 251 // Local video track <-> RTP video sender
250 ASSERT_TRUE(map_->GetVideoSenderInfos(*local_video_track_)); 252 ASSERT_TRUE(map_->GetVideoSenderInfos(*local_video_track_));
251 EXPECT_EQ(*map_->GetVideoSenderInfos(*local_video_track_), 253 EXPECT_EQ(
252 std::vector<cricket::VideoSenderInfo*>({ 254 *map_->GetVideoSenderInfos(*local_video_track_),
253 &video_media_info_->senders[0] })); 255 std::vector<cricket::VideoSenderInfo*>({&video_media_info_->senders[0]}));
254 EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[0]), 256 EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[0]),
255 local_video_track_.get()); 257 local_video_track_.get());
256 258
257 // Remote video track <-> RTP video receiver 259 // Remote video track <-> RTP video receiver
258 EXPECT_EQ(map_->GetVideoReceiverInfo(*remote_video_track_), 260 EXPECT_EQ(map_->GetVideoReceiverInfo(*remote_video_track_),
259 &video_media_info_->receivers[0]); 261 &video_media_info_->receivers[0]);
260 EXPECT_EQ(map_->GetVideoTrack(video_media_info_->receivers[0]), 262 EXPECT_EQ(map_->GetVideoTrack(video_media_info_->receivers[0]),
261 remote_video_track_.get()); 263 remote_video_track_.get());
262 } 264 }
263 265
264 TEST_F(TrackMediaInfoMapTest, SingleMultiSsrcSenderPerTrack) { 266 TEST_F(TrackMediaInfoMapTest, SingleMultiSsrcSenderPerTrack) {
265 AddRtpSenderWithSsrcs({ 1, 2 }, local_audio_track_); 267 AddRtpSenderWithSsrcs({1, 2}, local_audio_track_);
266 AddRtpSenderWithSsrcs({ 3, 4 }, local_video_track_); 268 AddRtpSenderWithSsrcs({3, 4}, local_video_track_);
267 CreateMap(); 269 CreateMap();
268 270
269 // Local audio track <-> RTP audio senders 271 // Local audio track <-> RTP audio senders
270 ASSERT_TRUE(map_->GetVoiceSenderInfos(*local_audio_track_)); 272 ASSERT_TRUE(map_->GetVoiceSenderInfos(*local_audio_track_));
271 EXPECT_EQ(*map_->GetVoiceSenderInfos(*local_audio_track_), 273 EXPECT_EQ(
272 std::vector<cricket::VoiceSenderInfo*>({ 274 *map_->GetVoiceSenderInfos(*local_audio_track_),
273 &voice_media_info_->senders[0] })); 275 std::vector<cricket::VoiceSenderInfo*>({&voice_media_info_->senders[0]}));
274 EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[0]), 276 EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[0]),
275 local_audio_track_.get()); 277 local_audio_track_.get());
276 278
277 // Local video track <-> RTP video senders 279 // Local video track <-> RTP video senders
278 ASSERT_TRUE(map_->GetVideoSenderInfos(*local_video_track_)); 280 ASSERT_TRUE(map_->GetVideoSenderInfos(*local_video_track_));
279 EXPECT_EQ(*map_->GetVideoSenderInfos(*local_video_track_), 281 EXPECT_EQ(
280 std::vector<cricket::VideoSenderInfo*>({ 282 *map_->GetVideoSenderInfos(*local_video_track_),
281 &video_media_info_->senders[0] })); 283 std::vector<cricket::VideoSenderInfo*>({&video_media_info_->senders[0]}));
282 EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[0]), 284 EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[0]),
283 local_video_track_.get()); 285 local_video_track_.get());
284 } 286 }
285 287
286 TEST_F(TrackMediaInfoMapTest, MultipleOneSsrcSendersPerTrack) { 288 TEST_F(TrackMediaInfoMapTest, MultipleOneSsrcSendersPerTrack) {
287 AddRtpSenderWithSsrcs({ 1 }, local_audio_track_); 289 AddRtpSenderWithSsrcs({1}, local_audio_track_);
288 AddRtpSenderWithSsrcs({ 2 }, local_audio_track_); 290 AddRtpSenderWithSsrcs({2}, local_audio_track_);
289 AddRtpSenderWithSsrcs({ 3 }, local_video_track_); 291 AddRtpSenderWithSsrcs({3}, local_video_track_);
290 AddRtpSenderWithSsrcs({ 4 }, local_video_track_); 292 AddRtpSenderWithSsrcs({4}, local_video_track_);
291 CreateMap(); 293 CreateMap();
292 294
293 // Local audio track <-> RTP audio senders 295 // Local audio track <-> RTP audio senders
294 ASSERT_TRUE(map_->GetVoiceSenderInfos(*local_audio_track_)); 296 ASSERT_TRUE(map_->GetVoiceSenderInfos(*local_audio_track_));
295 EXPECT_EQ(*map_->GetVoiceSenderInfos(*local_audio_track_), 297 EXPECT_EQ(
296 std::vector<cricket::VoiceSenderInfo*>({ 298 *map_->GetVoiceSenderInfos(*local_audio_track_),
297 &voice_media_info_->senders[0], 299 std::vector<cricket::VoiceSenderInfo*>(
298 &voice_media_info_->senders[1] })); 300 {&voice_media_info_->senders[0], &voice_media_info_->senders[1]}));
299 EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[0]), 301 EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[0]),
300 local_audio_track_.get()); 302 local_audio_track_.get());
301 EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[1]), 303 EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[1]),
302 local_audio_track_.get()); 304 local_audio_track_.get());
303 305
304 // Local video track <-> RTP video senders 306 // Local video track <-> RTP video senders
305 ASSERT_TRUE(map_->GetVideoSenderInfos(*local_video_track_)); 307 ASSERT_TRUE(map_->GetVideoSenderInfos(*local_video_track_));
306 EXPECT_EQ(*map_->GetVideoSenderInfos(*local_video_track_), 308 EXPECT_EQ(
307 std::vector<cricket::VideoSenderInfo*>({ 309 *map_->GetVideoSenderInfos(*local_video_track_),
308 &video_media_info_->senders[0], 310 std::vector<cricket::VideoSenderInfo*>(
309 &video_media_info_->senders[1] })); 311 {&video_media_info_->senders[0], &video_media_info_->senders[1]}));
310 EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[0]), 312 EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[0]),
311 local_video_track_.get()); 313 local_video_track_.get());
312 EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[1]), 314 EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[1]),
313 local_video_track_.get()); 315 local_video_track_.get());
314 } 316 }
315 317
316 TEST_F(TrackMediaInfoMapTest, MultipleMultiSsrcSendersPerTrack) { 318 TEST_F(TrackMediaInfoMapTest, MultipleMultiSsrcSendersPerTrack) {
317 AddRtpSenderWithSsrcs({ 1, 2 }, local_audio_track_); 319 AddRtpSenderWithSsrcs({1, 2}, local_audio_track_);
318 AddRtpSenderWithSsrcs({ 3, 4 }, local_audio_track_); 320 AddRtpSenderWithSsrcs({3, 4}, local_audio_track_);
319 AddRtpSenderWithSsrcs({ 5, 6 }, local_video_track_); 321 AddRtpSenderWithSsrcs({5, 6}, local_video_track_);
320 AddRtpSenderWithSsrcs({ 7, 8 }, local_video_track_); 322 AddRtpSenderWithSsrcs({7, 8}, local_video_track_);
321 CreateMap(); 323 CreateMap();
322 324
323 // Local audio track <-> RTP audio senders 325 // Local audio track <-> RTP audio senders
324 ASSERT_TRUE(map_->GetVoiceSenderInfos(*local_audio_track_)); 326 ASSERT_TRUE(map_->GetVoiceSenderInfos(*local_audio_track_));
325 EXPECT_EQ(*map_->GetVoiceSenderInfos(*local_audio_track_), 327 EXPECT_EQ(
326 std::vector<cricket::VoiceSenderInfo*>({ 328 *map_->GetVoiceSenderInfos(*local_audio_track_),
327 &voice_media_info_->senders[0], 329 std::vector<cricket::VoiceSenderInfo*>(
328 &voice_media_info_->senders[1] })); 330 {&voice_media_info_->senders[0], &voice_media_info_->senders[1]}));
329 EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[0]), 331 EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[0]),
330 local_audio_track_.get()); 332 local_audio_track_.get());
331 EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[1]), 333 EXPECT_EQ(map_->GetAudioTrack(voice_media_info_->senders[1]),
332 local_audio_track_.get()); 334 local_audio_track_.get());
333 335
334 // Local video track <-> RTP video senders 336 // Local video track <-> RTP video senders
335 ASSERT_TRUE(map_->GetVideoSenderInfos(*local_video_track_)); 337 ASSERT_TRUE(map_->GetVideoSenderInfos(*local_video_track_));
336 EXPECT_EQ(*map_->GetVideoSenderInfos(*local_video_track_), 338 EXPECT_EQ(
337 std::vector<cricket::VideoSenderInfo*>({ 339 *map_->GetVideoSenderInfos(*local_video_track_),
338 &video_media_info_->senders[0], 340 std::vector<cricket::VideoSenderInfo*>(
339 &video_media_info_->senders[1] })); 341 {&video_media_info_->senders[0], &video_media_info_->senders[1]}));
340 EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[0]), 342 EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[0]),
341 local_video_track_.get()); 343 local_video_track_.get());
342 EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[1]), 344 EXPECT_EQ(map_->GetVideoTrack(video_media_info_->senders[1]),
343 local_video_track_.get()); 345 local_video_track_.get());
344 } 346 }
345 347
346 // Death tests. 348 // Death tests.
347 // Disabled on Android because death tests misbehave on Android, see 349 // Disabled on Android because death tests misbehave on Android, see
348 // base/test/gtest_util.h. 350 // base/test/gtest_util.h.
349 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 351 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
350 352
351 class TrackMediaInfoMapDeathTest : public TrackMediaInfoMapTest { 353 class TrackMediaInfoMapDeathTest : public TrackMediaInfoMapTest {};
352 };
353 354
354 TEST_F(TrackMediaInfoMapDeathTest, MultipleOneSsrcReceiversPerTrack) { 355 TEST_F(TrackMediaInfoMapDeathTest, MultipleOneSsrcReceiversPerTrack) {
355 AddRtpReceiverWithSsrcs({ 1 }, remote_audio_track_); 356 AddRtpReceiverWithSsrcs({1}, remote_audio_track_);
356 AddRtpReceiverWithSsrcs({ 2 }, remote_audio_track_); 357 AddRtpReceiverWithSsrcs({2}, remote_audio_track_);
357 AddRtpReceiverWithSsrcs({ 3 }, remote_video_track_); 358 AddRtpReceiverWithSsrcs({3}, remote_video_track_);
358 AddRtpReceiverWithSsrcs({ 4 }, remote_video_track_); 359 AddRtpReceiverWithSsrcs({4}, remote_video_track_);
359 EXPECT_DEATH(CreateMap(), ""); 360 EXPECT_DEATH(CreateMap(), "");
360 } 361 }
361 362
362 TEST_F(TrackMediaInfoMapDeathTest, MultipleMultiSsrcReceiversPerTrack) { 363 TEST_F(TrackMediaInfoMapDeathTest, MultipleMultiSsrcReceiversPerTrack) {
363 AddRtpReceiverWithSsrcs({ 1, 2 }, remote_audio_track_); 364 AddRtpReceiverWithSsrcs({1, 2}, remote_audio_track_);
364 AddRtpReceiverWithSsrcs({ 3, 4 }, remote_audio_track_); 365 AddRtpReceiverWithSsrcs({3, 4}, remote_audio_track_);
365 AddRtpReceiverWithSsrcs({ 5, 6 }, remote_video_track_); 366 AddRtpReceiverWithSsrcs({5, 6}, remote_video_track_);
366 AddRtpReceiverWithSsrcs({ 7, 8 }, remote_video_track_); 367 AddRtpReceiverWithSsrcs({7, 8}, remote_video_track_);
367 EXPECT_DEATH(CreateMap(), ""); 368 EXPECT_DEATH(CreateMap(), "");
368 } 369 }
369 370
370 TEST_F(TrackMediaInfoMapDeathTest, 371 TEST_F(TrackMediaInfoMapDeathTest,
371 SingleSenderReceiverPerTrackWithSsrcNotUnique) { 372 SingleSenderReceiverPerTrackWithSsrcNotUnique) {
372 AddRtpSenderWithSsrcs({ 1 }, local_audio_track_); 373 AddRtpSenderWithSsrcs({1}, local_audio_track_);
373 AddRtpReceiverWithSsrcs({ 1 }, remote_audio_track_); 374 AddRtpReceiverWithSsrcs({1}, remote_audio_track_);
374 AddRtpSenderWithSsrcs({ 2 }, local_video_track_); 375 AddRtpSenderWithSsrcs({2}, local_video_track_);
375 AddRtpReceiverWithSsrcs({ 2 }, remote_video_track_); 376 AddRtpReceiverWithSsrcs({2}, remote_video_track_);
376 EXPECT_DEATH(CreateMap(), ""); 377 EXPECT_DEATH(CreateMap(), "");
377 } 378 }
378 379
379 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) 380 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
380 381
381 } // namespace webrtc 382 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/pc/trackmediainfomap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698