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

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

Issue 2005313003: Propagate probing cluster id to SendTimeHistory. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Feedback fixes. 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
(...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 bool is_probing = prober_->IsProbing();
394 int probe_cluster_id =
395 is_probing ? prober_->CurrentClusterId() : PacketInfo::kNotAProbe;
stefan-webrtc 2016/05/26 16:29:50 Any reason for doing this here instead of on line
392 while (!packets_->Empty()) { 396 while (!packets_->Empty()) {
393 if (media_budget_->bytes_remaining() == 0 && !prober_->IsProbing()) 397 if (media_budget_->bytes_remaining() == 0 && !is_probing)
394 return; 398 return;
395 399
396 // Since we need to release the lock in order to send, we first pop the 400 // Since we need to release the lock in order to send, we first pop the
397 // element from the priority queue but keep it in storage, so that we can 401 // element from the priority queue but keep it in storage, so that we can
398 // reinsert it if send fails. 402 // reinsert it if send fails.
399 const paced_sender::Packet& packet = packets_->BeginPop(); 403 const paced_sender::Packet& packet = packets_->BeginPop();
400 int probe_cluster_id =
401 prober_->IsProbing() ? prober_->CurrentClusterId() : -1;
402 404
403 if (SendPacket(packet, probe_cluster_id)) { 405 if (SendPacket(packet, probe_cluster_id)) {
404 // Send succeeded, remove it from the queue. 406 // Send succeeded, remove it from the queue.
405 packets_->FinalizePop(packet); 407 packets_->FinalizePop(packet);
406 if (prober_->IsProbing()) 408 if (is_probing)
407 return; 409 return;
408 } else { 410 } else {
409 // Send failed, put it back into the queue. 411 // Send failed, put it back into the queue.
410 packets_->CancelPop(packet); 412 packets_->CancelPop(packet);
411 return; 413 return;
412 } 414 }
413 } 415 }
414 416
415 // TODO(holmer): Remove the paused_ check when issue 5307 has been fixed. 417 // TODO(holmer): Remove the paused_ check when issue 5307 has been fixed.
416 if (paused_ || !packets_->Empty()) 418 if (paused_ || !packets_->Empty())
417 return; 419 return;
418 420
419 size_t padding_needed; 421 size_t padding_needed;
420 if (prober_->IsProbing()) { 422 if (is_probing) {
421 padding_needed = prober_->RecommendedPacketSize(); 423 padding_needed = prober_->RecommendedPacketSize();
422 } else { 424 } else {
423 padding_needed = padding_budget_->bytes_remaining(); 425 padding_needed = padding_budget_->bytes_remaining();
424 } 426 }
425 427
426 if (padding_needed > 0) 428 if (padding_needed > 0)
427 SendPadding(static_cast<size_t>(padding_needed)); 429 SendPadding(static_cast<size_t>(padding_needed), probe_cluster_id);
428 } 430 }
429 431
430 bool PacedSender::SendPacket(const paced_sender::Packet& packet, 432 bool PacedSender::SendPacket(const paced_sender::Packet& packet,
431 int probe_cluster_id) { 433 int probe_cluster_id) {
432 // TODO(holmer): Because of this bug issue 5307 we have to send audio 434 // TODO(holmer): Because of this bug issue 5307 we have to send audio
433 // packets even when the pacer is paused. Here we assume audio packets are 435 // packets even when the pacer is paused. Here we assume audio packets are
434 // always high priority and that they are the only high priority packets. 436 // always high priority and that they are the only high priority packets.
435 if (paused_ && packet.priority != kHighPriority) 437 if (paused_ && packet.priority != kHighPriority)
436 return false; 438 return false;
437 critsect_->Leave(); 439 critsect_->Leave();
438 const bool success = packet_sender_->TimeToSendPacket( 440 const bool success = packet_sender_->TimeToSendPacket(
439 packet.ssrc, packet.sequence_number, packet.capture_time_ms, 441 packet.ssrc, packet.sequence_number, packet.capture_time_ms,
440 packet.retransmission, probe_cluster_id); 442 packet.retransmission, probe_cluster_id);
441 critsect_->Enter(); 443 critsect_->Enter();
442 444
443 if (success) { 445 if (success) {
444 prober_->PacketSent(clock_->TimeInMilliseconds(), packet.bytes); 446 prober_->PacketSent(clock_->TimeInMilliseconds(), packet.bytes);
445 // TODO(holmer): High priority packets should only be accounted for if we 447 // TODO(holmer): High priority packets should only be accounted for if we
446 // are allocating bandwidth for audio. 448 // are allocating bandwidth for audio.
447 if (packet.priority != kHighPriority) { 449 if (packet.priority != kHighPriority) {
448 // Update media bytes sent. 450 // Update media bytes sent.
449 media_budget_->UseBudget(packet.bytes); 451 media_budget_->UseBudget(packet.bytes);
450 padding_budget_->UseBudget(packet.bytes); 452 padding_budget_->UseBudget(packet.bytes);
451 } 453 }
452 } 454 }
453 455
454 return success; 456 return success;
455 } 457 }
456 458
457 void PacedSender::SendPadding(size_t padding_needed) { 459 void PacedSender::SendPadding(size_t padding_needed, int probe_cluster_id) {
458 critsect_->Leave(); 460 critsect_->Leave();
459 size_t bytes_sent = packet_sender_->TimeToSendPadding(padding_needed); 461 size_t bytes_sent =
462 packet_sender_->TimeToSendPadding(padding_needed, probe_cluster_id);
460 critsect_->Enter(); 463 critsect_->Enter();
461 464
462 if (bytes_sent > 0) { 465 if (bytes_sent > 0) {
463 prober_->PacketSent(clock_->TimeInMilliseconds(), bytes_sent); 466 prober_->PacketSent(clock_->TimeInMilliseconds(), bytes_sent);
464 media_budget_->UseBudget(bytes_sent); 467 media_budget_->UseBudget(bytes_sent);
465 padding_budget_->UseBudget(bytes_sent); 468 padding_budget_->UseBudget(bytes_sent);
466 } 469 }
467 } 470 }
468 471
469 void PacedSender::UpdateBytesPerInterval(int64_t delta_time_ms) { 472 void PacedSender::UpdateBytesPerInterval(int64_t delta_time_ms) {
470 media_budget_->IncreaseBudget(delta_time_ms); 473 media_budget_->IncreaseBudget(delta_time_ms);
471 padding_budget_->IncreaseBudget(delta_time_ms); 474 padding_budget_->IncreaseBudget(delta_time_ms);
472 } 475 }
473 } // namespace webrtc 476 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698