| 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 |
| 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h" |
| 12 | 12 |
| 13 #include <assert.h> // assert | 13 #include <assert.h> // assert |
| 14 #include <stdlib.h> // rand | 14 #include <stdlib.h> // rand |
| 15 #include <string.h> // memcpy | 15 #include <string.h> // memcpy |
| 16 | 16 |
| 17 #include <algorithm> // min | 17 #include <algorithm> // min |
| 18 #include <limits> // max | 18 #include <limits> // max |
| 19 | 19 |
| 20 #include "webrtc/base/checks.h" | 20 #include "webrtc/base/checks.h" |
| 21 #include "webrtc/common_types.h" | 21 #include "webrtc/common_types.h" |
| 22 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 22 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
| 23 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" | 23 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" |
| 24 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
| 24 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 25 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
| 25 #include "webrtc/system_wrappers/interface/logging.h" | 26 #include "webrtc/system_wrappers/interface/logging.h" |
| 26 #include "webrtc/system_wrappers/interface/trace_event.h" | 27 #include "webrtc/system_wrappers/interface/trace_event.h" |
| 27 | 28 |
| 28 namespace webrtc { | 29 namespace webrtc { |
| 29 | 30 |
| 30 using RTCPUtility::RTCPCnameInformation; | 31 using RTCPUtility::RTCPCnameInformation; |
| 31 | 32 |
| 32 NACKStringBuilder::NACKStringBuilder() | 33 NACKStringBuilder::NACKStringBuilder() |
| 33 : stream_(""), count_(0), prevNack_(0), consecutive_(false) { | 34 : stream_(""), count_(0), prevNack_(0), consecutive_(false) { |
| (...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1203 } | 1204 } |
| 1204 | 1205 |
| 1205 bool RTCPSender::AllVolatileFlagsConsumed() const { | 1206 bool RTCPSender::AllVolatileFlagsConsumed() const { |
| 1206 for (const ReportFlag& flag : report_flags_) { | 1207 for (const ReportFlag& flag : report_flags_) { |
| 1207 if (flag.is_volatile) | 1208 if (flag.is_volatile) |
| 1208 return false; | 1209 return false; |
| 1209 } | 1210 } |
| 1210 return true; | 1211 return true; |
| 1211 } | 1212 } |
| 1212 | 1213 |
| 1214 bool RTCPSender::SendFeedbackPacket(const rtcp::TransportFeedback& packet) { |
| 1215 CriticalSectionScoped lock(critical_section_transport_.get()); |
| 1216 if (!cbTransport_) |
| 1217 return false; |
| 1218 |
| 1219 class Sender : public rtcp::RtcpPacket::PacketReadyCallback { |
| 1220 public: |
| 1221 Sender(Transport* transport, int32_t id) |
| 1222 : transport_(transport), id_(id), send_failure_(false) {} |
| 1223 |
| 1224 void OnPacketReady(uint8_t* data, size_t length) override { |
| 1225 if (transport_->SendRTCPPacket(id_, data, length) <= 0) |
| 1226 send_failure_ = true; |
| 1227 } |
| 1228 |
| 1229 Transport* const transport_; |
| 1230 int32_t id_; |
| 1231 bool send_failure_; |
| 1232 } sender(cbTransport_, id_); |
| 1233 |
| 1234 uint8_t buffer[IP_PACKET_SIZE]; |
| 1235 return packet.BuildExternalBuffer(buffer, IP_PACKET_SIZE, &sender) && |
| 1236 !sender.send_failure_; |
| 1237 } |
| 1238 |
| 1213 } // namespace webrtc | 1239 } // namespace webrtc |
| OLD | NEW |