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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 192 |
193 size_t RTPSenderVideo::FECPacketOverhead() const { | 193 size_t RTPSenderVideo::FECPacketOverhead() const { |
194 rtc::CritScope cs(&crit_); | 194 rtc::CritScope cs(&crit_); |
195 size_t overhead = 0; | 195 size_t overhead = 0; |
196 if (red_payload_type_ != 0) { | 196 if (red_payload_type_ != 0) { |
197 // Overhead is FEC headers plus RED for FEC header plus anything in RTP | 197 // Overhead is FEC headers plus RED for FEC header plus anything in RTP |
198 // header beyond the 12 bytes base header (CSRC list, extensions...) | 198 // header beyond the 12 bytes base header (CSRC list, extensions...) |
199 // This reason for the header extensions to be included here is that | 199 // This reason for the header extensions to be included here is that |
200 // from an FEC viewpoint, they are part of the payload to be protected. | 200 // from an FEC viewpoint, they are part of the payload to be protected. |
201 // (The base RTP header is already protected by the FEC header.) | 201 // (The base RTP header is already protected by the FEC header.) |
202 overhead = REDForFECHeaderLength + (_rtpSender.RTPHeaderLength() - | 202 return ForwardErrorCorrection::PacketOverhead() + REDForFECHeaderLength + |
203 kRtpHeaderSize); | 203 (_rtpSender.RtpHeaderLength() - kRtpHeaderSize); |
204 } | 204 } |
205 if (fec_enabled_) | 205 if (fec_enabled_) |
206 overhead += ForwardErrorCorrection::PacketOverhead(); | 206 overhead += ForwardErrorCorrection::PacketOverhead(); |
207 return overhead; | 207 return overhead; |
208 } | 208 } |
209 | 209 |
210 void RTPSenderVideo::SetFecParameters(const FecProtectionParams* delta_params, | 210 void RTPSenderVideo::SetFecParameters(const FecProtectionParams* delta_params, |
211 const FecProtectionParams* key_params) { | 211 const FecProtectionParams* key_params) { |
212 rtc::CritScope cs(&crit_); | 212 rtc::CritScope cs(&crit_); |
213 RTC_DCHECK(delta_params); | 213 RTC_DCHECK(delta_params); |
(...skipping 28 matching lines...) Expand all Loading... |
242 rtc::CritScope cs(&crit_); | 242 rtc::CritScope cs(&crit_); |
243 FecProtectionParams* fec_params = | 243 FecProtectionParams* fec_params = |
244 frameType == kVideoFrameKey ? &key_fec_params_ : &delta_fec_params_; | 244 frameType == kVideoFrameKey ? &key_fec_params_ : &delta_fec_params_; |
245 producer_fec_.SetFecParameters(fec_params, 0); | 245 producer_fec_.SetFecParameters(fec_params, 0); |
246 storage = packetizer->GetStorageType(_retransmissionSettings); | 246 storage = packetizer->GetStorageType(_retransmissionSettings); |
247 red_payload_type = red_payload_type_; | 247 red_payload_type = red_payload_type_; |
248 } | 248 } |
249 | 249 |
250 // Register CVO rtp header extension at the first time when we receive a frame | 250 // Register CVO rtp header extension at the first time when we receive a frame |
251 // with pending rotation. | 251 // with pending rotation. |
252 RTPSenderInterface::CVOMode cvo_mode = RTPSenderInterface::kCVONone; | 252 bool video_rotation_active = false; |
253 if (video_header && video_header->rotation != kVideoRotation_0) { | 253 if (video_header && video_header->rotation != kVideoRotation_0) { |
254 cvo_mode = _rtpSender.ActivateCVORtpHeaderExtension(); | 254 video_rotation_active = _rtpSender.ActivateCVORtpHeaderExtension(); |
255 } | 255 } |
256 | 256 |
257 uint16_t rtp_header_length = _rtpSender.RTPHeaderLength(); | 257 int rtp_header_length = _rtpSender.RtpHeaderLength(); |
258 size_t payload_bytes_to_send = payloadSize; | 258 size_t payload_bytes_to_send = payloadSize; |
259 const uint8_t* data = payloadData; | 259 const uint8_t* data = payloadData; |
260 | 260 |
261 // TODO(changbin): we currently don't support to configure the codec to | 261 // TODO(changbin): we currently don't support to configure the codec to |
262 // output multiple partitions for VP8. Should remove below check after the | 262 // output multiple partitions for VP8. Should remove below check after the |
263 // issue is fixed. | 263 // issue is fixed. |
264 const RTPFragmentationHeader* frag = | 264 const RTPFragmentationHeader* frag = |
265 (videoType == kRtpVideoVp8) ? NULL : fragmentation; | 265 (videoType == kRtpVideoVp8) ? NULL : fragmentation; |
266 | 266 |
267 packetizer->SetPayloadData(data, payload_bytes_to_send, frag); | 267 packetizer->SetPayloadData(data, payload_bytes_to_send, frag); |
268 | 268 |
269 bool first = true; | 269 bool first = true; |
270 bool last = false; | 270 bool last = false; |
271 while (!last) { | 271 while (!last) { |
272 uint8_t dataBuffer[IP_PACKET_SIZE] = {0}; | 272 uint8_t dataBuffer[IP_PACKET_SIZE] = {0}; |
273 size_t payload_bytes_in_packet = 0; | 273 size_t payload_bytes_in_packet = 0; |
| 274 |
274 if (!packetizer->NextPacket(&dataBuffer[rtp_header_length], | 275 if (!packetizer->NextPacket(&dataBuffer[rtp_header_length], |
275 &payload_bytes_in_packet, &last)) { | 276 &payload_bytes_in_packet, &last)) { |
276 return -1; | 277 return -1; |
277 } | 278 } |
278 | 279 |
279 // Write RTP header. | 280 // Write RTP header. |
280 // Set marker bit true if this is the last packet in frame. | |
281 _rtpSender.BuildRTPheader( | 281 _rtpSender.BuildRTPheader( |
282 dataBuffer, payloadType, last, captureTimeStamp, capture_time_ms); | 282 dataBuffer, payloadType, last, captureTimeStamp, capture_time_ms); |
| 283 |
283 // According to | 284 // According to |
284 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ | 285 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ |
285 // ts_126114v120700p.pdf Section 7.4.5: | 286 // ts_126114v120700p.pdf Section 7.4.5: |
286 // The MTSI client shall add the payload bytes as defined in this clause | 287 // The MTSI client shall add the payload bytes as defined in this clause |
287 // onto the last RTP packet in each group of packets which make up a key | 288 // onto the last RTP packet in each group of packets which make up a key |
288 // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265 | 289 // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265 |
289 // (HEVC)). The MTSI client may also add the payload bytes onto the last RTP | 290 // (HEVC)). The MTSI client may also add the payload bytes onto the last RTP |
290 // packet in each group of packets which make up another type of frame | 291 // packet in each group of packets which make up another type of frame |
291 // (e.g. a P-Frame) only if the current value is different from the previous | 292 // (e.g. a P-Frame) only if the current value is different from the previous |
292 // value sent. | 293 // value sent. |
293 // Here we are adding it to every packet of every frame at this point. | 294 // Here we are adding it to every packet of every frame at this point. |
294 if (!video_header) { | 295 if (!video_header) { |
295 RTC_DCHECK(!_rtpSender.IsRtpHeaderExtensionRegistered( | 296 RTC_DCHECK(!_rtpSender.IsRtpHeaderExtensionRegistered( |
296 kRtpExtensionVideoRotation)); | 297 kRtpExtensionVideoRotation)); |
297 } else if (cvo_mode == RTPSenderInterface::kCVOActivated) { | 298 } else if (video_rotation_active) { |
298 // Checking whether CVO header extension is registered will require taking | 299 // Checking whether CVO header extension is registered will require taking |
299 // a lock. It'll be a no-op if it's not registered. | 300 // a lock. It'll be a no-op if it's not registered. |
300 // TODO(guoweis): For now, all packets sent will carry the CVO such that | 301 // TODO(guoweis): For now, all packets sent will carry the CVO such that |
301 // the RTP header length is consistent, although the receiver side will | 302 // the RTP header length is consistent, although the receiver side will |
302 // only exam the packets with marker bit set. | 303 // only exam the packets with marker bit set. |
303 size_t packetSize = payloadSize + rtp_header_length; | 304 size_t packetSize = payloadSize + rtp_header_length; |
304 RtpUtility::RtpHeaderParser rtp_parser(dataBuffer, packetSize); | 305 RtpUtility::RtpHeaderParser rtp_parser(dataBuffer, packetSize); |
305 RTPHeader rtp_header; | 306 RTPHeader rtp_header; |
306 rtp_parser.Parse(&rtp_header); | 307 rtp_parser.Parse(&rtp_header); |
307 _rtpSender.UpdateVideoRotation(dataBuffer, packetSize, rtp_header, | 308 _rtpSender.UpdateVideoRotation(dataBuffer, packetSize, rtp_header, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 rtc::CritScope cs(&crit_); | 354 rtc::CritScope cs(&crit_); |
354 return _retransmissionSettings; | 355 return _retransmissionSettings; |
355 } | 356 } |
356 | 357 |
357 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { | 358 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { |
358 rtc::CritScope cs(&crit_); | 359 rtc::CritScope cs(&crit_); |
359 _retransmissionSettings = settings; | 360 _retransmissionSettings = settings; |
360 } | 361 } |
361 | 362 |
362 } // namespace webrtc | 363 } // namespace webrtc |
OLD | NEW |