Chromium Code Reviews

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

Issue 1623543002: Refactor RtpSender and SSRCDatabase a bit. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Add locking back for voe_auto_test Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 107 matching lines...)
118 bool audio, 118 bool audio,
119 Clock* clock, 119 Clock* clock,
120 Transport* transport, 120 Transport* transport,
121 RtpAudioFeedback* audio_feedback, 121 RtpAudioFeedback* audio_feedback,
122 RtpPacketSender* paced_sender, 122 RtpPacketSender* paced_sender,
123 TransportSequenceNumberAllocator* sequence_number_allocator, 123 TransportSequenceNumberAllocator* sequence_number_allocator,
124 TransportFeedbackObserver* transport_feedback_observer, 124 TransportFeedbackObserver* transport_feedback_observer,
125 BitrateStatisticsObserver* bitrate_callback, 125 BitrateStatisticsObserver* bitrate_callback,
126 FrameCountObserver* frame_count_observer, 126 FrameCountObserver* frame_count_observer,
127 SendSideDelayObserver* send_side_delay_observer, 127 SendSideDelayObserver* send_side_delay_observer,
128 RtcEventLog* event_log) 128 RtcEventLog* event_log,
129 SSRCDatabase* ssrc_database)
129 : clock_(clock), 130 : clock_(clock),
130 // TODO(holmer): Remove this conversion when we remove the use of 131 // TODO(holmer): Remove this conversion when we remove the use of
131 // TickTime. 132 // TickTime.
132 clock_delta_ms_(clock_->TimeInMilliseconds() - 133 clock_delta_ms_(clock_->TimeInMilliseconds() -
133 TickTime::MillisecondTimestamp()), 134 TickTime::MillisecondTimestamp()),
134 random_(clock_->TimeInMicroseconds()), 135 random_(clock_->TimeInMicroseconds()),
135 bitrates_(new BitrateAggregator(bitrate_callback)), 136 bitrates_(new BitrateAggregator(bitrate_callback)),
136 total_bitrate_sent_(clock, bitrates_->total_bitrate_observer()), 137 total_bitrate_sent_(clock, bitrates_->total_bitrate_observer()),
137 audio_configured_(audio), 138 audio_configured_(audio),
138 audio_(audio ? new RTPSenderAudio(clock, this, audio_feedback) : nullptr), 139 audio_(audio ? new RTPSenderAudio(clock, this, audio_feedback) : nullptr),
139 video_(audio ? nullptr : new RTPSenderVideo(clock, this)), 140 video_(audio ? nullptr : new RTPSenderVideo(clock, this)),
140 paced_sender_(paced_sender), 141 paced_sender_(paced_sender),
141 transport_sequence_number_allocator_(sequence_number_allocator), 142 transport_sequence_number_allocator_(sequence_number_allocator),
142 transport_feedback_observer_(transport_feedback_observer), 143 transport_feedback_observer_(transport_feedback_observer),
143 last_capture_time_ms_sent_(0), 144 last_capture_time_ms_sent_(0),
144 send_critsect_(CriticalSectionWrapper::CreateCriticalSection()),
145 transport_(transport), 145 transport_(transport),
146 sending_media_(true), // Default to sending media. 146 sending_media_(true), // Default to sending media.
147 max_payload_length_(IP_PACKET_SIZE - 28), // Default is IP-v4/UDP. 147 max_payload_length_(IP_PACKET_SIZE - 28), // Default is IP-v4/UDP.
148 packet_over_head_(28), 148 packet_over_head_(28),
149 payload_type_(-1), 149 payload_type_(-1),
150 payload_type_map_(), 150 payload_type_map_(),
151 rtp_header_extension_map_(), 151 rtp_header_extension_map_(),
152 transmission_time_offset_(0), 152 transmission_time_offset_(0),
153 absolute_send_time_(0), 153 absolute_send_time_(0),
154 rotation_(kVideoRotation_0), 154 rotation_(kVideoRotation_0),
155 cvo_mode_(kCVONone), 155 cvo_mode_(kCVONone),
156 transport_sequence_number_(0), 156 transport_sequence_number_(0),
157 // NACK. 157 // NACK.
158 nack_byte_count_times_(), 158 nack_byte_count_times_(),
159 nack_byte_count_(), 159 nack_byte_count_(),
160 nack_bitrate_(clock, bitrates_->retransmit_bitrate_observer()), 160 nack_bitrate_(clock, bitrates_->retransmit_bitrate_observer()),
161 packet_history_(clock), 161 packet_history_(clock),
162 // Statistics 162 // Statistics
163 statistics_crit_(CriticalSectionWrapper::CreateCriticalSection()), 163 statistics_crit_(CriticalSectionWrapper::CreateCriticalSection()),
164 rtp_stats_callback_(NULL), 164 rtp_stats_callback_(NULL),
165 frame_count_observer_(frame_count_observer), 165 frame_count_observer_(frame_count_observer),
166 send_side_delay_observer_(send_side_delay_observer), 166 send_side_delay_observer_(send_side_delay_observer),
167 event_log_(event_log), 167 event_log_(event_log),
168 // RTP variables 168 // RTP variables
169 start_timestamp_forced_(false), 169 start_timestamp_forced_(false),
170 start_timestamp_(0), 170 start_timestamp_(0),
171 ssrc_db_(*SSRCDatabase::GetSSRCDatabase()), 171 ssrc_db_(ssrc_database),
172 remote_ssrc_(0), 172 remote_ssrc_(0),
173 sequence_number_forced_(false), 173 sequence_number_forced_(false),
174 ssrc_forced_(false), 174 ssrc_forced_(false),
175 timestamp_(0), 175 timestamp_(0),
176 capture_time_ms_(0), 176 capture_time_ms_(0),
177 last_timestamp_time_ms_(0), 177 last_timestamp_time_ms_(0),
178 media_has_been_sent_(false), 178 media_has_been_sent_(false),
179 last_packet_marker_bit_(false), 179 last_packet_marker_bit_(false),
180 csrcs_(), 180 csrcs_(),
181 rtx_(kRtxOff), 181 rtx_(kRtxOff),
182 rtx_payload_type_(-1), 182 rtx_payload_type_(-1),
183 target_bitrate_critsect_(CriticalSectionWrapper::CreateCriticalSection()), 183 target_bitrate_critsect_(CriticalSectionWrapper::CreateCriticalSection()),
184 target_bitrate_(0) { 184 target_bitrate_(0) {
185 memset(nack_byte_count_times_, 0, sizeof(nack_byte_count_times_)); 185 memset(nack_byte_count_times_, 0, sizeof(nack_byte_count_times_));
186 memset(nack_byte_count_, 0, sizeof(nack_byte_count_)); 186 memset(nack_byte_count_, 0, sizeof(nack_byte_count_));
187 // We need to seed the random generator. 187 // We need to seed the random generator.
188 // TODO(holmer,tommi): Why?^^^ (SSRCDatabase does its own seeding).
189 // TODO(holmer,tommi): Note also that TimeInMilliseconds might return 0 on Mac
190 // early on in the process.
stefan-webrtc 2016/01/23 17:38:39 I think it's because timestamps and sequence numbe
tommi 2016/01/24 11:51:49 I might be misunderstanding, so please bear with m
stefan-webrtc 2016/01/25 10:09:32 I didn't actually read the code, but apparently se
188 srand(static_cast<uint32_t>(clock_->TimeInMilliseconds())); 191 srand(static_cast<uint32_t>(clock_->TimeInMilliseconds()));
189 ssrc_ = ssrc_db_.CreateSSRC(); // Can't be 0. 192 ssrc_ = ssrc_db_->CreateSSRC(); // Can't be 0.
190 ssrc_rtx_ = ssrc_db_.CreateSSRC(); // Can't be 0. 193 ssrc_rtx_ = ssrc_db_->CreateSSRC(); // Can't be 0.
194 // TODO(holmer, tommi): Should we DCHECK ^^^ on the 'Can't be 0' part?
stefan-webrtc 2016/01/23 17:38:39 Feel free to add. According to SsrcDatabase that s
tommi 2016/01/24 11:51:49 Done.
191 bitrates_->set_ssrc(ssrc_); 195 bitrates_->set_ssrc(ssrc_);
192 // Random start, 16 bits. Can't be 0. 196 // Random start, 16 bits. Can't be 0.
193 sequence_number_rtx_ = random_.Rand(1, kMaxInitRtpSeqNumber); 197 sequence_number_rtx_ = random_.Rand(1, kMaxInitRtpSeqNumber);
194 sequence_number_ = random_.Rand(1, kMaxInitRtpSeqNumber); 198 sequence_number_ = random_.Rand(1, kMaxInitRtpSeqNumber);
195 } 199 }
196 200
197 RTPSender::~RTPSender() { 201 RTPSender::~RTPSender() {
202 // TODO(tommi,holmer: We don't grab locks in the dtor before accessing member
stefan-webrtc 2016/01/23 17:38:39 TODO(tommi,holmer) I think the only known model
tommi 2016/01/24 11:51:49 Done
203 // variables but we grab them in all other methods. (what's the design?)
204 // Start documenting what thread we're on in what method so that it's easier
205 // to understand performance attributes and possibly remove locks.
198 if (remote_ssrc_ != 0) { 206 if (remote_ssrc_ != 0) {
199 ssrc_db_.ReturnSSRC(remote_ssrc_); 207 ssrc_db_->ReturnSSRC(remote_ssrc_);
200 } 208 }
201 ssrc_db_.ReturnSSRC(ssrc_); 209 ssrc_db_->ReturnSSRC(ssrc_);
202 210
203 SSRCDatabase::ReturnSSRCDatabase();
204 while (!payload_type_map_.empty()) { 211 while (!payload_type_map_.empty()) {
205 std::map<int8_t, RtpUtility::Payload*>::iterator it = 212 std::map<int8_t, RtpUtility::Payload*>::iterator it =
206 payload_type_map_.begin(); 213 payload_type_map_.begin();
207 delete it->second; 214 delete it->second;
208 payload_type_map_.erase(it); 215 payload_type_map_.erase(it);
209 } 216 }
210 } 217 }
211 218
212 void RTPSender::SetTargetBitrate(uint32_t bitrate) { 219 void RTPSender::SetTargetBitrate(uint32_t bitrate) {
213 CriticalSectionScoped cs(target_bitrate_critsect_.get()); 220 CriticalSectionScoped cs(target_bitrate_critsect_.get());
(...skipping 25 matching lines...)
239 246
240 uint32_t RTPSender::NackOverheadRate() const { 247 uint32_t RTPSender::NackOverheadRate() const {
241 return nack_bitrate_.BitrateLast(); 248 return nack_bitrate_.BitrateLast();
242 } 249 }
243 250
244 int32_t RTPSender::SetTransmissionTimeOffset(int32_t transmission_time_offset) { 251 int32_t RTPSender::SetTransmissionTimeOffset(int32_t transmission_time_offset) {
245 if (transmission_time_offset > (0x800000 - 1) || 252 if (transmission_time_offset > (0x800000 - 1) ||
246 transmission_time_offset < -(0x800000 - 1)) { // Word24. 253 transmission_time_offset < -(0x800000 - 1)) { // Word24.
247 return -1; 254 return -1;
248 } 255 }
249 CriticalSectionScoped cs(send_critsect_.get()); 256 rtc::CritScope lock(&send_critsect_);
250 transmission_time_offset_ = transmission_time_offset; 257 transmission_time_offset_ = transmission_time_offset;
251 return 0; 258 return 0;
252 } 259 }
253 260
254 int32_t RTPSender::SetAbsoluteSendTime(uint32_t absolute_send_time) { 261 int32_t RTPSender::SetAbsoluteSendTime(uint32_t absolute_send_time) {
255 if (absolute_send_time > 0xffffff) { // UWord24. 262 if (absolute_send_time > 0xffffff) { // UWord24.
256 return -1; 263 return -1;
257 } 264 }
258 CriticalSectionScoped cs(send_critsect_.get()); 265 rtc::CritScope lock(&send_critsect_);
259 absolute_send_time_ = absolute_send_time; 266 absolute_send_time_ = absolute_send_time;
260 return 0; 267 return 0;
261 } 268 }
262 269
263 void RTPSender::SetVideoRotation(VideoRotation rotation) { 270 void RTPSender::SetVideoRotation(VideoRotation rotation) {
264 CriticalSectionScoped cs(send_critsect_.get()); 271 rtc::CritScope lock(&send_critsect_);
265 rotation_ = rotation; 272 rotation_ = rotation;
266 } 273 }
267 274
268 int32_t RTPSender::SetTransportSequenceNumber(uint16_t sequence_number) { 275 int32_t RTPSender::SetTransportSequenceNumber(uint16_t sequence_number) {
269 CriticalSectionScoped cs(send_critsect_.get()); 276 rtc::CritScope lock(&send_critsect_);
270 transport_sequence_number_ = sequence_number; 277 transport_sequence_number_ = sequence_number;
271 return 0; 278 return 0;
272 } 279 }
273 280
274 int32_t RTPSender::RegisterRtpHeaderExtension(RTPExtensionType type, 281 int32_t RTPSender::RegisterRtpHeaderExtension(RTPExtensionType type,
275 uint8_t id) { 282 uint8_t id) {
276 CriticalSectionScoped cs(send_critsect_.get()); 283 rtc::CritScope lock(&send_critsect_);
277 if (type == kRtpExtensionVideoRotation) { 284 if (type == kRtpExtensionVideoRotation) {
278 cvo_mode_ = kCVOInactive; 285 cvo_mode_ = kCVOInactive;
279 return rtp_header_extension_map_.RegisterInactive(type, id); 286 return rtp_header_extension_map_.RegisterInactive(type, id);
280 } 287 }
281 return rtp_header_extension_map_.Register(type, id); 288 return rtp_header_extension_map_.Register(type, id);
282 } 289 }
283 290
284 bool RTPSender::IsRtpHeaderExtensionRegistered(RTPExtensionType type) { 291 bool RTPSender::IsRtpHeaderExtensionRegistered(RTPExtensionType type) {
285 CriticalSectionScoped cs(send_critsect_.get()); 292 rtc::CritScope lock(&send_critsect_);
286 return rtp_header_extension_map_.IsRegistered(type); 293 return rtp_header_extension_map_.IsRegistered(type);
287 } 294 }
288 295
289 int32_t RTPSender::DeregisterRtpHeaderExtension(RTPExtensionType type) { 296 int32_t RTPSender::DeregisterRtpHeaderExtension(RTPExtensionType type) {
290 CriticalSectionScoped cs(send_critsect_.get()); 297 rtc::CritScope lock(&send_critsect_);
291 return rtp_header_extension_map_.Deregister(type); 298 return rtp_header_extension_map_.Deregister(type);
292 } 299 }
293 300
294 size_t RTPSender::RtpHeaderExtensionTotalLength() const { 301 size_t RTPSender::RtpHeaderExtensionTotalLength() const {
295 CriticalSectionScoped cs(send_critsect_.get()); 302 rtc::CritScope lock(&send_critsect_);
296 return rtp_header_extension_map_.GetTotalLengthInBytes(); 303 return rtp_header_extension_map_.GetTotalLengthInBytes();
297 } 304 }
298 305
299 int32_t RTPSender::RegisterPayload( 306 int32_t RTPSender::RegisterPayload(
300 const char payload_name[RTP_PAYLOAD_NAME_SIZE], 307 const char payload_name[RTP_PAYLOAD_NAME_SIZE],
301 int8_t payload_number, 308 int8_t payload_number,
302 uint32_t frequency, 309 uint32_t frequency,
303 size_t channels, 310 size_t channels,
304 uint32_t rate) { 311 uint32_t rate) {
305 assert(payload_name); 312 assert(payload_name);
306 CriticalSectionScoped cs(send_critsect_.get()); 313 rtc::CritScope lock(&send_critsect_);
307 314
308 std::map<int8_t, RtpUtility::Payload*>::iterator it = 315 std::map<int8_t, RtpUtility::Payload*>::iterator it =
309 payload_type_map_.find(payload_number); 316 payload_type_map_.find(payload_number);
310 317
311 if (payload_type_map_.end() != it) { 318 if (payload_type_map_.end() != it) {
312 // We already use this payload type. 319 // We already use this payload type.
313 RtpUtility::Payload* payload = it->second; 320 RtpUtility::Payload* payload = it->second;
314 assert(payload); 321 assert(payload);
315 322
316 // Check if it's the same as we already have. 323 // Check if it's the same as we already have.
(...skipping 22 matching lines...)
339 } else { 346 } else {
340 payload = video_->CreateVideoPayload(payload_name, payload_number, rate); 347 payload = video_->CreateVideoPayload(payload_name, payload_number, rate);
341 } 348 }
342 if (payload) { 349 if (payload) {
343 payload_type_map_[payload_number] = payload; 350 payload_type_map_[payload_number] = payload;
344 } 351 }
345 return ret_val; 352 return ret_val;
346 } 353 }
347 354
348 int32_t RTPSender::DeRegisterSendPayload(int8_t payload_type) { 355 int32_t RTPSender::DeRegisterSendPayload(int8_t payload_type) {
349 CriticalSectionScoped lock(send_critsect_.get()); 356 rtc::CritScope lock(&send_critsect_);
350 357
351 std::map<int8_t, RtpUtility::Payload*>::iterator it = 358 std::map<int8_t, RtpUtility::Payload*>::iterator it =
352 payload_type_map_.find(payload_type); 359 payload_type_map_.find(payload_type);
353 360
354 if (payload_type_map_.end() == it) { 361 if (payload_type_map_.end() == it) {
355 return -1; 362 return -1;
356 } 363 }
357 RtpUtility::Payload* payload = it->second; 364 RtpUtility::Payload* payload = it->second;
358 delete payload; 365 delete payload;
359 payload_type_map_.erase(it); 366 payload_type_map_.erase(it);
360 return 0; 367 return 0;
361 } 368 }
362 369
363 void RTPSender::SetSendPayloadType(int8_t payload_type) { 370 void RTPSender::SetSendPayloadType(int8_t payload_type) {
364 CriticalSectionScoped cs(send_critsect_.get()); 371 rtc::CritScope lock(&send_critsect_);
365 payload_type_ = payload_type; 372 payload_type_ = payload_type;
366 } 373 }
367 374
368 int8_t RTPSender::SendPayloadType() const { 375 int8_t RTPSender::SendPayloadType() const {
369 CriticalSectionScoped cs(send_critsect_.get()); 376 rtc::CritScope lock(&send_critsect_);
370 return payload_type_; 377 return payload_type_;
371 } 378 }
372 379
373 int RTPSender::SendPayloadFrequency() const { 380 int RTPSender::SendPayloadFrequency() const {
374 return audio_ != NULL ? audio_->AudioFrequency() : kVideoPayloadTypeFrequency; 381 return audio_ != NULL ? audio_->AudioFrequency() : kVideoPayloadTypeFrequency;
375 } 382 }
376 383
377 int32_t RTPSender::SetMaxPayloadLength(size_t max_payload_length, 384 int32_t RTPSender::SetMaxPayloadLength(size_t max_payload_length,
378 uint16_t packet_over_head) { 385 uint16_t packet_over_head) {
379 // Sanity check. 386 // Sanity check.
380 RTC_DCHECK(max_payload_length >= 100 && max_payload_length <= IP_PACKET_SIZE) 387 RTC_DCHECK(max_payload_length >= 100 && max_payload_length <= IP_PACKET_SIZE)
381 << "Invalid max payload length: " << max_payload_length; 388 << "Invalid max payload length: " << max_payload_length;
382 CriticalSectionScoped cs(send_critsect_.get()); 389 rtc::CritScope lock(&send_critsect_);
383 max_payload_length_ = max_payload_length; 390 max_payload_length_ = max_payload_length;
384 packet_over_head_ = packet_over_head; 391 packet_over_head_ = packet_over_head;
385 return 0; 392 return 0;
386 } 393 }
387 394
388 size_t RTPSender::MaxDataPayloadLength() const { 395 size_t RTPSender::MaxDataPayloadLength() const {
389 int rtx; 396 int rtx;
390 { 397 {
391 CriticalSectionScoped rtx_lock(send_critsect_.get()); 398 rtc::CritScope lock(&send_critsect_);
392 rtx = rtx_; 399 rtx = rtx_;
393 } 400 }
394 if (audio_configured_) { 401 if (audio_configured_) {
395 return max_payload_length_ - RTPHeaderLength(); 402 return max_payload_length_ - RTPHeaderLength();
396 } else { 403 } else {
397 return max_payload_length_ - RTPHeaderLength() // RTP overhead. 404 return max_payload_length_ - RTPHeaderLength() // RTP overhead.
398 - video_->FECPacketOverhead() // FEC/ULP/RED overhead. 405 - video_->FECPacketOverhead() // FEC/ULP/RED overhead.
399 - ((rtx) ? 2 : 0); // RTX overhead. 406 - ((rtx) ? 2 : 0); // RTX overhead.
400 } 407 }
401 } 408 }
402 409
403 size_t RTPSender::MaxPayloadLength() const { 410 size_t RTPSender::MaxPayloadLength() const {
404 return max_payload_length_; 411 return max_payload_length_;
405 } 412 }
406 413
407 uint16_t RTPSender::PacketOverHead() const { return packet_over_head_; } 414 uint16_t RTPSender::PacketOverHead() const { return packet_over_head_; }
408 415
409 void RTPSender::SetRtxStatus(int mode) { 416 void RTPSender::SetRtxStatus(int mode) {
410 CriticalSectionScoped cs(send_critsect_.get()); 417 rtc::CritScope lock(&send_critsect_);
411 rtx_ = mode; 418 rtx_ = mode;
412 } 419 }
413 420
414 int RTPSender::RtxStatus() const { 421 int RTPSender::RtxStatus() const {
415 CriticalSectionScoped cs(send_critsect_.get()); 422 rtc::CritScope lock(&send_critsect_);
416 return rtx_; 423 return rtx_;
417 } 424 }
418 425
419 void RTPSender::SetRtxSsrc(uint32_t ssrc) { 426 void RTPSender::SetRtxSsrc(uint32_t ssrc) {
420 CriticalSectionScoped cs(send_critsect_.get()); 427 rtc::CritScope lock(&send_critsect_);
421 ssrc_rtx_ = ssrc; 428 ssrc_rtx_ = ssrc;
422 } 429 }
423 430
424 uint32_t RTPSender::RtxSsrc() const { 431 uint32_t RTPSender::RtxSsrc() const {
425 CriticalSectionScoped cs(send_critsect_.get()); 432 rtc::CritScope lock(&send_critsect_);
426 return ssrc_rtx_; 433 return ssrc_rtx_;
427 } 434 }
428 435
429 void RTPSender::SetRtxPayloadType(int payload_type, 436 void RTPSender::SetRtxPayloadType(int payload_type,
430 int associated_payload_type) { 437 int associated_payload_type) {
431 CriticalSectionScoped cs(send_critsect_.get()); 438 rtc::CritScope lock(&send_critsect_);
432 RTC_DCHECK_LE(payload_type, 127); 439 RTC_DCHECK_LE(payload_type, 127);
433 RTC_DCHECK_LE(associated_payload_type, 127); 440 RTC_DCHECK_LE(associated_payload_type, 127);
434 if (payload_type < 0) { 441 if (payload_type < 0) {
435 LOG(LS_ERROR) << "Invalid RTX payload type: " << payload_type; 442 LOG(LS_ERROR) << "Invalid RTX payload type: " << payload_type;
436 return; 443 return;
437 } 444 }
438 445
439 rtx_payload_type_map_[associated_payload_type] = payload_type; 446 rtx_payload_type_map_[associated_payload_type] = payload_type;
440 rtx_payload_type_ = payload_type; 447 rtx_payload_type_ = payload_type;
441 } 448 }
442 449
443 std::pair<int, int> RTPSender::RtxPayloadType() const { 450 std::pair<int, int> RTPSender::RtxPayloadType() const {
444 CriticalSectionScoped cs(send_critsect_.get()); 451 rtc::CritScope lock(&send_critsect_);
445 for (const auto& kv : rtx_payload_type_map_) { 452 for (const auto& kv : rtx_payload_type_map_) {
446 if (kv.second == rtx_payload_type_) { 453 if (kv.second == rtx_payload_type_) {
447 return std::make_pair(rtx_payload_type_, kv.first); 454 return std::make_pair(rtx_payload_type_, kv.first);
448 } 455 }
449 } 456 }
450 return std::make_pair(-1, -1); 457 return std::make_pair(-1, -1);
451 } 458 }
452 459
453 int32_t RTPSender::CheckPayloadType(int8_t payload_type, 460 int32_t RTPSender::CheckPayloadType(int8_t payload_type,
454 RtpVideoCodecTypes* video_type) { 461 RtpVideoCodecTypes* video_type) {
455 CriticalSectionScoped cs(send_critsect_.get()); 462 rtc::CritScope lock(&send_critsect_);
456 463
457 if (payload_type < 0) { 464 if (payload_type < 0) {
458 LOG(LS_ERROR) << "Invalid payload_type " << payload_type; 465 LOG(LS_ERROR) << "Invalid payload_type " << payload_type;
459 return -1; 466 return -1;
460 } 467 }
461 if (audio_configured_) { 468 if (audio_configured_) {
462 int8_t red_pl_type = -1; 469 int8_t red_pl_type = -1;
463 if (audio_->RED(&red_pl_type) == 0) { 470 if (audio_->RED(&red_pl_type) == 0) {
464 // We have configured RED. 471 // We have configured RED.
465 if (red_pl_type == payload_type) { 472 if (red_pl_type == payload_type) {
(...skipping 21 matching lines...)
487 if (!payload->audio && !audio_configured_) { 494 if (!payload->audio && !audio_configured_) {
488 video_->SetVideoCodecType(payload->typeSpecific.Video.videoCodecType); 495 video_->SetVideoCodecType(payload->typeSpecific.Video.videoCodecType);
489 *video_type = payload->typeSpecific.Video.videoCodecType; 496 *video_type = payload->typeSpecific.Video.videoCodecType;
490 video_->SetMaxConfiguredBitrateVideo(payload->typeSpecific.Video.maxRate); 497 video_->SetMaxConfiguredBitrateVideo(payload->typeSpecific.Video.maxRate);
491 } 498 }
492 return 0; 499 return 0;
493 } 500 }
494 501
495 RTPSenderInterface::CVOMode RTPSender::ActivateCVORtpHeaderExtension() { 502 RTPSenderInterface::CVOMode RTPSender::ActivateCVORtpHeaderExtension() {
496 if (cvo_mode_ == kCVOInactive) { 503 if (cvo_mode_ == kCVOInactive) {
497 CriticalSectionScoped cs(send_critsect_.get()); 504 rtc::CritScope lock(&send_critsect_);
498 if (rtp_header_extension_map_.SetActive(kRtpExtensionVideoRotation, true)) { 505 if (rtp_header_extension_map_.SetActive(kRtpExtensionVideoRotation, true)) {
499 cvo_mode_ = kCVOActivated; 506 cvo_mode_ = kCVOActivated;
500 } 507 }
501 } 508 }
502 return cvo_mode_; 509 return cvo_mode_;
503 } 510 }
504 511
505 int32_t RTPSender::SendOutgoingData(FrameType frame_type, 512 int32_t RTPSender::SendOutgoingData(FrameType frame_type,
506 int8_t payload_type, 513 int8_t payload_type,
507 uint32_t capture_timestamp, 514 uint32_t capture_timestamp,
508 int64_t capture_time_ms, 515 int64_t capture_time_ms,
509 const uint8_t* payload_data, 516 const uint8_t* payload_data,
510 size_t payload_size, 517 size_t payload_size,
511 const RTPFragmentationHeader* fragmentation, 518 const RTPFragmentationHeader* fragmentation,
512 const RTPVideoHeader* rtp_hdr) { 519 const RTPVideoHeader* rtp_hdr) {
513 uint32_t ssrc; 520 uint32_t ssrc;
514 { 521 {
515 // Drop this packet if we're not sending media packets. 522 // Drop this packet if we're not sending media packets.
516 CriticalSectionScoped cs(send_critsect_.get()); 523 rtc::CritScope lock(&send_critsect_);
517 ssrc = ssrc_; 524 ssrc = ssrc_;
518 if (!sending_media_) { 525 if (!sending_media_) {
519 return 0; 526 return 0;
520 } 527 }
521 } 528 }
522 RtpVideoCodecTypes video_type = kRtpVideoGeneric; 529 RtpVideoCodecTypes video_type = kRtpVideoGeneric;
523 if (CheckPayloadType(payload_type, &video_type) != 0) { 530 if (CheckPayloadType(payload_type, &video_type) != 0) {
524 LOG(LS_ERROR) << "Don't send data with unknown payload type: " 531 LOG(LS_ERROR) << "Don't send data with unknown payload type: "
525 << static_cast<int>(payload_type) << "."; 532 << static_cast<int>(payload_type) << ".";
526 return -1; 533 return -1;
(...skipping 31 matching lines...)
558 } 565 }
559 if (frame_count_observer_) { 566 if (frame_count_observer_) {
560 frame_count_observer_->FrameCountUpdated(frame_counts_, ssrc); 567 frame_count_observer_->FrameCountUpdated(frame_counts_, ssrc);
561 } 568 }
562 569
563 return ret_val; 570 return ret_val;
564 } 571 }
565 572
566 size_t RTPSender::TrySendRedundantPayloads(size_t bytes_to_send) { 573 size_t RTPSender::TrySendRedundantPayloads(size_t bytes_to_send) {
567 { 574 {
568 CriticalSectionScoped cs(send_critsect_.get()); 575 rtc::CritScope lock(&send_critsect_);
569 if ((rtx_ & kRtxRedundantPayloads) == 0) 576 if ((rtx_ & kRtxRedundantPayloads) == 0)
570 return 0; 577 return 0;
571 } 578 }
572 579
573 uint8_t buffer[IP_PACKET_SIZE]; 580 uint8_t buffer[IP_PACKET_SIZE];
574 int bytes_left = static_cast<int>(bytes_to_send); 581 int bytes_left = static_cast<int>(bytes_to_send);
575 while (bytes_left > 0) { 582 while (bytes_left > 0) {
576 size_t length = bytes_left; 583 size_t length = bytes_left;
577 int64_t capture_time_ms; 584 int64_t capture_time_ms;
578 if (!packet_history_.GetBestFittingPacket(buffer, &length, 585 if (!packet_history_.GetBestFittingPacket(buffer, &length,
(...skipping 41 matching lines...)
620 transport_sequence_number_allocator_; 627 transport_sequence_number_allocator_;
621 for (; bytes > 0; bytes -= padding_bytes_in_packet) { 628 for (; bytes > 0; bytes -= padding_bytes_in_packet) {
622 if (bytes < padding_bytes_in_packet) 629 if (bytes < padding_bytes_in_packet)
623 bytes = padding_bytes_in_packet; 630 bytes = padding_bytes_in_packet;
624 631
625 uint32_t ssrc; 632 uint32_t ssrc;
626 uint16_t sequence_number; 633 uint16_t sequence_number;
627 int payload_type; 634 int payload_type;
628 bool over_rtx; 635 bool over_rtx;
629 { 636 {
630 CriticalSectionScoped cs(send_critsect_.get()); 637 rtc::CritScope lock(&send_critsect_);
631 if (!timestamp_provided) { 638 if (!timestamp_provided) {
632 timestamp = timestamp_; 639 timestamp = timestamp_;
633 capture_time_ms = capture_time_ms_; 640 capture_time_ms = capture_time_ms_;
634 } 641 }
635 if (rtx_ == kRtxOff) { 642 if (rtx_ == kRtxOff) {
636 // Without RTX we can't send padding in the middle of frames. 643 // Without RTX we can't send padding in the middle of frames.
637 if (!last_packet_marker_bit_) 644 if (!last_packet_marker_bit_)
638 return 0; 645 return 0;
639 ssrc = ssrc_; 646 ssrc = ssrc_;
640 sequence_number = sequence_number_; 647 sequence_number = sequence_number_;
(...skipping 93 matching lines...)
734 // TickTime. 741 // TickTime.
735 int64_t corrected_capture_tims_ms = capture_time_ms + clock_delta_ms_; 742 int64_t corrected_capture_tims_ms = capture_time_ms + clock_delta_ms_;
736 paced_sender_->InsertPacket( 743 paced_sender_->InsertPacket(
737 RtpPacketSender::kNormalPriority, header.ssrc, header.sequenceNumber, 744 RtpPacketSender::kNormalPriority, header.ssrc, header.sequenceNumber,
738 corrected_capture_tims_ms, length - header.headerLength, true); 745 corrected_capture_tims_ms, length - header.headerLength, true);
739 746
740 return length; 747 return length;
741 } 748 }
742 int rtx = kRtxOff; 749 int rtx = kRtxOff;
743 { 750 {
744 CriticalSectionScoped lock(send_critsect_.get()); 751 rtc::CritScope lock(&send_critsect_);
745 rtx = rtx_; 752 rtx = rtx_;
746 } 753 }
747 if (!PrepareAndSendPacket(data_buffer, length, capture_time_ms, 754 if (!PrepareAndSendPacket(data_buffer, length, capture_time_ms,
748 (rtx & kRtxRetransmitted) > 0, true)) { 755 (rtx & kRtxRetransmitted) > 0, true)) {
749 return -1; 756 return -1;
750 } 757 }
751 return static_cast<int32_t>(length); 758 return static_cast<int32_t>(length);
752 } 759 }
753 760
754 bool RTPSender::SendPacketToNetwork(const uint8_t* packet, 761 bool RTPSender::SendPacketToNetwork(const uint8_t* packet,
(...skipping 77 matching lines...)
832 UpdateNACKBitRate(bytes_re_sent, now); 839 UpdateNACKBitRate(bytes_re_sent, now);
833 } 840 }
834 } 841 }
835 842
836 bool RTPSender::ProcessNACKBitRate(uint32_t now) { 843 bool RTPSender::ProcessNACKBitRate(uint32_t now) {
837 uint32_t num = 0; 844 uint32_t num = 0;
838 size_t byte_count = 0; 845 size_t byte_count = 0;
839 const uint32_t kAvgIntervalMs = 1000; 846 const uint32_t kAvgIntervalMs = 1000;
840 uint32_t target_bitrate = GetTargetBitrate(); 847 uint32_t target_bitrate = GetTargetBitrate();
841 848
842 CriticalSectionScoped cs(send_critsect_.get()); 849 rtc::CritScope lock(&send_critsect_);
843 850
844 if (target_bitrate == 0) { 851 if (target_bitrate == 0) {
845 return true; 852 return true;
846 } 853 }
847 for (num = 0; num < NACK_BYTECOUNT_SIZE; ++num) { 854 for (num = 0; num < NACK_BYTECOUNT_SIZE; ++num) {
848 if ((now - nack_byte_count_times_[num]) > kAvgIntervalMs) { 855 if ((now - nack_byte_count_times_[num]) > kAvgIntervalMs) {
849 // Don't use data older than 1sec. 856 // Don't use data older than 1sec.
850 break; 857 break;
851 } else { 858 } else {
852 byte_count += nack_byte_count_[num]; 859 byte_count += nack_byte_count_[num];
853 } 860 }
854 } 861 }
855 uint32_t time_interval = kAvgIntervalMs; 862 uint32_t time_interval = kAvgIntervalMs;
856 if (num == NACK_BYTECOUNT_SIZE) { 863 if (num == NACK_BYTECOUNT_SIZE) {
857 // More than NACK_BYTECOUNT_SIZE nack messages has been received 864 // More than NACK_BYTECOUNT_SIZE nack messages has been received
858 // during the last msg_interval. 865 // during the last msg_interval.
859 if (nack_byte_count_times_[num - 1] <= now) { 866 if (nack_byte_count_times_[num - 1] <= now) {
860 time_interval = now - nack_byte_count_times_[num - 1]; 867 time_interval = now - nack_byte_count_times_[num - 1];
861 } 868 }
862 } 869 }
863 return (byte_count * 8) < (target_bitrate / 1000 * time_interval); 870 return (byte_count * 8) < (target_bitrate / 1000 * time_interval);
864 } 871 }
865 872
866 void RTPSender::UpdateNACKBitRate(uint32_t bytes, int64_t now) { 873 void RTPSender::UpdateNACKBitRate(uint32_t bytes, int64_t now) {
867 CriticalSectionScoped cs(send_critsect_.get()); 874 rtc::CritScope lock(&send_critsect_);
868 if (bytes == 0) 875 if (bytes == 0)
869 return; 876 return;
870 nack_bitrate_.Update(bytes); 877 nack_bitrate_.Update(bytes);
871 // Save bitrate statistics. 878 // Save bitrate statistics.
872 // Shift all but first time. 879 // Shift all but first time.
873 for (int i = NACK_BYTECOUNT_SIZE - 2; i >= 0; i--) { 880 for (int i = NACK_BYTECOUNT_SIZE - 2; i >= 0; i--) {
874 nack_byte_count_[i + 1] = nack_byte_count_[i]; 881 nack_byte_count_[i + 1] = nack_byte_count_[i];
875 nack_byte_count_times_[i + 1] = nack_byte_count_times_[i]; 882 nack_byte_count_times_[i + 1] = nack_byte_count_times_[i];
876 } 883 }
877 nack_byte_count_[0] = bytes; 884 nack_byte_count_[0] = bytes;
(...skipping 15 matching lines...)
893 &length, 900 &length,
894 &stored_time_ms)) { 901 &stored_time_ms)) {
895 // Packet cannot be found. Allow sending to continue. 902 // Packet cannot be found. Allow sending to continue.
896 return true; 903 return true;
897 } 904 }
898 if (!retransmission && capture_time_ms > 0) { 905 if (!retransmission && capture_time_ms > 0) {
899 UpdateDelayStatistics(capture_time_ms, clock_->TimeInMilliseconds()); 906 UpdateDelayStatistics(capture_time_ms, clock_->TimeInMilliseconds());
900 } 907 }
901 int rtx; 908 int rtx;
902 { 909 {
903 CriticalSectionScoped lock(send_critsect_.get()); 910 rtc::CritScope lock(&send_critsect_);
904 rtx = rtx_; 911 rtx = rtx_;
905 } 912 }
906 return PrepareAndSendPacket(data_buffer, 913 return PrepareAndSendPacket(data_buffer,
907 length, 914 length,
908 capture_time_ms, 915 capture_time_ms,
909 retransmission && (rtx & kRtxRetransmitted) > 0, 916 retransmission && (rtx & kRtxRetransmitted) > 0,
910 retransmission); 917 retransmission);
911 } 918 }
912 919
913 bool RTPSender::PrepareAndSendPacket(uint8_t* buffer, 920 bool RTPSender::PrepareAndSendPacket(uint8_t* buffer,
(...skipping 37 matching lines...)
951 options.packet_id = 958 options.packet_id =
952 UpdateTransportSequenceNumber(buffer_to_send_ptr, length, rtp_header); 959 UpdateTransportSequenceNumber(buffer_to_send_ptr, length, rtp_header);
953 } 960 }
954 961
955 if (using_transport_seq && transport_feedback_observer_) { 962 if (using_transport_seq && transport_feedback_observer_) {
956 transport_feedback_observer_->AddPacket(options.packet_id, length, true); 963 transport_feedback_observer_->AddPacket(options.packet_id, length, true);
957 } 964 }
958 965
959 bool ret = SendPacketToNetwork(buffer_to_send_ptr, length, options); 966 bool ret = SendPacketToNetwork(buffer_to_send_ptr, length, options);
960 if (ret) { 967 if (ret) {
961 CriticalSectionScoped lock(send_critsect_.get()); 968 rtc::CritScope lock(&send_critsect_);
962 media_has_been_sent_ = true; 969 media_has_been_sent_ = true;
963 } 970 }
964 UpdateRtpStats(buffer_to_send_ptr, length, rtp_header, send_over_rtx, 971 UpdateRtpStats(buffer_to_send_ptr, length, rtp_header, send_over_rtx,
965 is_retransmit); 972 is_retransmit);
966 return ret; 973 return ret;
967 } 974 }
968 975
969 void RTPSender::UpdateRtpStats(const uint8_t* buffer, 976 void RTPSender::UpdateRtpStats(const uint8_t* buffer,
970 size_t packet_length, 977 size_t packet_length,
971 const RTPHeader& header, 978 const RTPHeader& header,
(...skipping 39 matching lines...)
1011 video_->GenericFECStatus(&fec_enabled, &pt_red, &pt_fec); 1018 video_->GenericFECStatus(&fec_enabled, &pt_red, &pt_fec);
1012 return fec_enabled && 1019 return fec_enabled &&
1013 header.payloadType == pt_red && 1020 header.payloadType == pt_red &&
1014 buffer[header.headerLength] == pt_fec; 1021 buffer[header.headerLength] == pt_fec;
1015 } 1022 }
1016 1023
1017 size_t RTPSender::TimeToSendPadding(size_t bytes) { 1024 size_t RTPSender::TimeToSendPadding(size_t bytes) {
1018 if (audio_configured_ || bytes == 0) 1025 if (audio_configured_ || bytes == 0)
1019 return 0; 1026 return 0;
1020 { 1027 {
1021 CriticalSectionScoped cs(send_critsect_.get()); 1028 rtc::CritScope lock(&send_critsect_);
1022 if (!sending_media_) 1029 if (!sending_media_)
1023 return 0; 1030 return 0;
1024 } 1031 }
1025 size_t bytes_sent = TrySendRedundantPayloads(bytes); 1032 size_t bytes_sent = TrySendRedundantPayloads(bytes);
1026 if (bytes_sent < bytes) 1033 if (bytes_sent < bytes)
1027 bytes_sent += SendPadData(bytes - bytes_sent, false, 0, 0); 1034 bytes_sent += SendPadData(bytes - bytes_sent, false, 0, 0);
1028 return bytes_sent; 1035 return bytes_sent;
1029 } 1036 }
1030 1037
1031 // TODO(pwestin): send in the RtpHeaderParser to avoid parsing it again. 1038 // TODO(pwestin): send in the RtpHeaderParser to avoid parsing it again.
(...skipping 51 matching lines...)
1083 1090
1084 // Mark the packet as sent in the history even if send failed. Dropping a 1091 // Mark the packet as sent in the history even if send failed. Dropping a
1085 // packet here should be treated as any other packet drop so we should be 1092 // packet here should be treated as any other packet drop so we should be
1086 // ready for a retransmission. 1093 // ready for a retransmission.
1087 packet_history_.SetSent(rtp_header.sequenceNumber); 1094 packet_history_.SetSent(rtp_header.sequenceNumber);
1088 1095
1089 if (!sent) 1096 if (!sent)
1090 return -1; 1097 return -1;
1091 1098
1092 { 1099 {
1093 CriticalSectionScoped lock(send_critsect_.get()); 1100 rtc::CritScope lock(&send_critsect_);
1094 media_has_been_sent_ = true; 1101 media_has_been_sent_ = true;
1095 } 1102 }
1096 UpdateRtpStats(buffer, length, rtp_header, false, false); 1103 UpdateRtpStats(buffer, length, rtp_header, false, false);
1097 return 0; 1104 return 0;
1098 } 1105 }
1099 1106
1100 void RTPSender::UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms) { 1107 void RTPSender::UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms) {
1101 if (!send_side_delay_observer_) 1108 if (!send_side_delay_observer_)
1102 return; 1109 return;
1103 1110
1104 uint32_t ssrc; 1111 uint32_t ssrc;
1105 int avg_delay_ms = 0; 1112 int avg_delay_ms = 0;
1106 int max_delay_ms = 0; 1113 int max_delay_ms = 0;
1107 { 1114 {
1108 CriticalSectionScoped lock(send_critsect_.get()); 1115 rtc::CritScope lock(&send_critsect_);
1109 ssrc = ssrc_; 1116 ssrc = ssrc_;
1110 } 1117 }
1111 { 1118 {
1112 CriticalSectionScoped cs(statistics_crit_.get()); 1119 CriticalSectionScoped cs(statistics_crit_.get());
1113 // TODO(holmer): Compute this iteratively instead. 1120 // TODO(holmer): Compute this iteratively instead.
1114 send_delays_[now_ms] = now_ms - capture_time_ms; 1121 send_delays_[now_ms] = now_ms - capture_time_ms;
1115 send_delays_.erase(send_delays_.begin(), 1122 send_delays_.erase(send_delays_.begin(),
1116 send_delays_.lower_bound(now_ms - 1123 send_delays_.lower_bound(now_ms -
1117 kSendSideDelayWindowMs)); 1124 kSendSideDelayWindowMs));
1118 int num_delays = 0; 1125 int num_delays = 0;
1119 for (auto it = send_delays_.upper_bound(now_ms - kSendSideDelayWindowMs); 1126 for (auto it = send_delays_.upper_bound(now_ms - kSendSideDelayWindowMs);
1120 it != send_delays_.end(); ++it) { 1127 it != send_delays_.end(); ++it) {
1121 max_delay_ms = std::max(max_delay_ms, it->second); 1128 max_delay_ms = std::max(max_delay_ms, it->second);
1122 avg_delay_ms += it->second; 1129 avg_delay_ms += it->second;
1123 ++num_delays; 1130 ++num_delays;
1124 } 1131 }
1125 if (num_delays == 0) 1132 if (num_delays == 0)
1126 return; 1133 return;
1127 avg_delay_ms = (avg_delay_ms + num_delays / 2) / num_delays; 1134 avg_delay_ms = (avg_delay_ms + num_delays / 2) / num_delays;
1128 } 1135 }
1129 send_side_delay_observer_->SendSideDelayUpdated(avg_delay_ms, max_delay_ms, 1136 send_side_delay_observer_->SendSideDelayUpdated(avg_delay_ms, max_delay_ms,
1130 ssrc); 1137 ssrc);
1131 } 1138 }
1132 1139
1133 void RTPSender::ProcessBitrate() { 1140 void RTPSender::ProcessBitrate() {
1134 CriticalSectionScoped cs(send_critsect_.get()); 1141 rtc::CritScope lock(&send_critsect_);
1135 total_bitrate_sent_.Process(); 1142 total_bitrate_sent_.Process();
1136 nack_bitrate_.Process(); 1143 nack_bitrate_.Process();
1137 if (audio_configured_) { 1144 if (audio_configured_) {
1138 return; 1145 return;
1139 } 1146 }
1140 video_->ProcessBitrate(); 1147 video_->ProcessBitrate();
1141 } 1148 }
1142 1149
1143 size_t RTPSender::RTPHeaderLength() const { 1150 size_t RTPSender::RTPHeaderLength() const {
1144 CriticalSectionScoped lock(send_critsect_.get()); 1151 rtc::CritScope lock(&send_critsect_);
1145 size_t rtp_header_length = kRtpHeaderLength; 1152 size_t rtp_header_length = kRtpHeaderLength;
1146 rtp_header_length += sizeof(uint32_t) * csrcs_.size(); 1153 rtp_header_length += sizeof(uint32_t) * csrcs_.size();
1147 rtp_header_length += RtpHeaderExtensionTotalLength(); 1154 rtp_header_length += RtpHeaderExtensionTotalLength();
1148 return rtp_header_length; 1155 return rtp_header_length;
1149 } 1156 }
1150 1157
1151 uint16_t RTPSender::AllocateSequenceNumber(uint16_t packets_to_send) { 1158 uint16_t RTPSender::AllocateSequenceNumber(uint16_t packets_to_send) {
1152 CriticalSectionScoped cs(send_critsect_.get()); 1159 rtc::CritScope lock(&send_critsect_);
1153 uint16_t first_allocated_sequence_number = sequence_number_; 1160 uint16_t first_allocated_sequence_number = sequence_number_;
1154 sequence_number_ += packets_to_send; 1161 sequence_number_ += packets_to_send;
1155 return first_allocated_sequence_number; 1162 return first_allocated_sequence_number;
1156 } 1163 }
1157 1164
1158 void RTPSender::GetDataCounters(StreamDataCounters* rtp_stats, 1165 void RTPSender::GetDataCounters(StreamDataCounters* rtp_stats,
1159 StreamDataCounters* rtx_stats) const { 1166 StreamDataCounters* rtx_stats) const {
1160 CriticalSectionScoped lock(statistics_crit_.get()); 1167 CriticalSectionScoped lock(statistics_crit_.get());
1161 *rtp_stats = rtp_stats_; 1168 *rtp_stats = rtp_stats_;
1162 *rtx_stats = rtx_rtp_stats_; 1169 *rtx_stats = rtx_rtp_stats_;
(...skipping 38 matching lines...)
1201 } 1208 }
1202 1209
1203 int32_t RTPSender::BuildRTPheader(uint8_t* data_buffer, 1210 int32_t RTPSender::BuildRTPheader(uint8_t* data_buffer,
1204 int8_t payload_type, 1211 int8_t payload_type,
1205 bool marker_bit, 1212 bool marker_bit,
1206 uint32_t capture_timestamp, 1213 uint32_t capture_timestamp,
1207 int64_t capture_time_ms, 1214 int64_t capture_time_ms,
1208 bool timestamp_provided, 1215 bool timestamp_provided,
1209 bool inc_sequence_number) { 1216 bool inc_sequence_number) {
1210 assert(payload_type >= 0); 1217 assert(payload_type >= 0);
1211 CriticalSectionScoped cs(send_critsect_.get()); 1218 rtc::CritScope lock(&send_critsect_);
1212 1219
1213 if (timestamp_provided) { 1220 if (timestamp_provided) {
1214 timestamp_ = start_timestamp_ + capture_timestamp; 1221 timestamp_ = start_timestamp_ + capture_timestamp;
1215 } else { 1222 } else {
1216 // Make a unique time stamp. 1223 // Make a unique time stamp.
1217 // We can't inc by the actual time, since then we increase the risk of back 1224 // We can't inc by the actual time, since then we increase the risk of back
1218 // timing. 1225 // timing.
1219 timestamp_++; 1226 timestamp_++;
1220 } 1227 }
1221 last_timestamp_time_ms_ = clock_->TimeInMilliseconds(); 1228 last_timestamp_time_ms_ = clock_->TimeInMilliseconds();
(...skipping 286 matching lines...)
1508 1515
1509 *extension_offset = block_pos; 1516 *extension_offset = block_pos;
1510 return ExtensionStatus::kOk; 1517 return ExtensionStatus::kOk;
1511 } 1518 }
1512 1519
1513 void RTPSender::UpdateTransmissionTimeOffset(uint8_t* rtp_packet, 1520 void RTPSender::UpdateTransmissionTimeOffset(uint8_t* rtp_packet,
1514 size_t rtp_packet_length, 1521 size_t rtp_packet_length,
1515 const RTPHeader& rtp_header, 1522 const RTPHeader& rtp_header,
1516 int64_t time_diff_ms) const { 1523 int64_t time_diff_ms) const {
1517 size_t offset; 1524 size_t offset;
1518 CriticalSectionScoped cs(send_critsect_.get()); 1525 rtc::CritScope lock(&send_critsect_);
1519 switch (VerifyExtension(kRtpExtensionTransmissionTimeOffset, rtp_packet, 1526 switch (VerifyExtension(kRtpExtensionTransmissionTimeOffset, rtp_packet,
1520 rtp_packet_length, rtp_header, 1527 rtp_packet_length, rtp_header,
1521 kTransmissionTimeOffsetLength, &offset)) { 1528 kTransmissionTimeOffsetLength, &offset)) {
1522 case ExtensionStatus::kNotRegistered: 1529 case ExtensionStatus::kNotRegistered:
1523 return; 1530 return;
1524 case ExtensionStatus::kError: 1531 case ExtensionStatus::kError:
1525 LOG(LS_WARNING) << "Failed to update transmission time offset."; 1532 LOG(LS_WARNING) << "Failed to update transmission time offset.";
1526 return; 1533 return;
1527 case ExtensionStatus::kOk: 1534 case ExtensionStatus::kOk:
1528 break; 1535 break;
1529 default: 1536 default:
1530 RTC_NOTREACHED(); 1537 RTC_NOTREACHED();
1531 } 1538 }
1532 1539
1533 // Update transmission offset field (converting to a 90 kHz timestamp). 1540 // Update transmission offset field (converting to a 90 kHz timestamp).
1534 ByteWriter<int32_t, 3>::WriteBigEndian(rtp_packet + offset + 1, 1541 ByteWriter<int32_t, 3>::WriteBigEndian(rtp_packet + offset + 1,
1535 time_diff_ms * 90); // RTP timestamp. 1542 time_diff_ms * 90); // RTP timestamp.
1536 } 1543 }
1537 1544
1538 bool RTPSender::UpdateAudioLevel(uint8_t* rtp_packet, 1545 bool RTPSender::UpdateAudioLevel(uint8_t* rtp_packet,
1539 size_t rtp_packet_length, 1546 size_t rtp_packet_length,
1540 const RTPHeader& rtp_header, 1547 const RTPHeader& rtp_header,
1541 bool is_voiced, 1548 bool is_voiced,
1542 uint8_t dBov) const { 1549 uint8_t dBov) const {
1543 size_t offset; 1550 size_t offset;
1544 CriticalSectionScoped cs(send_critsect_.get()); 1551 rtc::CritScope lock(&send_critsect_);
1545 1552
1546 switch (VerifyExtension(kRtpExtensionAudioLevel, rtp_packet, 1553 switch (VerifyExtension(kRtpExtensionAudioLevel, rtp_packet,
1547 rtp_packet_length, rtp_header, kAudioLevelLength, 1554 rtp_packet_length, rtp_header, kAudioLevelLength,
1548 &offset)) { 1555 &offset)) {
1549 case ExtensionStatus::kNotRegistered: 1556 case ExtensionStatus::kNotRegistered:
1550 return false; 1557 return false;
1551 case ExtensionStatus::kError: 1558 case ExtensionStatus::kError:
1552 LOG(LS_WARNING) << "Failed to update audio level."; 1559 LOG(LS_WARNING) << "Failed to update audio level.";
1553 return false; 1560 return false;
1554 case ExtensionStatus::kOk: 1561 case ExtensionStatus::kOk:
1555 break; 1562 break;
1556 default: 1563 default:
1557 RTC_NOTREACHED(); 1564 RTC_NOTREACHED();
1558 } 1565 }
1559 1566
1560 rtp_packet[offset + 1] = (is_voiced ? 0x80 : 0x00) + (dBov & 0x7f); 1567 rtp_packet[offset + 1] = (is_voiced ? 0x80 : 0x00) + (dBov & 0x7f);
1561 return true; 1568 return true;
1562 } 1569 }
1563 1570
1564 bool RTPSender::UpdateVideoRotation(uint8_t* rtp_packet, 1571 bool RTPSender::UpdateVideoRotation(uint8_t* rtp_packet,
1565 size_t rtp_packet_length, 1572 size_t rtp_packet_length,
1566 const RTPHeader& rtp_header, 1573 const RTPHeader& rtp_header,
1567 VideoRotation rotation) const { 1574 VideoRotation rotation) const {
1568 size_t offset; 1575 size_t offset;
1569 CriticalSectionScoped cs(send_critsect_.get()); 1576 rtc::CritScope lock(&send_critsect_);
1570 1577
1571 switch (VerifyExtension(kRtpExtensionVideoRotation, rtp_packet, 1578 switch (VerifyExtension(kRtpExtensionVideoRotation, rtp_packet,
1572 rtp_packet_length, rtp_header, kVideoRotationLength, 1579 rtp_packet_length, rtp_header, kVideoRotationLength,
1573 &offset)) { 1580 &offset)) {
1574 case ExtensionStatus::kNotRegistered: 1581 case ExtensionStatus::kNotRegistered:
1575 return false; 1582 return false;
1576 case ExtensionStatus::kError: 1583 case ExtensionStatus::kError:
1577 LOG(LS_WARNING) << "Failed to update CVO."; 1584 LOG(LS_WARNING) << "Failed to update CVO.";
1578 return false; 1585 return false;
1579 case ExtensionStatus::kOk: 1586 case ExtensionStatus::kOk:
1580 break; 1587 break;
1581 default: 1588 default:
1582 RTC_NOTREACHED(); 1589 RTC_NOTREACHED();
1583 } 1590 }
1584 1591
1585 rtp_packet[offset + 1] = ConvertVideoRotationToCVOByte(rotation); 1592 rtp_packet[offset + 1] = ConvertVideoRotationToCVOByte(rotation);
1586 return true; 1593 return true;
1587 } 1594 }
1588 1595
1589 void RTPSender::UpdateAbsoluteSendTime(uint8_t* rtp_packet, 1596 void RTPSender::UpdateAbsoluteSendTime(uint8_t* rtp_packet,
1590 size_t rtp_packet_length, 1597 size_t rtp_packet_length,
1591 const RTPHeader& rtp_header, 1598 const RTPHeader& rtp_header,
1592 int64_t now_ms) const { 1599 int64_t now_ms) const {
1593 size_t offset; 1600 size_t offset;
1594 CriticalSectionScoped cs(send_critsect_.get()); 1601 rtc::CritScope lock(&send_critsect_);
1595 1602
1596 switch (VerifyExtension(kRtpExtensionAbsoluteSendTime, rtp_packet, 1603 switch (VerifyExtension(kRtpExtensionAbsoluteSendTime, rtp_packet,
1597 rtp_packet_length, rtp_header, 1604 rtp_packet_length, rtp_header,
1598 kAbsoluteSendTimeLength, &offset)) { 1605 kAbsoluteSendTimeLength, &offset)) {
1599 case ExtensionStatus::kNotRegistered: 1606 case ExtensionStatus::kNotRegistered:
1600 return; 1607 return;
1601 case ExtensionStatus::kError: 1608 case ExtensionStatus::kError:
1602 LOG(LS_WARNING) << "Failed to update absolute send time"; 1609 LOG(LS_WARNING) << "Failed to update absolute send time";
1603 return; 1610 return;
1604 case ExtensionStatus::kOk: 1611 case ExtensionStatus::kOk:
1605 break; 1612 break;
1606 default: 1613 default:
1607 RTC_NOTREACHED(); 1614 RTC_NOTREACHED();
1608 } 1615 }
1609 1616
1610 // Update absolute send time field (convert ms to 24-bit unsigned with 18 bit 1617 // Update absolute send time field (convert ms to 24-bit unsigned with 18 bit
1611 // fractional part). 1618 // fractional part).
1612 ByteWriter<uint32_t, 3>::WriteBigEndian(rtp_packet + offset + 1, 1619 ByteWriter<uint32_t, 3>::WriteBigEndian(rtp_packet + offset + 1,
1613 ConvertMsTo24Bits(now_ms)); 1620 ConvertMsTo24Bits(now_ms));
1614 } 1621 }
1615 1622
1616 uint16_t RTPSender::UpdateTransportSequenceNumber( 1623 uint16_t RTPSender::UpdateTransportSequenceNumber(
1617 uint8_t* rtp_packet, 1624 uint8_t* rtp_packet,
1618 size_t rtp_packet_length, 1625 size_t rtp_packet_length,
1619 const RTPHeader& rtp_header) const { 1626 const RTPHeader& rtp_header) const {
1620 size_t offset; 1627 size_t offset;
1621 CriticalSectionScoped cs(send_critsect_.get()); 1628 rtc::CritScope lock(&send_critsect_);
1622 1629
1623 switch (VerifyExtension(kRtpExtensionTransportSequenceNumber, rtp_packet, 1630 switch (VerifyExtension(kRtpExtensionTransportSequenceNumber, rtp_packet,
1624 rtp_packet_length, rtp_header, 1631 rtp_packet_length, rtp_header,
1625 kTransportSequenceNumberLength, &offset)) { 1632 kTransportSequenceNumberLength, &offset)) {
1626 case ExtensionStatus::kNotRegistered: 1633 case ExtensionStatus::kNotRegistered:
1627 return 0; 1634 return 0;
1628 case ExtensionStatus::kError: 1635 case ExtensionStatus::kError:
1629 LOG(LS_WARNING) << "Failed to update transport sequence number"; 1636 LOG(LS_WARNING) << "Failed to update transport sequence number";
1630 return 0; 1637 return 0;
1631 case ExtensionStatus::kOk: 1638 case ExtensionStatus::kOk:
1632 break; 1639 break;
1633 default: 1640 default:
1634 RTC_NOTREACHED(); 1641 RTC_NOTREACHED();
1635 } 1642 }
1636 1643
1637 uint16_t seq = transport_sequence_number_allocator_->AllocateSequenceNumber(); 1644 uint16_t seq = transport_sequence_number_allocator_->AllocateSequenceNumber();
1638 BuildTransportSequenceNumberExtension(rtp_packet + offset, seq); 1645 BuildTransportSequenceNumberExtension(rtp_packet + offset, seq);
1639 return seq; 1646 return seq;
1640 } 1647 }
1641 1648
1642 void RTPSender::SetSendingStatus(bool enabled) { 1649 void RTPSender::SetSendingStatus(bool enabled) {
1643 if (enabled) { 1650 if (enabled) {
1644 uint32_t frequency_hz = SendPayloadFrequency(); 1651 uint32_t frequency_hz = SendPayloadFrequency();
1645 uint32_t RTPtime = CurrentRtp(*clock_, frequency_hz); 1652 uint32_t RTPtime = CurrentRtp(*clock_, frequency_hz);
1646 1653
1647 // Will be ignored if it's already configured via API. 1654 // Will be ignored if it's already configured via API.
1648 SetStartTimestamp(RTPtime, false); 1655 SetStartTimestamp(RTPtime, false);
1649 } else { 1656 } else {
1650 CriticalSectionScoped lock(send_critsect_.get()); 1657 rtc::CritScope lock(&send_critsect_);
1651 if (!ssrc_forced_) { 1658 if (!ssrc_forced_) {
1652 // Generate a new SSRC. 1659 // Generate a new SSRC.
1653 ssrc_db_.ReturnSSRC(ssrc_); 1660 ssrc_db_->ReturnSSRC(ssrc_);
1654 ssrc_ = ssrc_db_.CreateSSRC(); // Can't be 0. 1661 ssrc_ = ssrc_db_->CreateSSRC(); // Can't be 0.
1655 bitrates_->set_ssrc(ssrc_); 1662 bitrates_->set_ssrc(ssrc_);
1656 } 1663 }
1657 // Don't initialize seq number if SSRC passed externally. 1664 // Don't initialize seq number if SSRC passed externally.
1658 if (!sequence_number_forced_ && !ssrc_forced_) { 1665 if (!sequence_number_forced_ && !ssrc_forced_) {
1659 // Generate a new sequence number. 1666 // Generate a new sequence number.
1660 sequence_number_ = random_.Rand(1, kMaxInitRtpSeqNumber); 1667 sequence_number_ = random_.Rand(1, kMaxInitRtpSeqNumber);
1661 } 1668 }
1662 } 1669 }
1663 } 1670 }
1664 1671
1665 void RTPSender::SetSendingMediaStatus(bool enabled) { 1672 void RTPSender::SetSendingMediaStatus(bool enabled) {
1666 CriticalSectionScoped cs(send_critsect_.get()); 1673 rtc::CritScope lock(&send_critsect_);
1667 sending_media_ = enabled; 1674 sending_media_ = enabled;
1668 } 1675 }
1669 1676
1670 bool RTPSender::SendingMedia() const { 1677 bool RTPSender::SendingMedia() const {
1671 CriticalSectionScoped cs(send_critsect_.get()); 1678 rtc::CritScope lock(&send_critsect_);
1672 return sending_media_; 1679 return sending_media_;
1673 } 1680 }
1674 1681
1675 uint32_t RTPSender::Timestamp() const { 1682 uint32_t RTPSender::Timestamp() const {
1676 CriticalSectionScoped cs(send_critsect_.get()); 1683 rtc::CritScope lock(&send_critsect_);
1677 return timestamp_; 1684 return timestamp_;
1678 } 1685 }
1679 1686
1680 void RTPSender::SetStartTimestamp(uint32_t timestamp, bool force) { 1687 void RTPSender::SetStartTimestamp(uint32_t timestamp, bool force) {
1681 CriticalSectionScoped cs(send_critsect_.get()); 1688 rtc::CritScope lock(&send_critsect_);
1682 if (force) { 1689 if (force) {
1683 start_timestamp_forced_ = true; 1690 start_timestamp_forced_ = true;
1684 start_timestamp_ = timestamp; 1691 start_timestamp_ = timestamp;
1685 } else { 1692 } else {
1686 if (!start_timestamp_forced_) { 1693 if (!start_timestamp_forced_) {
1687 start_timestamp_ = timestamp; 1694 start_timestamp_ = timestamp;
1688 } 1695 }
1689 } 1696 }
1690 } 1697 }
1691 1698
1692 uint32_t RTPSender::StartTimestamp() const { 1699 uint32_t RTPSender::StartTimestamp() const {
1693 CriticalSectionScoped cs(send_critsect_.get()); 1700 rtc::CritScope lock(&send_critsect_);
1694 return start_timestamp_; 1701 return start_timestamp_;
1695 } 1702 }
1696 1703
1697 uint32_t RTPSender::GenerateNewSSRC() { 1704 uint32_t RTPSender::GenerateNewSSRC() {
1698 // If configured via API, return 0. 1705 // If configured via API, return 0.
1699 CriticalSectionScoped cs(send_critsect_.get()); 1706 rtc::CritScope lock(&send_critsect_);
1700 1707
1701 if (ssrc_forced_) { 1708 if (ssrc_forced_) {
1702 return 0; 1709 return 0;
1703 } 1710 }
1704 ssrc_ = ssrc_db_.CreateSSRC(); // Can't be 0. 1711 ssrc_ = ssrc_db_->CreateSSRC(); // Can't be 0.
1705 bitrates_->set_ssrc(ssrc_); 1712 bitrates_->set_ssrc(ssrc_);
1706 return ssrc_; 1713 return ssrc_;
1707 } 1714 }
1708 1715
1709 void RTPSender::SetSSRC(uint32_t ssrc) { 1716 void RTPSender::SetSSRC(uint32_t ssrc) {
1710 // This is configured via the API. 1717 // This is configured via the API.
1711 CriticalSectionScoped cs(send_critsect_.get()); 1718 rtc::CritScope lock(&send_critsect_);
1712 1719
1713 if (ssrc_ == ssrc && ssrc_forced_) { 1720 if (ssrc_ == ssrc && ssrc_forced_) {
1714 return; // Since it's same ssrc, don't reset anything. 1721 return; // Since it's same ssrc, don't reset anything.
1715 } 1722 }
1716 ssrc_forced_ = true; 1723 ssrc_forced_ = true;
1717 ssrc_db_.ReturnSSRC(ssrc_); 1724 ssrc_db_->ReturnSSRC(ssrc_);
1718 ssrc_db_.RegisterSSRC(ssrc); 1725 ssrc_db_->RegisterSSRC(ssrc);
1719 ssrc_ = ssrc; 1726 ssrc_ = ssrc;
1720 bitrates_->set_ssrc(ssrc_); 1727 bitrates_->set_ssrc(ssrc_);
1721 if (!sequence_number_forced_) { 1728 if (!sequence_number_forced_) {
1722 sequence_number_ = random_.Rand(1, kMaxInitRtpSeqNumber); 1729 sequence_number_ = random_.Rand(1, kMaxInitRtpSeqNumber);
1723 } 1730 }
1724 } 1731 }
1725 1732
1726 uint32_t RTPSender::SSRC() const { 1733 uint32_t RTPSender::SSRC() const {
1727 CriticalSectionScoped cs(send_critsect_.get()); 1734 rtc::CritScope lock(&send_critsect_);
1728 return ssrc_; 1735 return ssrc_;
1729 } 1736 }
1730 1737
1731 void RTPSender::SetCsrcs(const std::vector<uint32_t>& csrcs) { 1738 void RTPSender::SetCsrcs(const std::vector<uint32_t>& csrcs) {
1732 assert(csrcs.size() <= kRtpCsrcSize); 1739 assert(csrcs.size() <= kRtpCsrcSize);
1733 CriticalSectionScoped cs(send_critsect_.get()); 1740 rtc::CritScope lock(&send_critsect_);
1734 csrcs_ = csrcs; 1741 csrcs_ = csrcs;
1735 } 1742 }
1736 1743
1737 void RTPSender::SetSequenceNumber(uint16_t seq) { 1744 void RTPSender::SetSequenceNumber(uint16_t seq) {
1738 CriticalSectionScoped cs(send_critsect_.get()); 1745 rtc::CritScope lock(&send_critsect_);
1739 sequence_number_forced_ = true; 1746 sequence_number_forced_ = true;
1740 sequence_number_ = seq; 1747 sequence_number_ = seq;
1741 } 1748 }
1742 1749
1743 uint16_t RTPSender::SequenceNumber() const { 1750 uint16_t RTPSender::SequenceNumber() const {
1744 CriticalSectionScoped cs(send_critsect_.get()); 1751 rtc::CritScope lock(&send_critsect_);
1745 return sequence_number_; 1752 return sequence_number_;
1746 } 1753 }
1747 1754
1748 // Audio. 1755 // Audio.
1749 int32_t RTPSender::SendTelephoneEvent(uint8_t key, 1756 int32_t RTPSender::SendTelephoneEvent(uint8_t key,
1750 uint16_t time_ms, 1757 uint16_t time_ms,
1751 uint8_t level) { 1758 uint8_t level) {
1752 if (!audio_configured_) { 1759 if (!audio_configured_) {
1753 return -1; 1760 return -1;
1754 } 1761 }
(...skipping 56 matching lines...)
1811 const FecProtectionParams *key_params) { 1818 const FecProtectionParams *key_params) {
1812 if (audio_configured_) { 1819 if (audio_configured_) {
1813 return -1; 1820 return -1;
1814 } 1821 }
1815 video_->SetFecParameters(delta_params, key_params); 1822 video_->SetFecParameters(delta_params, key_params);
1816 return 0; 1823 return 0;
1817 } 1824 }
1818 1825
1819 void RTPSender::BuildRtxPacket(uint8_t* buffer, size_t* length, 1826 void RTPSender::BuildRtxPacket(uint8_t* buffer, size_t* length,
1820 uint8_t* buffer_rtx) { 1827 uint8_t* buffer_rtx) {
1821 CriticalSectionScoped cs(send_critsect_.get()); 1828 rtc::CritScope lock(&send_critsect_);
1822 uint8_t* data_buffer_rtx = buffer_rtx; 1829 uint8_t* data_buffer_rtx = buffer_rtx;
1823 // Add RTX header. 1830 // Add RTX header.
1824 RtpUtility::RtpHeaderParser rtp_parser( 1831 RtpUtility::RtpHeaderParser rtp_parser(
1825 reinterpret_cast<const uint8_t*>(buffer), *length); 1832 reinterpret_cast<const uint8_t*>(buffer), *length);
1826 1833
1827 RTPHeader rtp_header; 1834 RTPHeader rtp_header;
1828 rtp_parser.Parse(&rtp_header); 1835 rtp_parser.Parse(&rtp_header);
1829 1836
1830 // Add original RTP header. 1837 // Add original RTP header.
1831 memcpy(data_buffer_rtx, buffer, rtp_header.headerLength); 1838 memcpy(data_buffer_rtx, buffer, rtp_header.headerLength);
(...skipping 34 matching lines...)
1866 CriticalSectionScoped cs(statistics_crit_.get()); 1873 CriticalSectionScoped cs(statistics_crit_.get());
1867 return rtp_stats_callback_; 1874 return rtp_stats_callback_;
1868 } 1875 }
1869 1876
1870 uint32_t RTPSender::BitrateSent() const { 1877 uint32_t RTPSender::BitrateSent() const {
1871 return total_bitrate_sent_.BitrateLast(); 1878 return total_bitrate_sent_.BitrateLast();
1872 } 1879 }
1873 1880
1874 void RTPSender::SetRtpState(const RtpState& rtp_state) { 1881 void RTPSender::SetRtpState(const RtpState& rtp_state) {
1875 SetStartTimestamp(rtp_state.start_timestamp, true); 1882 SetStartTimestamp(rtp_state.start_timestamp, true);
1876 CriticalSectionScoped lock(send_critsect_.get()); 1883 rtc::CritScope lock(&send_critsect_);
1877 sequence_number_ = rtp_state.sequence_number; 1884 sequence_number_ = rtp_state.sequence_number;
1878 sequence_number_forced_ = true; 1885 sequence_number_forced_ = true;
1879 timestamp_ = rtp_state.timestamp; 1886 timestamp_ = rtp_state.timestamp;
1880 capture_time_ms_ = rtp_state.capture_time_ms; 1887 capture_time_ms_ = rtp_state.capture_time_ms;
1881 last_timestamp_time_ms_ = rtp_state.last_timestamp_time_ms; 1888 last_timestamp_time_ms_ = rtp_state.last_timestamp_time_ms;
1882 media_has_been_sent_ = rtp_state.media_has_been_sent; 1889 media_has_been_sent_ = rtp_state.media_has_been_sent;
1883 } 1890 }
1884 1891
1885 RtpState RTPSender::GetRtpState() const { 1892 RtpState RTPSender::GetRtpState() const {
1886 CriticalSectionScoped lock(send_critsect_.get()); 1893 rtc::CritScope lock(&send_critsect_);
1887 1894
1888 RtpState state; 1895 RtpState state;
1889 state.sequence_number = sequence_number_; 1896 state.sequence_number = sequence_number_;
1890 state.start_timestamp = start_timestamp_; 1897 state.start_timestamp = start_timestamp_;
1891 state.timestamp = timestamp_; 1898 state.timestamp = timestamp_;
1892 state.capture_time_ms = capture_time_ms_; 1899 state.capture_time_ms = capture_time_ms_;
1893 state.last_timestamp_time_ms = last_timestamp_time_ms_; 1900 state.last_timestamp_time_ms = last_timestamp_time_ms_;
1894 state.media_has_been_sent = media_has_been_sent_; 1901 state.media_has_been_sent = media_has_been_sent_;
1895 1902
1896 return state; 1903 return state;
1897 } 1904 }
1898 1905
1899 void RTPSender::SetRtxRtpState(const RtpState& rtp_state) { 1906 void RTPSender::SetRtxRtpState(const RtpState& rtp_state) {
1900 CriticalSectionScoped lock(send_critsect_.get()); 1907 rtc::CritScope lock(&send_critsect_);
1901 sequence_number_rtx_ = rtp_state.sequence_number; 1908 sequence_number_rtx_ = rtp_state.sequence_number;
1902 } 1909 }
1903 1910
1904 RtpState RTPSender::GetRtxRtpState() const { 1911 RtpState RTPSender::GetRtxRtpState() const {
1905 CriticalSectionScoped lock(send_critsect_.get()); 1912 rtc::CritScope lock(&send_critsect_);
1906 1913
1907 RtpState state; 1914 RtpState state;
1908 state.sequence_number = sequence_number_rtx_; 1915 state.sequence_number = sequence_number_rtx_;
1909 state.start_timestamp = start_timestamp_; 1916 state.start_timestamp = start_timestamp_;
1910 1917
1911 return state; 1918 return state;
1912 } 1919 }
1913 1920
1914 } // namespace webrtc 1921 } // namespace webrtc
OLDNEW

Powered by Google App Engine