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): Symbolic constant. |
125 SetMaxRtpPacketSize(IP_PACKET_SIZE - 40); | |
stefan-webrtc
2016/12/20 13:05:01
I think it would make sense to make 40 a named con
nisse-webrtc
2016/12/20 13:38:13
There's just too many named constants for the same
stefan-webrtc
2016/12/20 14:18:23
Probably, since then you won't be able to build th
nisse-webrtc
2017/01/09 16:02:24
Done.
| |
125 } | 126 } |
126 | 127 |
127 // Returns the number of milliseconds until the module want a worker thread | 128 // Returns the number of milliseconds until the module want a worker thread |
128 // to call Process. | 129 // to call Process. |
129 int64_t ModuleRtpRtcpImpl::TimeUntilNextProcess() { | 130 int64_t ModuleRtpRtcpImpl::TimeUntilNextProcess() { |
130 const int64_t now = clock_->TimeInMilliseconds(); | 131 const int64_t now = clock_->TimeInMilliseconds(); |
131 const int64_t kRtpRtcpMaxIdleTimeProcessMs = 5; | 132 const int64_t kRtpRtcpMaxIdleTimeProcessMs = 5; |
132 return kRtpRtcpMaxIdleTimeProcessMs - (now - last_process_time_); | 133 return kRtpRtcpMaxIdleTimeProcessMs - (now - last_process_time_); |
133 } | 134 } |
134 | 135 |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
408 int probe_cluster_id) { | 409 int probe_cluster_id) { |
409 return rtp_sender_.TimeToSendPacket(ssrc, sequence_number, capture_time_ms, | 410 return rtp_sender_.TimeToSendPacket(ssrc, sequence_number, capture_time_ms, |
410 retransmission, probe_cluster_id); | 411 retransmission, probe_cluster_id); |
411 } | 412 } |
412 | 413 |
413 size_t ModuleRtpRtcpImpl::TimeToSendPadding(size_t bytes, | 414 size_t ModuleRtpRtcpImpl::TimeToSendPadding(size_t bytes, |
414 int probe_cluster_id) { | 415 int probe_cluster_id) { |
415 return rtp_sender_.TimeToSendPadding(bytes, probe_cluster_id); | 416 return rtp_sender_.TimeToSendPadding(bytes, probe_cluster_id); |
416 } | 417 } |
417 | 418 |
418 uint16_t ModuleRtpRtcpImpl::MaxPayloadLength() const { | 419 size_t ModuleRtpRtcpImpl::MaxPayloadSize() const { |
419 return rtp_sender_.MaxPayloadLength(); | 420 return rtp_sender_.MaxPayloadSize(); |
420 } | 421 } |
421 | 422 |
422 uint16_t ModuleRtpRtcpImpl::MaxDataPayloadLength() const { | 423 size_t ModuleRtpRtcpImpl::MaxRtpPacketSize() const { |
423 return rtp_sender_.MaxDataPayloadLength(); | 424 return rtp_sender_.MaxRtpPacketSize(); |
424 } | 425 } |
425 | 426 |
426 int32_t ModuleRtpRtcpImpl::SetTransportOverhead( | 427 void ModuleRtpRtcpImpl::SetMaxRtpPacketSize(size_t rtp_packet_size) { |
427 const bool tcp, | 428 RTC_DCHECK_LE(rtp_packet_size, IP_PACKET_SIZE) |
428 const bool ipv6, | 429 << "rtp packet size too large: " << rtp_packet_size; |
429 const uint8_t authentication_overhead) { | 430 RTC_DCHECK_GT(rtp_packet_size, packet_overhead_) |
430 uint16_t packet_overhead = 0; | 431 << "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 | 432 |
445 if (packet_overhead == packet_overhead_) { | 433 rtcp_sender_.SetMaxRtpPacketSize(rtp_packet_size); |
446 // Ok same as before. | 434 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 } | 435 } |
478 | 436 |
479 RtcpMode ModuleRtpRtcpImpl::RTCP() const { | 437 RtcpMode ModuleRtpRtcpImpl::RTCP() const { |
480 return rtcp_sender_.Status(); | 438 return rtcp_sender_.Status(); |
481 } | 439 } |
482 | 440 |
483 // Configure RTCP status i.e on/off. | 441 // Configure RTCP status i.e on/off. |
484 void ModuleRtpRtcpImpl::SetRTCPStatus(const RtcpMode method) { | 442 void ModuleRtpRtcpImpl::SetRTCPStatus(const RtcpMode method) { |
485 rtcp_sender_.SetRTCPStatus(method); | 443 rtcp_sender_.SetRTCPStatus(method); |
486 } | 444 } |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
951 StreamDataCountersCallback* | 909 StreamDataCountersCallback* |
952 ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const { | 910 ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const { |
953 return rtp_sender_.GetRtpStatisticsCallback(); | 911 return rtp_sender_.GetRtpStatisticsCallback(); |
954 } | 912 } |
955 | 913 |
956 void ModuleRtpRtcpImpl::SetVideoBitrateAllocation( | 914 void ModuleRtpRtcpImpl::SetVideoBitrateAllocation( |
957 const BitrateAllocation& bitrate) { | 915 const BitrateAllocation& bitrate) { |
958 rtcp_sender_.SetVideoBitrateAllocation(bitrate); | 916 rtcp_sender_.SetVideoBitrateAllocation(bitrate); |
959 } | 917 } |
960 } // namespace webrtc | 918 } // namespace webrtc |
OLD | NEW |