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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc

Issue 1750533002: Replace scoped_ptr with unique_ptr in webrtc/modules/remote_bitrate_estimator/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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
11 #include "webrtc/modules/remote_bitrate_estimator/test/estimators/nada.h" 11 #include "webrtc/modules/remote_bitrate_estimator/test/estimators/nada.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <memory>
14 #include <numeric> 15 #include <numeric>
15 16
16 #include "webrtc/base/arraysize.h" 17 #include "webrtc/base/arraysize.h"
17 #include "webrtc/base/common.h" 18 #include "webrtc/base/common.h"
18 #include "webrtc/base/scoped_ptr.h"
19 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h" 19 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h"
20 #include "webrtc/modules/remote_bitrate_estimator/test/packet.h" 20 #include "webrtc/modules/remote_bitrate_estimator/test/packet.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 #include "webrtc/base/constructormagic.h" 22 #include "webrtc/base/constructormagic.h"
23 #include "webrtc/modules/remote_bitrate_estimator/test/packet_sender.h" 23 #include "webrtc/modules/remote_bitrate_estimator/test/packet_sender.h"
24 #include "webrtc/test/testsupport/fileutils.h" 24 #include "webrtc/test/testsupport/fileutils.h"
25 25
26 namespace webrtc { 26 namespace webrtc {
27 namespace testing { 27 namespace testing {
28 namespace bwe { 28 namespace bwe {
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 307
308 for (int i = 0; i < 100; ++i) { 308 for (int i = 0; i < 100; ++i) {
309 int previous_bitrate = nada_sender_.bitrate_kbps(); 309 int previous_bitrate = nada_sender_.bitrate_kbps();
310 nada_sender_.GiveFeedback(not_congested_fb); 310 nada_sender_.GiveFeedback(not_congested_fb);
311 EXPECT_GE(nada_sender_.bitrate_kbps(), previous_bitrate); 311 EXPECT_GE(nada_sender_.bitrate_kbps(), previous_bitrate);
312 } 312 }
313 EXPECT_EQ(nada_sender_.bitrate_kbps(), kMaxBitrateKbps); 313 EXPECT_EQ(nada_sender_.bitrate_kbps(), kMaxBitrateKbps);
314 } 314 }
315 315
316 TEST_F(NadaReceiverSideTest, FeedbackInitialCases) { 316 TEST_F(NadaReceiverSideTest, FeedbackInitialCases) {
317 rtc::scoped_ptr<NadaFeedback> nada_feedback( 317 std::unique_ptr<NadaFeedback> nada_feedback(
318 static_cast<NadaFeedback*>(nada_receiver_.GetFeedback(0))); 318 static_cast<NadaFeedback*>(nada_receiver_.GetFeedback(0)));
319 EXPECT_EQ(nada_feedback, nullptr); 319 EXPECT_EQ(nada_feedback, nullptr);
320 320
321 nada_feedback.reset( 321 nada_feedback.reset(
322 static_cast<NadaFeedback*>(nada_receiver_.GetFeedback(100))); 322 static_cast<NadaFeedback*>(nada_receiver_.GetFeedback(100)));
323 EXPECT_EQ(nada_feedback->exp_smoothed_delay_ms(), -1); 323 EXPECT_EQ(nada_feedback->exp_smoothed_delay_ms(), -1);
324 EXPECT_EQ(nada_feedback->est_queuing_delay_signal_ms(), 0L); 324 EXPECT_EQ(nada_feedback->est_queuing_delay_signal_ms(), 0L);
325 EXPECT_EQ(nada_feedback->congestion_signal(), 0L); 325 EXPECT_EQ(nada_feedback->congestion_signal(), 0L);
326 EXPECT_EQ(nada_feedback->derivative(), 0.0f); 326 EXPECT_EQ(nada_feedback->derivative(), 0.0f);
327 EXPECT_EQ(nada_feedback->receiving_rate(), 0.0f); 327 EXPECT_EQ(nada_feedback->receiving_rate(), 0.0f);
328 } 328 }
329 329
330 TEST_F(NadaReceiverSideTest, FeedbackEmptyQueues) { 330 TEST_F(NadaReceiverSideTest, FeedbackEmptyQueues) {
331 const int64_t kTimeGapMs = 50; // Between each packet. 331 const int64_t kTimeGapMs = 50; // Between each packet.
332 const int64_t kOneWayDelayMs = 50; 332 const int64_t kOneWayDelayMs = 50;
333 333
334 // No added latency, delay = kOneWayDelayMs. 334 // No added latency, delay = kOneWayDelayMs.
335 for (int i = 1; i < 10; ++i) { 335 for (int i = 1; i < 10; ++i) {
336 int64_t send_time_us = i * kTimeGapMs * 1000; 336 int64_t send_time_us = i * kTimeGapMs * 1000;
337 int64_t arrival_time_ms = send_time_us / 1000 + kOneWayDelayMs; 337 int64_t arrival_time_ms = send_time_us / 1000 + kOneWayDelayMs;
338 uint16_t sequence_number = static_cast<uint16_t>(i); 338 uint16_t sequence_number = static_cast<uint16_t>(i);
339 // Payload sizes are not important here. 339 // Payload sizes are not important here.
340 const MediaPacket media_packet(kFlowId, send_time_us, 0, sequence_number); 340 const MediaPacket media_packet(kFlowId, send_time_us, 0, sequence_number);
341 nada_receiver_.ReceivePacket(arrival_time_ms, media_packet); 341 nada_receiver_.ReceivePacket(arrival_time_ms, media_packet);
342 } 342 }
343 343
344 // Baseline delay will be equal kOneWayDelayMs. 344 // Baseline delay will be equal kOneWayDelayMs.
345 rtc::scoped_ptr<NadaFeedback> nada_feedback( 345 std::unique_ptr<NadaFeedback> nada_feedback(
346 static_cast<NadaFeedback*>(nada_receiver_.GetFeedback(500))); 346 static_cast<NadaFeedback*>(nada_receiver_.GetFeedback(500)));
347 EXPECT_EQ(nada_feedback->exp_smoothed_delay_ms(), 0L); 347 EXPECT_EQ(nada_feedback->exp_smoothed_delay_ms(), 0L);
348 EXPECT_EQ(nada_feedback->est_queuing_delay_signal_ms(), 0L); 348 EXPECT_EQ(nada_feedback->est_queuing_delay_signal_ms(), 0L);
349 EXPECT_EQ(nada_feedback->congestion_signal(), 0L); 349 EXPECT_EQ(nada_feedback->congestion_signal(), 0L);
350 EXPECT_EQ(nada_feedback->derivative(), 0.0f); 350 EXPECT_EQ(nada_feedback->derivative(), 0.0f);
351 } 351 }
352 352
353 TEST_F(NadaReceiverSideTest, FeedbackIncreasingDelay) { 353 TEST_F(NadaReceiverSideTest, FeedbackIncreasingDelay) {
354 // Since packets are 100ms apart, each one corresponds to a feedback. 354 // Since packets are 100ms apart, each one corresponds to a feedback.
355 const int64_t kTimeGapMs = 100; // Between each packet. 355 const int64_t kTimeGapMs = 100; // Between each packet.
(...skipping 15 matching lines...) Expand all
371 } 371 }
372 372
373 for (int i = 0; i < kNumPackets; ++i) { 373 for (int i = 0; i < kNumPackets; ++i) {
374 int64_t send_time_us = (i + 1) * kTimeGapMs * 1000; 374 int64_t send_time_us = (i + 1) * kTimeGapMs * 1000;
375 int64_t arrival_time_ms = send_time_us / 1000 + 10 * (i + 1); 375 int64_t arrival_time_ms = send_time_us / 1000 + 10 * (i + 1);
376 uint16_t sequence_number = static_cast<uint16_t>(i + 1); 376 uint16_t sequence_number = static_cast<uint16_t>(i + 1);
377 // Payload sizes are not important here. 377 // Payload sizes are not important here.
378 const MediaPacket media_packet(kFlowId, send_time_us, 0, sequence_number); 378 const MediaPacket media_packet(kFlowId, send_time_us, 0, sequence_number);
379 nada_receiver_.ReceivePacket(arrival_time_ms, media_packet); 379 nada_receiver_.ReceivePacket(arrival_time_ms, media_packet);
380 380
381 rtc::scoped_ptr<NadaFeedback> nada_feedback(static_cast<NadaFeedback*>( 381 std::unique_ptr<NadaFeedback> nada_feedback(static_cast<NadaFeedback*>(
382 nada_receiver_.GetFeedback(arrival_time_ms))); 382 nada_receiver_.GetFeedback(arrival_time_ms)));
383 EXPECT_EQ(nada_feedback->exp_smoothed_delay_ms(), 383 EXPECT_EQ(nada_feedback->exp_smoothed_delay_ms(),
384 exp_smoothed_delays_ms[i]); 384 exp_smoothed_delays_ms[i]);
385 // Since delay signals are lower than 50ms, they will not be non-linearly 385 // Since delay signals are lower than 50ms, they will not be non-linearly
386 // warped. 386 // warped.
387 EXPECT_EQ(nada_feedback->est_queuing_delay_signal_ms(), 387 EXPECT_EQ(nada_feedback->est_queuing_delay_signal_ms(),
388 exp_smoothed_delays_ms[i]); 388 exp_smoothed_delays_ms[i]);
389 // Zero loss, congestion signal = queuing_delay 389 // Zero loss, congestion signal = queuing_delay
390 EXPECT_EQ(nada_feedback->congestion_signal(), exp_smoothed_delays_ms[i]); 390 EXPECT_EQ(nada_feedback->congestion_signal(), exp_smoothed_delays_ms[i]);
391 if (i == 0) { 391 if (i == 0) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 } 440 }
441 441
442 for (int i = 0; i < kNumPackets; ++i) { 442 for (int i = 0; i < kNumPackets; ++i) {
443 int64_t send_time_us = (i + 1) * kTimeGapMs * 1000; 443 int64_t send_time_us = (i + 1) * kTimeGapMs * 1000;
444 int64_t arrival_time_ms = send_time_us / 1000 + 50 + 200 * i; 444 int64_t arrival_time_ms = send_time_us / 1000 + 50 + 200 * i;
445 uint16_t sequence_number = static_cast<uint16_t>(i + 1); 445 uint16_t sequence_number = static_cast<uint16_t>(i + 1);
446 // Payload sizes are not important here. 446 // Payload sizes are not important here.
447 const MediaPacket media_packet(kFlowId, send_time_us, 0, sequence_number); 447 const MediaPacket media_packet(kFlowId, send_time_us, 0, sequence_number);
448 nada_receiver_.ReceivePacket(arrival_time_ms, media_packet); 448 nada_receiver_.ReceivePacket(arrival_time_ms, media_packet);
449 449
450 rtc::scoped_ptr<NadaFeedback> nada_feedback(static_cast<NadaFeedback*>( 450 std::unique_ptr<NadaFeedback> nada_feedback(static_cast<NadaFeedback*>(
451 nada_receiver_.GetFeedback(arrival_time_ms))); 451 nada_receiver_.GetFeedback(arrival_time_ms)));
452 EXPECT_EQ(nada_feedback->exp_smoothed_delay_ms(), 452 EXPECT_EQ(nada_feedback->exp_smoothed_delay_ms(),
453 exp_smoothed_delays_ms[i]); 453 exp_smoothed_delays_ms[i]);
454 // Delays can be non-linearly warped. 454 // Delays can be non-linearly warped.
455 EXPECT_EQ(nada_feedback->est_queuing_delay_signal_ms(), 455 EXPECT_EQ(nada_feedback->est_queuing_delay_signal_ms(),
456 Warp(exp_smoothed_delays_ms[i])); 456 Warp(exp_smoothed_delays_ms[i]));
457 // Zero loss, congestion signal = queuing_delay 457 // Zero loss, congestion signal = queuing_delay
458 EXPECT_EQ(nada_feedback->congestion_signal(), 458 EXPECT_EQ(nada_feedback->congestion_signal(),
459 Warp(exp_smoothed_delays_ms[i])); 459 Warp(exp_smoothed_delays_ms[i]));
460 } 460 }
(...skipping 26 matching lines...) Expand all
487 for (int i = 1; i < kNumElements; ++i) { 487 for (int i = 1; i < kNumElements; ++i) {
488 EXPECT_EQ( 488 EXPECT_EQ(
489 exp_smoothed[i], 489 exp_smoothed[i],
490 static_cast<int64_t>(exp_smoothed[i - 1] * (1.0f - kAlpha) + 0.5f)); 490 static_cast<int64_t>(exp_smoothed[i - 1] * (1.0f - kAlpha) + 0.5f));
491 } 491 }
492 } 492 }
493 493
494 } // namespace bwe 494 } // namespace bwe
495 } // namespace testing 495 } // namespace testing
496 } // namespace webrtc 496 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698