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

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

Issue 2061423003: Refactor NACK bitrate allocation (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed nit Created 4 years, 5 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 | « webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc ('k') | webrtc/video/payload_router.h » ('j') | 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> 10 #include <algorithm>
11 #include <list> 11 #include <list>
12 #include <map> 12 #include <map>
13 #include <memory> 13 #include <memory>
14 #include <sstream> 14 #include <sstream>
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 #include "webrtc/base/checks.h" 20 #include "webrtc/base/checks.h"
21 #include "webrtc/base/event.h" 21 #include "webrtc/base/event.h"
22 #include "webrtc/call.h" 22 #include "webrtc/call.h"
23 #include "webrtc/call/transport_adapter.h" 23 #include "webrtc/call/transport_adapter.h"
24 #include "webrtc/common_video/include/frame_callback.h" 24 #include "webrtc/common_video/include/frame_callback.h"
25 #include "webrtc/modules/include/module_common_types.h" 25 #include "webrtc/modules/include/module_common_types.h"
26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
27 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 27 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
28 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" 28 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
29 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
29 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" 30 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
30 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" 31 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
31 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" 32 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
32 #include "webrtc/modules/video_coding/include/video_coding_defines.h" 33 #include "webrtc/modules/video_coding/include/video_coding_defines.h"
33 #include "webrtc/system_wrappers/include/metrics.h" 34 #include "webrtc/system_wrappers/include/metrics.h"
34 #include "webrtc/system_wrappers/include/metrics_default.h" 35 #include "webrtc/system_wrappers/include/metrics_default.h"
35 #include "webrtc/system_wrappers/include/sleep.h" 36 #include "webrtc/system_wrappers/include/sleep.h"
36 #include "webrtc/test/call_test.h" 37 #include "webrtc/test/call_test.h"
37 #include "webrtc/test/direct_transport.h" 38 #include "webrtc/test/direct_transport.h"
38 #include "webrtc/test/encoder_settings.h" 39 #include "webrtc/test/encoder_settings.h"
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 } 1521 }
1521 1522
1522 class TransportFeedbackTester : public test::EndToEndTest { 1523 class TransportFeedbackTester : public test::EndToEndTest {
1523 public: 1524 public:
1524 explicit TransportFeedbackTester(bool feedback_enabled, 1525 explicit TransportFeedbackTester(bool feedback_enabled,
1525 size_t num_video_streams, 1526 size_t num_video_streams,
1526 size_t num_audio_streams) 1527 size_t num_audio_streams)
1527 : EndToEndTest(::webrtc::EndToEndTest::kDefaultTimeoutMs), 1528 : EndToEndTest(::webrtc::EndToEndTest::kDefaultTimeoutMs),
1528 feedback_enabled_(feedback_enabled), 1529 feedback_enabled_(feedback_enabled),
1529 num_video_streams_(num_video_streams), 1530 num_video_streams_(num_video_streams),
1530 num_audio_streams_(num_audio_streams) { 1531 num_audio_streams_(num_audio_streams),
1532 receiver_call_(nullptr) {
1531 // Only one stream of each supported for now. 1533 // Only one stream of each supported for now.
1532 EXPECT_LE(num_video_streams, 1u); 1534 EXPECT_LE(num_video_streams, 1u);
1533 EXPECT_LE(num_audio_streams, 1u); 1535 EXPECT_LE(num_audio_streams, 1u);
1534 } 1536 }
1535 1537
1536 protected: 1538 protected:
1537 Action OnSendRtcp(const uint8_t* data, size_t length) override { 1539 Action OnSendRtcp(const uint8_t* data, size_t length) override {
1538 EXPECT_FALSE(HasTransportFeedback(data, length)); 1540 EXPECT_FALSE(HasTransportFeedback(data, length));
1539 return SEND_PACKET; 1541 return SEND_PACKET;
1540 } 1542 }
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
2532 public: 2534 public:
2533 StatsObserver() 2535 StatsObserver()
2534 : EndToEndTest(kLongTimeoutMs), 2536 : EndToEndTest(kLongTimeoutMs),
2535 encoder_(Clock::GetRealTimeClock(), 10), 2537 encoder_(Clock::GetRealTimeClock(), 10),
2536 send_stream_(nullptr), 2538 send_stream_(nullptr),
2537 expected_send_ssrcs_(), 2539 expected_send_ssrcs_(),
2538 check_stats_event_(false, false) {} 2540 check_stats_event_(false, false) {}
2539 2541
2540 private: 2542 private:
2541 Action OnSendRtp(const uint8_t* packet, size_t length) override { 2543 Action OnSendRtp(const uint8_t* packet, size_t length) override {
2544 // Drop every 25th packet => 4% loss.
2545 static const int kPacketLossFrac = 25;
2546 RTPHeader header;
2547 RtpUtility::RtpHeaderParser parser(packet, length);
2548 if (parser.Parse(&header) &&
2549 expected_send_ssrcs_.find(header.ssrc) !=
2550 expected_send_ssrcs_.end() &&
2551 header.sequenceNumber % kPacketLossFrac == 0) {
2552 return DROP_PACKET;
2553 }
2542 check_stats_event_.Set(); 2554 check_stats_event_.Set();
2543 return SEND_PACKET; 2555 return SEND_PACKET;
2544 } 2556 }
2545 2557
2546 Action OnSendRtcp(const uint8_t* packet, size_t length) override { 2558 Action OnSendRtcp(const uint8_t* packet, size_t length) override {
2547 check_stats_event_.Set(); 2559 check_stats_event_.Set();
2548 return SEND_PACKET; 2560 return SEND_PACKET;
2549 } 2561 }
2550 2562
2551 Action OnReceiveRtp(const uint8_t* packet, size_t length) override { 2563 Action OnReceiveRtp(const uint8_t* packet, size_t length) override {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2632 send_stats_filled_["CpuOveruseMetrics"] |= 2644 send_stats_filled_["CpuOveruseMetrics"] |=
2633 stats.avg_encode_time_ms != 0 && stats.encode_usage_percent != 0; 2645 stats.avg_encode_time_ms != 0 && stats.encode_usage_percent != 0;
2634 2646
2635 send_stats_filled_["EncoderImplementationName"] |= 2647 send_stats_filled_["EncoderImplementationName"] |=
2636 stats.encoder_implementation_name == 2648 stats.encoder_implementation_name ==
2637 test::FakeEncoder::kImplementationName; 2649 test::FakeEncoder::kImplementationName;
2638 2650
2639 for (std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator it = 2651 for (std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator it =
2640 stats.substreams.begin(); 2652 stats.substreams.begin();
2641 it != stats.substreams.end(); ++it) { 2653 it != stats.substreams.end(); ++it) {
2642 EXPECT_TRUE(expected_send_ssrcs_.find(it->first) != 2654 if (expected_send_ssrcs_.find(it->first) == expected_send_ssrcs_.end())
2643 expected_send_ssrcs_.end()); 2655 continue; // Probably RTX.
2644 2656
2645 send_stats_filled_[CompoundKey("CapturedFrameRate", it->first)] |= 2657 send_stats_filled_[CompoundKey("CapturedFrameRate", it->first)] |=
2646 stats.input_frame_rate != 0; 2658 stats.input_frame_rate != 0;
2647 2659
2648 const VideoSendStream::StreamStats& stream_stats = it->second; 2660 const VideoSendStream::StreamStats& stream_stats = it->second;
2649 2661
2650 send_stats_filled_[CompoundKey("StatisticsUpdated", it->first)] |= 2662 send_stats_filled_[CompoundKey("StatisticsUpdated", it->first)] |=
2651 stream_stats.rtcp_stats.cumulative_lost != 0 || 2663 stream_stats.rtcp_stats.cumulative_lost != 0 ||
2652 stream_stats.rtcp_stats.extended_max_sequence_number != 0 || 2664 stream_stats.rtcp_stats.extended_max_sequence_number != 0 ||
2653 stream_stats.rtcp_stats.fraction_lost != 0; 2665 stream_stats.rtcp_stats.fraction_lost != 0;
2654 2666
2655 send_stats_filled_[CompoundKey("DataCountersUpdated", it->first)] |= 2667 send_stats_filled_[CompoundKey("DataCountersUpdated", it->first)] |=
2656 stream_stats.rtp_stats.fec.packets != 0 || 2668 stream_stats.rtp_stats.fec.packets != 0 ||
2657 stream_stats.rtp_stats.transmitted.padding_bytes != 0 || 2669 stream_stats.rtp_stats.transmitted.padding_bytes != 0 ||
2658 stream_stats.rtp_stats.retransmitted.packets != 0 || 2670 stream_stats.rtp_stats.retransmitted.packets != 0 ||
2659 stream_stats.rtp_stats.transmitted.packets != 0; 2671 stream_stats.rtp_stats.transmitted.packets != 0;
2660 2672
2661 send_stats_filled_[CompoundKey("BitrateStatisticsObserver", 2673 send_stats_filled_[CompoundKey("BitrateStatisticsObserver.Total",
2662 it->first)] |= 2674 it->first)] |=
2663 stream_stats.total_bitrate_bps != 0; 2675 stream_stats.total_bitrate_bps != 0;
2664 2676
2677 send_stats_filled_[CompoundKey("BitrateStatisticsObserver.Retransmit",
2678 it->first)] |=
2679 stream_stats.retransmit_bitrate_bps != 0;
2680
2665 send_stats_filled_[CompoundKey("FrameCountObserver", it->first)] |= 2681 send_stats_filled_[CompoundKey("FrameCountObserver", it->first)] |=
2666 stream_stats.frame_counts.delta_frames != 0 || 2682 stream_stats.frame_counts.delta_frames != 0 ||
2667 stream_stats.frame_counts.key_frames != 0; 2683 stream_stats.frame_counts.key_frames != 0;
2668 2684
2669 send_stats_filled_[CompoundKey("OutgoingRate", it->first)] |= 2685 send_stats_filled_[CompoundKey("OutgoingRate", it->first)] |=
2670 stats.encode_frame_rate != 0; 2686 stats.encode_frame_rate != 0;
2671 2687
2672 send_stats_filled_[CompoundKey("Delay", it->first)] |= 2688 send_stats_filled_[CompoundKey("Delay", it->first)] |=
2673 stream_stats.avg_delay_ms != 0 || stream_stats.max_delay_ms != 0; 2689 stream_stats.avg_delay_ms != 0 || stream_stats.max_delay_ms != 0;
2674 2690
(...skipping 10 matching lines...) Expand all
2685 return AllStatsFilled(send_stats_filled_); 2701 return AllStatsFilled(send_stats_filled_);
2686 } 2702 }
2687 2703
2688 std::string CompoundKey(const char* name, uint32_t ssrc) { 2704 std::string CompoundKey(const char* name, uint32_t ssrc) {
2689 std::ostringstream oss; 2705 std::ostringstream oss;
2690 oss << name << "_" << ssrc; 2706 oss << name << "_" << ssrc;
2691 return oss.str(); 2707 return oss.str();
2692 } 2708 }
2693 2709
2694 bool AllStatsFilled(const std::map<std::string, bool>& stats_map) { 2710 bool AllStatsFilled(const std::map<std::string, bool>& stats_map) {
2695 for (std::map<std::string, bool>::const_iterator it = stats_map.begin(); 2711 for (const auto& stat : stats_map) {
2696 it != stats_map.end(); 2712 if (!stat.second)
2697 ++it) {
2698 if (!it->second)
2699 return false; 2713 return false;
2700 } 2714 }
2701 return true; 2715 return true;
2702 } 2716 }
2703 2717
2704 test::PacketTransport* CreateSendTransport(Call* sender_call) override { 2718 test::PacketTransport* CreateSendTransport(Call* sender_call) override {
2705 FakeNetworkPipe::Config network_config; 2719 FakeNetworkPipe::Config network_config;
2706 network_config.loss_percent = 5; 2720 network_config.loss_percent = 5;
2707 return new test::PacketTransport( 2721 return new test::PacketTransport(
2708 sender_call, this, test::PacketTransport::kSender, network_config); 2722 sender_call, this, test::PacketTransport::kSender, network_config);
2709 } 2723 }
2710 2724
2711 Call::Config GetSenderCallConfig() override { 2725 Call::Config GetSenderCallConfig() override {
2712 Call::Config config = EndToEndTest::GetSenderCallConfig(); 2726 Call::Config config = EndToEndTest::GetSenderCallConfig();
2713 config.bitrate_config.start_bitrate_bps = kStartBitrateBps; 2727 config.bitrate_config.start_bitrate_bps = kStartBitrateBps;
2714 return config; 2728 return config;
2715 } 2729 }
2716 2730
2717 void ModifyVideoConfigs( 2731 void ModifyVideoConfigs(
2718 VideoSendStream::Config* send_config, 2732 VideoSendStream::Config* send_config,
2719 std::vector<VideoReceiveStream::Config>* receive_configs, 2733 std::vector<VideoReceiveStream::Config>* receive_configs,
2720 VideoEncoderConfig* encoder_config) override { 2734 VideoEncoderConfig* encoder_config) override {
2735 // Set low rates to avoid waiting for rampup.
2736 for (size_t i = 0; i < encoder_config->streams.size(); ++i) {
2737 encoder_config->streams[i].min_bitrate_bps = 10000;
2738 encoder_config->streams[i].target_bitrate_bps = 15000;
2739 encoder_config->streams[i].max_bitrate_bps = 20000;
2740 }
2721 send_config->pre_encode_callback = this; // Used to inject delay. 2741 send_config->pre_encode_callback = this; // Used to inject delay.
2722 expected_cname_ = send_config->rtp.c_name = "SomeCName"; 2742 expected_cname_ = send_config->rtp.c_name = "SomeCName";
2723 2743
2744 send_config->rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
2745 send_config->rtp.rtx.payload_type = kSendRtxPayloadType;
2746
2724 const std::vector<uint32_t>& ssrcs = send_config->rtp.ssrcs; 2747 const std::vector<uint32_t>& ssrcs = send_config->rtp.ssrcs;
2725 for (size_t i = 0; i < ssrcs.size(); ++i) { 2748 for (size_t i = 0; i < ssrcs.size(); ++i) {
2726 expected_send_ssrcs_.insert(ssrcs[i]); 2749 expected_send_ssrcs_.insert(ssrcs[i]);
2727 expected_receive_ssrcs_.push_back( 2750 expected_receive_ssrcs_.push_back(
2728 (*receive_configs)[i].rtp.remote_ssrc); 2751 (*receive_configs)[i].rtp.remote_ssrc);
2729 (*receive_configs)[i].render_delay_ms = kExpectedRenderDelayMs; 2752 (*receive_configs)[i].render_delay_ms = kExpectedRenderDelayMs;
2730 (*receive_configs)[i].renderer = &receive_stream_renderer_; 2753 (*receive_configs)[i].renderer = &receive_stream_renderer_;
2754 (*receive_configs)[i].rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
2755
2756 (*receive_configs)[i].rtp.rtx[kFakeVideoSendPayloadType].ssrc =
2757 kSendRtxSsrcs[i];
2758 (*receive_configs)[i].rtp.rtx[kFakeVideoSendPayloadType].payload_type =
2759 kSendRtxPayloadType;
2731 } 2760 }
2761
2762 for (size_t i = 0; i < kNumSsrcs; ++i)
2763 send_config->rtp.rtx.ssrcs.push_back(kSendRtxSsrcs[i]);
2764
2732 // Use a delayed encoder to make sure we see CpuOveruseMetrics stats that 2765 // Use a delayed encoder to make sure we see CpuOveruseMetrics stats that
2733 // are non-zero. 2766 // are non-zero.
2734 send_config->encoder_settings.encoder = &encoder_; 2767 send_config->encoder_settings.encoder = &encoder_;
2735 } 2768 }
2736 2769
2737 size_t GetNumVideoStreams() const override { return kNumSsrcs; } 2770 size_t GetNumVideoStreams() const override { return kNumSsrcs; }
2738 2771
2739 void OnVideoStreamsCreated( 2772 void OnVideoStreamsCreated(
2740 VideoSendStream* send_stream, 2773 VideoSendStream* send_stream,
2741 const std::vector<VideoReceiveStream*>& receive_streams) override { 2774 const std::vector<VideoReceiveStream*>& receive_streams) override {
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
3575 private: 3608 private:
3576 bool video_observed_; 3609 bool video_observed_;
3577 bool audio_observed_; 3610 bool audio_observed_;
3578 SequenceNumberUnwrapper unwrapper_; 3611 SequenceNumberUnwrapper unwrapper_;
3579 std::set<int64_t> received_packet_ids_; 3612 std::set<int64_t> received_packet_ids_;
3580 } test; 3613 } test;
3581 3614
3582 RunBaseTest(&test); 3615 RunBaseTest(&test);
3583 } 3616 }
3584 } // namespace webrtc 3617 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc ('k') | webrtc/video/payload_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698