| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 22 matching lines...) Expand all Loading... |
| 33 #include "webrtc/video/receive_statistics_proxy.h" | 33 #include "webrtc/video/receive_statistics_proxy.h" |
| 34 #include "webrtc/video_engine/call_stats.h" | 34 #include "webrtc/video_engine/call_stats.h" |
| 35 #include "webrtc/video_engine/payload_router.h" | 35 #include "webrtc/video_engine/payload_router.h" |
| 36 #include "webrtc/video_engine/report_block_stats.h" | 36 #include "webrtc/video_engine/report_block_stats.h" |
| 37 #include "webrtc/video_engine/vie_defines.h" | 37 #include "webrtc/video_engine/vie_defines.h" |
| 38 | 38 |
| 39 namespace webrtc { | 39 namespace webrtc { |
| 40 | 40 |
| 41 const int kMaxDecodeWaitTimeMs = 50; | 41 const int kMaxDecodeWaitTimeMs = 50; |
| 42 static const int kMaxTargetDelayMs = 10000; | 42 static const int kMaxTargetDelayMs = 10000; |
| 43 static const float kMaxIncompleteTimeMultiplier = 3.5f; | |
| 44 | 43 |
| 45 // Helper class receiving statistics callbacks. | 44 // Helper class receiving statistics callbacks. |
| 46 class ChannelStatsObserver : public CallStatsObserver { | 45 class ChannelStatsObserver : public CallStatsObserver { |
| 47 public: | 46 public: |
| 48 explicit ChannelStatsObserver(ViEChannel* owner) : owner_(owner) {} | 47 explicit ChannelStatsObserver(ViEChannel* owner) : owner_(owner) {} |
| 49 virtual ~ChannelStatsObserver() {} | 48 virtual ~ChannelStatsObserver() {} |
| 50 | 49 |
| 51 // Implements StatsObserver. | 50 // Implements StatsObserver. |
| 52 virtual void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { | 51 virtual void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { |
| 53 owner_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); | 52 owner_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 // Don't allow a number lower than the default value. | 567 // Don't allow a number lower than the default value. |
| 569 if (nack_history_size_sender_ < kSendSidePacketHistorySize) { | 568 if (nack_history_size_sender_ < kSendSidePacketHistorySize) { |
| 570 nack_history_size_sender_ = kSendSidePacketHistorySize; | 569 nack_history_size_sender_ = kSendSidePacketHistorySize; |
| 571 } | 570 } |
| 572 } | 571 } |
| 573 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 572 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
| 574 rtp_rtcp->SetStorePacketsStatus(true, nack_history_size_sender_); | 573 rtp_rtcp->SetStorePacketsStatus(true, nack_history_size_sender_); |
| 575 return 0; | 574 return 0; |
| 576 } | 575 } |
| 577 | 576 |
| 578 int ViEChannel::SetReceiverBufferingMode(int target_delay_ms) { | |
| 579 if ((target_delay_ms < 0) || (target_delay_ms > kMaxTargetDelayMs)) { | |
| 580 LOG(LS_ERROR) << "Invalid receive buffer delay value."; | |
| 581 return -1; | |
| 582 } | |
| 583 int max_nack_list_size; | |
| 584 int max_incomplete_time_ms; | |
| 585 if (target_delay_ms == 0) { | |
| 586 // Real-time mode - restore default settings. | |
| 587 max_nack_reordering_threshold_ = kMaxPacketAgeToNack; | |
| 588 max_nack_list_size = kMaxNackListSize; | |
| 589 max_incomplete_time_ms = 0; | |
| 590 } else { | |
| 591 max_nack_list_size = 3 * GetRequiredNackListSize(target_delay_ms) / 4; | |
| 592 max_nack_reordering_threshold_ = max_nack_list_size; | |
| 593 // Calculate the max incomplete time and round to int. | |
| 594 max_incomplete_time_ms = static_cast<int>(kMaxIncompleteTimeMultiplier * | |
| 595 target_delay_ms + 0.5f); | |
| 596 } | |
| 597 vcm_->SetNackSettings(max_nack_list_size, max_nack_reordering_threshold_, | |
| 598 max_incomplete_time_ms); | |
| 599 vcm_->SetMinReceiverDelay(target_delay_ms); | |
| 600 if (vie_sync_.SetTargetBufferingDelay(target_delay_ms) < 0) | |
| 601 return -1; | |
| 602 return 0; | |
| 603 } | |
| 604 | |
| 605 int ViEChannel::GetRequiredNackListSize(int target_delay_ms) { | 577 int ViEChannel::GetRequiredNackListSize(int target_delay_ms) { |
| 606 // The max size of the nack list should be large enough to accommodate the | 578 // The max size of the nack list should be large enough to accommodate the |
| 607 // the number of packets (frames) resulting from the increased delay. | 579 // the number of packets (frames) resulting from the increased delay. |
| 608 // Roughly estimating for ~40 packets per frame @ 30fps. | 580 // Roughly estimating for ~40 packets per frame @ 30fps. |
| 609 return target_delay_ms * 40 * 30 / 1000; | 581 return target_delay_ms * 40 * 30 / 1000; |
| 610 } | 582 } |
| 611 | 583 |
| 612 int ViEChannel::SetSendTimestampOffsetStatus(bool enable, int id) { | 584 int ViEChannel::SetSendTimestampOffsetStatus(bool enable, int id) { |
| 613 // Disable any previous registrations of this extension to avoid errors. | 585 // Disable any previous registrations of this extension to avoid errors. |
| 614 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 586 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 CriticalSectionScoped cs(crit_.get()); | 1216 CriticalSectionScoped cs(crit_.get()); |
| 1245 receive_stats_callback_ = receive_statistics_proxy; | 1217 receive_stats_callback_ = receive_statistics_proxy; |
| 1246 } | 1218 } |
| 1247 | 1219 |
| 1248 void ViEChannel::SetIncomingVideoStream( | 1220 void ViEChannel::SetIncomingVideoStream( |
| 1249 IncomingVideoStream* incoming_video_stream) { | 1221 IncomingVideoStream* incoming_video_stream) { |
| 1250 CriticalSectionScoped cs(crit_.get()); | 1222 CriticalSectionScoped cs(crit_.get()); |
| 1251 incoming_video_stream_ = incoming_video_stream; | 1223 incoming_video_stream_ = incoming_video_stream; |
| 1252 } | 1224 } |
| 1253 } // namespace webrtc | 1225 } // namespace webrtc |
| OLD | NEW |