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

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

Issue 1962303002: Added cluster id to PacedSender::Callback::TimeToSendPacket. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Cluster id no longer a member of paced_sender::Packet. Created 4 years, 7 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // Packets have a handle to its own iterator in the list, for easy removal 107 // Packets have a handle to its own iterator in the list, for easy removal
108 // when popping from queue. 108 // when popping from queue.
109 packet_list_.push_front(packet); 109 packet_list_.push_front(packet);
110 std::list<Packet>::iterator it = packet_list_.begin(); 110 std::list<Packet>::iterator it = packet_list_.begin();
111 it->this_it = it; // Handle for direct removal from list. 111 it->this_it = it; // Handle for direct removal from list.
112 prio_queue_.push(&(*it)); // Pointer into list. 112 prio_queue_.push(&(*it)); // Pointer into list.
113 bytes_ += packet.bytes; 113 bytes_ += packet.bytes;
114 } 114 }
115 115
116 const Packet& BeginPop() { 116 const Packet& BeginPop() {
117 const Packet& packet = *prio_queue_.top(); 117 Packet& packet = *prio_queue_.top();
danilchap 2016/05/11 09:58:52 Restore const&
philipel 2016/05/11 14:19:04 Done.
118 prio_queue_.pop(); 118 prio_queue_.pop();
119 return packet; 119 return packet;
120 } 120 }
121 121
122 void CancelPop(const Packet& packet) { prio_queue_.push(&(*packet.this_it)); } 122 void CancelPop(const Packet& packet) { prio_queue_.push(&(*packet.this_it)); }
123 123
124 void FinalizePop(const Packet& packet) { 124 void FinalizePop(const Packet& packet) {
125 RemoveFromDupeSet(packet); 125 RemoveFromDupeSet(packet);
126 bytes_ -= packet.bytes; 126 bytes_ -= packet.bytes;
127 queue_time_sum_ -= (time_last_updated_ - packet.enqueue_time_ms); 127 queue_time_sum_ -= (time_last_updated_ - packet.enqueue_time_ms);
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 UpdateBytesPerInterval(delta_time_ms); 383 UpdateBytesPerInterval(delta_time_ms);
384 } 384 }
385 while (!packets_->Empty()) { 385 while (!packets_->Empty()) {
386 if (media_budget_->bytes_remaining() == 0 && !prober_->IsProbing()) 386 if (media_budget_->bytes_remaining() == 0 && !prober_->IsProbing())
387 return; 387 return;
388 388
389 // Since we need to release the lock in order to send, we first pop the 389 // Since we need to release the lock in order to send, we first pop the
390 // element from the priority queue but keep it in storage, so that we can 390 // element from the priority queue but keep it in storage, so that we can
391 // reinsert it if send fails. 391 // reinsert it if send fails.
392 const paced_sender::Packet& packet = packets_->BeginPop(); 392 const paced_sender::Packet& packet = packets_->BeginPop();
393 int cluster_id = prober_->IsProbing() ? prober_->CurrentClusterId() : -1;
danilchap 2016/05/11 09:58:52 may be rename variable to prober_cluster_id everyw
philipel 2016/05/11 14:19:04 Done.
393 394
394 if (SendPacket(packet)) { 395 if (SendPacket(packet, cluster_id)) {
395 // Send succeeded, remove it from the queue. 396 // Send succeeded, remove it from the queue.
396 packets_->FinalizePop(packet); 397 packets_->FinalizePop(packet);
397 if (prober_->IsProbing()) 398 if (prober_->IsProbing())
398 return; 399 return;
399 } else { 400 } else {
400 // Send failed, put it back into the queue. 401 // Send failed, put it back into the queue.
401 packets_->CancelPop(packet); 402 packets_->CancelPop(packet);
402 return; 403 return;
403 } 404 }
404 } 405 }
405 406
406 // TODO(holmer): Remove the paused_ check when issue 5307 has been fixed. 407 // TODO(holmer): Remove the paused_ check when issue 5307 has been fixed.
407 if (paused_ || !packets_->Empty()) 408 if (paused_ || !packets_->Empty())
408 return; 409 return;
409 410
410 size_t padding_needed; 411 size_t padding_needed;
411 if (prober_->IsProbing()) { 412 if (prober_->IsProbing()) {
412 padding_needed = prober_->RecommendedPacketSize(); 413 padding_needed = prober_->RecommendedPacketSize();
413 } else { 414 } else {
414 padding_needed = padding_budget_->bytes_remaining(); 415 padding_needed = padding_budget_->bytes_remaining();
415 } 416 }
416 417
417 if (padding_needed > 0) 418 if (padding_needed > 0)
418 SendPadding(static_cast<size_t>(padding_needed)); 419 SendPadding(static_cast<size_t>(padding_needed));
419 } 420 }
420 421
421 bool PacedSender::SendPacket(const paced_sender::Packet& packet) { 422 bool PacedSender::SendPacket(const paced_sender::Packet& packet,
423 int cluster_id) {
422 // TODO(holmer): Because of this bug issue 5307 we have to send audio 424 // TODO(holmer): Because of this bug issue 5307 we have to send audio
423 // packets even when the pacer is paused. Here we assume audio packets are 425 // packets even when the pacer is paused. Here we assume audio packets are
424 // always high priority and that they are the only high priority packets. 426 // always high priority and that they are the only high priority packets.
425 if (paused_ && packet.priority != kHighPriority) 427 if (paused_ && packet.priority != kHighPriority)
426 return false; 428 return false;
427 critsect_->Leave(); 429 critsect_->Leave();
428 const bool success = callback_->TimeToSendPacket(packet.ssrc, 430 const bool success = callback_->TimeToSendPacket(
429 packet.sequence_number, 431 packet.ssrc, packet.sequence_number, packet.capture_time_ms,
430 packet.capture_time_ms, 432 packet.retransmission, cluster_id);
431 packet.retransmission);
432 critsect_->Enter(); 433 critsect_->Enter();
433 434
434 if (success) { 435 if (success) {
435 prober_->PacketSent(clock_->TimeInMilliseconds(), packet.bytes); 436 prober_->PacketSent(clock_->TimeInMilliseconds(), packet.bytes);
436 // TODO(holmer): High priority packets should only be accounted for if we 437 // TODO(holmer): High priority packets should only be accounted for if we
437 // are allocating bandwidth for audio. 438 // are allocating bandwidth for audio.
438 if (packet.priority != kHighPriority) { 439 if (packet.priority != kHighPriority) {
439 // Update media bytes sent. 440 // Update media bytes sent.
440 media_budget_->UseBudget(packet.bytes); 441 media_budget_->UseBudget(packet.bytes);
441 padding_budget_->UseBudget(packet.bytes); 442 padding_budget_->UseBudget(packet.bytes);
(...skipping 13 matching lines...) Expand all
455 media_budget_->UseBudget(bytes_sent); 456 media_budget_->UseBudget(bytes_sent);
456 padding_budget_->UseBudget(bytes_sent); 457 padding_budget_->UseBudget(bytes_sent);
457 } 458 }
458 } 459 }
459 460
460 void PacedSender::UpdateBytesPerInterval(int64_t delta_time_ms) { 461 void PacedSender::UpdateBytesPerInterval(int64_t delta_time_ms) {
461 media_budget_->IncreaseBudget(delta_time_ms); 462 media_budget_->IncreaseBudget(delta_time_ms);
462 padding_budget_->IncreaseBudget(delta_time_ms); 463 padding_budget_->IncreaseBudget(delta_time_ms);
463 } 464 }
464 } // namespace webrtc 465 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698