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

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: Moved rate limiter and addressed comments 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
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 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 } 1515 }
1515 1516
1516 class TransportFeedbackTester : public test::EndToEndTest { 1517 class TransportFeedbackTester : public test::EndToEndTest {
1517 public: 1518 public:
1518 explicit TransportFeedbackTester(bool feedback_enabled, 1519 explicit TransportFeedbackTester(bool feedback_enabled,
1519 size_t num_video_streams, 1520 size_t num_video_streams,
1520 size_t num_audio_streams) 1521 size_t num_audio_streams)
1521 : EndToEndTest(::webrtc::EndToEndTest::kDefaultTimeoutMs), 1522 : EndToEndTest(::webrtc::EndToEndTest::kDefaultTimeoutMs),
1522 feedback_enabled_(feedback_enabled), 1523 feedback_enabled_(feedback_enabled),
1523 num_video_streams_(num_video_streams), 1524 num_video_streams_(num_video_streams),
1524 num_audio_streams_(num_audio_streams) { 1525 num_audio_streams_(num_audio_streams),
1526 receiver_call_(nullptr) {
1525 // Only one stream of each supported for now. 1527 // Only one stream of each supported for now.
1526 EXPECT_LE(num_video_streams, 1u); 1528 EXPECT_LE(num_video_streams, 1u);
1527 EXPECT_LE(num_audio_streams, 1u); 1529 EXPECT_LE(num_audio_streams, 1u);
1528 } 1530 }
1529 1531
1530 protected: 1532 protected:
1531 Action OnSendRtcp(const uint8_t* data, size_t length) override { 1533 Action OnSendRtcp(const uint8_t* data, size_t length) override {
1532 EXPECT_FALSE(HasTransportFeedback(data, length)); 1534 EXPECT_FALSE(HasTransportFeedback(data, length));
1533 return SEND_PACKET; 1535 return SEND_PACKET;
1534 } 1536 }
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
2509 public: 2511 public:
2510 StatsObserver() 2512 StatsObserver()
2511 : EndToEndTest(kLongTimeoutMs), 2513 : EndToEndTest(kLongTimeoutMs),
2512 encoder_(Clock::GetRealTimeClock(), 10), 2514 encoder_(Clock::GetRealTimeClock(), 10),
2513 send_stream_(nullptr), 2515 send_stream_(nullptr),
2514 expected_send_ssrcs_(), 2516 expected_send_ssrcs_(),
2515 check_stats_event_(false, false) {} 2517 check_stats_event_(false, false) {}
2516 2518
2517 private: 2519 private:
2518 Action OnSendRtp(const uint8_t* packet, size_t length) override { 2520 Action OnSendRtp(const uint8_t* packet, size_t length) override {
2521 const int kPacketLossFrac = 25; // Drop every 25th packet => 4% loss.
2522 RTPHeader header;
2523 RtpUtility::RtpHeaderParser parser(packet, length);
2524 if (parser.Parse(&header) &&
2525 expected_send_ssrcs_.find(header.ssrc) !=
2526 expected_send_ssrcs_.end() &&
2527 header.sequenceNumber % kPacketLossFrac == 0) {
2528 return DROP_PACKET;
2529 }
2519 check_stats_event_.Set(); 2530 check_stats_event_.Set();
2520 return SEND_PACKET; 2531 return SEND_PACKET;
2521 } 2532 }
2522 2533
2523 Action OnSendRtcp(const uint8_t* packet, size_t length) override { 2534 Action OnSendRtcp(const uint8_t* packet, size_t length) override {
2524 check_stats_event_.Set(); 2535 check_stats_event_.Set();
2525 return SEND_PACKET; 2536 return SEND_PACKET;
2526 } 2537 }
2527 2538
2528 Action OnReceiveRtp(const uint8_t* packet, size_t length) override { 2539 Action OnReceiveRtp(const uint8_t* packet, size_t length) override {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2609 send_stats_filled_["CpuOveruseMetrics"] |= 2620 send_stats_filled_["CpuOveruseMetrics"] |=
2610 stats.avg_encode_time_ms != 0 && stats.encode_usage_percent != 0; 2621 stats.avg_encode_time_ms != 0 && stats.encode_usage_percent != 0;
2611 2622
2612 send_stats_filled_["EncoderImplementationName"] |= 2623 send_stats_filled_["EncoderImplementationName"] |=
2613 stats.encoder_implementation_name == 2624 stats.encoder_implementation_name ==
2614 test::FakeEncoder::kImplementationName; 2625 test::FakeEncoder::kImplementationName;
2615 2626
2616 for (std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator it = 2627 for (std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator it =
2617 stats.substreams.begin(); 2628 stats.substreams.begin();
2618 it != stats.substreams.end(); ++it) { 2629 it != stats.substreams.end(); ++it) {
2619 EXPECT_TRUE(expected_send_ssrcs_.find(it->first) != 2630 if (expected_send_ssrcs_.find(it->first) == expected_send_ssrcs_.end())
2620 expected_send_ssrcs_.end()); 2631 continue; // Probably RTX.
2621 2632
2622 send_stats_filled_[CompoundKey("CapturedFrameRate", it->first)] |= 2633 send_stats_filled_[CompoundKey("CapturedFrameRate", it->first)] |=
2623 stats.input_frame_rate != 0; 2634 stats.input_frame_rate != 0;
2624 2635
2625 const VideoSendStream::StreamStats& stream_stats = it->second; 2636 const VideoSendStream::StreamStats& stream_stats = it->second;
2626 2637
2627 send_stats_filled_[CompoundKey("StatisticsUpdated", it->first)] |= 2638 send_stats_filled_[CompoundKey("StatisticsUpdated", it->first)] |=
2628 stream_stats.rtcp_stats.cumulative_lost != 0 || 2639 stream_stats.rtcp_stats.cumulative_lost != 0 ||
2629 stream_stats.rtcp_stats.extended_max_sequence_number != 0 || 2640 stream_stats.rtcp_stats.extended_max_sequence_number != 0 ||
2630 stream_stats.rtcp_stats.fraction_lost != 0; 2641 stream_stats.rtcp_stats.fraction_lost != 0;
2631 2642
2632 send_stats_filled_[CompoundKey("DataCountersUpdated", it->first)] |= 2643 send_stats_filled_[CompoundKey("DataCountersUpdated", it->first)] |=
2633 stream_stats.rtp_stats.fec.packets != 0 || 2644 stream_stats.rtp_stats.fec.packets != 0 ||
2634 stream_stats.rtp_stats.transmitted.padding_bytes != 0 || 2645 stream_stats.rtp_stats.transmitted.padding_bytes != 0 ||
2635 stream_stats.rtp_stats.retransmitted.packets != 0 || 2646 stream_stats.rtp_stats.retransmitted.packets != 0 ||
2636 stream_stats.rtp_stats.transmitted.packets != 0; 2647 stream_stats.rtp_stats.transmitted.packets != 0;
2637 2648
2638 send_stats_filled_[CompoundKey("BitrateStatisticsObserver", 2649 send_stats_filled_[CompoundKey("BitrateStatisticsObserver.Total",
2639 it->first)] |= 2650 it->first)] |=
2640 stream_stats.total_bitrate_bps != 0; 2651 stream_stats.total_bitrate_bps != 0;
2641 2652
2653 send_stats_filled_[CompoundKey("BitrateStatisticsObserver.Retransmit",
2654 it->first)] |=
2655 stream_stats.retransmit_bitrate_bps != 0;
2656
2642 send_stats_filled_[CompoundKey("FrameCountObserver", it->first)] |= 2657 send_stats_filled_[CompoundKey("FrameCountObserver", it->first)] |=
2643 stream_stats.frame_counts.delta_frames != 0 || 2658 stream_stats.frame_counts.delta_frames != 0 ||
2644 stream_stats.frame_counts.key_frames != 0; 2659 stream_stats.frame_counts.key_frames != 0;
2645 2660
2646 send_stats_filled_[CompoundKey("OutgoingRate", it->first)] |= 2661 send_stats_filled_[CompoundKey("OutgoingRate", it->first)] |=
2647 stats.encode_frame_rate != 0; 2662 stats.encode_frame_rate != 0;
2648 2663
2649 send_stats_filled_[CompoundKey("Delay", it->first)] |= 2664 send_stats_filled_[CompoundKey("Delay", it->first)] |=
2650 stream_stats.avg_delay_ms != 0 || stream_stats.max_delay_ms != 0; 2665 stream_stats.avg_delay_ms != 0 || stream_stats.max_delay_ms != 0;
2651 2666
(...skipping 10 matching lines...) Expand all
2662 return AllStatsFilled(send_stats_filled_); 2677 return AllStatsFilled(send_stats_filled_);
2663 } 2678 }
2664 2679
2665 std::string CompoundKey(const char* name, uint32_t ssrc) { 2680 std::string CompoundKey(const char* name, uint32_t ssrc) {
2666 std::ostringstream oss; 2681 std::ostringstream oss;
2667 oss << name << "_" << ssrc; 2682 oss << name << "_" << ssrc;
2668 return oss.str(); 2683 return oss.str();
2669 } 2684 }
2670 2685
2671 bool AllStatsFilled(const std::map<std::string, bool>& stats_map) { 2686 bool AllStatsFilled(const std::map<std::string, bool>& stats_map) {
2672 for (std::map<std::string, bool>::const_iterator it = stats_map.begin(); 2687 for (auto& it : stats_map) {
danilchap 2016/06/28 14:26:18 const auto& may be name variable kv [key_value] or
sprang_webrtc 2016/07/04 09:33:04 Done.
2673 it != stats_map.end(); 2688 if (!it.second)
2674 ++it) {
2675 if (!it->second)
2676 return false; 2689 return false;
2677 } 2690 }
2678 return true; 2691 return true;
2679 } 2692 }
2680 2693
2681 test::PacketTransport* CreateSendTransport(Call* sender_call) override { 2694 test::PacketTransport* CreateSendTransport(Call* sender_call) override {
2682 FakeNetworkPipe::Config network_config; 2695 FakeNetworkPipe::Config network_config;
2683 network_config.loss_percent = 5; 2696 network_config.loss_percent = 5;
2684 return new test::PacketTransport( 2697 return new test::PacketTransport(
2685 sender_call, this, test::PacketTransport::kSender, network_config); 2698 sender_call, this, test::PacketTransport::kSender, network_config);
2686 } 2699 }
2687 2700
2688 Call::Config GetSenderCallConfig() override { 2701 Call::Config GetSenderCallConfig() override {
2689 Call::Config config = EndToEndTest::GetSenderCallConfig(); 2702 Call::Config config = EndToEndTest::GetSenderCallConfig();
2690 config.bitrate_config.start_bitrate_bps = kStartBitrateBps; 2703 config.bitrate_config.start_bitrate_bps = kStartBitrateBps;
2691 return config; 2704 return config;
2692 } 2705 }
2693 2706
2694 void ModifyVideoConfigs( 2707 void ModifyVideoConfigs(
2695 VideoSendStream::Config* send_config, 2708 VideoSendStream::Config* send_config,
2696 std::vector<VideoReceiveStream::Config>* receive_configs, 2709 std::vector<VideoReceiveStream::Config>* receive_configs,
2697 VideoEncoderConfig* encoder_config) override { 2710 VideoEncoderConfig* encoder_config) override {
2711 // Set low rates to avoid waiting for rampup.
2712 for (size_t i = 0; i < encoder_config->streams.size(); ++i) {
2713 encoder_config->streams[i].min_bitrate_bps = 10000;
2714 encoder_config->streams[i].target_bitrate_bps = 15000;
2715 encoder_config->streams[i].max_bitrate_bps = 20000;
2716 }
2698 send_config->pre_encode_callback = this; // Used to inject delay. 2717 send_config->pre_encode_callback = this; // Used to inject delay.
2699 expected_cname_ = send_config->rtp.c_name = "SomeCName"; 2718 expected_cname_ = send_config->rtp.c_name = "SomeCName";
2700 2719
2720 send_config->rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
2721 send_config->rtp.rtx.payload_type = kSendRtxPayloadType;
2722
2701 const std::vector<uint32_t>& ssrcs = send_config->rtp.ssrcs; 2723 const std::vector<uint32_t>& ssrcs = send_config->rtp.ssrcs;
2702 for (size_t i = 0; i < ssrcs.size(); ++i) { 2724 for (size_t i = 0; i < ssrcs.size(); ++i) {
2703 expected_send_ssrcs_.insert(ssrcs[i]); 2725 expected_send_ssrcs_.insert(ssrcs[i]);
2704 expected_receive_ssrcs_.push_back( 2726 expected_receive_ssrcs_.push_back(
2705 (*receive_configs)[i].rtp.remote_ssrc); 2727 (*receive_configs)[i].rtp.remote_ssrc);
2706 (*receive_configs)[i].render_delay_ms = kExpectedRenderDelayMs; 2728 (*receive_configs)[i].render_delay_ms = kExpectedRenderDelayMs;
2707 (*receive_configs)[i].renderer = &receive_stream_renderer_; 2729 (*receive_configs)[i].renderer = &receive_stream_renderer_;
2730 (*receive_configs)[i].rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
2731
2732 (*receive_configs)[i].rtp.rtx[kFakeVideoSendPayloadType].ssrc =
2733 kSendRtxSsrcs[i];
2734 (*receive_configs)[i].rtp.rtx[kFakeVideoSendPayloadType].payload_type =
2735 kSendRtxPayloadType;
2708 } 2736 }
2737
2738 for (size_t i = 0; i < kNumSsrcs; ++i)
2739 send_config->rtp.rtx.ssrcs.push_back(kSendRtxSsrcs[i]);
2740
2709 // Use a delayed encoder to make sure we see CpuOveruseMetrics stats that 2741 // Use a delayed encoder to make sure we see CpuOveruseMetrics stats that
2710 // are non-zero. 2742 // are non-zero.
2711 send_config->encoder_settings.encoder = &encoder_; 2743 send_config->encoder_settings.encoder = &encoder_;
2712 } 2744 }
2713 2745
2714 size_t GetNumVideoStreams() const override { return kNumSsrcs; } 2746 size_t GetNumVideoStreams() const override { return kNumSsrcs; }
2715 2747
2716 void OnVideoStreamsCreated( 2748 void OnVideoStreamsCreated(
2717 VideoSendStream* send_stream, 2749 VideoSendStream* send_stream,
2718 const std::vector<VideoReceiveStream*>& receive_streams) override { 2750 const std::vector<VideoReceiveStream*>& receive_streams) override {
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
3557 private: 3589 private:
3558 bool video_observed_; 3590 bool video_observed_;
3559 bool audio_observed_; 3591 bool audio_observed_;
3560 SequenceNumberUnwrapper unwrapper_; 3592 SequenceNumberUnwrapper unwrapper_;
3561 std::set<int64_t> received_packet_ids_; 3593 std::set<int64_t> received_packet_ids_;
3562 } test; 3594 } test;
3563 3595
3564 RunBaseTest(&test); 3596 RunBaseTest(&test);
3565 } 3597 }
3566 } // namespace webrtc 3598 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698