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

Unified Diff: webrtc/modules/rtp_rtcp/source/rtp_receiver_unittest.cc

Issue 3000713002: Add audio_level member to RtpSource and set it from RtpReceiverImpl::IncomingRtpPacket. (Closed)
Patch Set: Style feedback from deadbeef Created 3 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/rtp_rtcp/source/rtp_receiver_unittest.cc
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_receiver_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_receiver_unittest.cc
index b0531c3c51a820ec7fd361b7653b06f1df00b586..e20d2d52a911d6ad3254830fc684f44ad29ae058 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_receiver_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_receiver_unittest.cc
@@ -255,4 +255,88 @@ TEST_F(RtpReceiverTest, GetSourcesRemoveOutdatedSource) {
csrc_sources.begin()->timestamp_ms());
}
+// The audio level from the RTPHeader extension should be stored in the
+// RtpSource with the matching SSRC.
+TEST_F(RtpReceiverTest, GetSourcesContainsAudioLevelExtension) {
+ RTPHeader header;
+ int64_t time1_ms = fake_clock_.TimeInMilliseconds();
+ header.payloadType = kPcmuPayloadType;
+ header.ssrc = kSsrc1;
+ header.timestamp = rtp_timestamp(time1_ms);
+ header.extension.hasAudioLevel = true;
+ header.extension.audioLevel = 10;
+ PayloadUnion payload_specific = {AudioPayload()};
+
+ EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket(
+ header, kTestPayload, sizeof(kTestPayload), payload_specific, !kInOrder));
+ auto sources = rtp_receiver_->GetSources();
+ EXPECT_THAT(sources, UnorderedElementsAre(RtpSource(
+ time1_ms, kSsrc1, RtpSourceType::SSRC, 10)));
+
+ // Receive a packet from a different SSRC with a different level and check
+ // that they are both remembered.
+ fake_clock_.AdvanceTimeMilliseconds(1);
+ int64_t time2_ms = fake_clock_.TimeInMilliseconds();
+ header.ssrc = kSsrc2;
+ header.timestamp = rtp_timestamp(time2_ms);
+ header.extension.hasAudioLevel = true;
+ header.extension.audioLevel = 20;
+
+ EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket(
+ header, kTestPayload, sizeof(kTestPayload), payload_specific, !kInOrder));
+ sources = rtp_receiver_->GetSources();
+ EXPECT_THAT(sources,
+ UnorderedElementsAre(
+ RtpSource(time1_ms, kSsrc1, RtpSourceType::SSRC, 10),
+ RtpSource(time2_ms, kSsrc2, RtpSourceType::SSRC, 20)));
+
+ // Receive a packet from the first SSRC again and check that the level is
+ // updated.
+ fake_clock_.AdvanceTimeMilliseconds(1);
+ int64_t time3_ms = fake_clock_.TimeInMilliseconds();
+ header.ssrc = kSsrc1;
+ header.timestamp = rtp_timestamp(time3_ms);
+ header.extension.hasAudioLevel = true;
+ header.extension.audioLevel = 30;
+
+ EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket(
+ header, kTestPayload, sizeof(kTestPayload), payload_specific, !kInOrder));
+ sources = rtp_receiver_->GetSources();
+ EXPECT_THAT(sources,
+ UnorderedElementsAre(
+ RtpSource(time3_ms, kSsrc1, RtpSourceType::SSRC, 30),
+ RtpSource(time2_ms, kSsrc2, RtpSourceType::SSRC, 20)));
+}
+
+TEST_F(RtpReceiverTest,
+ MissingAudioLevelHeaderExtensionClearsRtpSourceAudioLevel) {
+ RTPHeader header;
+ int64_t time1_ms = fake_clock_.TimeInMilliseconds();
+ header.payloadType = kPcmuPayloadType;
+ header.ssrc = kSsrc1;
+ header.timestamp = rtp_timestamp(time1_ms);
+ header.extension.hasAudioLevel = true;
+ header.extension.audioLevel = 10;
+ PayloadUnion payload_specific = {AudioPayload()};
+
+ EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket(
+ header, kTestPayload, sizeof(kTestPayload), payload_specific, !kInOrder));
+ auto sources = rtp_receiver_->GetSources();
+ EXPECT_THAT(sources, UnorderedElementsAre(RtpSource(
+ time1_ms, kSsrc1, RtpSourceType::SSRC, 10)));
+
+ // Receive a second packet without the audio level header extension and check
+ // that the audio level is cleared.
+ fake_clock_.AdvanceTimeMilliseconds(1);
+ int64_t time2_ms = fake_clock_.TimeInMilliseconds();
+ header.timestamp = rtp_timestamp(time2_ms);
+ header.extension.hasAudioLevel = false;
+
+ EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket(
+ header, kTestPayload, sizeof(kTestPayload), payload_specific, !kInOrder));
+ sources = rtp_receiver_->GetSources();
+ EXPECT_THAT(sources, UnorderedElementsAre(
+ RtpSource(time2_ms, kSsrc1, RtpSourceType::SSRC)));
+}
+
} // namespace webrtc
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698