| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 static const int kTransportSequenceNumberExtensionId = 8; | 29 static const int kTransportSequenceNumberExtensionId = 8; |
| 30 static const unsigned int kSingleStreamTargetBps = 1000000; | 30 static const unsigned int kSingleStreamTargetBps = 1000000; |
| 31 | 31 |
| 32 class Clock; | 32 class Clock; |
| 33 class PacketRouter; | 33 class PacketRouter; |
| 34 class ReceiveStatistics; | 34 class ReceiveStatistics; |
| 35 class RtpHeaderParser; | 35 class RtpHeaderParser; |
| 36 class RTPPayloadRegistry; | 36 class RTPPayloadRegistry; |
| 37 class RtpRtcp; | 37 class RtpRtcp; |
| 38 | 38 |
| 39 class StreamObserver : public newapi::Transport, public RemoteBitrateObserver { | 39 class RampUpTester : public test::EndToEndTest { |
| 40 public: | 40 public: |
| 41 typedef std::map<uint32_t, int> BytesSentMap; | 41 RampUpTester(size_t num_streams, |
| 42 typedef std::map<uint32_t, uint32_t> SsrcMap; | 42 unsigned int start_bitrate_bps, |
| 43 StreamObserver(const SsrcMap& rtx_media_ssrcs, | 43 const std::string& extension_type, |
| 44 newapi::Transport* feedback_transport, | 44 bool rtx, |
| 45 Clock* clock); | 45 bool red); |
| 46 virtual ~StreamObserver(); | 46 ~RampUpTester() override; |
| 47 | 47 |
| 48 void set_expected_bitrate_bps(unsigned int expected_bitrate_bps); | 48 void PerformTest() override; |
| 49 | 49 |
| 50 void set_start_bitrate_bps(unsigned int start_bitrate_bps); | 50 protected: |
| 51 virtual bool PollStats(); |
| 51 | 52 |
| 52 void OnReceiveBitrateChanged(const std::vector<unsigned int>& ssrcs, | 53 void GetStats(const VideoSendStream::StreamStats& stream, |
| 53 unsigned int bitrate) override; | 54 size_t* total_packets_sent, |
| 55 size_t* total_sent, |
| 56 size_t* padding_sent, |
| 57 size_t* media_sent) const; |
| 54 | 58 |
| 55 bool SendRtp(const uint8_t* packet, size_t length) override; | 59 void ReportResult(const std::string& measurement, |
| 60 size_t value, |
| 61 const std::string& units) const; |
| 62 void TriggerTestDone(); |
| 56 | 63 |
| 57 bool SendRtcp(const uint8_t* packet, size_t length) override; | 64 rtc::Event event_; |
| 58 | 65 Clock* const clock_; |
| 59 EventTypeWrapper Wait(); | 66 const size_t num_streams_; |
| 60 | 67 const bool rtx_; |
| 61 void SetRemoteBitrateEstimator(RemoteBitrateEstimator* rbe); | 68 const bool red_; |
| 62 | 69 VideoSendStream* send_stream_; |
| 63 PacketRouter* GetPacketRouter(); | |
| 64 | 70 |
| 65 private: | 71 private: |
| 66 void ReportResult(const std::string& measurement, | 72 typedef std::map<uint32_t, uint32_t> SsrcMap; |
| 67 size_t value, | |
| 68 const std::string& units); | |
| 69 void TriggerTestDone() EXCLUSIVE_LOCKS_REQUIRED(crit_); | |
| 70 | 73 |
| 71 Clock* const clock_; | 74 Call::Config GetSenderCallConfig() override; |
| 72 const rtc::scoped_ptr<EventWrapper> test_done_; | 75 void OnStreamsCreated( |
| 73 const rtc::scoped_ptr<RtpHeaderParser> rtp_parser_; | 76 VideoSendStream* send_stream, |
| 74 rtc::scoped_ptr<RtpRtcp> rtp_rtcp_; | 77 const std::vector<VideoReceiveStream*>& receive_streams) override; |
| 75 rtc::scoped_ptr<PacketRouter> packet_router_; | 78 size_t GetNumStreams() const; |
| 76 internal::TransportAdapter feedback_transport_; | 79 void ModifyConfigs(VideoSendStream::Config* send_config, |
| 77 const rtc::scoped_ptr<ReceiveStatistics> receive_stats_; | 80 std::vector<VideoReceiveStream::Config>* receive_configs, |
| 78 const rtc::scoped_ptr<RTPPayloadRegistry> payload_registry_; | 81 VideoEncoderConfig* encoder_config) override; |
| 79 rtc::scoped_ptr<RemoteBitrateEstimator> remote_bitrate_estimator_; | 82 void OnCallsCreated(Call* sender_call, Call* receiver_call) override; |
| 80 | 83 |
| 81 rtc::CriticalSection crit_; | 84 static bool BitrateStatsPollingThread(void* obj); |
| 82 unsigned int expected_bitrate_bps_ GUARDED_BY(crit_); | 85 |
| 83 unsigned int start_bitrate_bps_ GUARDED_BY(crit_); | 86 const int start_bitrate_bps_; |
| 84 SsrcMap rtx_media_ssrcs_ GUARDED_BY(crit_); | 87 bool start_bitrate_verified_; |
| 85 size_t total_sent_ GUARDED_BY(crit_); | 88 int expected_bitrate_bps_; |
| 86 size_t padding_sent_ GUARDED_BY(crit_); | 89 int64_t test_start_ms_; |
| 87 size_t rtx_media_sent_ GUARDED_BY(crit_); | 90 int64_t ramp_up_finished_ms_; |
| 88 int total_packets_sent_ GUARDED_BY(crit_); | 91 |
| 89 int padding_packets_sent_ GUARDED_BY(crit_); | 92 const std::string extension_type_; |
| 90 int rtx_media_packets_sent_ GUARDED_BY(crit_); | 93 std::vector<uint32_t> ssrcs_; |
| 91 int64_t test_start_ms_ GUARDED_BY(crit_); | 94 std::vector<uint32_t> rtx_ssrcs_; |
| 92 int64_t ramp_up_finished_ms_ GUARDED_BY(crit_); | 95 SsrcMap rtx_ssrc_map_; |
| 96 |
| 97 rtc::scoped_ptr<ThreadWrapper> poller_thread_; |
| 98 Call* sender_call_; |
| 93 }; | 99 }; |
| 94 | 100 |
| 95 class LowRateStreamObserver : public test::DirectTransport, | 101 class RampUpDownUpTester : public RampUpTester { |
| 96 public RemoteBitrateObserver, | |
| 97 public PacketReceiver { | |
| 98 public: | 102 public: |
| 99 LowRateStreamObserver(newapi::Transport* feedback_transport, | 103 RampUpDownUpTester(size_t num_streams, |
| 100 Clock* clock, | |
| 101 size_t number_of_streams, | |
| 102 bool rtx_used); | |
| 103 | |
| 104 virtual void SetSendStream(VideoSendStream* send_stream); | |
| 105 | |
| 106 virtual void OnReceiveBitrateChanged(const std::vector<unsigned int>& ssrcs, | |
| 107 unsigned int bitrate); | |
| 108 | |
| 109 bool SendRtp(const uint8_t* data, size_t length) override; | |
| 110 | |
| 111 DeliveryStatus DeliverPacket(MediaType media_type, | |
| 112 const uint8_t* packet, | |
| 113 size_t length, | |
| 114 const PacketTime& packet_time) override; | |
| 115 | |
| 116 bool SendRtcp(const uint8_t* packet, size_t length) override; | |
| 117 | |
| 118 // Produces a string similar to "1stream_nortx", depending on the values of | |
| 119 // number_of_streams_ and rtx_used_; | |
| 120 std::string GetModifierString(); | |
| 121 | |
| 122 // This method defines the state machine for the ramp up-down-up test. | |
| 123 void EvolveTestState(unsigned int bitrate_bps); | |
| 124 | |
| 125 EventTypeWrapper Wait(); | |
| 126 | |
| 127 private: | |
| 128 static const unsigned int kHighBandwidthLimitBps = 80000; | |
| 129 static const unsigned int kExpectedHighBitrateBps = 60000; | |
| 130 static const unsigned int kLowBandwidthLimitBps = 20000; | |
| 131 static const unsigned int kExpectedLowBitrateBps = 20000; | |
| 132 enum TestStates { kFirstRampup, kLowRate, kSecondRampup }; | |
| 133 | |
| 134 Clock* const clock_; | |
| 135 const size_t number_of_streams_; | |
| 136 const bool rtx_used_; | |
| 137 const rtc::scoped_ptr<EventWrapper> test_done_; | |
| 138 const rtc::scoped_ptr<RtpHeaderParser> rtp_parser_; | |
| 139 const rtc::scoped_ptr<RTPPayloadRegistry> payload_registry_; | |
| 140 rtc::scoped_ptr<RtpRtcp> rtp_rtcp_; | |
| 141 internal::TransportAdapter feedback_transport_; | |
| 142 const rtc::scoped_ptr<ReceiveStatistics> receive_stats_; | |
| 143 rtc::scoped_ptr<RemoteBitrateEstimator> remote_bitrate_estimator_; | |
| 144 | |
| 145 rtc::CriticalSection crit_; | |
| 146 VideoSendStream* send_stream_ GUARDED_BY(crit_); | |
| 147 FakeNetworkPipe::Config forward_transport_config_ GUARDED_BY(crit_); | |
| 148 TestStates test_state_ GUARDED_BY(crit_); | |
| 149 int64_t state_start_ms_ GUARDED_BY(crit_); | |
| 150 int64_t interval_start_ms_ GUARDED_BY(crit_); | |
| 151 unsigned int last_remb_bps_ GUARDED_BY(crit_); | |
| 152 size_t sent_bytes_ GUARDED_BY(crit_); | |
| 153 size_t total_overuse_bytes_ GUARDED_BY(crit_); | |
| 154 bool suspended_in_stats_ GUARDED_BY(crit_); | |
| 155 }; | |
| 156 | |
| 157 class RampUpTest : public test::CallTest { | |
| 158 protected: | |
| 159 void RunRampUpTest(size_t num_streams, | |
| 160 unsigned int start_bitrate_bps, | 104 unsigned int start_bitrate_bps, |
| 161 const std::string& extension_type, | 105 const std::string& extension_type, |
| 162 bool rtx, | 106 bool rtx, |
| 163 bool red); | 107 bool red); |
| 108 ~RampUpDownUpTester() override; |
| 164 | 109 |
| 165 void RunRampUpDownUpTest(size_t number_of_streams, bool rtx, bool red); | 110 protected: |
| 111 bool PollStats() override; |
| 112 |
| 113 private: |
| 114 static const int kHighBandwidthLimitBps = 80000; |
| 115 static const int kExpectedHighBitrateBps = 60000; |
| 116 static const int kLowBandwidthLimitBps = 20000; |
| 117 static const int kExpectedLowBitrateBps = 20000; |
| 118 enum TestStates { kFirstRampup, kLowRate, kSecondRampup }; |
| 119 |
| 120 Call::Config GetReceiverCallConfig() override; |
| 121 |
| 122 std::string GetModifierString() const; |
| 123 void EvolveTestState(int bitrate_bps, bool suspended); |
| 124 |
| 125 FakeNetworkPipe::Config forward_transport_config_; |
| 126 TestStates test_state_; |
| 127 int64_t state_start_ms_; |
| 128 int64_t interval_start_ms_; |
| 129 int sent_bytes_; |
| 166 }; | 130 }; |
| 167 } // namespace webrtc | 131 } // namespace webrtc |
| 168 #endif // WEBRTC_VIDEO_RAMPUP_TESTS_H_ | 132 #endif // WEBRTC_VIDEO_RAMPUP_TESTS_H_ |
| OLD | NEW |