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

Side by Side Diff: webrtc/modules/pacing/paced_sender.cc

Issue 2235373004: Probing: Add support for exponential startup probing (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@fix_probing2
Patch Set: Addressed comments Created 4 years, 3 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 void PacedSender::SetEstimatedBitrate(int bitrate_bps) { 291 void PacedSender::SetEstimatedBitrate(int bitrate_bps) {
292 if (bitrate_bps == 0) 292 if (bitrate_bps == 0)
293 LOG(LS_ERROR) << "PacedSender is not designed to handle 0 bitrate."; 293 LOG(LS_ERROR) << "PacedSender is not designed to handle 0 bitrate.";
294 CriticalSectionScoped cs(critsect_.get()); 294 CriticalSectionScoped cs(critsect_.get());
295 estimated_bitrate_bps_ = bitrate_bps; 295 estimated_bitrate_bps_ = bitrate_bps;
296 padding_budget_->set_target_rate_kbps( 296 padding_budget_->set_target_rate_kbps(
297 std::min(estimated_bitrate_bps_ / 1000, max_padding_bitrate_kbps_)); 297 std::min(estimated_bitrate_bps_ / 1000, max_padding_bitrate_kbps_));
298 pacing_bitrate_kbps_ = 298 pacing_bitrate_kbps_ =
299 std::max(min_send_bitrate_kbps_, estimated_bitrate_bps_ / 1000) * 299 std::max(min_send_bitrate_kbps_, estimated_bitrate_bps_ / 1000) *
300 kDefaultPaceMultiplier; 300 kDefaultPaceMultiplier;
301 prober_->SetEstimatedBitrate(bitrate_bps);
301 } 302 }
302 303
303 void PacedSender::SetSendBitrateLimits(int min_send_bitrate_bps, 304 void PacedSender::SetSendBitrateLimits(int min_send_bitrate_bps,
304 int padding_bitrate) { 305 int padding_bitrate) {
305 CriticalSectionScoped cs(critsect_.get()); 306 CriticalSectionScoped cs(critsect_.get());
306 min_send_bitrate_kbps_ = min_send_bitrate_bps / 1000; 307 min_send_bitrate_kbps_ = min_send_bitrate_bps / 1000;
307 pacing_bitrate_kbps_ = 308 pacing_bitrate_kbps_ =
308 std::max(min_send_bitrate_kbps_, estimated_bitrate_bps_ / 1000) * 309 std::max(min_send_bitrate_kbps_, estimated_bitrate_bps_ / 1000) *
309 kDefaultPaceMultiplier; 310 kDefaultPaceMultiplier;
310 max_padding_bitrate_kbps_ = padding_bitrate / 1000; 311 max_padding_bitrate_kbps_ = padding_bitrate / 1000;
311 padding_budget_->set_target_rate_kbps( 312 padding_budget_->set_target_rate_kbps(
312 std::min(estimated_bitrate_bps_ / 1000, max_padding_bitrate_kbps_)); 313 std::min(estimated_bitrate_bps_ / 1000, max_padding_bitrate_kbps_));
313 } 314 }
314 315
315 void PacedSender::InsertPacket(RtpPacketSender::Priority priority, 316 void PacedSender::InsertPacket(RtpPacketSender::Priority priority,
316 uint32_t ssrc, 317 uint32_t ssrc,
317 uint16_t sequence_number, 318 uint16_t sequence_number,
318 int64_t capture_time_ms, 319 int64_t capture_time_ms,
319 size_t bytes, 320 size_t bytes,
320 bool retransmission) { 321 bool retransmission) {
321 CriticalSectionScoped cs(critsect_.get()); 322 CriticalSectionScoped cs(critsect_.get());
322 RTC_DCHECK(estimated_bitrate_bps_ > 0) 323 RTC_DCHECK(estimated_bitrate_bps_ > 0)
323 << "SetEstimatedBitrate must be called before InsertPacket."; 324 << "SetEstimatedBitrate must be called before InsertPacket.";
324 325
325 int64_t now_ms = clock_->TimeInMilliseconds(); 326 int64_t now_ms = clock_->TimeInMilliseconds();
326 prober_->OnIncomingPacket(bytes); 327 prober_->OnIncomingPacket(now_ms, bytes);
327 328
328 if (capture_time_ms < 0) 329 if (capture_time_ms < 0)
329 capture_time_ms = now_ms; 330 capture_time_ms = now_ms;
330 331
331 packets_->Push(paced_sender::Packet(priority, ssrc, sequence_number, 332 packets_->Push(paced_sender::Packet(priority, ssrc, sequence_number,
332 capture_time_ms, now_ms, bytes, 333 capture_time_ms, now_ms, bytes,
333 retransmission, packet_counter_++)); 334 retransmission, packet_counter_++));
334 } 335 }
335 336
336 int64_t PacedSender::ExpectedQueueTimeMs() const { 337 int64_t PacedSender::ExpectedQueueTimeMs() const {
(...skipping 29 matching lines...) Expand all
366 if (prober_->IsProbing()) { 367 if (prober_->IsProbing()) {
367 int64_t ret = prober_->TimeUntilNextProbe(clock_->TimeInMilliseconds()); 368 int64_t ret = prober_->TimeUntilNextProbe(clock_->TimeInMilliseconds());
368 if (ret >= 0) 369 if (ret >= 0)
369 return ret; 370 return ret;
370 } 371 }
371 int64_t elapsed_time_us = clock_->TimeInMicroseconds() - time_last_update_us_; 372 int64_t elapsed_time_us = clock_->TimeInMicroseconds() - time_last_update_us_;
372 int64_t elapsed_time_ms = (elapsed_time_us + 500) / 1000; 373 int64_t elapsed_time_ms = (elapsed_time_us + 500) / 1000;
373 return std::max<int64_t>(kMinPacketLimitMs - elapsed_time_ms, 0); 374 return std::max<int64_t>(kMinPacketLimitMs - elapsed_time_ms, 0);
374 } 375 }
375 376
377 bool PacedSender::IsExpectingProbingResults() const {
378 CriticalSectionScoped cs(critsect_.get());
379 return prober_->IsExpectingProbingResults();
380 }
381
376 void PacedSender::Process() { 382 void PacedSender::Process() {
377 int64_t now_us = clock_->TimeInMicroseconds(); 383 int64_t now_us = clock_->TimeInMicroseconds();
378 CriticalSectionScoped cs(critsect_.get()); 384 CriticalSectionScoped cs(critsect_.get());
379 int64_t elapsed_time_ms = (now_us - time_last_update_us_ + 500) / 1000; 385 int64_t elapsed_time_ms = (now_us - time_last_update_us_ + 500) / 1000;
380 time_last_update_us_ = now_us; 386 time_last_update_us_ = now_us;
381 int target_bitrate_kbps = pacing_bitrate_kbps_; 387 int target_bitrate_kbps = pacing_bitrate_kbps_;
382 // TODO(holmer): Remove the !paused_ check when issue 5307 has been fixed. 388 // TODO(holmer): Remove the !paused_ check when issue 5307 has been fixed.
383 if (!paused_ && elapsed_time_ms > 0) { 389 if (!paused_ && elapsed_time_ms > 0) {
384 size_t queue_size_bytes = packets_->SizeInBytes(); 390 size_t queue_size_bytes = packets_->SizeInBytes();
385 if (queue_size_bytes > 0) { 391 if (queue_size_bytes > 0) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 return false; 457 return false;
452 } 458 }
453 } 459 }
454 critsect_->Leave(); 460 critsect_->Leave();
455 const bool success = packet_sender_->TimeToSendPacket( 461 const bool success = packet_sender_->TimeToSendPacket(
456 packet.ssrc, packet.sequence_number, packet.capture_time_ms, 462 packet.ssrc, packet.sequence_number, packet.capture_time_ms,
457 packet.retransmission, probe_cluster_id); 463 packet.retransmission, probe_cluster_id);
458 critsect_->Enter(); 464 critsect_->Enter();
459 465
460 if (success) { 466 if (success) {
461 prober_->PacketSent(clock_->TimeInMilliseconds(), packet.bytes); 467 // Is this a probe ?
468 if (probe_cluster_id != PacketInfo::kNotAProbe)
469 prober_->PacketSent(clock_->TimeInMilliseconds(), packet.bytes);
462 // TODO(holmer): High priority packets should only be accounted for if we 470 // TODO(holmer): High priority packets should only be accounted for if we
463 // are allocating bandwidth for audio. 471 // are allocating bandwidth for audio.
464 if (packet.priority != kHighPriority) { 472 if (packet.priority != kHighPriority) {
465 // Update media bytes sent. 473 // Update media bytes sent.
466 media_budget_->UseBudget(packet.bytes); 474 media_budget_->UseBudget(packet.bytes);
467 padding_budget_->UseBudget(packet.bytes); 475 padding_budget_->UseBudget(packet.bytes);
468 } 476 }
469 } 477 }
470 478
471 return success; 479 return success;
472 } 480 }
473 481
474 void PacedSender::SendPadding(size_t padding_needed, int probe_cluster_id) { 482 void PacedSender::SendPadding(size_t padding_needed, int probe_cluster_id) {
475 critsect_->Leave(); 483 critsect_->Leave();
476 size_t bytes_sent = 484 size_t bytes_sent =
477 packet_sender_->TimeToSendPadding(padding_needed, probe_cluster_id); 485 packet_sender_->TimeToSendPadding(padding_needed, probe_cluster_id);
478 critsect_->Enter(); 486 critsect_->Enter();
479 487
480 if (bytes_sent > 0) { 488 if (bytes_sent > 0) {
481 prober_->PacketSent(clock_->TimeInMilliseconds(), bytes_sent); 489 // Is this a probe ?
490 if (probe_cluster_id != PacketInfo::kNotAProbe)
491 prober_->PacketSent(clock_->TimeInMilliseconds(), bytes_sent);
482 media_budget_->UseBudget(bytes_sent); 492 media_budget_->UseBudget(bytes_sent);
483 padding_budget_->UseBudget(bytes_sent); 493 padding_budget_->UseBudget(bytes_sent);
484 } 494 }
485 } 495 }
486 496
487 void PacedSender::UpdateBytesPerInterval(int64_t delta_time_ms) { 497 void PacedSender::UpdateBytesPerInterval(int64_t delta_time_ms) {
488 media_budget_->IncreaseBudget(delta_time_ms); 498 media_budget_->IncreaseBudget(delta_time_ms);
489 padding_budget_->IncreaseBudget(delta_time_ms); 499 padding_budget_->IncreaseBudget(delta_time_ms);
490 } 500 }
491 } // namespace webrtc 501 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698