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

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

Issue 2007743003: Add sender controlled playout delay limits (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@cleanup_rtp_hdr_extensions
Patch Set: Rename OnReceivedRtcpReport to OnReceivedRtcpReportBlocks Created 4 years, 6 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
11 #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h" 11 #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h"
12 12
13 #include <stdlib.h> // srand 13 #include <stdlib.h> // srand
14 #include <algorithm> 14 #include <algorithm>
15 #include <utility> 15 #include <utility>
16 16
17 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
18 #include "webrtc/base/logging.h" 18 #include "webrtc/base/logging.h"
19 #include "webrtc/base/trace_event.h" 19 #include "webrtc/base/trace_event.h"
20 #include "webrtc/base/timeutils.h" 20 #include "webrtc/base/timeutils.h"
21 #include "webrtc/call.h" 21 #include "webrtc/call.h"
22 #include "webrtc/call/rtc_event_log.h" 22 #include "webrtc/call/rtc_event_log.h"
23 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" 23 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h"
24 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 24 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
25 #include "webrtc/modules/rtp_rtcp/source/playout_delay_oracle.h"
25 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h" 26 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h"
26 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_video.h" 27 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_video.h"
27 #include "webrtc/modules/rtp_rtcp/source/time_util.h" 28 #include "webrtc/modules/rtp_rtcp/source/time_util.h"
28 29
29 namespace webrtc { 30 namespace webrtc {
30 31
31 // Max in the RFC 3550 is 255 bytes, we limit it to be modulus 32 for SRTP. 32 // Max in the RFC 3550 is 255 bytes, we limit it to be modulus 32 for SRTP.
32 static const size_t kMaxPaddingLength = 224; 33 static const size_t kMaxPaddingLength = 224;
33 static const int kSendSideDelayWindowMs = 1000; 34 static const int kSendSideDelayWindowMs = 1000;
34 static const uint32_t kAbsSendTimeFraction = 18; 35 static const uint32_t kAbsSendTimeFraction = 18;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 last_capture_time_ms_sent_(0), 131 last_capture_time_ms_sent_(0),
131 transport_(transport), 132 transport_(transport),
132 sending_media_(true), // Default to sending media. 133 sending_media_(true), // Default to sending media.
133 max_payload_length_(IP_PACKET_SIZE - 28), // Default is IP-v4/UDP. 134 max_payload_length_(IP_PACKET_SIZE - 28), // Default is IP-v4/UDP.
134 payload_type_(-1), 135 payload_type_(-1),
135 payload_type_map_(), 136 payload_type_map_(),
136 rtp_header_extension_map_(), 137 rtp_header_extension_map_(),
137 transmission_time_offset_(0), 138 transmission_time_offset_(0),
138 absolute_send_time_(0), 139 absolute_send_time_(0),
139 rotation_(kVideoRotation_0), 140 rotation_(kVideoRotation_0),
140 cvo_mode_(kCVONone), 141 video_rotation_active_(false),
141 transport_sequence_number_(0), 142 transport_sequence_number_(0),
142 // NACK. 143 // NACK.
143 nack_byte_count_times_(), 144 nack_byte_count_times_(),
144 nack_byte_count_(), 145 nack_byte_count_(),
145 nack_bitrate_(clock, bitrates_.retransmit_bitrate_observer()), 146 nack_bitrate_(clock, bitrates_.retransmit_bitrate_observer()),
147 playout_delay_active_(false),
146 packet_history_(clock), 148 packet_history_(clock),
147 // Statistics 149 // Statistics
148 rtp_stats_callback_(NULL), 150 rtp_stats_callback_(NULL),
149 frame_count_observer_(frame_count_observer), 151 frame_count_observer_(frame_count_observer),
150 send_side_delay_observer_(send_side_delay_observer), 152 send_side_delay_observer_(send_side_delay_observer),
151 event_log_(event_log), 153 event_log_(event_log),
152 send_packet_observer_(send_packet_observer), 154 send_packet_observer_(send_packet_observer),
153 // RTP variables 155 // RTP variables
154 start_timestamp_forced_(false), 156 start_timestamp_forced_(false),
155 start_timestamp_(0), 157 start_timestamp_(0),
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 266
265 int32_t RTPSender::SetTransportSequenceNumber(uint16_t sequence_number) { 267 int32_t RTPSender::SetTransportSequenceNumber(uint16_t sequence_number) {
266 rtc::CritScope lock(&send_critsect_); 268 rtc::CritScope lock(&send_critsect_);
267 transport_sequence_number_ = sequence_number; 269 transport_sequence_number_ = sequence_number;
268 return 0; 270 return 0;
269 } 271 }
270 272
271 int32_t RTPSender::RegisterRtpHeaderExtension(RTPExtensionType type, 273 int32_t RTPSender::RegisterRtpHeaderExtension(RTPExtensionType type,
272 uint8_t id) { 274 uint8_t id) {
273 rtc::CritScope lock(&send_critsect_); 275 rtc::CritScope lock(&send_critsect_);
274 if (type == kRtpExtensionVideoRotation) { 276 switch (type) {
275 cvo_mode_ = kCVOInactive; 277 case kRtpExtensionVideoRotation:
276 return rtp_header_extension_map_.RegisterInactive(type, id); 278 video_rotation_active_ = false;
279 return rtp_header_extension_map_.RegisterInactive(type, id);
280 case kRtpExtensionPlayoutDelay:
281 playout_delay_active_ = false;
282 return rtp_header_extension_map_.RegisterInactive(type, id);
283 case kRtpExtensionTransmissionTimeOffset:
284 case kRtpExtensionAbsoluteSendTime:
285 case kRtpExtensionAudioLevel:
286 case kRtpExtensionTransportSequenceNumber:
287 return rtp_header_extension_map_.Register(type, id);
288 case kRtpExtensionNone:
289 LOG(LS_ERROR) << "Invalid RTP extension type for registration";
290 return -1;
277 } 291 }
278 return rtp_header_extension_map_.Register(type, id); 292 return -1;
279 } 293 }
280 294
281 bool RTPSender::IsRtpHeaderExtensionRegistered(RTPExtensionType type) { 295 bool RTPSender::IsRtpHeaderExtensionRegistered(RTPExtensionType type) {
282 rtc::CritScope lock(&send_critsect_); 296 rtc::CritScope lock(&send_critsect_);
283 return rtp_header_extension_map_.IsRegistered(type); 297 return rtp_header_extension_map_.IsRegistered(type);
284 } 298 }
285 299
286 int32_t RTPSender::DeregisterRtpHeaderExtension(RTPExtensionType type) { 300 int32_t RTPSender::DeregisterRtpHeaderExtension(RTPExtensionType type) {
287 rtc::CritScope lock(&send_critsect_); 301 rtc::CritScope lock(&send_critsect_);
288 return rtp_header_extension_map_.Deregister(type); 302 return rtp_header_extension_map_.Deregister(type);
289 } 303 }
290 304
291 size_t RTPSender::RtpHeaderExtensionTotalLength() const { 305 size_t RTPSender::RtpHeaderExtensionLength() const {
292 rtc::CritScope lock(&send_critsect_); 306 rtc::CritScope lock(&send_critsect_);
293 return rtp_header_extension_map_.GetTotalLengthInBytes(); 307 return rtp_header_extension_map_.GetTotalLengthInBytes();
294 } 308 }
295 309
296 int32_t RTPSender::RegisterPayload( 310 int32_t RTPSender::RegisterPayload(
297 const char payload_name[RTP_PAYLOAD_NAME_SIZE], 311 const char payload_name[RTP_PAYLOAD_NAME_SIZE],
298 int8_t payload_number, 312 int8_t payload_number,
299 uint32_t frequency, 313 uint32_t frequency,
300 size_t channels, 314 size_t channels,
301 uint32_t rate) { 315 uint32_t rate) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 max_payload_length_ = max_payload_length; 393 max_payload_length_ = max_payload_length;
380 } 394 }
381 395
382 size_t RTPSender::MaxDataPayloadLength() const { 396 size_t RTPSender::MaxDataPayloadLength() const {
383 int rtx; 397 int rtx;
384 { 398 {
385 rtc::CritScope lock(&send_critsect_); 399 rtc::CritScope lock(&send_critsect_);
386 rtx = rtx_; 400 rtx = rtx_;
387 } 401 }
388 if (audio_configured_) { 402 if (audio_configured_) {
389 return max_payload_length_ - RTPHeaderLength(); 403 return max_payload_length_ - RtpHeaderLength();
390 } else { 404 } else {
391 return max_payload_length_ - RTPHeaderLength() // RTP overhead. 405 return max_payload_length_ - RtpHeaderLength() // RTP overhead.
392 - video_->FECPacketOverhead() // FEC/ULP/RED overhead. 406 - video_->FECPacketOverhead() // FEC/ULP/RED overhead.
393 - ((rtx) ? 2 : 0); // RTX overhead. 407 - ((rtx) ? 2 : 0); // RTX overhead.
394 } 408 }
395 } 409 }
396 410
397 size_t RTPSender::MaxPayloadLength() const { 411 size_t RTPSender::MaxPayloadLength() const {
398 return max_payload_length_; 412 return max_payload_length_;
399 } 413 }
400 414
401 void RTPSender::SetRtxStatus(int mode) { 415 void RTPSender::SetRtxStatus(int mode) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 SetSendPayloadType(payload_type); 479 SetSendPayloadType(payload_type);
466 RtpUtility::Payload* payload = it->second; 480 RtpUtility::Payload* payload = it->second;
467 assert(payload); 481 assert(payload);
468 if (!payload->audio && !audio_configured_) { 482 if (!payload->audio && !audio_configured_) {
469 video_->SetVideoCodecType(payload->typeSpecific.Video.videoCodecType); 483 video_->SetVideoCodecType(payload->typeSpecific.Video.videoCodecType);
470 *video_type = payload->typeSpecific.Video.videoCodecType; 484 *video_type = payload->typeSpecific.Video.videoCodecType;
471 } 485 }
472 return 0; 486 return 0;
473 } 487 }
474 488
475 RTPSenderInterface::CVOMode RTPSender::ActivateCVORtpHeaderExtension() { 489 bool RTPSender::ActivateCVORtpHeaderExtension() {
476 if (cvo_mode_ == kCVOInactive) { 490 if (!video_rotation_active_) {
477 rtc::CritScope lock(&send_critsect_); 491 rtc::CritScope lock(&send_critsect_);
478 if (rtp_header_extension_map_.SetActive(kRtpExtensionVideoRotation, true)) { 492 if (rtp_header_extension_map_.SetActive(kRtpExtensionVideoRotation, true)) {
479 cvo_mode_ = kCVOActivated; 493 video_rotation_active_ = true;
480 } 494 }
481 } 495 }
482 return cvo_mode_; 496 return video_rotation_active_;
483 } 497 }
484 498
485 int32_t RTPSender::SendOutgoingData(FrameType frame_type, 499 int32_t RTPSender::SendOutgoingData(FrameType frame_type,
486 int8_t payload_type, 500 int8_t payload_type,
487 uint32_t capture_timestamp, 501 uint32_t capture_timestamp,
488 int64_t capture_time_ms, 502 int64_t capture_time_ms,
489 const uint8_t* payload_data, 503 const uint8_t* payload_data,
490 size_t payload_size, 504 size_t payload_size,
491 const RTPFragmentationHeader* fragmentation, 505 const RTPFragmentationHeader* fragmentation,
492 const RTPVideoHeader* rtp_hdr) { 506 const RTPVideoHeader* rtp_hdr) {
493 uint32_t ssrc; 507 uint32_t ssrc;
508 uint16_t sequence_number;
494 { 509 {
495 // Drop this packet if we're not sending media packets. 510 // Drop this packet if we're not sending media packets.
496 rtc::CritScope lock(&send_critsect_); 511 rtc::CritScope lock(&send_critsect_);
497 ssrc = ssrc_; 512 ssrc = ssrc_;
513 sequence_number = sequence_number_;
498 if (!sending_media_) { 514 if (!sending_media_) {
499 return 0; 515 return 0;
500 } 516 }
501 } 517 }
502 RtpVideoCodecTypes video_type = kRtpVideoGeneric; 518 RtpVideoCodecTypes video_type = kRtpVideoGeneric;
503 if (CheckPayloadType(payload_type, &video_type) != 0) { 519 if (CheckPayloadType(payload_type, &video_type) != 0) {
504 LOG(LS_ERROR) << "Don't send data with unknown payload type: " 520 LOG(LS_ERROR) << "Don't send data with unknown payload type: "
505 << static_cast<int>(payload_type) << "."; 521 << static_cast<int>(payload_type) << ".";
506 return -1; 522 return -1;
507 } 523 }
508 524
509 int32_t ret_val; 525 int32_t ret_val;
510 if (audio_configured_) { 526 if (audio_configured_) {
511 TRACE_EVENT_ASYNC_STEP1("webrtc", "Audio", capture_timestamp, 527 TRACE_EVENT_ASYNC_STEP1("webrtc", "Audio", capture_timestamp,
512 "Send", "type", FrameTypeToString(frame_type)); 528 "Send", "type", FrameTypeToString(frame_type));
513 assert(frame_type == kAudioFrameSpeech || frame_type == kAudioFrameCN || 529 assert(frame_type == kAudioFrameSpeech || frame_type == kAudioFrameCN ||
514 frame_type == kEmptyFrame); 530 frame_type == kEmptyFrame);
515 531
516 ret_val = audio_->SendAudio(frame_type, payload_type, capture_timestamp, 532 ret_val = audio_->SendAudio(frame_type, payload_type, capture_timestamp,
517 payload_data, payload_size, fragmentation); 533 payload_data, payload_size, fragmentation);
518 } else { 534 } else {
519 TRACE_EVENT_ASYNC_STEP1("webrtc", "Video", capture_time_ms, 535 TRACE_EVENT_ASYNC_STEP1("webrtc", "Video", capture_time_ms,
520 "Send", "type", FrameTypeToString(frame_type)); 536 "Send", "type", FrameTypeToString(frame_type));
521 assert(frame_type != kAudioFrameSpeech && frame_type != kAudioFrameCN); 537 assert(frame_type != kAudioFrameSpeech && frame_type != kAudioFrameCN);
522 538
523 if (frame_type == kEmptyFrame) 539 if (frame_type == kEmptyFrame)
524 return 0; 540 return 0;
525 541
526 ret_val = 542 if (rtp_hdr) {
527 video_->SendVideo(video_type, frame_type, payload_type, 543 playout_delay_oracle_.UpdateRequest(ssrc, rtp_hdr->playout_delay,
528 capture_timestamp, capture_time_ms, payload_data, 544 sequence_number);
529 payload_size, fragmentation, rtp_hdr); 545 }
546
547 // Update the active/inactive status of playout delay extension based
548 // on what the oracle indicates.
549 {
550 rtc::CritScope lock(&send_critsect_);
551 if (playout_delay_active_ != playout_delay_oracle_.send_playout_delay()) {
552 playout_delay_active_ = playout_delay_oracle_.send_playout_delay();
553 rtp_header_extension_map_.SetActive(kRtpExtensionPlayoutDelay,
554 playout_delay_active_);
555 }
556 }
557
558 ret_val = video_->SendVideo(
559 video_type, frame_type, payload_type, capture_timestamp,
560 capture_time_ms, payload_data, payload_size, fragmentation, rtp_hdr);
530 } 561 }
531 562
532 rtc::CritScope cs(&statistics_crit_); 563 rtc::CritScope cs(&statistics_crit_);
533 // Note: This is currently only counting for video. 564 // Note: This is currently only counting for video.
534 if (frame_type == kVideoFrameKey) { 565 if (frame_type == kVideoFrameKey) {
535 ++frame_counts_.key_frames; 566 ++frame_counts_.key_frames;
536 } else if (frame_type == kVideoFrameDelta) { 567 } else if (frame_type == kVideoFrameDelta) {
537 ++frame_counts_.delta_frames; 568 ++frame_counts_.delta_frames;
538 } 569 }
539 if (frame_count_observer_) { 570 if (frame_count_observer_) {
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 if (bytes_re_sent > target_bytes) { 857 if (bytes_re_sent > target_bytes) {
827 break; // Ignore the rest of the packets in the list. 858 break; // Ignore the rest of the packets in the list.
828 } 859 }
829 } 860 }
830 } 861 }
831 if (bytes_re_sent > 0) { 862 if (bytes_re_sent > 0) {
832 UpdateNACKBitRate(bytes_re_sent, now); 863 UpdateNACKBitRate(bytes_re_sent, now);
833 } 864 }
834 } 865 }
835 866
867 void RTPSender::OnReceivedRtcpReportBlocks(
868 const ReportBlockList& report_blocks) {
869 playout_delay_oracle_.OnReceivedRtcpReportBlocks(report_blocks);
870 }
871
836 bool RTPSender::ProcessNACKBitRate(uint32_t now) { 872 bool RTPSender::ProcessNACKBitRate(uint32_t now) {
837 uint32_t num = 0; 873 uint32_t num = 0;
838 size_t byte_count = 0; 874 size_t byte_count = 0;
839 const uint32_t kAvgIntervalMs = 1000; 875 const uint32_t kAvgIntervalMs = 1000;
840 uint32_t target_bitrate = GetTargetBitrate(); 876 uint32_t target_bitrate = GetTargetBitrate();
841 877
842 rtc::CritScope lock(&send_critsect_); 878 rtc::CritScope lock(&send_critsect_);
843 879
844 if (target_bitrate == 0) { 880 if (target_bitrate == 0) {
845 return true; 881 return true;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 void RTPSender::ProcessBitrate() { 1181 void RTPSender::ProcessBitrate() {
1146 rtc::CritScope lock(&send_critsect_); 1182 rtc::CritScope lock(&send_critsect_);
1147 total_bitrate_sent_.Process(); 1183 total_bitrate_sent_.Process();
1148 nack_bitrate_.Process(); 1184 nack_bitrate_.Process();
1149 if (audio_configured_) { 1185 if (audio_configured_) {
1150 return; 1186 return;
1151 } 1187 }
1152 video_->ProcessBitrate(); 1188 video_->ProcessBitrate();
1153 } 1189 }
1154 1190
1155 size_t RTPSender::RTPHeaderLength() const { 1191 size_t RTPSender::RtpHeaderLength() const {
1156 rtc::CritScope lock(&send_critsect_); 1192 rtc::CritScope lock(&send_critsect_);
1157 size_t rtp_header_length = kRtpHeaderLength; 1193 size_t rtp_header_length = kRtpHeaderLength;
1158 rtp_header_length += sizeof(uint32_t) * csrcs_.size(); 1194 rtp_header_length += sizeof(uint32_t) * csrcs_.size();
1159 rtp_header_length += RtpHeaderExtensionTotalLength(); 1195 rtp_header_length += RtpHeaderExtensionLength();
1160 return rtp_header_length; 1196 return rtp_header_length;
1161 } 1197 }
1162 1198
1163 uint16_t RTPSender::AllocateSequenceNumber(uint16_t packets_to_send) { 1199 uint16_t RTPSender::AllocateSequenceNumber(uint16_t packets_to_send) {
1164 rtc::CritScope lock(&send_critsect_); 1200 rtc::CritScope lock(&send_critsect_);
1165 uint16_t first_allocated_sequence_number = sequence_number_; 1201 uint16_t first_allocated_sequence_number = sequence_number_;
1166 sequence_number_ += packets_to_send; 1202 sequence_number_ += packets_to_send;
1167 return first_allocated_sequence_number; 1203 return first_allocated_sequence_number;
1168 } 1204 }
1169 1205
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 case kRtpExtensionAbsoluteSendTime: 1312 case kRtpExtensionAbsoluteSendTime:
1277 block_length = BuildAbsoluteSendTimeExtension(extension_data); 1313 block_length = BuildAbsoluteSendTimeExtension(extension_data);
1278 break; 1314 break;
1279 case kRtpExtensionVideoRotation: 1315 case kRtpExtensionVideoRotation:
1280 block_length = BuildVideoRotationExtension(extension_data); 1316 block_length = BuildVideoRotationExtension(extension_data);
1281 break; 1317 break;
1282 case kRtpExtensionTransportSequenceNumber: 1318 case kRtpExtensionTransportSequenceNumber:
1283 block_length = BuildTransportSequenceNumberExtension( 1319 block_length = BuildTransportSequenceNumberExtension(
1284 extension_data, transport_sequence_number_); 1320 extension_data, transport_sequence_number_);
1285 break; 1321 break;
1322 case kRtpExtensionPlayoutDelay:
1323 block_length = BuildPlayoutDelayExtension(
1324 extension_data, playout_delay_oracle_.min_playout_delay_ms(),
1325 playout_delay_oracle_.max_playout_delay_ms());
1326 break;
1286 default: 1327 default:
1287 assert(false); 1328 assert(false);
1288 } 1329 }
1289 total_block_length += block_length; 1330 total_block_length += block_length;
1290 type = rtp_header_extension_map_.Next(type); 1331 type = rtp_header_extension_map_.Next(type);
1291 } 1332 }
1292 if (total_block_length == 0) { 1333 if (total_block_length == 0) {
1293 // No extension added. 1334 // No extension added.
1294 return 0; 1335 return 0;
1295 } 1336 }
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 } 1492 }
1452 size_t pos = 0; 1493 size_t pos = 0;
1453 const uint8_t len = 1; 1494 const uint8_t len = 1;
1454 data_buffer[pos++] = (id << 4) + len; 1495 data_buffer[pos++] = (id << 4) + len;
1455 ByteWriter<uint16_t>::WriteBigEndian(data_buffer + pos, sequence_number); 1496 ByteWriter<uint16_t>::WriteBigEndian(data_buffer + pos, sequence_number);
1456 pos += 2; 1497 pos += 2;
1457 assert(pos == kTransportSequenceNumberLength); 1498 assert(pos == kTransportSequenceNumberLength);
1458 return kTransportSequenceNumberLength; 1499 return kTransportSequenceNumberLength;
1459 } 1500 }
1460 1501
1502 uint8_t RTPSender::BuildPlayoutDelayExtension(
1503 uint8_t* data_buffer,
1504 uint16_t min_playout_delay_ms,
1505 uint16_t max_playout_delay_ms) const {
1506 RTC_DCHECK_LE(min_playout_delay_ms, kPlayoutDelayMaxMs);
1507 RTC_DCHECK_LE(max_playout_delay_ms, kPlayoutDelayMaxMs);
1508 RTC_DCHECK_LE(min_playout_delay_ms, max_playout_delay_ms);
1509 // 0 1 2 3
1510 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1511 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1512 // | ID | len=2 | MIN delay | MAX delay |
1513 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1514 uint8_t id;
1515 if (rtp_header_extension_map_.GetId(kRtpExtensionPlayoutDelay, &id) != 0) {
1516 // Not registered.
1517 return 0;
1518 }
1519 size_t pos = 0;
1520 const uint8_t len = 2;
1521 // Convert MS to value to be sent on extension header.
1522 uint16_t min_playout = min_playout_delay_ms / kPlayoutDelayGranularityMs;
1523 uint16_t max_playout = max_playout_delay_ms / kPlayoutDelayGranularityMs;
1524
1525 data_buffer[pos++] = (id << 4) + len;
1526 data_buffer[pos++] = min_playout >> 4;
1527 data_buffer[pos++] = ((min_playout & 0xf) << 4) | (max_playout >> 8);
1528 data_buffer[pos++] = max_playout & 0xff;
1529 assert(pos == kPlayoutDelayLength);
1530 return kPlayoutDelayLength;
1531 }
1532
1461 bool RTPSender::FindHeaderExtensionPosition(RTPExtensionType type, 1533 bool RTPSender::FindHeaderExtensionPosition(RTPExtensionType type,
1462 const uint8_t* rtp_packet, 1534 const uint8_t* rtp_packet,
1463 size_t rtp_packet_length, 1535 size_t rtp_packet_length,
1464 const RTPHeader& rtp_header, 1536 const RTPHeader& rtp_header,
1465 size_t* position) const { 1537 size_t* position) const {
1466 // Get length until start of header extension block. 1538 // Get length until start of header extension block.
1467 int extension_block_pos = 1539 int extension_block_pos =
1468 rtp_header_extension_map_.GetLengthUntilBlockStartInBytes(type); 1540 rtp_header_extension_map_.GetLengthUntilBlockStartInBytes(type);
1469 if (extension_block_pos < 0) { 1541 if (extension_block_pos < 0) {
1470 LOG(LS_WARNING) << "Failed to find extension position for " << type 1542 LOG(LS_WARNING) << "Failed to find extension position for " << type
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1924 rtc::CritScope lock(&send_critsect_); 1996 rtc::CritScope lock(&send_critsect_);
1925 1997
1926 RtpState state; 1998 RtpState state;
1927 state.sequence_number = sequence_number_rtx_; 1999 state.sequence_number = sequence_number_rtx_;
1928 state.start_timestamp = start_timestamp_; 2000 state.start_timestamp = start_timestamp_;
1929 2001
1930 return state; 2002 return state;
1931 } 2003 }
1932 2004
1933 } // namespace webrtc 2005 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698