| 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 if (payloadSize == 0) { | 225 if (payloadSize == 0) { |
| 226 return -1; | 226 return -1; |
| 227 } | 227 } |
| 228 | 228 |
| 229 rtc::scoped_ptr<RtpPacketizer> packetizer(RtpPacketizer::Create( | 229 rtc::scoped_ptr<RtpPacketizer> packetizer(RtpPacketizer::Create( |
| 230 videoType, _rtpSender.MaxDataPayloadLength(), | 230 videoType, _rtpSender.MaxDataPayloadLength(), |
| 231 video_header ? &(video_header->codecHeader) : nullptr, frameType)); | 231 video_header ? &(video_header->codecHeader) : nullptr, frameType)); |
| 232 | 232 |
| 233 StorageType storage; | 233 StorageType storage; |
| 234 bool fec_enabled; | 234 bool fec_enabled; |
| 235 bool first_frame = first_frame_sent_(); |
| 235 { | 236 { |
| 236 CriticalSectionScoped cs(crit_.get()); | 237 CriticalSectionScoped cs(crit_.get()); |
| 237 FecProtectionParams* fec_params = | 238 FecProtectionParams* fec_params = |
| 238 frameType == kVideoFrameKey ? &key_fec_params_ : &delta_fec_params_; | 239 frameType == kVideoFrameKey ? &key_fec_params_ : &delta_fec_params_; |
| 239 producer_fec_.SetFecParameters(fec_params, 0); | 240 producer_fec_.SetFecParameters(fec_params, 0); |
| 240 storage = packetizer->GetStorageType(_retransmissionSettings); | 241 storage = packetizer->GetStorageType(_retransmissionSettings); |
| 241 fec_enabled = fec_enabled_; | 242 fec_enabled = fec_enabled_; |
| 242 } | 243 } |
| 243 | 244 |
| 244 // Register CVO rtp header extension at the first time when we receive a frame | 245 // Register CVO rtp header extension at the first time when we receive a frame |
| 245 // with pending rotation. | 246 // with pending rotation. |
| 246 RTPSenderInterface::CVOMode cvo_mode = RTPSenderInterface::kCVONone; | 247 RTPSenderInterface::CVOMode cvo_mode = RTPSenderInterface::kCVONone; |
| 247 if (video_header && video_header->rotation != kVideoRotation_0) { | 248 if (video_header && video_header->rotation != kVideoRotation_0) { |
| 248 cvo_mode = _rtpSender.ActivateCVORtpHeaderExtension(); | 249 cvo_mode = _rtpSender.ActivateCVORtpHeaderExtension(); |
| 249 } | 250 } |
| 250 | 251 |
| 251 uint16_t rtp_header_length = _rtpSender.RTPHeaderLength(); | 252 uint16_t rtp_header_length = _rtpSender.RTPHeaderLength(); |
| 252 size_t payload_bytes_to_send = payloadSize; | 253 size_t payload_bytes_to_send = payloadSize; |
| 253 const uint8_t* data = payloadData; | 254 const uint8_t* data = payloadData; |
| 254 | 255 |
| 255 // TODO(changbin): we currently don't support to configure the codec to | 256 // TODO(changbin): we currently don't support to configure the codec to |
| 256 // output multiple partitions for VP8. Should remove below check after the | 257 // output multiple partitions for VP8. Should remove below check after the |
| 257 // issue is fixed. | 258 // issue is fixed. |
| 258 const RTPFragmentationHeader* frag = | 259 const RTPFragmentationHeader* frag = |
| 259 (videoType == kRtpVideoVp8) ? NULL : fragmentation; | 260 (videoType == kRtpVideoVp8) ? NULL : fragmentation; |
| 260 | 261 |
| 261 packetizer->SetPayloadData(data, payload_bytes_to_send, frag); | 262 packetizer->SetPayloadData(data, payload_bytes_to_send, frag); |
| 262 | 263 |
| 264 bool first = true; |
| 263 bool last = false; | 265 bool last = false; |
| 264 while (!last) { | 266 while (!last) { |
| 265 uint8_t dataBuffer[IP_PACKET_SIZE] = {0}; | 267 uint8_t dataBuffer[IP_PACKET_SIZE] = {0}; |
| 266 size_t payload_bytes_in_packet = 0; | 268 size_t payload_bytes_in_packet = 0; |
| 267 if (!packetizer->NextPacket(&dataBuffer[rtp_header_length], | 269 if (!packetizer->NextPacket(&dataBuffer[rtp_header_length], |
| 268 &payload_bytes_in_packet, &last)) { | 270 &payload_bytes_in_packet, &last)) { |
| 269 return -1; | 271 return -1; |
| 270 } | 272 } |
| 273 |
| 271 // Write RTP header. | 274 // Write RTP header. |
| 272 // Set marker bit true if this is the last packet in frame. | 275 // Set marker bit true if this is the last packet in frame. |
| 273 _rtpSender.BuildRTPheader( | 276 _rtpSender.BuildRTPheader( |
| 274 dataBuffer, payloadType, last, captureTimeStamp, capture_time_ms); | 277 dataBuffer, payloadType, last, captureTimeStamp, capture_time_ms); |
| 275 // According to | 278 // According to |
| 276 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ | 279 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ |
| 277 // ts_126114v120700p.pdf Section 7.4.5: | 280 // ts_126114v120700p.pdf Section 7.4.5: |
| 278 // The MTSI client shall add the payload bytes as defined in this clause | 281 // The MTSI client shall add the payload bytes as defined in this clause |
| 279 // onto the last RTP packet in each group of packets which make up a key | 282 // onto the last RTP packet in each group of packets which make up a key |
| 280 // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265 | 283 // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 302 if (fec_enabled) { | 305 if (fec_enabled) { |
| 303 SendVideoPacketAsRed(dataBuffer, payload_bytes_in_packet, | 306 SendVideoPacketAsRed(dataBuffer, payload_bytes_in_packet, |
| 304 rtp_header_length, _rtpSender.SequenceNumber(), | 307 rtp_header_length, _rtpSender.SequenceNumber(), |
| 305 captureTimeStamp, capture_time_ms, storage, | 308 captureTimeStamp, capture_time_ms, storage, |
| 306 packetizer->GetProtectionType() == kProtectedPacket); | 309 packetizer->GetProtectionType() == kProtectedPacket); |
| 307 } else { | 310 } else { |
| 308 SendVideoPacket(dataBuffer, payload_bytes_in_packet, rtp_header_length, | 311 SendVideoPacket(dataBuffer, payload_bytes_in_packet, rtp_header_length, |
| 309 _rtpSender.SequenceNumber(), captureTimeStamp, | 312 _rtpSender.SequenceNumber(), captureTimeStamp, |
| 310 capture_time_ms, storage); | 313 capture_time_ms, storage); |
| 311 } | 314 } |
| 315 |
| 316 if (first_frame) { |
| 317 if (first) { |
| 318 LOG(LS_INFO) |
| 319 << "Sent first RTP packet of the first video frame (pre-pacer)"; |
| 320 } |
| 321 if (last) { |
| 322 LOG(LS_INFO) |
| 323 << "Sent last RTP packet of the first video frame (pre-pacer)"; |
| 324 } |
| 325 } |
| 326 first = false; |
| 312 } | 327 } |
| 313 | 328 |
| 314 TRACE_EVENT_ASYNC_END1( | 329 TRACE_EVENT_ASYNC_END1( |
| 315 "webrtc", "Video", capture_time_ms, "timestamp", _rtpSender.Timestamp()); | 330 "webrtc", "Video", capture_time_ms, "timestamp", _rtpSender.Timestamp()); |
| 316 return 0; | 331 return 0; |
| 317 } | 332 } |
| 318 | 333 |
| 319 void RTPSenderVideo::ProcessBitrate() { | 334 void RTPSenderVideo::ProcessBitrate() { |
| 320 _videoBitrate.Process(); | 335 _videoBitrate.Process(); |
| 321 _fecOverheadRate.Process(); | 336 _fecOverheadRate.Process(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 333 CriticalSectionScoped cs(crit_.get()); | 348 CriticalSectionScoped cs(crit_.get()); |
| 334 return _retransmissionSettings; | 349 return _retransmissionSettings; |
| 335 } | 350 } |
| 336 | 351 |
| 337 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { | 352 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { |
| 338 CriticalSectionScoped cs(crit_.get()); | 353 CriticalSectionScoped cs(crit_.get()); |
| 339 _retransmissionSettings = settings; | 354 _retransmissionSettings = settings; |
| 340 } | 355 } |
| 341 | 356 |
| 342 } // namespace webrtc | 357 } // namespace webrtc |
| OLD | NEW |