| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 void RTPSenderVideo::SendVideoPacketAsRed(uint8_t* data_buffer, | 96 void RTPSenderVideo::SendVideoPacketAsRed(uint8_t* data_buffer, |
| 97 size_t payload_length, | 97 size_t payload_length, |
| 98 size_t rtp_header_length, | 98 size_t rtp_header_length, |
| 99 uint16_t media_seq_num, | 99 uint16_t media_seq_num, |
| 100 uint32_t capture_timestamp, | 100 uint32_t capture_timestamp, |
| 101 int64_t capture_time_ms, | 101 int64_t capture_time_ms, |
| 102 StorageType media_packet_storage, | 102 StorageType media_packet_storage, |
| 103 bool protect) { | 103 bool protect) { |
| 104 std::unique_ptr<RedPacket> red_packet; | 104 std::unique_ptr<RedPacket> red_packet; |
| 105 std::vector<RedPacket*> fec_packets; | 105 std::vector<std::unique_ptr<RedPacket>> fec_packets; |
| 106 StorageType fec_storage = kDontRetransmit; | 106 StorageType fec_storage = kDontRetransmit; |
| 107 uint16_t next_fec_sequence_number = 0; | 107 uint16_t next_fec_sequence_number = 0; |
| 108 { | 108 { |
| 109 // Only protect while creating RED and FEC packets, not when sending. | 109 // Only protect while creating RED and FEC packets, not when sending. |
| 110 rtc::CritScope cs(&crit_); | 110 rtc::CritScope cs(&crit_); |
| 111 red_packet.reset(producer_fec_.BuildRedPacket( | 111 red_packet = ProducerFec::BuildRedPacket( |
| 112 data_buffer, payload_length, rtp_header_length, red_payload_type_)); | 112 data_buffer, payload_length, rtp_header_length, red_payload_type_); |
| 113 if (protect) { | 113 if (protect) { |
| 114 producer_fec_.AddRtpPacketAndGenerateFec(data_buffer, payload_length, | 114 producer_fec_.AddRtpPacketAndGenerateFec(data_buffer, payload_length, |
| 115 rtp_header_length); | 115 rtp_header_length); |
| 116 } | 116 } |
| 117 uint16_t num_fec_packets = producer_fec_.NumAvailableFecPackets(); | 117 uint16_t num_fec_packets = producer_fec_.NumAvailableFecPackets(); |
| 118 if (num_fec_packets > 0) { | 118 if (num_fec_packets > 0) { |
| 119 next_fec_sequence_number = | 119 next_fec_sequence_number = |
| 120 rtp_sender_->AllocateSequenceNumber(num_fec_packets); | 120 rtp_sender_->AllocateSequenceNumber(num_fec_packets); |
| 121 fec_packets = producer_fec_.GetFecPackets( | 121 fec_packets = producer_fec_.GetFecPacketsAsRed( |
| 122 red_payload_type_, fec_payload_type_, next_fec_sequence_number, | 122 red_payload_type_, fec_payload_type_, next_fec_sequence_number, |
| 123 rtp_header_length); | 123 rtp_header_length); |
| 124 RTC_DCHECK_EQ(num_fec_packets, fec_packets.size()); | 124 RTC_DCHECK_EQ(num_fec_packets, fec_packets.size()); |
| 125 if (retransmission_settings_ & kRetransmitFECPackets) | 125 if (retransmission_settings_ & kRetransmitFECPackets) |
| 126 fec_storage = kAllowRetransmission; | 126 fec_storage = kAllowRetransmission; |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 if (rtp_sender_->SendToNetwork( | 129 if (rtp_sender_->SendToNetwork( |
| 130 red_packet->data(), red_packet->length() - rtp_header_length, | 130 red_packet->data(), red_packet->length() - rtp_header_length, |
| 131 rtp_header_length, capture_time_ms, media_packet_storage, | 131 rtp_header_length, capture_time_ms, media_packet_storage, |
| 132 RtpPacketSender::kLowPriority)) { | 132 RtpPacketSender::kLowPriority)) { |
| 133 rtc::CritScope cs(&stats_crit_); | 133 rtc::CritScope cs(&stats_crit_); |
| 134 video_bitrate_.Update(red_packet->length(), clock_->TimeInMilliseconds()); | 134 video_bitrate_.Update(red_packet->length(), clock_->TimeInMilliseconds()); |
| 135 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), | 135 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), |
| 136 "Video::PacketRed", "timestamp", capture_timestamp, | 136 "Video::PacketRed", "timestamp", capture_timestamp, |
| 137 "seqnum", media_seq_num); | 137 "seqnum", media_seq_num); |
| 138 } else { | 138 } else { |
| 139 LOG(LS_WARNING) << "Failed to send RED packet " << media_seq_num; | 139 LOG(LS_WARNING) << "Failed to send RED packet " << media_seq_num; |
| 140 } | 140 } |
| 141 for (RedPacket* fec_packet : fec_packets) { | 141 for (const auto& fec_packet : fec_packets) { |
| 142 if (rtp_sender_->SendToNetwork( | 142 if (rtp_sender_->SendToNetwork( |
| 143 fec_packet->data(), fec_packet->length() - rtp_header_length, | 143 fec_packet->data(), fec_packet->length() - rtp_header_length, |
| 144 rtp_header_length, capture_time_ms, fec_storage, | 144 rtp_header_length, capture_time_ms, fec_storage, |
| 145 RtpPacketSender::kLowPriority)) { | 145 RtpPacketSender::kLowPriority)) { |
| 146 rtc::CritScope cs(&stats_crit_); | 146 rtc::CritScope cs(&stats_crit_); |
| 147 fec_bitrate_.Update(fec_packet->length(), clock_->TimeInMilliseconds()); | 147 fec_bitrate_.Update(fec_packet->length(), clock_->TimeInMilliseconds()); |
| 148 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), | 148 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), |
| 149 "Video::PacketFec", "timestamp", capture_timestamp, | 149 "Video::PacketFec", "timestamp", capture_timestamp, |
| 150 "seqnum", next_fec_sequence_number); | 150 "seqnum", next_fec_sequence_number); |
| 151 } else { | 151 } else { |
| 152 LOG(LS_WARNING) << "Failed to send FEC packet " | 152 LOG(LS_WARNING) << "Failed to send FEC packet " |
| 153 << next_fec_sequence_number; | 153 << next_fec_sequence_number; |
| 154 } | 154 } |
| 155 delete fec_packet; | |
| 156 ++next_fec_sequence_number; | 155 ++next_fec_sequence_number; |
| 157 } | 156 } |
| 158 } | 157 } |
| 159 | 158 |
| 160 void RTPSenderVideo::SetGenericFECStatus(bool enable, | 159 void RTPSenderVideo::SetGenericFECStatus(bool enable, |
| 161 uint8_t payload_type_red, | 160 uint8_t payload_type_red, |
| 162 uint8_t payload_type_fec) { | 161 uint8_t payload_type_fec) { |
| 163 RTC_DCHECK(!enable || payload_type_red > 0); | 162 RTC_DCHECK(!enable || payload_type_red > 0); |
| 164 rtc::CritScope cs(&crit_); | 163 rtc::CritScope cs(&crit_); |
| 165 fec_enabled_ = enable; | 164 fec_enabled_ = enable; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 video_type, rtp_sender_->MaxDataPayloadLength(), | 221 video_type, rtp_sender_->MaxDataPayloadLength(), |
| 223 video_header ? &(video_header->codecHeader) : nullptr, frame_type)); | 222 video_header ? &(video_header->codecHeader) : nullptr, frame_type)); |
| 224 | 223 |
| 225 StorageType storage; | 224 StorageType storage; |
| 226 int red_payload_type; | 225 int red_payload_type; |
| 227 bool first_frame = first_frame_sent_(); | 226 bool first_frame = first_frame_sent_(); |
| 228 { | 227 { |
| 229 rtc::CritScope cs(&crit_); | 228 rtc::CritScope cs(&crit_); |
| 230 FecProtectionParams* fec_params = | 229 FecProtectionParams* fec_params = |
| 231 frame_type == kVideoFrameKey ? &key_fec_params_ : &delta_fec_params_; | 230 frame_type == kVideoFrameKey ? &key_fec_params_ : &delta_fec_params_; |
| 232 producer_fec_.SetFecParameters(fec_params, 0); | 231 // We currently do not use unequal protection in the FEC. |
| 232 // This is signalled both here (by setting the number of important |
| 233 // packets to zero), as well as in ProducerFec::AddRtpPacketAndGenerateFec. |
| 234 constexpr int kNumImportantPackets = 0; |
| 235 producer_fec_.SetFecParameters(fec_params, kNumImportantPackets); |
| 233 storage = packetizer->GetStorageType(retransmission_settings_); | 236 storage = packetizer->GetStorageType(retransmission_settings_); |
| 234 red_payload_type = red_payload_type_; | 237 red_payload_type = red_payload_type_; |
| 235 } | 238 } |
| 236 | 239 |
| 237 // Register CVO rtp header extension at the first time when we receive a frame | 240 // Register CVO rtp header extension at the first time when we receive a frame |
| 238 // with pending rotation. | 241 // with pending rotation. |
| 239 bool video_rotation_active = false; | 242 bool video_rotation_active = false; |
| 240 if (video_header && video_header->rotation != kVideoRotation_0) { | 243 if (video_header && video_header->rotation != kVideoRotation_0) { |
| 241 video_rotation_active = rtp_sender_->ActivateCVORtpHeaderExtension(); | 244 video_rotation_active = rtp_sender_->ActivateCVORtpHeaderExtension(); |
| 242 } | 245 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 rtc::CritScope cs(&crit_); | 343 rtc::CritScope cs(&crit_); |
| 341 return retransmission_settings_; | 344 return retransmission_settings_; |
| 342 } | 345 } |
| 343 | 346 |
| 344 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { | 347 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { |
| 345 rtc::CritScope cs(&crit_); | 348 rtc::CritScope cs(&crit_); |
| 346 retransmission_settings_ = settings; | 349 retransmission_settings_ = settings; |
| 347 } | 350 } |
| 348 | 351 |
| 349 } // namespace webrtc | 352 } // namespace webrtc |
| OLD | NEW |