| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 fec_bitrate_.Update(fec_packet->length(), clock_->TimeInMilliseconds()); | 163 fec_bitrate_.Update(fec_packet->length(), clock_->TimeInMilliseconds()); |
| 164 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), | 164 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), |
| 165 "Video::PacketFec", "timestamp", rtp_timestamp, | 165 "Video::PacketFec", "timestamp", rtp_timestamp, |
| 166 "seqnum", fec_sequence_number); | 166 "seqnum", fec_sequence_number); |
| 167 } else { | 167 } else { |
| 168 LOG(LS_WARNING) << "Failed to send FEC packet " << fec_sequence_number; | 168 LOG(LS_WARNING) << "Failed to send FEC packet " << fec_sequence_number; |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 } | 171 } |
| 172 | 172 |
| 173 void RTPSenderVideo::SetGenericFECStatus(bool enable, | 173 void RTPSenderVideo::SetUlpfecConfig(bool enabled, |
| 174 uint8_t payload_type_red, | 174 int red_payload_type, |
| 175 uint8_t payload_type_fec) { | 175 int ulpfec_payload_type) { |
| 176 RTC_DCHECK(!enable || payload_type_red > 0); | 176 RTC_DCHECK(!enabled || red_payload_type > 0); |
| 177 RTC_DCHECK_LE(red_payload_type, 127); |
| 178 RTC_DCHECK_LE(ulpfec_payload_type, 127); |
| 179 |
| 177 rtc::CritScope cs(&crit_); | 180 rtc::CritScope cs(&crit_); |
| 178 fec_enabled_ = enable; | 181 fec_enabled_ = enabled; |
| 179 red_payload_type_ = payload_type_red; | 182 red_payload_type_ = red_payload_type; |
| 180 fec_payload_type_ = payload_type_fec; | 183 fec_payload_type_ = ulpfec_payload_type; |
| 184 |
| 185 // Reset FEC rates. |
| 181 delta_fec_params_ = FecProtectionParams{0, 1, kFecMaskRandom}; | 186 delta_fec_params_ = FecProtectionParams{0, 1, kFecMaskRandom}; |
| 182 key_fec_params_ = FecProtectionParams{0, 1, kFecMaskRandom}; | 187 key_fec_params_ = FecProtectionParams{0, 1, kFecMaskRandom}; |
| 183 } | 188 } |
| 184 | 189 |
| 185 void RTPSenderVideo::GenericFECStatus(bool* enable, | 190 void RTPSenderVideo::UlpfecConfig(bool* enabled, |
| 186 uint8_t* payload_type_red, | 191 int* red_payload_type, |
| 187 uint8_t* payload_type_fec) const { | 192 int* ulpfec_payload_type) const { |
| 188 rtc::CritScope cs(&crit_); | 193 rtc::CritScope cs(&crit_); |
| 189 *enable = fec_enabled_; | 194 *enabled = fec_enabled_; |
| 190 *payload_type_red = red_payload_type_; | 195 *red_payload_type = red_payload_type_; |
| 191 *payload_type_fec = fec_payload_type_; | 196 *ulpfec_payload_type = fec_payload_type_; |
| 192 } | 197 } |
| 193 | 198 |
| 194 size_t RTPSenderVideo::FecPacketOverhead() const { | 199 size_t RTPSenderVideo::FecPacketOverhead() const { |
| 195 rtc::CritScope cs(&crit_); | 200 rtc::CritScope cs(&crit_); |
| 196 size_t overhead = 0; | 201 size_t overhead = 0; |
| 197 if (red_payload_type_ != 0) { | 202 if (red_payload_type_ != -1) { |
| 198 // Overhead is FEC headers plus RED for FEC header plus anything in RTP | 203 // Overhead is FEC headers plus RED for FEC header plus anything in RTP |
| 199 // header beyond the 12 bytes base header (CSRC list, extensions...) | 204 // header beyond the 12 bytes base header (CSRC list, extensions...) |
| 200 // This reason for the header extensions to be included here is that | 205 // This reason for the header extensions to be included here is that |
| 201 // from an FEC viewpoint, they are part of the payload to be protected. | 206 // from an FEC viewpoint, they are part of the payload to be protected. |
| 202 // (The base RTP header is already protected by the FEC header.) | 207 // (The base RTP header is already protected by the FEC header.) |
| 203 return producer_fec_.MaxPacketOverhead() + kRedForFecHeaderLength + | 208 return producer_fec_.MaxPacketOverhead() + kRedForFecHeaderLength + |
| 204 (rtp_sender_->RtpHeaderLength() - kRtpHeaderSize); | 209 (rtp_sender_->RtpHeaderLength() - kRtpHeaderSize); |
| 205 } | 210 } |
| 206 if (fec_enabled_) | 211 if (fec_enabled_) |
| 207 overhead += producer_fec_.MaxPacketOverhead(); | 212 overhead += producer_fec_.MaxPacketOverhead(); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 | 300 |
| 296 size_t payload_bytes_in_packet = 0; | 301 size_t payload_bytes_in_packet = 0; |
| 297 if (!packetizer->NextPacket(payload, &payload_bytes_in_packet, &last)) | 302 if (!packetizer->NextPacket(payload, &payload_bytes_in_packet, &last)) |
| 298 return false; | 303 return false; |
| 299 | 304 |
| 300 packet->SetPayloadSize(payload_bytes_in_packet); | 305 packet->SetPayloadSize(payload_bytes_in_packet); |
| 301 packet->SetMarker(last); | 306 packet->SetMarker(last); |
| 302 if (!rtp_sender_->AssignSequenceNumber(packet.get())) | 307 if (!rtp_sender_->AssignSequenceNumber(packet.get())) |
| 303 return false; | 308 return false; |
| 304 | 309 |
| 305 if (red_payload_type != 0) { | 310 if (red_payload_type != -1) { |
| 306 SendVideoPacketAsRed(std::move(packet), storage, | 311 SendVideoPacketAsRed(std::move(packet), storage, |
| 307 packetizer->GetProtectionType() == kProtectedPacket); | 312 packetizer->GetProtectionType() == kProtectedPacket); |
| 308 } else { | 313 } else { |
| 309 SendVideoPacket(std::move(packet), storage); | 314 SendVideoPacket(std::move(packet), storage); |
| 310 } | 315 } |
| 311 | 316 |
| 312 if (first_frame) { | 317 if (first_frame) { |
| 313 if (first) { | 318 if (first) { |
| 314 LOG(LS_INFO) | 319 LOG(LS_INFO) |
| 315 << "Sent first RTP packet of the first video frame (pre-pacer)"; | 320 << "Sent first RTP packet of the first video frame (pre-pacer)"; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 341 rtc::CritScope cs(&crit_); | 346 rtc::CritScope cs(&crit_); |
| 342 return retransmission_settings_; | 347 return retransmission_settings_; |
| 343 } | 348 } |
| 344 | 349 |
| 345 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { | 350 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { |
| 346 rtc::CritScope cs(&crit_); | 351 rtc::CritScope cs(&crit_); |
| 347 retransmission_settings_ = settings; | 352 retransmission_settings_ = settings; |
| 348 } | 353 } |
| 349 | 354 |
| 350 } // namespace webrtc | 355 } // namespace webrtc |
| OLD | NEW |