Chromium Code Reviews| 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 if (fec_enabled_) { |
| 195 // Overhead is FEC headers plus RED for FEC header plus anything in RTP | 195 // Overhead is FEC headers plus RED for FEC header plus anything in RTP |
| 196 // header beyond the 12 bytes base header (CSRC list, extensions...) | 196 // header beyond the 12 bytes base header (CSRC list, extensions...) |
| 197 // This reason for the header extensions to be included here is that | 197 // 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. | 198 // 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.) | 199 // (The base RTP header is already protected by the FEC header.) |
| 200 return ForwardErrorCorrection::PacketOverhead() + REDForFECHeaderLength + | 200 return ForwardErrorCorrection::PacketOverhead() + REDForFECHeaderLength + |
| 201 (_rtpSender.RTPHeaderLength() - kRtpHeaderSize); | 201 (_rtpSender.RtpHeaderMaxLength() - kRtpHeaderSize); |
| 202 } | 202 } |
| 203 return 0; | 203 return 0; |
| 204 } | 204 } |
| 205 | 205 |
| 206 void RTPSenderVideo::SetFecParameters(const FecProtectionParams* delta_params, | 206 void RTPSenderVideo::SetFecParameters(const FecProtectionParams* delta_params, |
| 207 const FecProtectionParams* key_params) { | 207 const FecProtectionParams* key_params) { |
| 208 rtc::CritScope cs(&crit_); | 208 rtc::CritScope cs(&crit_); |
| 209 RTC_DCHECK(delta_params); | 209 RTC_DCHECK(delta_params); |
| 210 RTC_DCHECK(key_params); | 210 RTC_DCHECK(key_params); |
| 211 delta_fec_params_ = *delta_params; | 211 delta_fec_params_ = *delta_params; |
| 212 key_fec_params_ = *key_params; | 212 key_fec_params_ = *key_params; |
| 213 } | 213 } |
| 214 | 214 |
| 215 int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType, | 215 int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType, |
| 216 const FrameType frameType, | 216 const FrameType frameType, |
| 217 const int8_t payloadType, | 217 const int8_t payloadType, |
| 218 const uint32_t captureTimeStamp, | 218 const uint32_t captureTimeStamp, |
| 219 int64_t capture_time_ms, | 219 int64_t capture_time_ms, |
| 220 const uint8_t* payloadData, | 220 const uint8_t* payloadData, |
| 221 const size_t payloadSize, | 221 const size_t payloadSize, |
| 222 const RTPFragmentationHeader* fragmentation, | 222 const RTPFragmentationHeader* fragmentation, |
| 223 const RTPVideoHeader* video_header) { | 223 const RTPVideoHeader* video_header) { |
| 224 if (payloadSize == 0) { | 224 if (payloadSize == 0) { |
| 225 return -1; | 225 return -1; |
| 226 } | 226 } |
| 227 | 227 |
| 228 std::unique_ptr<RtpPacketizer> packetizer(RtpPacketizer::Create( | 228 std::unique_ptr<RtpPacketizer> packetizer(RtpPacketizer::Create( |
| 229 videoType, _rtpSender.MaxDataPayloadLength(), | 229 videoType, _rtpSender.MaxDataPayloadLength(), |
|
danilchap
2016/06/02 12:12:34
Please note that packetizer use this value to deci
Irfan
2016/06/02 18:15:53
Right, with my updated change the length is treate
| |
| 230 video_header ? &(video_header->codecHeader) : nullptr, frameType)); | 230 video_header ? &(video_header->codecHeader) : nullptr, frameType)); |
| 231 | 231 |
| 232 StorageType storage; | 232 StorageType storage; |
| 233 bool fec_enabled; | 233 bool fec_enabled; |
| 234 bool first_frame = first_frame_sent_(); | 234 bool first_frame = first_frame_sent_(); |
| 235 { | 235 { |
| 236 rtc::CritScope cs(&crit_); | 236 rtc::CritScope cs(&crit_); |
| 237 FecProtectionParams* fec_params = | 237 FecProtectionParams* fec_params = |
| 238 frameType == kVideoFrameKey ? &key_fec_params_ : &delta_fec_params_; | 238 frameType == kVideoFrameKey ? &key_fec_params_ : &delta_fec_params_; |
| 239 producer_fec_.SetFecParameters(fec_params, 0); | 239 producer_fec_.SetFecParameters(fec_params, 0); |
| 240 storage = packetizer->GetStorageType(_retransmissionSettings); | 240 storage = packetizer->GetStorageType(_retransmissionSettings); |
| 241 fec_enabled = fec_enabled_; | 241 fec_enabled = fec_enabled_; |
| 242 } | 242 } |
| 243 | 243 |
| 244 // Register CVO rtp header extension at the first time when we receive a frame | 244 // Register CVO rtp header extension at the first time when we receive a frame |
| 245 // with pending rotation. | 245 // with pending rotation. |
| 246 RTPSenderInterface::CVOMode cvo_mode = RTPSenderInterface::kCVONone; | 246 RTPSenderInterface::CVOMode cvo_mode = RTPSenderInterface::kCVONone; |
| 247 if (video_header && video_header->rotation != kVideoRotation_0) { | 247 if (video_header && video_header->rotation != kVideoRotation_0) { |
| 248 cvo_mode = _rtpSender.ActivateCVORtpHeaderExtension(); | 248 cvo_mode = _rtpSender.ActivateCVORtpHeaderExtension(); |
| 249 } | 249 } |
| 250 | 250 |
| 251 uint16_t rtp_header_length = _rtpSender.RTPHeaderLength(); | 251 int rtp_header_length = _rtpSender.RtpHeaderCurrentLength(); |
| 252 size_t payload_bytes_to_send = payloadSize; | 252 size_t payload_bytes_to_send = payloadSize; |
| 253 const uint8_t* data = payloadData; | 253 const uint8_t* data = payloadData; |
| 254 | 254 |
| 255 // TODO(changbin): we currently don't support to configure the codec to | 255 // TODO(changbin): we currently don't support to configure the codec to |
| 256 // output multiple partitions for VP8. Should remove below check after the | 256 // output multiple partitions for VP8. Should remove below check after the |
| 257 // issue is fixed. | 257 // issue is fixed. |
| 258 const RTPFragmentationHeader* frag = | 258 const RTPFragmentationHeader* frag = |
| 259 (videoType == kRtpVideoVp8) ? NULL : fragmentation; | 259 (videoType == kRtpVideoVp8) ? NULL : fragmentation; |
| 260 | 260 |
| 261 packetizer->SetPayloadData(data, payload_bytes_to_send, frag); | 261 packetizer->SetPayloadData(data, payload_bytes_to_send, frag); |
| 262 | 262 |
| 263 bool first = true; | 263 bool first = true; |
| 264 bool last = false; | 264 bool last = false; |
| 265 while (!last) { | 265 while (!last) { |
| 266 uint8_t dataBuffer[IP_PACKET_SIZE] = {0}; | 266 uint8_t dataBuffer[IP_PACKET_SIZE] = {0}; |
| 267 size_t payload_bytes_in_packet = 0; | 267 size_t payload_bytes_in_packet = 0; |
| 268 if (!packetizer->NextPacket(&dataBuffer[rtp_header_length], | 268 |
| 269 &payload_bytes_in_packet, &last)) { | 269 // Note that RTP header size is dynamically computed since there may be |
| 270 // an optional RTP header extension. | |
| 271 if (!packetizer->NextPacket( | |
| 272 &dataBuffer[_rtpSender.RtpHeaderCurrentLength()], | |
| 273 &payload_bytes_in_packet, &last)) { | |
| 270 return -1; | 274 return -1; |
| 271 } | 275 } |
| 272 | 276 |
| 273 // Write RTP header. | 277 // Write RTP header. |
| 274 // Set marker bit true if this is the last packet in frame. | |
| 275 _rtpSender.BuildRTPheader( | 278 _rtpSender.BuildRTPheader( |
|
danilchap
2016/06/02 12:12:34
playout_delay_oracle_ is not protected by crit_
Th
Irfan
2016/06/02 18:15:53
Thanks for pointing this out. With the updated cha
| |
| 276 dataBuffer, payloadType, last, captureTimeStamp, capture_time_ms); | 279 dataBuffer, payloadType, last, captureTimeStamp, capture_time_ms); |
| 280 | |
| 277 // According to | 281 // According to |
| 278 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ | 282 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ |
| 279 // ts_126114v120700p.pdf Section 7.4.5: | 283 // ts_126114v120700p.pdf Section 7.4.5: |
| 280 // The MTSI client shall add the payload bytes as defined in this clause | 284 // The MTSI client shall add the payload bytes as defined in this clause |
| 281 // onto the last RTP packet in each group of packets which make up a key | 285 // onto the last RTP packet in each group of packets which make up a key |
| 282 // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265 | 286 // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265 |
| 283 // (HEVC)). The MTSI client may also add the payload bytes onto the last RTP | 287 // (HEVC)). The MTSI client may also add the payload bytes onto the last RTP |
| 284 // packet in each group of packets which make up another type of frame | 288 // packet in each group of packets which make up another type of frame |
| 285 // (e.g. a P-Frame) only if the current value is different from the previous | 289 // (e.g. a P-Frame) only if the current value is different from the previous |
| 286 // value sent. | 290 // value sent. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 rtc::CritScope cs(&crit_); | 351 rtc::CritScope cs(&crit_); |
| 348 return _retransmissionSettings; | 352 return _retransmissionSettings; |
| 349 } | 353 } |
| 350 | 354 |
| 351 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { | 355 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { |
| 352 rtc::CritScope cs(&crit_); | 356 rtc::CritScope cs(&crit_); |
| 353 _retransmissionSettings = settings; | 357 _retransmissionSettings = settings; |
| 354 } | 358 } |
| 355 | 359 |
| 356 } // namespace webrtc | 360 } // namespace webrtc |
| OLD | NEW |