Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc

Issue 2954503002: Implement FrameMarking header extension support
Patch Set: remove unneeded change in comment Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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) {
nisse-webrtc 2017/08/22 07:44:46 Should we really add more codec-specific logic in
sergio.garcia.murillo 2017/08/25 10:49:38 The information is codec specific and varies withi
316 case kRtpVideoH264:
317 // Nothing to add
318 frame_marks.discardable = false;
319 frame_marks.temporal_layer_id = kNoTemporalIdx;
320 frame_marks.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.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 // Layer id format is codec dependant.
333 frame_marks.temporal_layer_id =
334 video_header->codecHeader.VP9.temporal_idx;
335 frame_marks.layer_id =
336 FrameMarking::CreateLayerId(video_header->codecHeader.VP9);
337 frame_marks.tl0_pic_idx = video_header->codecHeader.VP9.tl0_pic_idx;
338 break;
339 default:
340 // Do not use frame marking.
341 frame_marking_enabled = false;
342 }
343 // Only add frame marking for known codecs.
344 if (frame_marking_enabled)
345 // Add extension header for frame marking.
346 rtp_header->SetExtension<FrameMarking>(frame_marks);
danilchap 2017/07/17 15:14:39 [ RUN ] VideoSendStreamTest.Vp9FlexModeRefCou
sergio.garcia.murillo 2017/08/25 10:49:38 Done. Created default constructor to initialize me
347
304 auto last_packet = rtc::MakeUnique<RtpPacketToSend>(*rtp_header); 348 auto last_packet = rtc::MakeUnique<RtpPacketToSend>(*rtp_header);
305 349
306 size_t fec_packet_overhead; 350 size_t fec_packet_overhead;
307 bool red_enabled; 351 bool red_enabled;
308 int32_t retransmission_settings; 352 int32_t retransmission_settings;
309 { 353 {
310 rtc::CritScope cs(&crit_); 354 rtc::CritScope cs(&crit_);
311 // According to 355 // According to
312 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ 356 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/
313 // ts_126114v120700p.pdf Section 7.4.5: 357 // ts_126114v120700p.pdf Section 7.4.5:
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 const RTPFragmentationHeader* frag = 418 const RTPFragmentationHeader* frag =
375 (video_type == kRtpVideoVp8) ? nullptr : fragmentation; 419 (video_type == kRtpVideoVp8) ? nullptr : fragmentation;
376 size_t num_packets = 420 size_t num_packets =
377 packetizer->SetPayloadData(payload_data, payload_size, frag); 421 packetizer->SetPayloadData(payload_data, payload_size, frag);
378 422
379 if (num_packets == 0) 423 if (num_packets == 0)
380 return false; 424 return false;
381 425
382 bool first_frame = first_frame_sent_(); 426 bool first_frame = first_frame_sent_();
383 for (size_t i = 0; i < num_packets; ++i) { 427 for (size_t i = 0; i < num_packets; ++i) {
428 bool first = (i == 0);
384 bool last = (i + 1) == num_packets; 429 bool last = (i + 1) == num_packets;
385 auto packet = last ? std::move(last_packet) 430 auto packet = last ? std::move(last_packet)
386 : rtc::MakeUnique<RtpPacketToSend>(*rtp_header); 431 : rtc::MakeUnique<RtpPacketToSend>(*rtp_header);
387 if (!packetizer->NextPacket(packet.get())) 432 if (!packetizer->NextPacket(packet.get()))
388 return false; 433 return false;
389 RTC_DCHECK_LE(packet->payload_size(), 434 RTC_DCHECK_LE(packet->payload_size(),
390 last ? max_data_payload_length - last_packet_reduction_len 435 last ? max_data_payload_length - last_packet_reduction_len
391 : max_data_payload_length); 436 : max_data_payload_length);
437
438 // Only add frame marking for known codecs.
439 if (frame_marking_enabled) {
440 // Update start and end marks.
441 frame_marks.start_of_frame = first;
442 frame_marks.end_of_frame = last;
443 // Update extension header for frame marking.
444 packet->SetExtension<FrameMarking>(frame_marks);
445 }
446
392 if (!rtp_sender_->AssignSequenceNumber(packet.get())) 447 if (!rtp_sender_->AssignSequenceNumber(packet.get()))
393 return false; 448 return false;
394 449
395 bool protect_packet = (packetizer->GetProtectionType() == kProtectedPacket); 450 bool protect_packet = (packetizer->GetProtectionType() == kProtectedPacket);
396 // Put packetization finish timestamp into extension. 451 // Put packetization finish timestamp into extension.
397 if (packet->HasExtension<VideoTimingExtension>()) { 452 if (packet->HasExtension<VideoTimingExtension>()) {
398 packet->set_packetization_finish_time_ms(clock_->TimeInMilliseconds()); 453 packet->set_packetization_finish_time_ms(clock_->TimeInMilliseconds());
399 // TODO(ilnik): Due to webrtc:7859, packets with timing extensions are not 454 // TODO(ilnik): Due to webrtc:7859, packets with timing extensions are not
400 // protected by FEC. It reduces FEC efficiency a bit. When FEC is moved 455 // protected by FEC. It reduces FEC efficiency a bit. When FEC is moved
401 // below the pacer, it can be re-enabled for these packets. 456 // below the pacer, it can be re-enabled for these packets.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 rtc::CritScope cs(&crit_); 502 rtc::CritScope cs(&crit_);
448 return retransmission_settings_; 503 return retransmission_settings_;
449 } 504 }
450 505
451 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { 506 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) {
452 rtc::CritScope cs(&crit_); 507 rtc::CritScope cs(&crit_);
453 retransmission_settings_ = settings; 508 retransmission_settings_ = settings;
454 } 509 }
455 510
456 } // namespace webrtc 511 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc ('k') | webrtc/modules/rtp_rtcp/source/rtp_utility.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698