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 | 10 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 static const int kMinRunTimeMs = 30000; | 81 static const int kMinRunTimeMs = 30000; |
82 | 82 |
83 public: | 83 public: |
84 explicit VideoRtcpAndSyncObserver(Clock* clock) | 84 explicit VideoRtcpAndSyncObserver(Clock* clock) |
85 : test::RtpRtcpObserver(CallPerfTest::kLongTimeoutMs), | 85 : test::RtpRtcpObserver(CallPerfTest::kLongTimeoutMs), |
86 clock_(clock), | 86 clock_(clock), |
87 creation_time_ms_(clock_->TimeInMilliseconds()), | 87 creation_time_ms_(clock_->TimeInMilliseconds()), |
88 first_time_in_sync_(-1), | 88 first_time_in_sync_(-1), |
89 receive_stream_(nullptr) {} | 89 receive_stream_(nullptr) {} |
90 | 90 |
91 void RenderFrame(const VideoFrame& video_frame, | 91 void OnFrame(const VideoFrame& video_frame) override { |
92 int time_to_render_ms) override { | |
93 VideoReceiveStream::Stats stats; | 92 VideoReceiveStream::Stats stats; |
94 { | 93 { |
95 rtc::CritScope lock(&crit_); | 94 rtc::CritScope lock(&crit_); |
96 if (receive_stream_) | 95 if (receive_stream_) |
97 stats = receive_stream_->GetStats(); | 96 stats = receive_stream_->GetStats(); |
98 } | 97 } |
99 if (stats.sync_offset_ms == std::numeric_limits<int>::max()) | 98 if (stats.sync_offset_ms == std::numeric_limits<int>::max()) |
100 return; | 99 return; |
101 | 100 |
102 int64_t now_ms = clock_->TimeInMilliseconds(); | 101 int64_t now_ms = clock_->TimeInMilliseconds(); |
(...skipping 19 matching lines...) Expand all Loading... |
122 "synchronization", | 121 "synchronization", |
123 time_since_creation, | 122 time_since_creation, |
124 "ms", | 123 "ms", |
125 false); | 124 false); |
126 } | 125 } |
127 if (time_since_creation > kMinRunTimeMs) | 126 if (time_since_creation > kMinRunTimeMs) |
128 observation_complete_.Set(); | 127 observation_complete_.Set(); |
129 } | 128 } |
130 } | 129 } |
131 | 130 |
132 bool IsTextureSupported() const override { return false; } | |
133 | |
134 void set_receive_stream(VideoReceiveStream* receive_stream) { | 131 void set_receive_stream(VideoReceiveStream* receive_stream) { |
135 rtc::CritScope lock(&crit_); | 132 rtc::CritScope lock(&crit_); |
136 receive_stream_ = receive_stream; | 133 receive_stream_ = receive_stream; |
137 } | 134 } |
138 | 135 |
139 private: | 136 private: |
140 Clock* const clock_; | 137 Clock* const clock_; |
141 const int64_t creation_time_ms_; | 138 const int64_t creation_time_ms_; |
142 int64_t first_time_in_sync_; | 139 int64_t first_time_in_sync_; |
143 rtc::CriticalSection crit_; | 140 rtc::CriticalSection crit_; |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 test::PacketTransport* CreateSendTransport(Call* sender_call) override { | 367 test::PacketTransport* CreateSendTransport(Call* sender_call) override { |
371 return new test::PacketTransport( | 368 return new test::PacketTransport( |
372 sender_call, this, test::PacketTransport::kSender, net_config_); | 369 sender_call, this, test::PacketTransport::kSender, net_config_); |
373 } | 370 } |
374 | 371 |
375 test::PacketTransport* CreateReceiveTransport() override { | 372 test::PacketTransport* CreateReceiveTransport() override { |
376 return new test::PacketTransport( | 373 return new test::PacketTransport( |
377 nullptr, this, test::PacketTransport::kReceiver, net_config_); | 374 nullptr, this, test::PacketTransport::kReceiver, net_config_); |
378 } | 375 } |
379 | 376 |
380 void RenderFrame(const VideoFrame& video_frame, | 377 void OnFrame(const VideoFrame& video_frame) override { |
381 int time_to_render_ms) override { | |
382 rtc::CritScope lock(&crit_); | 378 rtc::CritScope lock(&crit_); |
383 if (video_frame.ntp_time_ms() <= 0) { | 379 if (video_frame.ntp_time_ms() <= 0) { |
384 // 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 |
385 // time. | 381 // time. |
386 return; | 382 return; |
387 } | 383 } |
388 | 384 |
389 int64_t now_ms = clock_->TimeInMilliseconds(); | 385 int64_t now_ms = clock_->TimeInMilliseconds(); |
390 int64_t time_since_creation = now_ms - creation_time_ms_; | 386 int64_t time_since_creation = now_ms - creation_time_ms_; |
391 if (time_since_creation < start_time_ms_) { | 387 if (time_since_creation < start_time_ms_) { |
(...skipping 18 matching lines...) Expand all Loading... |
410 int time_offset_ms = real_capture_timestamp - estimated_capture_timestamp; | 406 int time_offset_ms = real_capture_timestamp - estimated_capture_timestamp; |
411 time_offset_ms = time_offset_ms / 90; | 407 time_offset_ms = time_offset_ms / 90; |
412 std::stringstream ss; | 408 std::stringstream ss; |
413 ss << time_offset_ms; | 409 ss << time_offset_ms; |
414 | 410 |
415 webrtc::test::PrintResult( | 411 webrtc::test::PrintResult( |
416 "capture_ntp_time", "", "real - estimated", ss.str(), "ms", true); | 412 "capture_ntp_time", "", "real - estimated", ss.str(), "ms", true); |
417 EXPECT_TRUE(std::abs(time_offset_ms) < threshold_ms_); | 413 EXPECT_TRUE(std::abs(time_offset_ms) < threshold_ms_); |
418 } | 414 } |
419 | 415 |
420 bool IsTextureSupported() const override { return false; } | |
421 | |
422 virtual Action OnSendRtp(const uint8_t* packet, size_t length) { | 416 virtual Action OnSendRtp(const uint8_t* packet, size_t length) { |
423 rtc::CritScope lock(&crit_); | 417 rtc::CritScope lock(&crit_); |
424 RTPHeader header; | 418 RTPHeader header; |
425 EXPECT_TRUE(parser_->Parse(packet, length, &header)); | 419 EXPECT_TRUE(parser_->Parse(packet, length, &header)); |
426 | 420 |
427 if (!rtp_start_timestamp_set_) { | 421 if (!rtp_start_timestamp_set_) { |
428 // Calculate the rtp timestamp offset in order to calculate the real | 422 // Calculate the rtp timestamp offset in order to calculate the real |
429 // capture time. | 423 // capture time. |
430 uint32_t first_capture_timestamp = | 424 uint32_t first_capture_timestamp = |
431 90 * static_cast<uint32_t>(capturer_->first_frame_capture_time()); | 425 90 * static_cast<uint32_t>(capturer_->first_frame_capture_time()); |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 int encoder_inits_; | 711 int encoder_inits_; |
718 uint32_t last_set_bitrate_; | 712 uint32_t last_set_bitrate_; |
719 VideoSendStream* send_stream_; | 713 VideoSendStream* send_stream_; |
720 VideoEncoderConfig encoder_config_; | 714 VideoEncoderConfig encoder_config_; |
721 } test; | 715 } test; |
722 | 716 |
723 RunBaseTest(&test); | 717 RunBaseTest(&test); |
724 } | 718 } |
725 | 719 |
726 } // namespace webrtc | 720 } // namespace webrtc |
OLD | NEW |