| 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 <string.h> // memcpy | 13 #include <string.h> // memcpy |
| 14 | 14 |
| 15 #include <utility> | 15 #include <utility> |
| 16 | 16 |
| 17 #include "webrtc/common_types.h" | 17 #include "webrtc/common_types.h" |
| 18 #include "webrtc/logging/rtc_event_log/events/rtc_event_rtcp_packet_outgoing.h" |
| 18 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 19 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
| 19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" | 20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" |
| 20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" | 21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" |
| 21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h" | 22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h" |
| 22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" | 23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" |
| 23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h" | 24 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h" |
| 24 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h" | 25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h" |
| 25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h" | 26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h" |
| 26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" | 27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" |
| 27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h" | 28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h" |
| 28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h" | 29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h" |
| 29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" | 30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" |
| 30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbn.h" | 31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbn.h" |
| 31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbr.h" | 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbr.h" |
| 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
| 33 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" | 34 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" |
| 34 #include "webrtc/modules/rtp_rtcp/source/time_util.h" | 35 #include "webrtc/modules/rtp_rtcp/source/time_util.h" |
| 35 #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h" | 36 #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h" |
| 36 #include "webrtc/rtc_base/checks.h" | 37 #include "webrtc/rtc_base/checks.h" |
| 37 #include "webrtc/rtc_base/constructormagic.h" | 38 #include "webrtc/rtc_base/constructormagic.h" |
| 38 #include "webrtc/rtc_base/logging.h" | 39 #include "webrtc/rtc_base/logging.h" |
| 40 #include "webrtc/rtc_base/ptr_util.h" |
| 39 #include "webrtc/rtc_base/trace_event.h" | 41 #include "webrtc/rtc_base/trace_event.h" |
| 40 | 42 |
| 41 namespace webrtc { | 43 namespace webrtc { |
| 42 | 44 |
| 43 namespace { | 45 namespace { |
| 44 const uint32_t kRtcpAnyExtendedReports = | 46 const uint32_t kRtcpAnyExtendedReports = |
| 45 kRtcpXrVoipMetric | kRtcpXrReceiverReferenceTime | kRtcpXrDlrrReportBlock | | 47 kRtcpXrVoipMetric | kRtcpXrReceiverReferenceTime | kRtcpXrDlrrReportBlock | |
| 46 kRtcpXrTargetBitrate; | 48 kRtcpXrTargetBitrate; |
| 47 } // namespace | 49 } // namespace |
| 48 | 50 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 : transport_(transport), event_log_(event_log), bytes_sent_(0) {} | 94 : transport_(transport), event_log_(event_log), bytes_sent_(0) {} |
| 93 virtual ~PacketContainer() { | 95 virtual ~PacketContainer() { |
| 94 for (RtcpPacket* packet : appended_packets_) | 96 for (RtcpPacket* packet : appended_packets_) |
| 95 delete packet; | 97 delete packet; |
| 96 } | 98 } |
| 97 | 99 |
| 98 void OnPacketReady(uint8_t* data, size_t length) override { | 100 void OnPacketReady(uint8_t* data, size_t length) override { |
| 99 if (transport_->SendRtcp(data, length)) { | 101 if (transport_->SendRtcp(data, length)) { |
| 100 bytes_sent_ += length; | 102 bytes_sent_ += length; |
| 101 if (event_log_) { | 103 if (event_log_) { |
| 102 event_log_->LogOutgoingRtcpPacket( | 104 event_log_->Log(rtc::MakeUnique<RtcEventRtcpPacketOutgoing>( |
| 103 rtc::ArrayView<const uint8_t>(data, length)); | 105 rtc::ArrayView<const uint8_t>(data, length))); |
| 104 } | 106 } |
| 105 } | 107 } |
| 106 } | 108 } |
| 107 | 109 |
| 108 size_t SendPackets(size_t max_payload_length) { | 110 size_t SendPackets(size_t max_payload_length) { |
| 109 RTC_DCHECK_LE(max_payload_length, IP_PACKET_SIZE); | 111 RTC_DCHECK_LE(max_payload_length, IP_PACKET_SIZE); |
| 110 uint8_t buffer[IP_PACKET_SIZE]; | 112 uint8_t buffer[IP_PACKET_SIZE]; |
| 111 BuildExternalBuffer(buffer, max_payload_length, this); | 113 BuildExternalBuffer(buffer, max_payload_length, this); |
| 112 return bytes_sent_; | 114 return bytes_sent_; |
| 113 } | 115 } |
| (...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 | 958 |
| 957 bool RTCPSender::SendFeedbackPacket(const rtcp::TransportFeedback& packet) { | 959 bool RTCPSender::SendFeedbackPacket(const rtcp::TransportFeedback& packet) { |
| 958 class Sender : public rtcp::RtcpPacket::PacketReadyCallback { | 960 class Sender : public rtcp::RtcpPacket::PacketReadyCallback { |
| 959 public: | 961 public: |
| 960 Sender(Transport* transport, RtcEventLog* event_log) | 962 Sender(Transport* transport, RtcEventLog* event_log) |
| 961 : transport_(transport), event_log_(event_log), send_failure_(false) {} | 963 : transport_(transport), event_log_(event_log), send_failure_(false) {} |
| 962 | 964 |
| 963 void OnPacketReady(uint8_t* data, size_t length) override { | 965 void OnPacketReady(uint8_t* data, size_t length) override { |
| 964 if (transport_->SendRtcp(data, length)) { | 966 if (transport_->SendRtcp(data, length)) { |
| 965 if (event_log_) { | 967 if (event_log_) { |
| 966 event_log_->LogOutgoingRtcpPacket( | 968 event_log_->Log(rtc::MakeUnique<RtcEventRtcpPacketOutgoing>( |
| 967 rtc::ArrayView<const uint8_t>(data, length)); | 969 rtc::ArrayView<const uint8_t>(data, length))); |
| 968 } | 970 } |
| 969 } else { | 971 } else { |
| 970 send_failure_ = true; | 972 send_failure_ = true; |
| 971 } | 973 } |
| 972 } | 974 } |
| 973 | 975 |
| 974 Transport* const transport_; | 976 Transport* const transport_; |
| 975 RtcEventLog* const event_log_; | 977 RtcEventLog* const event_log_; |
| 976 bool send_failure_; | 978 bool send_failure_; |
| 977 // TODO(terelius): We would like to | 979 // TODO(terelius): We would like to |
| 978 // RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Sender); | 980 // RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Sender); |
| 979 // but we can't because of an incorrect warning (C4822) in MVS 2013. | 981 // but we can't because of an incorrect warning (C4822) in MVS 2013. |
| 980 } sender(transport_, event_log_); | 982 } sender(transport_, event_log_); |
| 981 | 983 |
| 982 size_t max_packet_size; | 984 size_t max_packet_size; |
| 983 { | 985 { |
| 984 rtc::CritScope lock(&critical_section_rtcp_sender_); | 986 rtc::CritScope lock(&critical_section_rtcp_sender_); |
| 985 if (method_ == RtcpMode::kOff) | 987 if (method_ == RtcpMode::kOff) |
| 986 return false; | 988 return false; |
| 987 max_packet_size = max_packet_size_; | 989 max_packet_size = max_packet_size_; |
| 988 } | 990 } |
| 989 | 991 |
| 990 RTC_DCHECK_LE(max_packet_size, IP_PACKET_SIZE); | 992 RTC_DCHECK_LE(max_packet_size, IP_PACKET_SIZE); |
| 991 uint8_t buffer[IP_PACKET_SIZE]; | 993 uint8_t buffer[IP_PACKET_SIZE]; |
| 992 return packet.BuildExternalBuffer(buffer, max_packet_size, &sender) && | 994 return packet.BuildExternalBuffer(buffer, max_packet_size, &sender) && |
| 993 !sender.send_failure_; | 995 !sender.send_failure_; |
| 994 } | 996 } |
| 995 | 997 |
| 996 } // namespace webrtc | 998 } // namespace webrtc |
| OLD | NEW |