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. |
| 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 |
| 276 // Receive a packet from a different SSRC with a different level and check |
| 277 // that they are both remembered. |
| 278 fake_clock_.AdvanceTimeMilliseconds(1); |
| 279 int64_t time2_ms = fake_clock_.TimeInMilliseconds(); |
| 280 header.ssrc = kSsrc2; |
| 281 header.timestamp = rtp_timestamp(time2_ms); |
| 282 header.extension.hasAudioLevel = true; |
| 283 header.extension.audioLevel = 20; |
| 284 |
| 285 EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket( |
| 286 header, kTestPayload, sizeof(kTestPayload), payload_specific, !kInOrder)); |
| 287 sources = rtp_receiver_->GetSources(); |
| 288 EXPECT_THAT(sources, |
| 289 UnorderedElementsAre( |
| 290 RtpSource(time1_ms, kSsrc1, RtpSourceType::SSRC, 10), |
| 291 RtpSource(time2_ms, kSsrc2, RtpSourceType::SSRC, 20))); |
| 292 |
| 293 // Receive a packet from the first SSRC again and check that the level is |
| 294 // updated. |
| 295 fake_clock_.AdvanceTimeMilliseconds(1); |
| 296 int64_t time3_ms = fake_clock_.TimeInMilliseconds(); |
| 297 header.ssrc = kSsrc1; |
| 298 header.timestamp = rtp_timestamp(time3_ms); |
| 299 header.extension.hasAudioLevel = true; |
| 300 header.extension.audioLevel = 30; |
| 301 |
| 302 EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket( |
| 303 header, kTestPayload, sizeof(kTestPayload), payload_specific, !kInOrder)); |
| 304 sources = rtp_receiver_->GetSources(); |
| 305 EXPECT_THAT(sources, |
| 306 UnorderedElementsAre( |
| 307 RtpSource(time3_ms, kSsrc1, RtpSourceType::SSRC, 30), |
| 308 RtpSource(time2_ms, kSsrc2, RtpSourceType::SSRC, 20))); |
| 309 } |
| 310 |
| 311 TEST_F(RtpReceiverTest, |
| 312 MissingAudioLevelHeaderExtensionClearsRtpSourceAudioLevel) { |
| 313 RTPHeader header; |
| 314 int64_t time1_ms = fake_clock_.TimeInMilliseconds(); |
| 315 header.payloadType = kPcmuPayloadType; |
| 316 header.ssrc = kSsrc1; |
| 317 header.timestamp = rtp_timestamp(time1_ms); |
| 318 header.extension.hasAudioLevel = true; |
| 319 header.extension.audioLevel = 10; |
| 320 PayloadUnion payload_specific = {AudioPayload()}; |
| 321 |
| 322 EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket( |
| 323 header, kTestPayload, sizeof(kTestPayload), payload_specific, !kInOrder)); |
| 324 auto sources = rtp_receiver_->GetSources(); |
| 325 EXPECT_THAT(sources, UnorderedElementsAre(RtpSource( |
| 326 time1_ms, kSsrc1, RtpSourceType::SSRC, 10))); |
| 327 |
| 328 // Receive a second packet without the audio level header extension and check |
| 329 // that the audio level is cleared. |
| 330 fake_clock_.AdvanceTimeMilliseconds(1); |
| 331 int64_t time2_ms = fake_clock_.TimeInMilliseconds(); |
| 332 header.timestamp = rtp_timestamp(time2_ms); |
| 333 header.extension.hasAudioLevel = false; |
| 334 |
| 335 EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket( |
| 336 header, kTestPayload, sizeof(kTestPayload), payload_specific, !kInOrder)); |
| 337 sources = rtp_receiver_->GetSources(); |
| 338 EXPECT_THAT(sources, UnorderedElementsAre( |
| 339 RtpSource(time2_ms, kSsrc1, RtpSourceType::SSRC))); |
| 340 } |
| 341 |
258 } // namespace webrtc | 342 } // namespace webrtc |
OLD | NEW |