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

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

Issue 2032463003: Revert of Propagate probing cluster id to SendTimeHistory. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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
« no previous file with comments | « webrtc/modules/pacing/paced_sender.h ('k') | webrtc/modules/pacing/paced_sender_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 static_cast<int>(queue_size_bytes * 8 / avg_time_left_ms); 382 static_cast<int>(queue_size_bytes * 8 / avg_time_left_ms);
383 if (min_bitrate_needed_kbps > target_bitrate_kbps) 383 if (min_bitrate_needed_kbps > target_bitrate_kbps)
384 target_bitrate_kbps = min_bitrate_needed_kbps; 384 target_bitrate_kbps = min_bitrate_needed_kbps;
385 } 385 }
386 386
387 media_budget_->set_target_rate_kbps(target_bitrate_kbps); 387 media_budget_->set_target_rate_kbps(target_bitrate_kbps);
388 388
389 int64_t delta_time_ms = std::min(kMaxIntervalTimeMs, elapsed_time_ms); 389 int64_t delta_time_ms = std::min(kMaxIntervalTimeMs, elapsed_time_ms);
390 UpdateBytesPerInterval(delta_time_ms); 390 UpdateBytesPerInterval(delta_time_ms);
391 } 391 }
392
393 int probe_cluster_id = prober_->IsProbing() ? prober_->CurrentClusterId()
394 : PacketInfo::kNotAProbe;
395 while (!packets_->Empty()) { 392 while (!packets_->Empty()) {
396 if (media_budget_->bytes_remaining() == 0 && !prober_->IsProbing()) 393 if (media_budget_->bytes_remaining() == 0 && !prober_->IsProbing())
397 return; 394 return;
398 395
399 // Since we need to release the lock in order to send, we first pop the 396 // Since we need to release the lock in order to send, we first pop the
400 // element from the priority queue but keep it in storage, so that we can 397 // element from the priority queue but keep it in storage, so that we can
401 // reinsert it if send fails. 398 // reinsert it if send fails.
402 const paced_sender::Packet& packet = packets_->BeginPop(); 399 const paced_sender::Packet& packet = packets_->BeginPop();
400 int probe_cluster_id =
401 prober_->IsProbing() ? prober_->CurrentClusterId() : -1;
403 402
404 if (SendPacket(packet, probe_cluster_id)) { 403 if (SendPacket(packet, probe_cluster_id)) {
405 // Send succeeded, remove it from the queue. 404 // Send succeeded, remove it from the queue.
406 packets_->FinalizePop(packet); 405 packets_->FinalizePop(packet);
407 if (prober_->IsProbing()) 406 if (prober_->IsProbing())
408 return; 407 return;
409 } else { 408 } else {
410 // Send failed, put it back into the queue. 409 // Send failed, put it back into the queue.
411 packets_->CancelPop(packet); 410 packets_->CancelPop(packet);
412 return; 411 return;
413 } 412 }
414 } 413 }
415 414
416 // TODO(holmer): Remove the paused_ check when issue 5307 has been fixed. 415 // TODO(holmer): Remove the paused_ check when issue 5307 has been fixed.
417 if (paused_ || !packets_->Empty()) 416 if (paused_ || !packets_->Empty())
418 return; 417 return;
419 418
420 size_t padding_needed; 419 size_t padding_needed;
421 if (prober_->IsProbing()) { 420 if (prober_->IsProbing()) {
422 padding_needed = prober_->RecommendedPacketSize(); 421 padding_needed = prober_->RecommendedPacketSize();
423 } else { 422 } else {
424 padding_needed = padding_budget_->bytes_remaining(); 423 padding_needed = padding_budget_->bytes_remaining();
425 } 424 }
426 425
427 if (padding_needed > 0) 426 if (padding_needed > 0)
428 SendPadding(padding_needed, probe_cluster_id); 427 SendPadding(static_cast<size_t>(padding_needed));
429 } 428 }
430 429
431 bool PacedSender::SendPacket(const paced_sender::Packet& packet, 430 bool PacedSender::SendPacket(const paced_sender::Packet& packet,
432 int probe_cluster_id) { 431 int probe_cluster_id) {
433 // TODO(holmer): Because of this bug issue 5307 we have to send audio 432 // TODO(holmer): Because of this bug issue 5307 we have to send audio
434 // packets even when the pacer is paused. Here we assume audio packets are 433 // packets even when the pacer is paused. Here we assume audio packets are
435 // always high priority and that they are the only high priority packets. 434 // always high priority and that they are the only high priority packets.
436 if (paused_ && packet.priority != kHighPriority) 435 if (paused_ && packet.priority != kHighPriority)
437 return false; 436 return false;
438 critsect_->Leave(); 437 critsect_->Leave();
439 const bool success = packet_sender_->TimeToSendPacket( 438 const bool success = packet_sender_->TimeToSendPacket(
440 packet.ssrc, packet.sequence_number, packet.capture_time_ms, 439 packet.ssrc, packet.sequence_number, packet.capture_time_ms,
441 packet.retransmission, probe_cluster_id); 440 packet.retransmission, probe_cluster_id);
442 critsect_->Enter(); 441 critsect_->Enter();
443 442
444 if (success) { 443 if (success) {
445 prober_->PacketSent(clock_->TimeInMilliseconds(), packet.bytes); 444 prober_->PacketSent(clock_->TimeInMilliseconds(), packet.bytes);
446 // TODO(holmer): High priority packets should only be accounted for if we 445 // TODO(holmer): High priority packets should only be accounted for if we
447 // are allocating bandwidth for audio. 446 // are allocating bandwidth for audio.
448 if (packet.priority != kHighPriority) { 447 if (packet.priority != kHighPriority) {
449 // Update media bytes sent. 448 // Update media bytes sent.
450 media_budget_->UseBudget(packet.bytes); 449 media_budget_->UseBudget(packet.bytes);
451 padding_budget_->UseBudget(packet.bytes); 450 padding_budget_->UseBudget(packet.bytes);
452 } 451 }
453 } 452 }
454 453
455 return success; 454 return success;
456 } 455 }
457 456
458 void PacedSender::SendPadding(size_t padding_needed, int probe_cluster_id) { 457 void PacedSender::SendPadding(size_t padding_needed) {
459 critsect_->Leave(); 458 critsect_->Leave();
460 size_t bytes_sent = 459 size_t bytes_sent = packet_sender_->TimeToSendPadding(padding_needed);
461 packet_sender_->TimeToSendPadding(padding_needed, probe_cluster_id);
462 critsect_->Enter(); 460 critsect_->Enter();
463 461
464 if (bytes_sent > 0) { 462 if (bytes_sent > 0) {
465 prober_->PacketSent(clock_->TimeInMilliseconds(), bytes_sent); 463 prober_->PacketSent(clock_->TimeInMilliseconds(), bytes_sent);
466 media_budget_->UseBudget(bytes_sent); 464 media_budget_->UseBudget(bytes_sent);
467 padding_budget_->UseBudget(bytes_sent); 465 padding_budget_->UseBudget(bytes_sent);
468 } 466 }
469 } 467 }
470 468
471 void PacedSender::UpdateBytesPerInterval(int64_t delta_time_ms) { 469 void PacedSender::UpdateBytesPerInterval(int64_t delta_time_ms) {
472 media_budget_->IncreaseBudget(delta_time_ms); 470 media_budget_->IncreaseBudget(delta_time_ms);
473 padding_budget_->IncreaseBudget(delta_time_ms); 471 padding_budget_->IncreaseBudget(delta_time_ms);
474 } 472 }
475 } // namespace webrtc 473 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/pacing/paced_sender.h ('k') | webrtc/modules/pacing/paced_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698