Chromium Code Reviews| Index: webrtc/modules/rtp_rtcp/source/rtcp_sender.cc |
| diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc |
| index a5fccebad1dd67eb792fcf70ae402fafdcac5700..edca8ff36f4d0adfc656004dedd6da06c655a49d 100644 |
| --- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc |
| +++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc |
| @@ -99,8 +99,10 @@ class PacketContainer : public rtcp::CompoundPacket, |
| } |
| } |
| - size_t SendPackets() { |
| - rtcp::CompoundPacket::Build(this); |
| + size_t SendPackets(size_t max_payload_length) { |
| + RTC_DCHECK_LE(max_payload_length, static_cast<size_t>(IP_PACKET_SIZE)); |
| + uint8_t buffer[IP_PACKET_SIZE]; |
| + BuildExternalBuffer(buffer, max_payload_length, this); |
| return bytes_sent_; |
| } |
| @@ -168,7 +170,8 @@ RTCPSender::RTCPSender( |
| tmmbr_help_(), |
| tmmbr_send_(0), |
| - packet_oh_send_(0), |
| + packet_overhead_(28), |
| + max_payload_length_(IP_PACKET_SIZE - packet_overhead_), |
| app_sub_type_(0), |
| app_name_(0), |
| @@ -277,6 +280,12 @@ void RTCPSender::SetTMMBRStatus(bool enable) { |
| } |
| } |
| +void RTCPSender::SetMaxPayloadLength(size_t length, uint16_t packet_overhead) { |
| + rtc::CritScope lock(&critical_section_rtcp_sender_); |
| + max_payload_length_ = length; |
| + packet_overhead_ = packet_overhead; |
| +} |
| + |
| void RTCPSender::SetStartTimestamp(uint32_t start_timestamp) { |
| rtc::CritScope lock(&critical_section_rtcp_sender_); |
| start_timestamp_ = start_timestamp; |
| @@ -590,7 +599,7 @@ std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBR( |
| if (lengthOfBoundingSet > 0) { |
| for (int32_t i = 0; i < lengthOfBoundingSet; i++) { |
| if (candidateSet->Tmmbr(i) == tmmbr_send_ && |
| - candidateSet->PacketOH(i) == packet_oh_send_) { |
| + candidateSet->PacketOH(i) == packet_overhead_) { |
| // Do not send the same tuple. |
| return nullptr; |
| } |
| @@ -598,7 +607,7 @@ std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBR( |
| if (!tmmbrOwner) { |
| // use received bounding set as candidate set |
| // add current tuple |
| - candidateSet->SetEntry(lengthOfBoundingSet, tmmbr_send_, packet_oh_send_, |
| + candidateSet->SetEntry(lengthOfBoundingSet, tmmbr_send_, packet_overhead_, |
|
åsapersson
2016/03/30 10:28:36
Should packet_overhead_ for tmmbr include the RTP
danilchap
2016/03/30 12:38:24
Yes, in fact it should, as well as rtp header exte
|
| ssrc_); |
| int numCandidates = lengthOfBoundingSet + 1; |
| @@ -622,7 +631,7 @@ std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBR( |
| rtcp::TmmbItem request; |
| request.set_ssrc(remote_ssrc_); |
| request.set_bitrate_bps(tmmbr_send_ * 1000); |
| - request.set_packet_overhead(packet_oh_send_); |
| + request.set_packet_overhead(packet_overhead_); |
| tmmbr->WithTmmbr(request); |
| return std::unique_ptr<rtcp::RtcpPacket>(tmmbr); |
| @@ -809,7 +818,7 @@ int32_t RTCPSender::SendCompoundRTCP( |
| RTC_DCHECK(AllVolatileFlagsConsumed()); |
| } |
| - size_t bytes_sent = container.SendPackets(); |
| + size_t bytes_sent = container.SendPackets(max_payload_length_); |
| return bytes_sent == 0 ? -1 : 0; |
| } |
| @@ -1030,8 +1039,9 @@ bool RTCPSender::SendFeedbackPacket(const rtcp::TransportFeedback& packet) { |
| // but we can't because of an incorrect warning (C4822) in MVS 2013. |
| } sender(transport_, event_log_); |
| + RTC_DCHECK_LE(max_payload_length_, static_cast<size_t>(IP_PACKET_SIZE)); |
| uint8_t buffer[IP_PACKET_SIZE]; |
| - return packet.BuildExternalBuffer(buffer, IP_PACKET_SIZE, &sender) && |
| + return packet.BuildExternalBuffer(buffer, max_payload_length_, &sender) && |
| !sender.send_failure_; |
| } |