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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 return packet.BuildExternalBuffer( | 125 return packet.BuildExternalBuffer( |
126 &context_->buffer[context_->position], | 126 &context_->buffer[context_->position], |
127 context_->buffer_size - context_->position, this); | 127 context_->buffer_size - context_->position, this); |
128 } | 128 } |
129 | 129 |
130 private: | 130 private: |
131 RtcpContext* const context_; | 131 RtcpContext* const context_; |
132 }; | 132 }; |
133 | 133 |
134 RTCPSender::RTCPSender( | 134 RTCPSender::RTCPSender( |
135 int32_t id, | |
136 bool audio, | 135 bool audio, |
137 Clock* clock, | 136 Clock* clock, |
138 ReceiveStatistics* receive_statistics, | 137 ReceiveStatistics* receive_statistics, |
139 RtcpPacketTypeCounterObserver* packet_type_counter_observer) | 138 RtcpPacketTypeCounterObserver* packet_type_counter_observer) |
140 : id_(id), | 139 : audio_(audio), |
141 audio_(audio), | |
142 clock_(clock), | 140 clock_(clock), |
143 method_(kRtcpOff), | 141 method_(kRtcpOff), |
144 critical_section_transport_( | 142 critical_section_transport_( |
145 CriticalSectionWrapper::CreateCriticalSection()), | 143 CriticalSectionWrapper::CreateCriticalSection()), |
146 cbTransport_(nullptr), | 144 cbTransport_(nullptr), |
147 | 145 |
148 critical_section_rtcp_sender_( | 146 critical_section_rtcp_sender_( |
149 CriticalSectionWrapper::CreateCriticalSection()), | 147 CriticalSectionWrapper::CreateCriticalSection()), |
150 using_nack_(false), | 148 using_nack_(false), |
151 sending_(false), | 149 sending_(false), |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 delaySinceLastReceivedSR = now-receiveTime; | 1110 delaySinceLastReceivedSR = now-receiveTime; |
1113 } | 1111 } |
1114 report_block->delaySinceLastSR = delaySinceLastReceivedSR; | 1112 report_block->delaySinceLastSR = delaySinceLastReceivedSR; |
1115 report_block->lastSR = feedback_state.remote_sr; | 1113 report_block->lastSR = feedback_state.remote_sr; |
1116 return true; | 1114 return true; |
1117 } | 1115 } |
1118 | 1116 |
1119 int32_t RTCPSender::SendToNetwork(const uint8_t* dataBuffer, size_t length) { | 1117 int32_t RTCPSender::SendToNetwork(const uint8_t* dataBuffer, size_t length) { |
1120 CriticalSectionScoped lock(critical_section_transport_.get()); | 1118 CriticalSectionScoped lock(critical_section_transport_.get()); |
1121 if (cbTransport_) { | 1119 if (cbTransport_) { |
1122 if (cbTransport_->SendRTCPPacket(id_, dataBuffer, length) > 0) | 1120 if (cbTransport_->SendRTCPPacket(dataBuffer, length) > 0) |
1123 return 0; | 1121 return 0; |
1124 } | 1122 } |
1125 return -1; | 1123 return -1; |
1126 } | 1124 } |
1127 | 1125 |
1128 void RTCPSender::SetCsrcs(const std::vector<uint32_t>& csrcs) { | 1126 void RTCPSender::SetCsrcs(const std::vector<uint32_t>& csrcs) { |
1129 assert(csrcs.size() <= kRtpCsrcSize); | 1127 assert(csrcs.size() <= kRtpCsrcSize); |
1130 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); | 1128 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); |
1131 csrcs_ = csrcs; | 1129 csrcs_ = csrcs; |
1132 } | 1130 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 return true; | 1209 return true; |
1212 } | 1210 } |
1213 | 1211 |
1214 bool RTCPSender::SendFeedbackPacket(const rtcp::TransportFeedback& packet) { | 1212 bool RTCPSender::SendFeedbackPacket(const rtcp::TransportFeedback& packet) { |
1215 CriticalSectionScoped lock(critical_section_transport_.get()); | 1213 CriticalSectionScoped lock(critical_section_transport_.get()); |
1216 if (!cbTransport_) | 1214 if (!cbTransport_) |
1217 return false; | 1215 return false; |
1218 | 1216 |
1219 class Sender : public rtcp::RtcpPacket::PacketReadyCallback { | 1217 class Sender : public rtcp::RtcpPacket::PacketReadyCallback { |
1220 public: | 1218 public: |
1221 Sender(Transport* transport, int32_t id) | 1219 Sender(Transport* transport) |
1222 : transport_(transport), id_(id), send_failure_(false) {} | 1220 : transport_(transport), send_failure_(false) {} |
1223 | 1221 |
1224 void OnPacketReady(uint8_t* data, size_t length) override { | 1222 void OnPacketReady(uint8_t* data, size_t length) override { |
1225 if (transport_->SendRTCPPacket(id_, data, length) <= 0) | 1223 if (transport_->SendRTCPPacket(data, length) <= 0) |
1226 send_failure_ = true; | 1224 send_failure_ = true; |
1227 } | 1225 } |
1228 | 1226 |
1229 Transport* const transport_; | 1227 Transport* const transport_; |
1230 int32_t id_; | |
1231 bool send_failure_; | 1228 bool send_failure_; |
1232 } sender(cbTransport_, id_); | 1229 } sender(cbTransport_); |
1233 | 1230 |
1234 uint8_t buffer[IP_PACKET_SIZE]; | 1231 uint8_t buffer[IP_PACKET_SIZE]; |
1235 return packet.BuildExternalBuffer(buffer, IP_PACKET_SIZE, &sender) && | 1232 return packet.BuildExternalBuffer(buffer, IP_PACKET_SIZE, &sender) && |
1236 !sender.send_failure_; | 1233 !sender.send_failure_; |
1237 } | 1234 } |
1238 | 1235 |
1239 } // namespace webrtc | 1236 } // namespace webrtc |
OLD | NEW |