 Chromium Code Reviews
 Chromium Code Reviews Issue 2033763002:
  Always send RED headers if configured.  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master
    
  
    Issue 2033763002:
  Always send RED headers if configured.  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master| 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 18 matching lines...) Expand all Loading... | |
| 29 namespace webrtc { | 29 namespace webrtc { | 
| 30 enum { REDForFECHeaderLength = 1 }; | 30 enum { REDForFECHeaderLength = 1 }; | 
| 31 | 31 | 
| 32 RTPSenderVideo::RTPSenderVideo(Clock* clock, RTPSenderInterface* rtpSender) | 32 RTPSenderVideo::RTPSenderVideo(Clock* clock, RTPSenderInterface* rtpSender) | 
| 33 : _rtpSender(*rtpSender), | 33 : _rtpSender(*rtpSender), | 
| 34 _videoType(kRtpVideoGeneric), | 34 _videoType(kRtpVideoGeneric), | 
| 35 _retransmissionSettings(kRetransmitBaseLayer), | 35 _retransmissionSettings(kRetransmitBaseLayer), | 
| 36 // Generic FEC | 36 // Generic FEC | 
| 37 fec_(), | 37 fec_(), | 
| 38 fec_enabled_(false), | 38 fec_enabled_(false), | 
| 39 red_payload_type_(-1), | 39 red_payload_type_(0), | 
| 40 fec_payload_type_(-1), | 40 fec_payload_type_(0), | 
| 41 delta_fec_params_(), | 41 delta_fec_params_(), | 
| 42 key_fec_params_(), | 42 key_fec_params_(), | 
| 43 producer_fec_(&fec_), | 43 producer_fec_(&fec_), | 
| 44 _fecOverheadRate(clock, NULL), | 44 _fecOverheadRate(clock, NULL), | 
| 45 _videoBitrate(clock, NULL) { | 45 _videoBitrate(clock, NULL) { | 
| 46 memset(&delta_fec_params_, 0, sizeof(delta_fec_params_)); | 46 memset(&delta_fec_params_, 0, sizeof(delta_fec_params_)); | 
| 47 memset(&key_fec_params_, 0, sizeof(key_fec_params_)); | 47 memset(&key_fec_params_, 0, sizeof(key_fec_params_)); | 
| 48 delta_fec_params_.max_fec_frames = key_fec_params_.max_fec_frames = 1; | 48 delta_fec_params_.max_fec_frames = key_fec_params_.max_fec_frames = 1; | 
| 49 delta_fec_params_.fec_mask_type = key_fec_params_.fec_mask_type = | 49 delta_fec_params_.fec_mask_type = key_fec_params_.fec_mask_type = | 
| 50 kFecMaskRandom; | 50 kFecMaskRandom; | 
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 } | 163 } | 
| 164 delete fec_packet; | 164 delete fec_packet; | 
| 165 ++next_fec_sequence_number; | 165 ++next_fec_sequence_number; | 
| 166 } | 166 } | 
| 167 } | 167 } | 
| 168 | 168 | 
| 169 void RTPSenderVideo::SetGenericFECStatus(const bool enable, | 169 void RTPSenderVideo::SetGenericFECStatus(const bool enable, | 
| 170 const uint8_t payloadTypeRED, | 170 const uint8_t payloadTypeRED, | 
| 171 const uint8_t payloadTypeFEC) { | 171 const uint8_t payloadTypeFEC) { | 
| 172 rtc::CritScope cs(&crit_); | 172 rtc::CritScope cs(&crit_); | 
| 173 fec_enabled_ = enable; | 173 fec_enabled_ = enable; | 
| 
mflodman
2016/06/03 07:28:16
I think we should DCHECK the pl types != 0 here, o
 | |
| 174 red_payload_type_ = payloadTypeRED; | 174 red_payload_type_ = payloadTypeRED; | 
| 175 fec_payload_type_ = payloadTypeFEC; | 175 fec_payload_type_ = payloadTypeFEC; | 
| 176 memset(&delta_fec_params_, 0, sizeof(delta_fec_params_)); | 176 memset(&delta_fec_params_, 0, sizeof(delta_fec_params_)); | 
| 177 memset(&key_fec_params_, 0, sizeof(key_fec_params_)); | 177 memset(&key_fec_params_, 0, sizeof(key_fec_params_)); | 
| 178 delta_fec_params_.max_fec_frames = key_fec_params_.max_fec_frames = 1; | 178 delta_fec_params_.max_fec_frames = key_fec_params_.max_fec_frames = 1; | 
| 179 delta_fec_params_.fec_mask_type = key_fec_params_.fec_mask_type = | 179 delta_fec_params_.fec_mask_type = key_fec_params_.fec_mask_type = | 
| 180 kFecMaskRandom; | 180 kFecMaskRandom; | 
| 181 } | 181 } | 
| 182 | 182 | 
| 183 void RTPSenderVideo::GenericFECStatus(bool* enable, | 183 void RTPSenderVideo::GenericFECStatus(bool* enable, | 
| 184 uint8_t* payloadTypeRED, | 184 uint8_t* payloadTypeRED, | 
| 185 uint8_t* payloadTypeFEC) const { | 185 uint8_t* payloadTypeFEC) const { | 
| 186 rtc::CritScope cs(&crit_); | 186 rtc::CritScope cs(&crit_); | 
| 187 *enable = fec_enabled_; | 187 *enable = fec_enabled_; | 
| 188 *payloadTypeRED = red_payload_type_; | 188 *payloadTypeRED = red_payload_type_; | 
| 189 *payloadTypeFEC = fec_payload_type_; | 189 *payloadTypeFEC = fec_payload_type_; | 
| 190 } | 190 } | 
| 191 | 191 | 
| 192 size_t RTPSenderVideo::FECPacketOverhead() const { | 192 size_t RTPSenderVideo::FECPacketOverhead() const { | 
| 193 rtc::CritScope cs(&crit_); | 193 rtc::CritScope cs(&crit_); | 
| 194 if (fec_enabled_) { | 194 size_t overhead = 0; | 
| 195 if (red_payload_type_ != 0) { | |
| 195 // Overhead is FEC headers plus RED for FEC header plus anything in RTP | 196 // Overhead is FEC headers plus RED for FEC header plus anything in RTP | 
| 196 // header beyond the 12 bytes base header (CSRC list, extensions...) | 197 // header beyond the 12 bytes base header (CSRC list, extensions...) | 
| 197 // This reason for the header extensions to be included here is that | 198 // This reason for the header extensions to be included here is that | 
| 198 // from an FEC viewpoint, they are part of the payload to be protected. | 199 // from an FEC viewpoint, they are part of the payload to be protected. | 
| 199 // (The base RTP header is already protected by the FEC header.) | 200 // (The base RTP header is already protected by the FEC header.) | 
| 200 return ForwardErrorCorrection::PacketOverhead() + REDForFECHeaderLength + | 201 overhead = REDForFECHeaderLength + (_rtpSender.RTPHeaderLength() - | 
| 201 (_rtpSender.RTPHeaderLength() - kRtpHeaderSize); | 202 kRtpHeaderSize); | 
| 202 } | 203 } | 
| 203 return 0; | 204 if (fec_enabled_) | 
| 205 overhead += ForwardErrorCorrection::PacketOverhead(); | |
| 206 return overhead; | |
| 204 } | 207 } | 
| 205 | 208 | 
| 206 void RTPSenderVideo::SetFecParameters(const FecProtectionParams* delta_params, | 209 void RTPSenderVideo::SetFecParameters(const FecProtectionParams* delta_params, | 
| 207 const FecProtectionParams* key_params) { | 210 const FecProtectionParams* key_params) { | 
| 208 rtc::CritScope cs(&crit_); | 211 rtc::CritScope cs(&crit_); | 
| 209 RTC_DCHECK(delta_params); | 212 RTC_DCHECK(delta_params); | 
| 210 RTC_DCHECK(key_params); | 213 RTC_DCHECK(key_params); | 
| 211 delta_fec_params_ = *delta_params; | 214 if (fec_enabled_) { | 
| 212 key_fec_params_ = *key_params; | 215 delta_fec_params_ = *delta_params; | 
| 216 key_fec_params_ = *key_params; | |
| 217 } | |
| 213 } | 218 } | 
| 214 | 219 | 
| 215 int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType, | 220 int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType, | 
| 216 const FrameType frameType, | 221 const FrameType frameType, | 
| 217 const int8_t payloadType, | 222 const int8_t payloadType, | 
| 218 const uint32_t captureTimeStamp, | 223 const uint32_t captureTimeStamp, | 
| 219 int64_t capture_time_ms, | 224 int64_t capture_time_ms, | 
| 220 const uint8_t* payloadData, | 225 const uint8_t* payloadData, | 
| 221 const size_t payloadSize, | 226 const size_t payloadSize, | 
| 222 const RTPFragmentationHeader* fragmentation, | 227 const RTPFragmentationHeader* fragmentation, | 
| 223 const RTPVideoHeader* video_header) { | 228 const RTPVideoHeader* video_header) { | 
| 224 if (payloadSize == 0) { | 229 if (payloadSize == 0) { | 
| 225 return -1; | 230 return -1; | 
| 226 } | 231 } | 
| 227 | 232 | 
| 228 std::unique_ptr<RtpPacketizer> packetizer(RtpPacketizer::Create( | 233 std::unique_ptr<RtpPacketizer> packetizer(RtpPacketizer::Create( | 
| 229 videoType, _rtpSender.MaxDataPayloadLength(), | 234 videoType, _rtpSender.MaxDataPayloadLength(), | 
| 230 video_header ? &(video_header->codecHeader) : nullptr, frameType)); | 235 video_header ? &(video_header->codecHeader) : nullptr, frameType)); | 
| 231 | 236 | 
| 232 StorageType storage; | 237 StorageType storage; | 
| 233 bool fec_enabled; | 238 int red_payload_type; | 
| 234 bool first_frame = first_frame_sent_(); | 239 bool first_frame = first_frame_sent_(); | 
| 235 { | 240 { | 
| 236 rtc::CritScope cs(&crit_); | 241 rtc::CritScope cs(&crit_); | 
| 237 FecProtectionParams* fec_params = | 242 FecProtectionParams* fec_params = | 
| 238 frameType == kVideoFrameKey ? &key_fec_params_ : &delta_fec_params_; | 243 frameType == kVideoFrameKey ? &key_fec_params_ : &delta_fec_params_; | 
| 239 producer_fec_.SetFecParameters(fec_params, 0); | 244 producer_fec_.SetFecParameters(fec_params, 0); | 
| 240 storage = packetizer->GetStorageType(_retransmissionSettings); | 245 storage = packetizer->GetStorageType(_retransmissionSettings); | 
| 241 fec_enabled = fec_enabled_; | 246 red_payload_type = red_payload_type_; | 
| 242 } | 247 } | 
| 243 | 248 | 
| 244 // Register CVO rtp header extension at the first time when we receive a frame | 249 // Register CVO rtp header extension at the first time when we receive a frame | 
| 245 // with pending rotation. | 250 // with pending rotation. | 
| 246 RTPSenderInterface::CVOMode cvo_mode = RTPSenderInterface::kCVONone; | 251 RTPSenderInterface::CVOMode cvo_mode = RTPSenderInterface::kCVONone; | 
| 247 if (video_header && video_header->rotation != kVideoRotation_0) { | 252 if (video_header && video_header->rotation != kVideoRotation_0) { | 
| 248 cvo_mode = _rtpSender.ActivateCVORtpHeaderExtension(); | 253 cvo_mode = _rtpSender.ActivateCVORtpHeaderExtension(); | 
| 249 } | 254 } | 
| 250 | 255 | 
| 251 uint16_t rtp_header_length = _rtpSender.RTPHeaderLength(); | 256 uint16_t rtp_header_length = _rtpSender.RTPHeaderLength(); | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 // TODO(guoweis): For now, all packets sent will carry the CVO such that | 299 // TODO(guoweis): For now, all packets sent will carry the CVO such that | 
| 295 // the RTP header length is consistent, although the receiver side will | 300 // the RTP header length is consistent, although the receiver side will | 
| 296 // only exam the packets with marker bit set. | 301 // only exam the packets with marker bit set. | 
| 297 size_t packetSize = payloadSize + rtp_header_length; | 302 size_t packetSize = payloadSize + rtp_header_length; | 
| 298 RtpUtility::RtpHeaderParser rtp_parser(dataBuffer, packetSize); | 303 RtpUtility::RtpHeaderParser rtp_parser(dataBuffer, packetSize); | 
| 299 RTPHeader rtp_header; | 304 RTPHeader rtp_header; | 
| 300 rtp_parser.Parse(&rtp_header); | 305 rtp_parser.Parse(&rtp_header); | 
| 301 _rtpSender.UpdateVideoRotation(dataBuffer, packetSize, rtp_header, | 306 _rtpSender.UpdateVideoRotation(dataBuffer, packetSize, rtp_header, | 
| 302 video_header->rotation); | 307 video_header->rotation); | 
| 303 } | 308 } | 
| 304 if (fec_enabled) { | 309 if (red_payload_type != 0) { | 
| 305 SendVideoPacketAsRed(dataBuffer, payload_bytes_in_packet, | 310 SendVideoPacketAsRed(dataBuffer, payload_bytes_in_packet, | 
| 306 rtp_header_length, _rtpSender.SequenceNumber(), | 311 rtp_header_length, _rtpSender.SequenceNumber(), | 
| 307 captureTimeStamp, capture_time_ms, storage, | 312 captureTimeStamp, capture_time_ms, storage, | 
| 308 packetizer->GetProtectionType() == kProtectedPacket); | 313 packetizer->GetProtectionType() == kProtectedPacket); | 
| 309 } else { | 314 } else { | 
| 310 SendVideoPacket(dataBuffer, payload_bytes_in_packet, rtp_header_length, | 315 SendVideoPacket(dataBuffer, payload_bytes_in_packet, rtp_header_length, | 
| 311 _rtpSender.SequenceNumber(), captureTimeStamp, | 316 _rtpSender.SequenceNumber(), captureTimeStamp, | 
| 312 capture_time_ms, storage); | 317 capture_time_ms, storage); | 
| 313 } | 318 } | 
| 314 | 319 | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 rtc::CritScope cs(&crit_); | 352 rtc::CritScope cs(&crit_); | 
| 348 return _retransmissionSettings; | 353 return _retransmissionSettings; | 
| 349 } | 354 } | 
| 350 | 355 | 
| 351 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { | 356 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { | 
| 352 rtc::CritScope cs(&crit_); | 357 rtc::CritScope cs(&crit_); | 
| 353 _retransmissionSettings = settings; | 358 _retransmissionSettings = settings; | 
| 354 } | 359 } | 
| 355 | 360 | 
| 356 } // namespace webrtc | 361 } // namespace webrtc | 
| OLD | NEW |