Chromium Code Reviews| OLD | NEW |
|---|---|
| 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> |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 void TestMinTransmitBitrate(bool pad_to_min_bitrate); | 51 void TestMinTransmitBitrate(bool pad_to_min_bitrate); |
| 52 | 52 |
| 53 void TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, | 53 void TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, |
| 54 int threshold_ms, | 54 int threshold_ms, |
| 55 int start_time_ms, | 55 int start_time_ms, |
| 56 int run_time_ms); | 56 int run_time_ms); |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 class SyncRtcpObserver : public test::RtpRtcpObserver { | 59 class SyncRtcpObserver : public test::RtpRtcpObserver { |
| 60 public: | 60 public: |
| 61 explicit SyncRtcpObserver(const FakeNetworkPipe::Config& config) | 61 SyncRtcpObserver() : test::RtpRtcpObserver(CallPerfTest::kLongTimeoutMs) {} |
| 62 : test::RtpRtcpObserver(CallPerfTest::kLongTimeoutMs, config) {} | |
| 63 | 62 |
| 64 Action OnSendRtcp(const uint8_t* packet, size_t length) override { | 63 Action OnSendRtcp(const uint8_t* packet, size_t length) override { |
| 65 RTCPUtility::RTCPParserV2 parser(packet, length, true); | 64 RTCPUtility::RTCPParserV2 parser(packet, length, true); |
| 66 EXPECT_TRUE(parser.IsValid()); | 65 EXPECT_TRUE(parser.IsValid()); |
| 67 | 66 |
| 68 for (RTCPUtility::RTCPPacketTypes packet_type = parser.Begin(); | 67 for (RTCPUtility::RTCPPacketTypes packet_type = parser.Begin(); |
| 69 packet_type != RTCPUtility::RTCPPacketTypes::kInvalid; | 68 packet_type != RTCPUtility::RTCPPacketTypes::kInvalid; |
| 70 packet_type = parser.Iterate()) { | 69 packet_type = parser.Iterate()) { |
| 71 if (packet_type == RTCPUtility::RTCPPacketTypes::kSr) { | 70 if (packet_type == RTCPUtility::RTCPPacketTypes::kSr) { |
| 72 const RTCPUtility::RTCPPacket& packet = parser.Packet(); | 71 const RTCPUtility::RTCPPacket& packet = parser.Packet(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 class VideoRtcpAndSyncObserver : public SyncRtcpObserver, public VideoRenderer { | 119 class VideoRtcpAndSyncObserver : public SyncRtcpObserver, public VideoRenderer { |
| 121 static const int kInSyncThresholdMs = 50; | 120 static const int kInSyncThresholdMs = 50; |
| 122 static const int kStartupTimeMs = 2000; | 121 static const int kStartupTimeMs = 2000; |
| 123 static const int kMinRunTimeMs = 30000; | 122 static const int kMinRunTimeMs = 30000; |
| 124 | 123 |
| 125 public: | 124 public: |
| 126 VideoRtcpAndSyncObserver(Clock* clock, | 125 VideoRtcpAndSyncObserver(Clock* clock, |
| 127 int voe_channel, | 126 int voe_channel, |
| 128 VoEVideoSync* voe_sync, | 127 VoEVideoSync* voe_sync, |
| 129 SyncRtcpObserver* audio_observer) | 128 SyncRtcpObserver* audio_observer) |
| 130 : SyncRtcpObserver(FakeNetworkPipe::Config()), | 129 : SyncRtcpObserver(), |
|
pbos-webrtc
2015/10/27 14:06:29
Remove from ctor list
stefan-webrtc
2015/10/27 14:33:16
Done.
| |
| 131 clock_(clock), | 130 clock_(clock), |
| 132 voe_channel_(voe_channel), | 131 voe_channel_(voe_channel), |
| 133 voe_sync_(voe_sync), | 132 voe_sync_(voe_sync), |
| 134 audio_observer_(audio_observer), | 133 audio_observer_(audio_observer), |
| 135 creation_time_ms_(clock_->TimeInMilliseconds()), | 134 creation_time_ms_(clock_->TimeInMilliseconds()), |
| 136 first_time_in_sync_(-1) {} | 135 first_time_in_sync_(-1) {} |
| 137 | 136 |
| 138 void RenderFrame(const VideoFrame& video_frame, | 137 void RenderFrame(const VideoFrame& video_frame, |
| 139 int time_to_render_ms) override { | 138 int time_to_render_ms) override { |
| 140 int64_t now_ms = clock_->TimeInMilliseconds(); | 139 int64_t now_ms = clock_->TimeInMilliseconds(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 } | 174 } |
| 176 if (time_since_creation > kMinRunTimeMs) | 175 if (time_since_creation > kMinRunTimeMs) |
| 177 observation_complete_->Set(); | 176 observation_complete_->Set(); |
| 178 } | 177 } |
| 179 } | 178 } |
| 180 | 179 |
| 181 bool IsTextureSupported() const override { return false; } | 180 bool IsTextureSupported() const override { return false; } |
| 182 | 181 |
| 183 private: | 182 private: |
| 184 Clock* const clock_; | 183 Clock* const clock_; |
| 185 int voe_channel_; | 184 const int voe_channel_; |
| 186 VoEVideoSync* voe_sync_; | 185 VoEVideoSync* const voe_sync_; |
| 187 SyncRtcpObserver* audio_observer_; | 186 SyncRtcpObserver* const audio_observer_; |
| 188 int64_t creation_time_ms_; | 187 const int64_t creation_time_ms_; |
| 189 int64_t first_time_in_sync_; | 188 int64_t first_time_in_sync_; |
| 190 }; | 189 }; |
| 191 | 190 |
| 192 void CallPerfTest::TestAudioVideoSync(bool fec, bool create_audio_first) { | 191 void CallPerfTest::TestAudioVideoSync(bool fec, bool create_audio_first) { |
| 193 const char* kSyncGroup = "av_sync"; | 192 const char* kSyncGroup = "av_sync"; |
| 194 class AudioPacketReceiver : public PacketReceiver { | 193 class AudioPacketReceiver : public PacketReceiver { |
| 195 public: | 194 public: |
| 196 AudioPacketReceiver(int channel, VoENetwork* voe_network) | 195 AudioPacketReceiver(int channel, VoENetwork* voe_network) |
| 197 : channel_(channel), | 196 : channel_(channel), |
| 198 voe_network_(voe_network), | 197 voe_network_(voe_network), |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 225 VoENetwork* voe_network = VoENetwork::GetInterface(voice_engine); | 224 VoENetwork* voe_network = VoENetwork::GetInterface(voice_engine); |
| 226 VoEVideoSync* voe_sync = VoEVideoSync::GetInterface(voice_engine); | 225 VoEVideoSync* voe_sync = VoEVideoSync::GetInterface(voice_engine); |
| 227 const std::string audio_filename = | 226 const std::string audio_filename = |
| 228 test::ResourcePath("voice_engine/audio_long16", "pcm"); | 227 test::ResourcePath("voice_engine/audio_long16", "pcm"); |
| 229 ASSERT_STRNE("", audio_filename.c_str()); | 228 ASSERT_STRNE("", audio_filename.c_str()); |
| 230 test::FakeAudioDevice fake_audio_device(Clock::GetRealTimeClock(), | 229 test::FakeAudioDevice fake_audio_device(Clock::GetRealTimeClock(), |
| 231 audio_filename); | 230 audio_filename); |
| 232 EXPECT_EQ(0, voe_base->Init(&fake_audio_device, nullptr)); | 231 EXPECT_EQ(0, voe_base->Init(&fake_audio_device, nullptr)); |
| 233 int channel = voe_base->CreateChannel(); | 232 int channel = voe_base->CreateChannel(); |
| 234 | 233 |
| 235 FakeNetworkPipe::Config net_config; | 234 SyncRtcpObserver audio_observer; |
| 236 net_config.queue_delay_ms = 500; | |
| 237 net_config.loss_percent = 5; | |
| 238 SyncRtcpObserver audio_observer(net_config); | |
| 239 VideoRtcpAndSyncObserver observer(Clock::GetRealTimeClock(), | |
| 240 channel, | |
| 241 voe_sync, | |
| 242 &audio_observer); | |
| 243 | 235 |
| 244 Call::Config receiver_config; | 236 Call::Config receiver_config; |
| 245 receiver_config.voice_engine = voice_engine; | 237 receiver_config.voice_engine = voice_engine; |
| 246 CreateCalls(Call::Config(), receiver_config); | 238 CreateCalls(Call::Config(), receiver_config); |
| 247 | 239 |
| 248 CodecInst isac = {103, "ISAC", 16000, 480, 1, 32000}; | 240 CodecInst isac = {103, "ISAC", 16000, 480, 1, 32000}; |
| 249 EXPECT_EQ(0, voe_codec->SetSendCodec(channel, isac)); | 241 EXPECT_EQ(0, voe_codec->SetSendCodec(channel, isac)); |
| 250 | 242 |
| 251 AudioPacketReceiver voe_packet_receiver(channel, voe_network); | 243 AudioPacketReceiver voe_packet_receiver(channel, voe_network); |
| 252 audio_observer.SetReceivers(&voe_packet_receiver, &voe_packet_receiver); | |
| 253 | 244 |
| 254 internal::TransportAdapter transport_adapter(audio_observer.SendTransport()); | 245 FakeNetworkPipe::Config net_config; |
| 246 net_config.queue_delay_ms = 500; | |
| 247 net_config.loss_percent = 5; | |
| 248 test::PacketTransport audio_send_transport( | |
| 249 nullptr, &audio_observer, test::PacketTransport::kSender, net_config); | |
| 250 audio_send_transport.SetReceiver(&voe_packet_receiver); | |
|
pbos-webrtc
2015/10/27 14:06:29
consider adding this to ctor if possible in a foll
stefan-webrtc
2015/10/27 14:33:16
TODO for now.
| |
| 251 test::PacketTransport audio_receive_transport( | |
| 252 nullptr, &audio_observer, test::PacketTransport::kReceiver, net_config); | |
| 253 audio_receive_transport.SetReceiver(&voe_packet_receiver); | |
| 254 audio_observer.SetTransports(&audio_send_transport, &audio_receive_transport); | |
| 255 | |
| 256 internal::TransportAdapter transport_adapter(&audio_send_transport); | |
| 255 transport_adapter.Enable(); | 257 transport_adapter.Enable(); |
| 256 EXPECT_EQ(0, | 258 EXPECT_EQ(0, |
| 257 voe_network->RegisterExternalTransport(channel, transport_adapter)); | 259 voe_network->RegisterExternalTransport(channel, transport_adapter)); |
| 258 | 260 |
| 259 observer.SetReceivers(receiver_call_->Receiver(), sender_call_->Receiver()); | 261 VideoRtcpAndSyncObserver observer(Clock::GetRealTimeClock(), channel, |
| 262 voe_sync, &audio_observer); | |
| 263 | |
| 264 test::PacketTransport sync_send_transport(sender_call_.get(), &observer, | |
| 265 test::PacketTransport::kSender, | |
| 266 FakeNetworkPipe::Config()); | |
| 267 sync_send_transport.SetReceiver(receiver_call_->Receiver()); | |
| 268 test::PacketTransport sync_receive_transport(receiver_call_.get(), &observer, | |
| 269 test::PacketTransport::kReceiver, | |
| 270 FakeNetworkPipe::Config()); | |
| 271 sync_receive_transport.SetReceiver(sender_call_->Receiver()); | |
| 272 | |
| 273 observer.SetTransports(&sync_send_transport, &sync_receive_transport); | |
| 260 | 274 |
| 261 test::FakeDecoder fake_decoder; | 275 test::FakeDecoder fake_decoder; |
| 262 | 276 |
| 263 CreateSendConfig(1, observer.SendTransport()); | 277 CreateSendConfig(1, &sync_send_transport); |
| 264 CreateMatchingReceiveConfigs(observer.ReceiveTransport()); | 278 CreateMatchingReceiveConfigs(&sync_receive_transport); |
| 265 | 279 |
| 266 send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs; | 280 send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs; |
| 267 if (fec) { | 281 if (fec) { |
| 268 send_config_.rtp.fec.red_payload_type = kRedPayloadType; | 282 send_config_.rtp.fec.red_payload_type = kRedPayloadType; |
| 269 send_config_.rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; | 283 send_config_.rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; |
| 270 receive_configs_[0].rtp.fec.red_payload_type = kRedPayloadType; | 284 receive_configs_[0].rtp.fec.red_payload_type = kRedPayloadType; |
| 271 receive_configs_[0].rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; | 285 receive_configs_[0].rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; |
| 272 } | 286 } |
| 273 receive_configs_[0].rtp.nack.rtp_history_ms = 1000; | 287 receive_configs_[0].rtp.nack.rtp_history_ms = 1000; |
| 274 receive_configs_[0].renderer = &observer; | 288 receive_configs_[0].renderer = &observer; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 301 | 315 |
| 302 EXPECT_EQ(kEventSignaled, observer.Wait()) | 316 EXPECT_EQ(kEventSignaled, observer.Wait()) |
| 303 << "Timed out while waiting for audio and video to be synchronized."; | 317 << "Timed out while waiting for audio and video to be synchronized."; |
| 304 | 318 |
| 305 EXPECT_EQ(0, voe_base->StopSend(channel)); | 319 EXPECT_EQ(0, voe_base->StopSend(channel)); |
| 306 EXPECT_EQ(0, voe_base->StopReceive(channel)); | 320 EXPECT_EQ(0, voe_base->StopReceive(channel)); |
| 307 EXPECT_EQ(0, voe_base->StopPlayout(channel)); | 321 EXPECT_EQ(0, voe_base->StopPlayout(channel)); |
| 308 fake_audio_device.Stop(); | 322 fake_audio_device.Stop(); |
| 309 | 323 |
| 310 Stop(); | 324 Stop(); |
| 311 observer.StopSending(); | 325 sync_send_transport.StopSending(); |
| 312 audio_observer.StopSending(); | 326 sync_receive_transport.StopSending(); |
| 327 audio_send_transport.StopSending(); | |
| 328 audio_receive_transport.StopSending(); | |
| 313 | 329 |
| 314 voe_base->DeleteChannel(channel); | 330 voe_base->DeleteChannel(channel); |
| 315 voe_base->Release(); | 331 voe_base->Release(); |
| 316 voe_codec->Release(); | 332 voe_codec->Release(); |
| 317 voe_network->Release(); | 333 voe_network->Release(); |
| 318 voe_sync->Release(); | 334 voe_sync->Release(); |
| 319 | 335 |
| 320 DestroyStreams(); | 336 DestroyStreams(); |
| 321 | 337 |
| 322 receiver_call_->DestroyAudioReceiveStream(audio_receive_stream); | 338 receiver_call_->DestroyAudioReceiveStream(audio_receive_stream); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 338 TestAudioVideoSync(true, false); | 354 TestAudioVideoSync(true, false); |
| 339 } | 355 } |
| 340 | 356 |
| 341 void CallPerfTest::TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, | 357 void CallPerfTest::TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, |
| 342 int threshold_ms, | 358 int threshold_ms, |
| 343 int start_time_ms, | 359 int start_time_ms, |
| 344 int run_time_ms) { | 360 int run_time_ms) { |
| 345 class CaptureNtpTimeObserver : public test::EndToEndTest, | 361 class CaptureNtpTimeObserver : public test::EndToEndTest, |
| 346 public VideoRenderer { | 362 public VideoRenderer { |
| 347 public: | 363 public: |
| 348 CaptureNtpTimeObserver(const FakeNetworkPipe::Config& config, | 364 CaptureNtpTimeObserver(int threshold_ms, int start_time_ms, int run_time_ms) |
| 349 int threshold_ms, | 365 : EndToEndTest(kLongTimeoutMs), |
| 350 int start_time_ms, | |
| 351 int run_time_ms) | |
| 352 : EndToEndTest(kLongTimeoutMs, config), | |
| 353 clock_(Clock::GetRealTimeClock()), | 366 clock_(Clock::GetRealTimeClock()), |
| 354 threshold_ms_(threshold_ms), | 367 threshold_ms_(threshold_ms), |
| 355 start_time_ms_(start_time_ms), | 368 start_time_ms_(start_time_ms), |
| 356 run_time_ms_(run_time_ms), | 369 run_time_ms_(run_time_ms), |
| 357 creation_time_ms_(clock_->TimeInMilliseconds()), | 370 creation_time_ms_(clock_->TimeInMilliseconds()), |
| 358 capturer_(nullptr), | 371 capturer_(nullptr), |
| 359 rtp_start_timestamp_set_(false), | 372 rtp_start_timestamp_set_(false), |
| 360 rtp_start_timestamp_(0) {} | 373 rtp_start_timestamp_(0) {} |
| 361 | 374 |
| 362 private: | 375 private: |
| 363 void RenderFrame(const VideoFrame& video_frame, | 376 void RenderFrame(const VideoFrame& video_frame, |
| 364 int time_to_render_ms) override { | 377 int time_to_render_ms) override { |
| 378 rtc::CritScope lock(&crit_); | |
| 365 if (video_frame.ntp_time_ms() <= 0) { | 379 if (video_frame.ntp_time_ms() <= 0) { |
| 366 // Haven't got enough RTCP SR in order to calculate the capture ntp | 380 // Haven't got enough RTCP SR in order to calculate the capture ntp |
| 367 // time. | 381 // time. |
| 368 return; | 382 return; |
| 369 } | 383 } |
| 370 | 384 |
| 371 int64_t now_ms = clock_->TimeInMilliseconds(); | 385 int64_t now_ms = clock_->TimeInMilliseconds(); |
| 372 int64_t time_since_creation = now_ms - creation_time_ms_; | 386 int64_t time_since_creation = now_ms - creation_time_ms_; |
| 373 if (time_since_creation < start_time_ms_) { | 387 if (time_since_creation < start_time_ms_) { |
| 374 // Wait for |start_time_ms_| before start measuring. | 388 // Wait for |start_time_ms_| before start measuring. |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 395 ss << time_offset_ms; | 409 ss << time_offset_ms; |
| 396 | 410 |
| 397 webrtc::test::PrintResult( | 411 webrtc::test::PrintResult( |
| 398 "capture_ntp_time", "", "real - estimated", ss.str(), "ms", true); | 412 "capture_ntp_time", "", "real - estimated", ss.str(), "ms", true); |
| 399 EXPECT_TRUE(std::abs(time_offset_ms) < threshold_ms_); | 413 EXPECT_TRUE(std::abs(time_offset_ms) < threshold_ms_); |
| 400 } | 414 } |
| 401 | 415 |
| 402 bool IsTextureSupported() const override { return false; } | 416 bool IsTextureSupported() const override { return false; } |
| 403 | 417 |
| 404 virtual Action OnSendRtp(const uint8_t* packet, size_t length) { | 418 virtual Action OnSendRtp(const uint8_t* packet, size_t length) { |
| 419 rtc::CritScope lock(&crit_); | |
| 405 RTPHeader header; | 420 RTPHeader header; |
| 406 EXPECT_TRUE(parser_->Parse(packet, length, &header)); | 421 EXPECT_TRUE(parser_->Parse(packet, length, &header)); |
| 407 | 422 |
| 408 if (!rtp_start_timestamp_set_) { | 423 if (!rtp_start_timestamp_set_) { |
| 409 // Calculate the rtp timestamp offset in order to calculate the real | 424 // Calculate the rtp timestamp offset in order to calculate the real |
| 410 // capture time. | 425 // capture time. |
| 411 uint32_t first_capture_timestamp = | 426 uint32_t first_capture_timestamp = |
| 412 90 * static_cast<uint32_t>(capturer_->first_frame_capture_time()); | 427 90 * static_cast<uint32_t>(capturer_->first_frame_capture_time()); |
| 413 rtp_start_timestamp_ = header.timestamp - first_capture_timestamp; | 428 rtp_start_timestamp_ = header.timestamp - first_capture_timestamp; |
| 414 rtp_start_timestamp_set_ = true; | 429 rtp_start_timestamp_set_ = true; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 433 // Enable the receiver side rtt calculation. | 448 // Enable the receiver side rtt calculation. |
| 434 (*receive_configs)[0].rtp.rtcp_xr.receiver_reference_time_report = true; | 449 (*receive_configs)[0].rtp.rtcp_xr.receiver_reference_time_report = true; |
| 435 } | 450 } |
| 436 | 451 |
| 437 void PerformTest() override { | 452 void PerformTest() override { |
| 438 EXPECT_EQ(kEventSignaled, Wait()) << "Timed out while waiting for " | 453 EXPECT_EQ(kEventSignaled, Wait()) << "Timed out while waiting for " |
| 439 "estimated capture NTP time to be " | 454 "estimated capture NTP time to be " |
| 440 "within bounds."; | 455 "within bounds."; |
| 441 } | 456 } |
| 442 | 457 |
| 458 rtc::CriticalSection crit_; | |
| 443 Clock* clock_; | 459 Clock* clock_; |
|
pbos-webrtc
2015/10/27 14:06:29
const
| |
| 444 int threshold_ms_; | 460 int threshold_ms_; |
|
pbos-webrtc
2015/10/27 14:06:29
thread annotate what you need
stefan-webrtc
2015/10/27 14:33:16
Done.
| |
| 445 int start_time_ms_; | 461 int start_time_ms_; |
| 446 int run_time_ms_; | 462 int run_time_ms_; |
| 447 int64_t creation_time_ms_; | 463 int64_t creation_time_ms_; |
| 448 test::FrameGeneratorCapturer* capturer_; | 464 test::FrameGeneratorCapturer* capturer_; |
| 449 bool rtp_start_timestamp_set_; | 465 bool rtp_start_timestamp_set_; |
| 450 uint32_t rtp_start_timestamp_; | 466 uint32_t rtp_start_timestamp_; |
| 451 typedef std::map<uint32_t, uint32_t> FrameCaptureTimeList; | 467 typedef std::map<uint32_t, uint32_t> FrameCaptureTimeList; |
| 452 FrameCaptureTimeList capture_time_list_; | 468 FrameCaptureTimeList capture_time_list_; |
| 453 } test(net_config, threshold_ms, start_time_ms, run_time_ms); | 469 } test(threshold_ms, start_time_ms, run_time_ms); |
| 454 | 470 |
| 455 RunBaseTest(&test); | 471 RunBaseTest(&test, net_config); |
| 456 } | 472 } |
| 457 | 473 |
| 458 TEST_F(CallPerfTest, CaptureNtpTimeWithNetworkDelay) { | 474 TEST_F(CallPerfTest, CaptureNtpTimeWithNetworkDelay) { |
| 459 FakeNetworkPipe::Config net_config; | 475 FakeNetworkPipe::Config net_config; |
| 460 net_config.queue_delay_ms = 100; | 476 net_config.queue_delay_ms = 100; |
| 461 // TODO(wu): lower the threshold as the calculation/estimatation becomes more | 477 // TODO(wu): lower the threshold as the calculation/estimatation becomes more |
| 462 // accurate. | 478 // accurate. |
| 463 const int kThresholdMs = 100; | 479 const int kThresholdMs = 100; |
| 464 const int kStartTimeMs = 10000; | 480 const int kStartTimeMs = 10000; |
| 465 const int kRunTimeMs = 20000; | 481 const int kRunTimeMs = 20000; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 501 | 517 |
| 502 void PerformTest() override { | 518 void PerformTest() override { |
| 503 EXPECT_EQ(kEventSignaled, Wait()) | 519 EXPECT_EQ(kEventSignaled, Wait()) |
| 504 << "Timed out before receiving an overuse callback."; | 520 << "Timed out before receiving an overuse callback."; |
| 505 } | 521 } |
| 506 | 522 |
| 507 LoadObserver::Load tested_load_; | 523 LoadObserver::Load tested_load_; |
| 508 test::DelayedEncoder encoder_; | 524 test::DelayedEncoder encoder_; |
| 509 } test(tested_load, encode_delay_ms); | 525 } test(tested_load, encode_delay_ms); |
| 510 | 526 |
| 511 RunBaseTest(&test); | 527 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 512 } | 528 } |
| 513 | 529 |
| 514 TEST_F(CallPerfTest, ReceivesCpuUnderuse) { | 530 TEST_F(CallPerfTest, ReceivesCpuUnderuse) { |
| 515 const int kEncodeDelayMs = 2; | 531 const int kEncodeDelayMs = 2; |
| 516 TestCpuOveruse(LoadObserver::kUnderuse, kEncodeDelayMs); | 532 TestCpuOveruse(LoadObserver::kUnderuse, kEncodeDelayMs); |
| 517 } | 533 } |
| 518 | 534 |
| 519 TEST_F(CallPerfTest, ReceivesCpuOveruse) { | 535 TEST_F(CallPerfTest, ReceivesCpuOveruse) { |
| 520 const int kEncodeDelayMs = 35; | 536 const int kEncodeDelayMs = 35; |
| 521 TestCpuOveruse(LoadObserver::kOveruse, kEncodeDelayMs); | 537 TestCpuOveruse(LoadObserver::kOveruse, kEncodeDelayMs); |
| 522 } | 538 } |
| 523 | 539 |
| 524 void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) { | 540 void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) { |
| 525 static const int kMaxEncodeBitrateKbps = 30; | 541 static const int kMaxEncodeBitrateKbps = 30; |
| 526 static const int kMinTransmitBitrateBps = 150000; | 542 static const int kMinTransmitBitrateBps = 150000; |
| 527 static const int kMinAcceptableTransmitBitrate = 130; | 543 static const int kMinAcceptableTransmitBitrate = 130; |
| 528 static const int kMaxAcceptableTransmitBitrate = 170; | 544 static const int kMaxAcceptableTransmitBitrate = 170; |
| 529 static const int kNumBitrateObservationsInRange = 100; | 545 static const int kNumBitrateObservationsInRange = 10; |
| 530 static const int kAcceptableBitrateErrorMargin = 15; // +- 7 | 546 static const int kAcceptableBitrateErrorMargin = 15; // +- 7 |
| 531 class BitrateObserver : public test::EndToEndTest, public PacketReceiver { | 547 class BitrateObserver : public test::EndToEndTest { |
| 532 public: | 548 public: |
| 533 explicit BitrateObserver(bool using_min_transmit_bitrate) | 549 explicit BitrateObserver(bool using_min_transmit_bitrate) |
| 534 : EndToEndTest(kLongTimeoutMs), | 550 : EndToEndTest(kLongTimeoutMs), |
| 535 send_stream_(nullptr), | 551 send_stream_(nullptr), |
| 536 send_transport_receiver_(nullptr), | |
| 537 pad_to_min_bitrate_(using_min_transmit_bitrate), | 552 pad_to_min_bitrate_(using_min_transmit_bitrate), |
| 538 num_bitrate_observations_in_range_(0) {} | 553 num_bitrate_observations_in_range_(0) {} |
| 539 | 554 |
| 540 private: | 555 private: |
| 541 void SetReceivers(PacketReceiver* send_transport_receiver, | 556 Action OnSendRtcp(const uint8_t* packet, size_t length) override { |
|
pbos-webrtc
2015/10/27 14:06:29
Make a TODO to make this into something that runs
| |
| 542 PacketReceiver* receive_transport_receiver) override { | |
| 543 send_transport_receiver_ = send_transport_receiver; | |
| 544 test::RtpRtcpObserver::SetReceivers(this, receive_transport_receiver); | |
| 545 } | |
| 546 | |
| 547 DeliveryStatus DeliverPacket(MediaType media_type, | |
| 548 const uint8_t* packet, | |
| 549 size_t length, | |
| 550 const PacketTime& packet_time) override { | |
| 551 VideoSendStream::Stats stats = send_stream_->GetStats(); | 557 VideoSendStream::Stats stats = send_stream_->GetStats(); |
| 552 if (stats.substreams.size() > 0) { | 558 if (stats.substreams.size() > 0) { |
| 553 RTC_DCHECK_EQ(1u, stats.substreams.size()); | 559 RTC_DCHECK_EQ(1u, stats.substreams.size()); |
| 554 int bitrate_kbps = | 560 int bitrate_kbps = |
| 555 stats.substreams.begin()->second.total_bitrate_bps / 1000; | 561 stats.substreams.begin()->second.total_bitrate_bps / 1000; |
| 556 if (bitrate_kbps > 0) { | 562 if (bitrate_kbps > 0) { |
| 557 test::PrintResult( | 563 test::PrintResult( |
| 558 "bitrate_stats_", | 564 "bitrate_stats_", |
| 559 (pad_to_min_bitrate_ ? "min_transmit_bitrate" | 565 (pad_to_min_bitrate_ ? "min_transmit_bitrate" |
| 560 : "without_min_transmit_bitrate"), | 566 : "without_min_transmit_bitrate"), |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 574 bitrate_kbps < (kMaxEncodeBitrateKbps + | 580 bitrate_kbps < (kMaxEncodeBitrateKbps + |
| 575 kAcceptableBitrateErrorMargin / 2)) { | 581 kAcceptableBitrateErrorMargin / 2)) { |
| 576 ++num_bitrate_observations_in_range_; | 582 ++num_bitrate_observations_in_range_; |
| 577 } | 583 } |
| 578 } | 584 } |
| 579 if (num_bitrate_observations_in_range_ == | 585 if (num_bitrate_observations_in_range_ == |
| 580 kNumBitrateObservationsInRange) | 586 kNumBitrateObservationsInRange) |
| 581 observation_complete_->Set(); | 587 observation_complete_->Set(); |
| 582 } | 588 } |
| 583 } | 589 } |
| 584 return send_transport_receiver_->DeliverPacket(media_type, packet, length, | 590 return SEND_PACKET; |
| 585 packet_time); | |
| 586 } | 591 } |
| 587 | 592 |
| 588 void OnStreamsCreated( | 593 void OnStreamsCreated( |
| 589 VideoSendStream* send_stream, | 594 VideoSendStream* send_stream, |
| 590 const std::vector<VideoReceiveStream*>& receive_streams) override { | 595 const std::vector<VideoReceiveStream*>& receive_streams) override { |
| 591 send_stream_ = send_stream; | 596 send_stream_ = send_stream; |
| 592 } | 597 } |
| 593 | 598 |
| 594 void ModifyConfigs(VideoSendStream::Config* send_config, | 599 void ModifyConfigs(VideoSendStream::Config* send_config, |
| 595 std::vector<VideoReceiveStream::Config>* receive_configs, | 600 std::vector<VideoReceiveStream::Config>* receive_configs, |
| 596 VideoEncoderConfig* encoder_config) override { | 601 VideoEncoderConfig* encoder_config) override { |
| 597 if (pad_to_min_bitrate_) { | 602 if (pad_to_min_bitrate_) { |
| 598 encoder_config->min_transmit_bitrate_bps = kMinTransmitBitrateBps; | 603 encoder_config->min_transmit_bitrate_bps = kMinTransmitBitrateBps; |
| 599 } else { | 604 } else { |
| 600 RTC_DCHECK_EQ(0, encoder_config->min_transmit_bitrate_bps); | 605 RTC_DCHECK_EQ(0, encoder_config->min_transmit_bitrate_bps); |
| 601 } | 606 } |
| 602 } | 607 } |
| 603 | 608 |
| 604 void PerformTest() override { | 609 void PerformTest() override { |
| 605 EXPECT_EQ(kEventSignaled, Wait()) | 610 EXPECT_EQ(kEventSignaled, Wait()) |
| 606 << "Timeout while waiting for send-bitrate stats."; | 611 << "Timeout while waiting for send-bitrate stats."; |
| 607 } | 612 } |
| 608 | 613 |
| 609 VideoSendStream* send_stream_; | 614 VideoSendStream* send_stream_; |
| 610 PacketReceiver* send_transport_receiver_; | |
| 611 const bool pad_to_min_bitrate_; | 615 const bool pad_to_min_bitrate_; |
| 612 int num_bitrate_observations_in_range_; | 616 int num_bitrate_observations_in_range_; |
| 613 } test(pad_to_min_bitrate); | 617 } test(pad_to_min_bitrate); |
| 614 | 618 |
| 615 fake_encoder_.SetMaxBitrate(kMaxEncodeBitrateKbps); | 619 fake_encoder_.SetMaxBitrate(kMaxEncodeBitrateKbps); |
| 616 RunBaseTest(&test); | 620 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 617 } | 621 } |
| 618 | 622 |
| 619 TEST_F(CallPerfTest, PadsToMinTransmitBitrate) { TestMinTransmitBitrate(true); } | 623 TEST_F(CallPerfTest, PadsToMinTransmitBitrate) { TestMinTransmitBitrate(true); } |
| 620 | 624 |
| 621 TEST_F(CallPerfTest, NoPadWithoutMinTransmitBitrate) { | 625 TEST_F(CallPerfTest, NoPadWithoutMinTransmitBitrate) { |
| 622 TestMinTransmitBitrate(false); | 626 TestMinTransmitBitrate(false); |
| 623 } | 627 } |
| 624 | 628 |
| 625 TEST_F(CallPerfTest, KeepsHighBitrateWhenReconfiguringSender) { | 629 TEST_F(CallPerfTest, KeepsHighBitrateWhenReconfiguringSender) { |
| 626 static const uint32_t kInitialBitrateKbps = 400; | 630 static const uint32_t kInitialBitrateKbps = 400; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 701 } | 705 } |
| 702 | 706 |
| 703 private: | 707 private: |
| 704 rtc::scoped_ptr<webrtc::EventWrapper> time_to_reconfigure_; | 708 rtc::scoped_ptr<webrtc::EventWrapper> time_to_reconfigure_; |
| 705 int encoder_inits_; | 709 int encoder_inits_; |
| 706 uint32_t last_set_bitrate_; | 710 uint32_t last_set_bitrate_; |
| 707 VideoSendStream* send_stream_; | 711 VideoSendStream* send_stream_; |
| 708 VideoEncoderConfig encoder_config_; | 712 VideoEncoderConfig encoder_config_; |
| 709 } test; | 713 } test; |
| 710 | 714 |
| 711 RunBaseTest(&test); | 715 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 712 } | 716 } |
| 713 | 717 |
| 714 } // namespace webrtc | 718 } // namespace webrtc |
| OLD | NEW |