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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 const RTPFragmentationHeader* fragmentation, | 294 const RTPFragmentationHeader* fragmentation, |
295 const RTPVideoHeader* video_header) { | 295 const RTPVideoHeader* video_header) { |
296 if (payload_size == 0) | 296 if (payload_size == 0) |
297 return false; | 297 return false; |
298 | 298 |
299 // Create header that will be reused in all packets. | 299 // Create header that will be reused in all packets. |
300 std::unique_ptr<RtpPacketToSend> rtp_header = rtp_sender_->AllocatePacket(); | 300 std::unique_ptr<RtpPacketToSend> rtp_header = rtp_sender_->AllocatePacket(); |
301 rtp_header->SetPayloadType(payload_type); | 301 rtp_header->SetPayloadType(payload_type); |
302 rtp_header->SetTimestamp(rtp_timestamp); | 302 rtp_header->SetTimestamp(rtp_timestamp); |
303 rtp_header->set_capture_time_ms(capture_time_ms); | 303 rtp_header->set_capture_time_ms(capture_time_ms); |
| 304 |
| 305 // Set Frame Marks. |
| 306 FrameMarks frame_marks; |
| 307 bool frame_marking_enabled = true; |
| 308 |
| 309 // Common info |
| 310 frame_marks.start_of_frame = true; |
| 311 frame_marks.end_of_frame = false; |
| 312 frame_marks.independent = (frame_type == kVideoFrameKey); |
| 313 |
| 314 // Codec specific. |
| 315 switch (video_type) { |
| 316 case kRtpVideoH264: |
| 317 // Nothing to add |
| 318 frame_marks.discardable = false; |
| 319 frame_marks.temporal_layer_id = kNoTemporalIdx; |
| 320 frame_marks.spatial_layer_id = kNoSpatialIdx; |
| 321 frame_marks.tl0_pic_idx = static_cast<uint8_t>(kNoTl0PicIdx); |
| 322 break; |
| 323 case kRtpVideoVp8: |
| 324 frame_marks.discardable = video_header->codecHeader.VP8.nonReference; |
| 325 frame_marks.base_layer_sync = video_header->codecHeader.VP8.layerSync; |
| 326 frame_marks.temporal_layer_id = video_header->codecHeader.VP8.temporalIdx; |
| 327 frame_marks.spatial_layer_id = kNoSpatialIdx; |
| 328 frame_marks.tl0_pic_idx = video_header->codecHeader.VP8.tl0PicIdx; |
| 329 break; |
| 330 case kRtpVideoVp9: |
| 331 frame_marks.discardable = false; |
| 332 frame_marks.temporal_layer_id = |
| 333 video_header->codecHeader.VP9.temporal_idx; |
| 334 frame_marks.spatial_layer_id = kNoSpatialIdx; |
| 335 frame_marks.tl0_pic_idx = video_header->codecHeader.VP9.tl0_pic_idx; |
| 336 // TODO(sergio.garcia.murillo@gmail.com): This will need to be changed to |
| 337 // support VP9 SVC, but videoheader is set per-frame, not per packet, |
| 338 // so we can't have access to this values. |
| 339 // Also, small modifications to the extensions will be needed to not |
| 340 // change size of the extension between sid:0 and sid:1 |
| 341 // frame_marks.start_of_frame = |
| 342 // video_header->codecHeader.VP9.beginning_of_frame; |
| 343 // frame_marks.end_of_frame = |
| 344 // video_header->codecHeader.VP9.end_of_frame; |
| 345 // frame_marks.spatial_layer_id = |
| 346 // video_header->codecHeader.VP9.spatial_idx; |
| 347 break; |
| 348 default: |
| 349 // Do not use frame marking. |
| 350 frame_marking_enabled = false; |
| 351 } |
| 352 // Only add frame marking for known codecs. |
| 353 if (frame_marking_enabled) |
| 354 // Add extension header for frame marking. |
| 355 rtp_header->SetExtension<FrameMarking>(frame_marks); |
| 356 |
304 auto last_packet = rtc::MakeUnique<RtpPacketToSend>(*rtp_header); | 357 auto last_packet = rtc::MakeUnique<RtpPacketToSend>(*rtp_header); |
305 | 358 |
306 size_t fec_packet_overhead; | 359 size_t fec_packet_overhead; |
307 bool red_enabled; | 360 bool red_enabled; |
308 int32_t retransmission_settings; | 361 int32_t retransmission_settings; |
309 { | 362 { |
310 rtc::CritScope cs(&crit_); | 363 rtc::CritScope cs(&crit_); |
311 // According to | 364 // According to; |
312 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ | 365 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ |
313 // ts_126114v120700p.pdf Section 7.4.5: | 366 // ts_126114v120700p.pdf Section 7.4.5: |
314 // The MTSI client shall add the payload bytes as defined in this clause | 367 // The MTSI client shall add the payload bytes as defined in this clause |
315 // onto the last RTP packet in each group of packets which make up a key | 368 // onto the last RTP packet in each group of packets which make up a key |
316 // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265 | 369 // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265 |
317 // (HEVC)). The MTSI client may also add the payload bytes onto the last RTP | 370 // (HEVC)). The MTSI client may also add the payload bytes onto the last RTP |
318 // packet in each group of packets which make up another type of frame | 371 // packet in each group of packets which make up another type of frame |
319 // (e.g. a P-Frame) only if the current value is different from the previous | 372 // (e.g. a P-Frame) only if the current value is different from the previous |
320 // value sent. | 373 // value sent. |
321 if (video_header) { | 374 if (video_header) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 const RTPFragmentationHeader* frag = | 423 const RTPFragmentationHeader* frag = |
371 (video_type == kRtpVideoVp8) ? nullptr : fragmentation; | 424 (video_type == kRtpVideoVp8) ? nullptr : fragmentation; |
372 size_t num_packets = | 425 size_t num_packets = |
373 packetizer->SetPayloadData(payload_data, payload_size, frag); | 426 packetizer->SetPayloadData(payload_data, payload_size, frag); |
374 | 427 |
375 if (num_packets == 0) | 428 if (num_packets == 0) |
376 return false; | 429 return false; |
377 | 430 |
378 bool first_frame = first_frame_sent_(); | 431 bool first_frame = first_frame_sent_(); |
379 for (size_t i = 0; i < num_packets; ++i) { | 432 for (size_t i = 0; i < num_packets; ++i) { |
| 433 bool first = (i == 0); |
380 bool last = (i + 1) == num_packets; | 434 bool last = (i + 1) == num_packets; |
381 auto packet = last ? std::move(last_packet) | 435 auto packet = last ? std::move(last_packet) |
382 : rtc::MakeUnique<RtpPacketToSend>(*rtp_header); | 436 : rtc::MakeUnique<RtpPacketToSend>(*rtp_header); |
383 if (!packetizer->NextPacket(packet.get())) | 437 if (!packetizer->NextPacket(packet.get())) |
384 return false; | 438 return false; |
385 RTC_DCHECK_LE(packet->payload_size(), | 439 RTC_DCHECK_LE(packet->payload_size(), |
386 last ? max_data_payload_length - last_packet_reduction_len | 440 last ? max_data_payload_length - last_packet_reduction_len |
387 : max_data_payload_length); | 441 : max_data_payload_length); |
| 442 |
| 443 // Only add frame marking for known codecs. |
| 444 if (frame_marking_enabled) { |
| 445 // Update start and end marks. |
| 446 frame_marks.start_of_frame = first; |
| 447 frame_marks.end_of_frame = last; |
| 448 // Update extension header for frame marking. |
| 449 packet->SetExtension<FrameMarking>(frame_marks); |
| 450 } |
| 451 |
388 if (!rtp_sender_->AssignSequenceNumber(packet.get())) | 452 if (!rtp_sender_->AssignSequenceNumber(packet.get())) |
389 return false; | 453 return false; |
390 | 454 |
391 const bool protect_packet = | 455 const bool protect_packet = |
392 (packetizer->GetProtectionType() == kProtectedPacket); | 456 (packetizer->GetProtectionType() == kProtectedPacket); |
393 if (flexfec_enabled()) { | 457 if (flexfec_enabled()) { |
394 // TODO(brandtr): Remove the FlexFEC code path when FlexfecSender | 458 // TODO(brandtr): Remove the FlexFEC code path when FlexfecSender |
395 // is wired up to PacedSender instead. | 459 // is wired up to PacedSender instead. |
396 SendVideoPacketWithFlexfec(std::move(packet), storage, protect_packet); | 460 SendVideoPacketWithFlexfec(std::move(packet), storage, protect_packet); |
397 } else if (red_enabled) { | 461 } else if (red_enabled) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 rtc::CritScope cs(&crit_); | 496 rtc::CritScope cs(&crit_); |
433 return retransmission_settings_; | 497 return retransmission_settings_; |
434 } | 498 } |
435 | 499 |
436 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { | 500 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { |
437 rtc::CritScope cs(&crit_); | 501 rtc::CritScope cs(&crit_); |
438 retransmission_settings_ = settings; | 502 retransmission_settings_ = settings; |
439 } | 503 } |
440 | 504 |
441 } // namespace webrtc | 505 } // namespace webrtc |
OLD | NEW |