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.RtpHeaderLength() - 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; |
(...skipping 24 matching lines...) Expand all Loading... | |
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 bool video_rotation_active = false; |
247 if (video_header && video_header->rotation != kVideoRotation_0) { | 247 if (video_header && video_header->rotation != kVideoRotation_0) { |
248 cvo_mode = _rtpSender.ActivateCVORtpHeaderExtension(); | 248 video_rotation_active = _rtpSender.ActivateCVORtpHeaderExtension(); |
249 } | 249 } |
250 | 250 |
251 uint16_t rtp_header_length = _rtpSender.RTPHeaderLength(); | 251 int rtp_header_length = _rtpSender.RtpHeaderLength(); |
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 | |
269 // Note that RTP header size is dynamically computed since there may be | |
danilchap
2016/06/03 09:01:37
probably should be removed now.
Irfan
2016/06/03 15:55:33
Done.
| |
270 // an optional RTP header extension. | |
268 if (!packetizer->NextPacket(&dataBuffer[rtp_header_length], | 271 if (!packetizer->NextPacket(&dataBuffer[rtp_header_length], |
269 &payload_bytes_in_packet, &last)) { | 272 &payload_bytes_in_packet, &last)) { |
270 return -1; | 273 return -1; |
271 } | 274 } |
272 | 275 |
273 // Write RTP header. | 276 // Write RTP header. |
274 // Set marker bit true if this is the last packet in frame. | |
275 _rtpSender.BuildRTPheader( | 277 _rtpSender.BuildRTPheader( |
276 dataBuffer, payloadType, last, captureTimeStamp, capture_time_ms); | 278 dataBuffer, payloadType, last, captureTimeStamp, capture_time_ms); |
279 | |
277 // According to | 280 // According to |
278 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ | 281 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ |
279 // ts_126114v120700p.pdf Section 7.4.5: | 282 // ts_126114v120700p.pdf Section 7.4.5: |
280 // The MTSI client shall add the payload bytes as defined in this clause | 283 // 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 | 284 // 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 | 285 // 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 | 286 // (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 | 287 // 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 | 288 // (e.g. a P-Frame) only if the current value is different from the previous |
286 // value sent. | 289 // value sent. |
287 // Here we are adding it to every packet of every frame at this point. | 290 // Here we are adding it to every packet of every frame at this point. |
288 if (!video_header) { | 291 if (!video_header) { |
289 RTC_DCHECK(!_rtpSender.IsRtpHeaderExtensionRegistered( | 292 RTC_DCHECK(!_rtpSender.IsRtpHeaderExtensionRegistered( |
290 kRtpExtensionVideoRotation)); | 293 kRtpExtensionVideoRotation)); |
291 } else if (cvo_mode == RTPSenderInterface::kCVOActivated) { | 294 } else if (video_rotation_active) { |
292 // Checking whether CVO header extension is registered will require taking | 295 // Checking whether CVO header extension is registered will require taking |
293 // a lock. It'll be a no-op if it's not registered. | 296 // a lock. It'll be a no-op if it's not registered. |
294 // TODO(guoweis): For now, all packets sent will carry the CVO such that | 297 // 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 | 298 // the RTP header length is consistent, although the receiver side will |
296 // only exam the packets with marker bit set. | 299 // only exam the packets with marker bit set. |
297 size_t packetSize = payloadSize + rtp_header_length; | 300 size_t packetSize = payloadSize + rtp_header_length; |
298 RtpUtility::RtpHeaderParser rtp_parser(dataBuffer, packetSize); | 301 RtpUtility::RtpHeaderParser rtp_parser(dataBuffer, packetSize); |
299 RTPHeader rtp_header; | 302 RTPHeader rtp_header; |
300 rtp_parser.Parse(&rtp_header); | 303 rtp_parser.Parse(&rtp_header); |
301 _rtpSender.UpdateVideoRotation(dataBuffer, packetSize, rtp_header, | 304 _rtpSender.UpdateVideoRotation(dataBuffer, packetSize, rtp_header, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 rtc::CritScope cs(&crit_); | 350 rtc::CritScope cs(&crit_); |
348 return _retransmissionSettings; | 351 return _retransmissionSettings; |
349 } | 352 } |
350 | 353 |
351 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { | 354 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { |
352 rtc::CritScope cs(&crit_); | 355 rtc::CritScope cs(&crit_); |
353 _retransmissionSettings = settings; | 356 _retransmissionSettings = settings; |
354 } | 357 } |
355 | 358 |
356 } // namespace webrtc | 359 } // namespace webrtc |
OLD | NEW |