OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 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 |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 ssrc_sources.begin()->timestamp_ms()); | 248 ssrc_sources.begin()->timestamp_ms()); |
249 | 249 |
250 auto csrc_sources = rtp_receiver_impl->csrc_sources_for_testing(); | 250 auto csrc_sources = rtp_receiver_impl->csrc_sources_for_testing(); |
251 ASSERT_EQ(1u, csrc_sources.size()); | 251 ASSERT_EQ(1u, csrc_sources.size()); |
252 EXPECT_EQ(kCsrc1, csrc_sources.begin()->source_id()); | 252 EXPECT_EQ(kCsrc1, csrc_sources.begin()->source_id()); |
253 EXPECT_EQ(RtpSourceType::CSRC, csrc_sources.begin()->source_type()); | 253 EXPECT_EQ(RtpSourceType::CSRC, csrc_sources.begin()->source_type()); |
254 EXPECT_EQ(fake_clock_.TimeInMilliseconds(), | 254 EXPECT_EQ(fake_clock_.TimeInMilliseconds(), |
255 csrc_sources.begin()->timestamp_ms()); | 255 csrc_sources.begin()->timestamp_ms()); |
256 } | 256 } |
257 | 257 |
258 // The audio level from the RTPHeader extension should be stored in the | |
259 // RTPSource with the matching SSRC. | |
Taylor Brandstetter
2017/08/24 20:40:57
nit: RtpSource
Zach Stein
2017/08/24 21:14:53
Done.
| |
260 TEST_F(RtpReceiverTest, GetSourcesContainsAudioLevelExtension) { | |
261 RTPHeader header; | |
262 int64_t time1_ms = fake_clock_.TimeInMilliseconds(); | |
263 header.payloadType = kPcmuPayloadType; | |
264 header.ssrc = kSsrc1; | |
265 header.timestamp = rtp_timestamp(time1_ms); | |
266 header.extension.hasAudioLevel = true; | |
267 header.extension.audioLevel = 10; | |
268 PayloadUnion payload_specific = {AudioPayload()}; | |
269 | |
270 EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket( | |
271 header, kTestPayload, sizeof(kTestPayload), payload_specific, !kInOrder)); | |
272 auto sources = rtp_receiver_->GetSources(); | |
273 EXPECT_THAT(sources, UnorderedElementsAre(RtpSource( | |
274 time1_ms, kSsrc1, RtpSourceType::SSRC, 10))); | |
275 | |
Taylor Brandstetter
2017/08/24 20:40:57
May help to have some comments for the different s
Zach Stein
2017/08/24 21:14:53
Done.
| |
276 fake_clock_.AdvanceTimeMilliseconds(1); | |
277 int64_t time2_ms = fake_clock_.TimeInMilliseconds(); | |
278 header.ssrc = kSsrc2; | |
279 header.timestamp = rtp_timestamp(time2_ms); | |
280 header.extension.hasAudioLevel = true; | |
281 header.extension.audioLevel = 20; | |
282 | |
283 EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket( | |
284 header, kTestPayload, sizeof(kTestPayload), payload_specific, !kInOrder)); | |
285 sources = rtp_receiver_->GetSources(); | |
286 EXPECT_THAT(sources, | |
287 UnorderedElementsAre( | |
288 RtpSource(time1_ms, kSsrc1, RtpSourceType::SSRC, 10), | |
289 RtpSource(time2_ms, kSsrc2, RtpSourceType::SSRC, 20))); | |
290 | |
291 fake_clock_.AdvanceTimeMilliseconds(1); | |
292 int64_t time3_ms = fake_clock_.TimeInMilliseconds(); | |
293 header.ssrc = kSsrc1; | |
294 header.timestamp = rtp_timestamp(time3_ms); | |
295 header.extension.hasAudioLevel = true; | |
296 header.extension.audioLevel = 30; | |
297 | |
298 EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket( | |
299 header, kTestPayload, sizeof(kTestPayload), payload_specific, !kInOrder)); | |
300 sources = rtp_receiver_->GetSources(); | |
301 EXPECT_THAT(sources, | |
302 UnorderedElementsAre( | |
303 RtpSource(time3_ms, kSsrc1, RtpSourceType::SSRC, 30), | |
304 RtpSource(time2_ms, kSsrc2, RtpSourceType::SSRC, 20))); | |
305 } | |
306 | |
307 TEST_F(RtpReceiverTest, | |
308 MissingAudioLevelHeaderExtensionClearsRtpSourceAudioLevel) { | |
309 RTPHeader header; | |
310 int64_t time1_ms = fake_clock_.TimeInMilliseconds(); | |
311 header.payloadType = kPcmuPayloadType; | |
312 header.ssrc = kSsrc1; | |
313 header.timestamp = rtp_timestamp(time1_ms); | |
314 header.extension.hasAudioLevel = true; | |
315 header.extension.audioLevel = 10; | |
316 PayloadUnion payload_specific = {AudioPayload()}; | |
317 | |
318 EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket( | |
319 header, kTestPayload, sizeof(kTestPayload), payload_specific, !kInOrder)); | |
320 auto sources = rtp_receiver_->GetSources(); | |
321 EXPECT_THAT(sources, UnorderedElementsAre(RtpSource( | |
322 time1_ms, kSsrc1, RtpSourceType::SSRC, 10))); | |
323 | |
324 fake_clock_.AdvanceTimeMilliseconds(1); | |
325 int64_t time2_ms = fake_clock_.TimeInMilliseconds(); | |
326 header.timestamp = rtp_timestamp(time2_ms); | |
327 header.extension.hasAudioLevel = false; | |
328 | |
329 EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket( | |
330 header, kTestPayload, sizeof(kTestPayload), payload_specific, !kInOrder)); | |
331 sources = rtp_receiver_->GetSources(); | |
332 EXPECT_THAT(sources, UnorderedElementsAre( | |
333 RtpSource(time2_ms, kSsrc1, RtpSourceType::SSRC))); | |
334 } | |
Taylor Brandstetter
2017/08/24 20:40:57
Good tests!
| |
335 | |
258 } // namespace webrtc | 336 } // namespace webrtc |
OLD | NEW |