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

Unified Diff: webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc

Issue 1853183002: Change NetEq::GetPlayoutTimestamp to return an rtc::Optional<uint32_t> (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing Minyue's comments Created 4 years, 8 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/audio_coding/neteq/neteq_impl_unittest.cc
diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc
index e1eb403022cecac01aec1273864568f3208d3438..2fd52982469832900762178d2067f1d5157752ac 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc
@@ -478,11 +478,9 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) {
// The value of the last of the output samples is the same as the number of
// samples played from the decoded packet. Thus, this number + the RTP
// timestamp should match the playout timestamp.
- uint32_t timestamp = 0;
- EXPECT_TRUE(neteq_->GetPlayoutTimestamp(&timestamp));
EXPECT_EQ(rtp_header.header.timestamp +
output.data_[output.samples_per_channel_ - 1],
- timestamp);
+ *neteq_->GetPlayoutTimestamp());
kwiberg-webrtc 2016/04/05 14:04:02 IIRC, Optional::operator* does a DCHECK, not a CHE
hlundin-webrtc 2016/04/05 14:19:44 Done.
// Check the timestamp for the last value in the sync buffer. This should
// be one full frame length ahead of the RTP timestamp.
@@ -714,8 +712,6 @@ TEST_F(NetEqImplTest, CodecInternalCng) {
const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateKhz);
AudioFrame output;
- uint32_t timestamp;
- uint32_t last_timestamp;
AudioFrame::SpeechType expected_type[8] = {
AudioFrame::kNormalSpeech, AudioFrame::kNormalSpeech,
AudioFrame::kCNG, AudioFrame::kCNG,
@@ -731,16 +727,19 @@ TEST_F(NetEqImplTest, CodecInternalCng) {
};
EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output));
- EXPECT_TRUE(neteq_->GetPlayoutTimestamp(&last_timestamp));
+ rtc::Optional<uint32_t> last_timestamp = neteq_->GetPlayoutTimestamp();
+ EXPECT_TRUE(last_timestamp);
for (size_t i = 1; i < 6; ++i) {
ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_);
EXPECT_EQ(1u, output.num_channels_);
EXPECT_EQ(expected_type[i - 1], output.speech_type_);
- EXPECT_TRUE(neteq_->GetPlayoutTimestamp(&timestamp));
+ rtc::Optional<uint32_t> timestamp = neteq_->GetPlayoutTimestamp();
+ EXPECT_TRUE(timestamp);
EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output));
- EXPECT_TRUE(neteq_->GetPlayoutTimestamp(&timestamp));
- EXPECT_EQ(timestamp, last_timestamp + expected_timestamp_increment[i]);
+ timestamp = neteq_->GetPlayoutTimestamp();
+ EXPECT_TRUE(timestamp);
+ EXPECT_EQ(*timestamp, *last_timestamp + expected_timestamp_increment[i]);
kwiberg-webrtc 2016/04/05 14:04:02 To avoid dereferencing invalid Optionals (which wi
hlundin-webrtc 2016/04/05 14:19:45 Yes, I learned that the hard way in the next CL af
last_timestamp = timestamp;
}
@@ -756,8 +755,9 @@ TEST_F(NetEqImplTest, CodecInternalCng) {
EXPECT_EQ(1u, output.num_channels_);
EXPECT_EQ(expected_type[i - 1], output.speech_type_);
EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output));
- EXPECT_TRUE(neteq_->GetPlayoutTimestamp(&timestamp));
- EXPECT_EQ(timestamp, last_timestamp + expected_timestamp_increment[i]);
+ rtc::Optional<uint32_t> timestamp = neteq_->GetPlayoutTimestamp();
+ EXPECT_TRUE(timestamp);
+ EXPECT_EQ(*timestamp, *last_timestamp + expected_timestamp_increment[i]);
last_timestamp = timestamp;
}

Powered by Google App Engine
This is Rietveld 408576698