| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 rtt_ms_(0) { | 114 rtt_ms_(0) { |
| 115 // Make sure that RTCP objects are aware of our SSRC. | 115 // Make sure that RTCP objects are aware of our SSRC. |
| 116 uint32_t SSRC = rtp_sender_.SSRC(); | 116 uint32_t SSRC = rtp_sender_.SSRC(); |
| 117 rtcp_sender_.SetSSRC(SSRC); | 117 rtcp_sender_.SetSSRC(SSRC); |
| 118 SetRtcpReceiverSsrcs(SSRC); | 118 SetRtcpReceiverSsrcs(SSRC); |
| 119 | 119 |
| 120 // Make sure rtcp sender use same timestamp offset as rtp sender. | 120 // Make sure rtcp sender use same timestamp offset as rtp sender. |
| 121 rtcp_sender_.SetTimestampOffset(rtp_sender_.TimestampOffset()); | 121 rtcp_sender_.SetTimestampOffset(rtp_sender_.TimestampOffset()); |
| 122 | 122 |
| 123 // Set default packet size limit. | 123 // Set default packet size limit. |
| 124 SetMaxTransferUnit(IP_PACKET_SIZE); | 124 // TODO(nisse): Kind-of duplicates |
| 125 // webrtc::VideoSendStream::Config::Rtp::kDefaultMaxPacketSize. |
| 126 const size_t kTcpOverIpv4HeaderSize = 40; |
| 127 SetMaxRtpPacketSize(IP_PACKET_SIZE - kTcpOverIpv4HeaderSize); |
| 125 } | 128 } |
| 126 | 129 |
| 127 // Returns the number of milliseconds until the module want a worker thread | 130 // Returns the number of milliseconds until the module want a worker thread |
| 128 // to call Process. | 131 // to call Process. |
| 129 int64_t ModuleRtpRtcpImpl::TimeUntilNextProcess() { | 132 int64_t ModuleRtpRtcpImpl::TimeUntilNextProcess() { |
| 130 const int64_t now = clock_->TimeInMilliseconds(); | 133 const int64_t now = clock_->TimeInMilliseconds(); |
| 131 const int64_t kRtpRtcpMaxIdleTimeProcessMs = 5; | 134 const int64_t kRtpRtcpMaxIdleTimeProcessMs = 5; |
| 132 return kRtpRtcpMaxIdleTimeProcessMs - (now - last_process_time_); | 135 return kRtpRtcpMaxIdleTimeProcessMs - (now - last_process_time_); |
| 133 } | 136 } |
| 134 | 137 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 int probe_cluster_id) { | 411 int probe_cluster_id) { |
| 409 return rtp_sender_.TimeToSendPacket(ssrc, sequence_number, capture_time_ms, | 412 return rtp_sender_.TimeToSendPacket(ssrc, sequence_number, capture_time_ms, |
| 410 retransmission, probe_cluster_id); | 413 retransmission, probe_cluster_id); |
| 411 } | 414 } |
| 412 | 415 |
| 413 size_t ModuleRtpRtcpImpl::TimeToSendPadding(size_t bytes, | 416 size_t ModuleRtpRtcpImpl::TimeToSendPadding(size_t bytes, |
| 414 int probe_cluster_id) { | 417 int probe_cluster_id) { |
| 415 return rtp_sender_.TimeToSendPadding(bytes, probe_cluster_id); | 418 return rtp_sender_.TimeToSendPadding(bytes, probe_cluster_id); |
| 416 } | 419 } |
| 417 | 420 |
| 418 uint16_t ModuleRtpRtcpImpl::MaxPayloadLength() const { | 421 size_t ModuleRtpRtcpImpl::MaxPayloadSize() const { |
| 419 return rtp_sender_.MaxPayloadLength(); | 422 return rtp_sender_.MaxPayloadSize(); |
| 420 } | 423 } |
| 421 | 424 |
| 422 uint16_t ModuleRtpRtcpImpl::MaxDataPayloadLength() const { | 425 size_t ModuleRtpRtcpImpl::MaxRtpPacketSize() const { |
| 423 return rtp_sender_.MaxDataPayloadLength(); | 426 return rtp_sender_.MaxRtpPacketSize(); |
| 424 } | 427 } |
| 425 | 428 |
| 426 int32_t ModuleRtpRtcpImpl::SetTransportOverhead( | 429 void ModuleRtpRtcpImpl::SetMaxRtpPacketSize(size_t rtp_packet_size) { |
| 427 const bool tcp, | 430 RTC_DCHECK_LE(rtp_packet_size, IP_PACKET_SIZE) |
| 428 const bool ipv6, | 431 << "rtp packet size too large: " << rtp_packet_size; |
| 429 const uint8_t authentication_overhead) { | 432 RTC_DCHECK_GT(rtp_packet_size, packet_overhead_) |
| 430 uint16_t packet_overhead = 0; | 433 << "rtp packet size too small: " << rtp_packet_size; |
| 431 if (ipv6) { | |
| 432 packet_overhead = 40; | |
| 433 } else { | |
| 434 packet_overhead = 20; | |
| 435 } | |
| 436 if (tcp) { | |
| 437 // TCP. | |
| 438 packet_overhead += 20; | |
| 439 } else { | |
| 440 // UDP. | |
| 441 packet_overhead += 8; | |
| 442 } | |
| 443 packet_overhead += authentication_overhead; | |
| 444 | 434 |
| 445 if (packet_overhead == packet_overhead_) { | 435 rtcp_sender_.SetMaxRtpPacketSize(rtp_packet_size); |
| 446 // Ok same as before. | 436 rtp_sender_.SetMaxRtpPacketSize(rtp_packet_size); |
| 447 return 0; | |
| 448 } | |
| 449 | |
| 450 size_t mtu = rtp_sender_.MaxPayloadLength() + packet_overhead_; | |
| 451 size_t max_payload_length = mtu - packet_overhead; | |
| 452 packet_overhead_ = packet_overhead; | |
| 453 rtcp_sender_.SetMaxPayloadLength(max_payload_length); | |
| 454 rtp_sender_.SetMaxPayloadLength(max_payload_length); | |
| 455 return 0; | |
| 456 } | |
| 457 | |
| 458 void ModuleRtpRtcpImpl::SetTransportOverhead( | |
| 459 int transport_overhead_per_packet) { | |
| 460 RTC_DCHECK_GT(transport_overhead_per_packet, 0); | |
| 461 int mtu = rtp_sender_.MaxPayloadLength() + packet_overhead_; | |
| 462 RTC_DCHECK_LT(transport_overhead_per_packet, mtu); | |
| 463 size_t max_payload_length = mtu - transport_overhead_per_packet; | |
| 464 packet_overhead_ = transport_overhead_per_packet; | |
| 465 rtp_sender_.SetTransportOverhead(packet_overhead_); | |
| 466 rtcp_sender_.SetMaxPayloadLength(max_payload_length); | |
| 467 rtp_sender_.SetMaxPayloadLength(max_payload_length); | |
| 468 } | |
| 469 | |
| 470 int32_t ModuleRtpRtcpImpl::SetMaxTransferUnit(uint16_t mtu) { | |
| 471 RTC_DCHECK_LE(mtu, IP_PACKET_SIZE) << "MTU too large: " << mtu; | |
| 472 RTC_DCHECK_GT(mtu, packet_overhead_) << "MTU too small: " << mtu; | |
| 473 size_t max_payload_length = mtu - packet_overhead_; | |
| 474 rtcp_sender_.SetMaxPayloadLength(max_payload_length); | |
| 475 rtp_sender_.SetMaxPayloadLength(max_payload_length); | |
| 476 return 0; | |
| 477 } | 437 } |
| 478 | 438 |
| 479 RtcpMode ModuleRtpRtcpImpl::RTCP() const { | 439 RtcpMode ModuleRtpRtcpImpl::RTCP() const { |
| 480 return rtcp_sender_.Status(); | 440 return rtcp_sender_.Status(); |
| 481 } | 441 } |
| 482 | 442 |
| 483 // Configure RTCP status i.e on/off. | 443 // Configure RTCP status i.e on/off. |
| 484 void ModuleRtpRtcpImpl::SetRTCPStatus(const RtcpMode method) { | 444 void ModuleRtpRtcpImpl::SetRTCPStatus(const RtcpMode method) { |
| 485 rtcp_sender_.SetRTCPStatus(method); | 445 rtcp_sender_.SetRTCPStatus(method); |
| 486 } | 446 } |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 StreamDataCountersCallback* | 911 StreamDataCountersCallback* |
| 952 ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const { | 912 ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const { |
| 953 return rtp_sender_.GetRtpStatisticsCallback(); | 913 return rtp_sender_.GetRtpStatisticsCallback(); |
| 954 } | 914 } |
| 955 | 915 |
| 956 void ModuleRtpRtcpImpl::SetVideoBitrateAllocation( | 916 void ModuleRtpRtcpImpl::SetVideoBitrateAllocation( |
| 957 const BitrateAllocation& bitrate) { | 917 const BitrateAllocation& bitrate) { |
| 958 rtcp_sender_.SetVideoBitrateAllocation(bitrate); | 918 rtcp_sender_.SetVideoBitrateAllocation(bitrate); |
| 959 } | 919 } |
| 960 } // namespace webrtc | 920 } // namespace webrtc |
| OLD | NEW |