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

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: 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
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..7a3bd449e776a1ad8817e924a8ee3da37d5a8c79 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_receiver_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_receiver_unittest.cc
@@ -255,4 +255,54 @@ 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(
danilchap 2017/08/15 08:18:29 ASSERT_THAT otherwise next line might crash if thi
Zach Stein 2017/08/15 21:44:59 The following line is actually redundant with this
+ time1_ms, kSsrc1, RtpSourceType::SSRC, 10)));
+ ASSERT_EQ(rtc::Optional<uint8_t>(10), sources.begin()->audio_level());
danilchap 2017/08/15 08:18:29 there is a compare operator between optional<T> an
Zach Stein 2017/08/15 21:44:59 Acknowledged.
+
+ 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)));
+
+ 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)));
+}
+
danilchap 2017/08/15 08:18:29 may be add a test that absent of audio level exten
Zach Stein 2017/08/15 21:44:59 Done.
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698