| Index: webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
|
| diff --git a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
|
| index a6c7647be5e9e3b0d301b450425ecffd7a451dac..51bbf3996e1c5a011d7896bad576dcc6942db334 100644
|
| --- a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
|
| +++ b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
|
| @@ -12,6 +12,7 @@
|
|
|
| #include <string.h>
|
|
|
| +#include <algorithm>
|
| #include <set>
|
| #include <string>
|
|
|
| @@ -26,6 +27,11 @@
|
| #endif
|
|
|
| namespace webrtc {
|
| +namespace {
|
| +const int64_t kRtpRtcpMaxIdleTimeProcessMs = 5;
|
| +const int64_t kRtpRtcpRttProcessTimeMs = 1000;
|
| +const int64_t kRtpRtcpBitrateProcessTimeMs = 10;
|
| +} // namespace
|
|
|
| RTPExtensionType StringToRtpExtensionType(const std::string& extension) {
|
| if (extension == RtpExtension::kTimestampOffsetUri)
|
| @@ -89,9 +95,12 @@ ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const Configuration& configuration)
|
| this),
|
| clock_(configuration.clock),
|
| audio_(configuration.audio),
|
| - last_process_time_(configuration.clock->TimeInMilliseconds()),
|
| - last_bitrate_process_time_(configuration.clock->TimeInMilliseconds()),
|
| - last_rtt_process_time_(configuration.clock->TimeInMilliseconds()),
|
| + keepalive_config_(configuration.keepalive_config),
|
| + last_bitrate_process_time_(clock_->TimeInMilliseconds()),
|
| + last_rtt_process_time_(clock_->TimeInMilliseconds()),
|
| + next_process_time_(clock_->TimeInMilliseconds() +
|
| + kRtpRtcpMaxIdleTimeProcessMs),
|
| + next_keepalive_time_(-1),
|
| packet_overhead_(28), // IPV4 UDP.
|
| nack_last_time_sent_full_(0),
|
| nack_last_time_sent_full_prev_(0),
|
| @@ -118,6 +127,11 @@ ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const Configuration& configuration)
|
| configuration.overhead_observer));
|
| // Make sure rtcp sender use same timestamp offset as rtp sender.
|
| rtcp_sender_.SetTimestampOffset(rtp_sender_->TimestampOffset());
|
| +
|
| + if (keepalive_config_.timeout_interval_ms != -1) {
|
| + next_keepalive_time_ =
|
| + clock_->TimeInMilliseconds() + keepalive_config_.timeout_interval_ms;
|
| + }
|
| }
|
|
|
| // Set default packet size limit.
|
| @@ -130,24 +144,38 @@ ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const Configuration& configuration)
|
| // Returns the number of milliseconds until the module want a worker thread
|
| // to call Process.
|
| int64_t ModuleRtpRtcpImpl::TimeUntilNextProcess() {
|
| - const int64_t now = clock_->TimeInMilliseconds();
|
| - const int64_t kRtpRtcpMaxIdleTimeProcessMs = 5;
|
| - return kRtpRtcpMaxIdleTimeProcessMs - (now - last_process_time_);
|
| + return std::max<int64_t>(0,
|
| + next_process_time_ - clock_->TimeInMilliseconds());
|
| }
|
|
|
| // Process any pending tasks such as timeouts (non time critical events).
|
| void ModuleRtpRtcpImpl::Process() {
|
| const int64_t now = clock_->TimeInMilliseconds();
|
| - last_process_time_ = now;
|
| + next_process_time_ = now + kRtpRtcpMaxIdleTimeProcessMs;
|
|
|
| if (rtp_sender_) {
|
| - const int64_t kRtpRtcpBitrateProcessTimeMs = 10;
|
| if (now >= last_bitrate_process_time_ + kRtpRtcpBitrateProcessTimeMs) {
|
| rtp_sender_->ProcessBitrate();
|
| last_bitrate_process_time_ = now;
|
| + next_process_time_ =
|
| + std::min(next_process_time_, now + kRtpRtcpBitrateProcessTimeMs);
|
| + }
|
| + if (keepalive_config_.timeout_interval_ms > 0 &&
|
| + now >= next_keepalive_time_) {
|
| + int64_t last_send_time_ms = rtp_sender_->LastTimestampTimeMs();
|
| + // If no packet has been sent, |last_send_time_ms| will be 0, and so the
|
| + // keep-alive will be triggered as expected.
|
| + if (now >= last_send_time_ms + keepalive_config_.timeout_interval_ms) {
|
| + rtp_sender_->SendKeepAlive(keepalive_config_.payload_type);
|
| + next_keepalive_time_ = now + keepalive_config_.timeout_interval_ms;
|
| + } else {
|
| + next_keepalive_time_ =
|
| + last_send_time_ms + keepalive_config_.timeout_interval_ms;
|
| + }
|
| + next_process_time_ = std::min(next_process_time_, next_keepalive_time_);
|
| }
|
| }
|
| - const int64_t kRtpRtcpRttProcessTimeMs = 1000;
|
| +
|
| bool process_rtt = now >= last_rtt_process_time_ + kRtpRtcpRttProcessTimeMs;
|
| if (rtcp_sender_.Sending()) {
|
| // Process RTT if we have received a receiver report and we haven't
|
| @@ -201,6 +229,8 @@ void ModuleRtpRtcpImpl::Process() {
|
| // Get processed rtt.
|
| if (process_rtt) {
|
| last_rtt_process_time_ = now;
|
| + next_process_time_ = std::min(
|
| + next_process_time_, last_rtt_process_time_ + kRtpRtcpRttProcessTimeMs);
|
| if (rtt_stats_) {
|
| // Make sure we have a valid RTT before setting.
|
| int64_t last_rtt = rtt_stats_->LastProcessedRtt();
|
|
|