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

Side by Side Diff: webrtc/video/video_send_stream_tests.cc

Issue 2984283002: Simplify FakeReceiveStatistics in video send stream tests (Closed)
Patch Set: add a test check 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 #include <algorithm> // max 10 #include <algorithm> // max
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } 367 }
368 368
369 void PerformTest() override { 369 void PerformTest() override {
370 EXPECT_TRUE(Wait()) << "Timed out while waiting for timing frames."; 370 EXPECT_TRUE(Wait()) << "Timed out while waiting for timing frames.";
371 } 371 }
372 } test; 372 } test;
373 373
374 RunBaseTest(&test); 374 RunBaseTest(&test);
375 } 375 }
376 376
377 class FakeReceiveStatistics : public NullReceiveStatistics { 377 class FakeReceiveStatistics : public ReceiveStatisticsProvider {
378 public: 378 public:
379 FakeReceiveStatistics(uint32_t send_ssrc, 379 FakeReceiveStatistics(uint32_t send_ssrc,
380 uint32_t last_sequence_number, 380 uint32_t last_sequence_number,
381 uint32_t cumulative_lost, 381 uint32_t cumulative_lost,
382 uint8_t fraction_lost) 382 uint8_t fraction_lost) {
383 : lossy_stats_(new LossyStatistician(last_sequence_number, 383 stat_.SetMediaSsrc(send_ssrc);
384 cumulative_lost, 384 stat_.SetExtHighestSeqNum(last_sequence_number);
385 fraction_lost)) { 385 stat_.SetCumulativeLost(cumulative_lost);
386 stats_map_[send_ssrc] = lossy_stats_.get(); 386 stat_.SetFractionLost(fraction_lost);
387 } 387 }
388 388
389 StatisticianMap GetActiveStatisticians() const override { return stats_map_; } 389 std::vector<rtcp::ReportBlock> RtcpReportBlocks(size_t max_blocks) override {
390 390 EXPECT_GE(max_blocks, 1u);
391 StreamStatistician* GetStatistician(uint32_t ssrc) const override { 391 return {stat_};
392 return lossy_stats_.get();
393 } 392 }
394 393
395 private: 394 private:
396 class LossyStatistician : public StreamStatistician { 395 rtcp::ReportBlock stat_;
397 public:
398 LossyStatistician(uint32_t extended_max_sequence_number,
399 uint32_t cumulative_lost,
400 uint8_t fraction_lost) {
401 stats_.fraction_lost = fraction_lost;
402 stats_.cumulative_lost = cumulative_lost;
403 stats_.extended_max_sequence_number = extended_max_sequence_number;
404 }
405 bool GetStatistics(RtcpStatistics* statistics, bool reset) override {
406 *statistics = stats_;
407 return true;
408 }
409 void GetDataCounters(size_t* bytes_received,
410 uint32_t* packets_received) const override {
411 *bytes_received = 0;
412 *packets_received = 0;
413 }
414 void GetReceiveStreamDataCounters(
415 StreamDataCounters* data_counters) const override {}
416 uint32_t BitrateReceived() const override { return 0; }
417 bool IsRetransmitOfOldPacket(const RTPHeader& header,
418 int64_t min_rtt) const override {
419 return false;
420 }
421
422 bool IsPacketInOrder(uint16_t sequence_number) const override {
423 return true;
424 }
425
426 RtcpStatistics stats_;
427 };
428
429 std::unique_ptr<LossyStatistician> lossy_stats_;
430 StatisticianMap stats_map_;
431 }; 396 };
432 397
433 class UlpfecObserver : public test::EndToEndTest { 398 class UlpfecObserver : public test::EndToEndTest {
434 public: 399 public:
435 UlpfecObserver(bool header_extensions_enabled, 400 UlpfecObserver(bool header_extensions_enabled,
436 bool use_nack, 401 bool use_nack,
437 bool expect_red, 402 bool expect_red,
438 bool expect_ulpfec, 403 bool expect_ulpfec,
439 const std::string& codec, 404 const std::string& codec,
440 VideoEncoder* encoder) 405 VideoEncoder* encoder)
(...skipping 3007 matching lines...) Expand 10 before | Expand all | Expand 10 after
3448 capturer_ = frame_generator_capturer; 3413 capturer_ = frame_generator_capturer;
3449 } 3414 }
3450 3415
3451 test::FrameGeneratorCapturer* capturer_ = nullptr; 3416 test::FrameGeneratorCapturer* capturer_ = nullptr;
3452 } test; 3417 } test;
3453 3418
3454 RunBaseTest(&test); 3419 RunBaseTest(&test);
3455 } 3420 }
3456 3421
3457 } // namespace webrtc 3422 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698