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

Side by Side Diff: webrtc/modules/video_coding/jitter_buffer.cc

Issue 2007743003: Add sender controlled playout delay limits (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@cleanup_rtp_hdr_extensions
Patch Set: Rename OnReceivedRtcpReport to OnReceivedRtcpReportBlocks 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 #include "webrtc/modules/video_coding/jitter_buffer.h" 10 #include "webrtc/modules/video_coding/jitter_buffer.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 void FrameList::Reset(UnorderedFrameList* free_frames) { 118 void FrameList::Reset(UnorderedFrameList* free_frames) {
119 while (!empty()) { 119 while (!empty()) {
120 begin()->second->Reset(); 120 begin()->second->Reset();
121 free_frames->push_back(begin()->second); 121 free_frames->push_back(begin()->second);
122 erase(begin()); 122 erase(begin());
123 } 123 }
124 } 124 }
125 125
126 bool Vp9SsMap::Insert(const VCMPacket& packet) { 126 bool Vp9SsMap::Insert(const VCMPacket& packet) {
127 if (!packet.codecSpecificHeader.codecHeader.VP9.ss_data_available) 127 if (!packet.video_header.codecHeader.VP9.ss_data_available)
128 return false; 128 return false;
129 129
130 ss_map_[packet.timestamp] = packet.codecSpecificHeader.codecHeader.VP9.gof; 130 ss_map_[packet.timestamp] = packet.video_header.codecHeader.VP9.gof;
131 return true; 131 return true;
132 } 132 }
133 133
134 void Vp9SsMap::Reset() { 134 void Vp9SsMap::Reset() {
135 ss_map_.clear(); 135 ss_map_.clear();
136 } 136 }
137 137
138 bool Vp9SsMap::Find(uint32_t timestamp, SsMap::iterator* it_out) { 138 bool Vp9SsMap::Find(uint32_t timestamp, SsMap::iterator* it_out) {
139 bool found = false; 139 bool found = false;
140 for (SsMap::iterator it = ss_map_.begin(); it != ss_map_.end(); ++it) { 140 for (SsMap::iterator it = ss_map_.begin(); it != ss_map_.end(); ++it) {
(...skipping 27 matching lines...) Expand all
168 168
169 void Vp9SsMap::AdvanceFront(uint32_t timestamp) { 169 void Vp9SsMap::AdvanceFront(uint32_t timestamp) {
170 RTC_DCHECK(!ss_map_.empty()); 170 RTC_DCHECK(!ss_map_.empty());
171 GofInfoVP9 gof = ss_map_.begin()->second; 171 GofInfoVP9 gof = ss_map_.begin()->second;
172 ss_map_.erase(ss_map_.begin()); 172 ss_map_.erase(ss_map_.begin());
173 ss_map_[timestamp] = gof; 173 ss_map_[timestamp] = gof;
174 } 174 }
175 175
176 // TODO(asapersson): Update according to updates in RTP payload profile. 176 // TODO(asapersson): Update according to updates in RTP payload profile.
177 bool Vp9SsMap::UpdatePacket(VCMPacket* packet) { 177 bool Vp9SsMap::UpdatePacket(VCMPacket* packet) {
178 uint8_t gof_idx = packet->codecSpecificHeader.codecHeader.VP9.gof_idx; 178 uint8_t gof_idx = packet->video_header.codecHeader.VP9.gof_idx;
179 if (gof_idx == kNoGofIdx) 179 if (gof_idx == kNoGofIdx)
180 return false; // No update needed. 180 return false; // No update needed.
181 181
182 SsMap::iterator it; 182 SsMap::iterator it;
183 if (!Find(packet->timestamp, &it)) 183 if (!Find(packet->timestamp, &it))
184 return false; // Corresponding SS not yet received. 184 return false; // Corresponding SS not yet received.
185 185
186 if (gof_idx >= it->second.num_frames_in_gof) 186 if (gof_idx >= it->second.num_frames_in_gof)
187 return false; // Assume corresponding SS not yet received. 187 return false; // Assume corresponding SS not yet received.
188 188
189 RTPVideoHeaderVP9* vp9 = &packet->codecSpecificHeader.codecHeader.VP9; 189 RTPVideoHeaderVP9* vp9 = &packet->video_header.codecHeader.VP9;
190 vp9->temporal_idx = it->second.temporal_idx[gof_idx]; 190 vp9->temporal_idx = it->second.temporal_idx[gof_idx];
191 vp9->temporal_up_switch = it->second.temporal_up_switch[gof_idx]; 191 vp9->temporal_up_switch = it->second.temporal_up_switch[gof_idx];
192 192
193 // TODO(asapersson): Set vp9.ref_picture_id[i] and add usage. 193 // TODO(asapersson): Set vp9.ref_picture_id[i] and add usage.
194 vp9->num_ref_pics = it->second.num_ref_pics[gof_idx]; 194 vp9->num_ref_pics = it->second.num_ref_pics[gof_idx];
195 for (uint8_t i = 0; i < it->second.num_ref_pics[gof_idx]; ++i) { 195 for (uint8_t i = 0; i < it->second.num_ref_pics[gof_idx]; ++i) {
196 vp9->pid_diff[i] = it->second.pid_diff[gof_idx][i]; 196 vp9->pid_diff[i] = it->second.pid_diff[gof_idx][i];
197 } 197 }
198 return true; 198 return true;
199 } 199 }
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 } 490 }
491 } else if (incomplete_frames_.size() <= 1) { 491 } else if (incomplete_frames_.size() <= 1) {
492 // Frame not ready to be decoded. 492 // Frame not ready to be decoded.
493 return true; 493 return true;
494 } 494 }
495 return false; 495 return false;
496 } 496 }
497 497
498 // Returns immediately or a |max_wait_time_ms| ms event hang waiting for a 498 // Returns immediately or a |max_wait_time_ms| ms event hang waiting for a
499 // complete frame, |max_wait_time_ms| decided by caller. 499 // complete frame, |max_wait_time_ms| decided by caller.
500 bool VCMJitterBuffer::NextCompleteTimestamp(uint32_t max_wait_time_ms, 500 VCMEncodedFrame* VCMJitterBuffer::NextCompleteFrame(uint32_t max_wait_time_ms) {
501 uint32_t* timestamp) {
502 crit_sect_->Enter(); 501 crit_sect_->Enter();
503 if (!running_) { 502 if (!running_) {
504 crit_sect_->Leave(); 503 crit_sect_->Leave();
505 return false; 504 return nullptr;
506 } 505 }
507 CleanUpOldOrEmptyFrames(); 506 CleanUpOldOrEmptyFrames();
508 507
509 if (decodable_frames_.empty() || 508 if (decodable_frames_.empty() ||
510 decodable_frames_.Front()->GetState() != kStateComplete) { 509 decodable_frames_.Front()->GetState() != kStateComplete) {
511 const int64_t end_wait_time_ms = 510 const int64_t end_wait_time_ms =
512 clock_->TimeInMilliseconds() + max_wait_time_ms; 511 clock_->TimeInMilliseconds() + max_wait_time_ms;
513 int64_t wait_time_ms = max_wait_time_ms; 512 int64_t wait_time_ms = max_wait_time_ms;
514 while (wait_time_ms > 0) { 513 while (wait_time_ms > 0) {
515 crit_sect_->Leave(); 514 crit_sect_->Leave();
516 const EventTypeWrapper ret = 515 const EventTypeWrapper ret =
517 frame_event_->Wait(static_cast<uint32_t>(wait_time_ms)); 516 frame_event_->Wait(static_cast<uint32_t>(wait_time_ms));
518 crit_sect_->Enter(); 517 crit_sect_->Enter();
519 if (ret == kEventSignaled) { 518 if (ret == kEventSignaled) {
520 // Are we shutting down the jitter buffer? 519 // Are we shutting down the jitter buffer?
521 if (!running_) { 520 if (!running_) {
522 crit_sect_->Leave(); 521 crit_sect_->Leave();
523 return false; 522 return nullptr;
524 } 523 }
525 // Finding oldest frame ready for decoder. 524 // Finding oldest frame ready for decoder.
526 CleanUpOldOrEmptyFrames(); 525 CleanUpOldOrEmptyFrames();
527 if (decodable_frames_.empty() || 526 if (decodable_frames_.empty() ||
528 decodable_frames_.Front()->GetState() != kStateComplete) { 527 decodable_frames_.Front()->GetState() != kStateComplete) {
529 wait_time_ms = end_wait_time_ms - clock_->TimeInMilliseconds(); 528 wait_time_ms = end_wait_time_ms - clock_->TimeInMilliseconds();
530 } else { 529 } else {
531 break; 530 break;
532 } 531 }
533 } else { 532 } else {
534 break; 533 break;
535 } 534 }
536 } 535 }
537 } 536 }
538 if (decodable_frames_.empty() || 537 if (decodable_frames_.empty() ||
539 decodable_frames_.Front()->GetState() != kStateComplete) { 538 decodable_frames_.Front()->GetState() != kStateComplete) {
540 crit_sect_->Leave(); 539 crit_sect_->Leave();
541 return false; 540 return nullptr;
542 } 541 }
543 *timestamp = decodable_frames_.Front()->TimeStamp(); 542 VCMEncodedFrame* encoded_frame = decodable_frames_.Front();
544 crit_sect_->Leave(); 543 crit_sect_->Leave();
545 return true; 544 return encoded_frame;
546 } 545 }
547 546
548 bool VCMJitterBuffer::NextMaybeIncompleteTimestamp(uint32_t* timestamp) { 547 bool VCMJitterBuffer::NextMaybeIncompleteTimestamp(uint32_t* timestamp) {
549 CriticalSectionScoped cs(crit_sect_); 548 CriticalSectionScoped cs(crit_sect_);
550 if (!running_) { 549 if (!running_) {
551 return false; 550 return false;
552 } 551 }
553 if (decode_error_mode_ == kNoErrors) { 552 if (decode_error_mode_ == kNoErrors) {
554 // No point to continue, as we are not decoding with errors. 553 // No point to continue, as we are not decoding with errors.
555 return false; 554 return false;
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 if (nack_module_) 1380 if (nack_module_)
1382 return nack_module_->TimeUntilNextProcess(); 1381 return nack_module_->TimeUntilNextProcess();
1383 return std::numeric_limits<int64_t>::max(); 1382 return std::numeric_limits<int64_t>::max();
1384 } 1383 }
1385 1384
1386 void VCMJitterBuffer::Process() { 1385 void VCMJitterBuffer::Process() {
1387 if (nack_module_) 1386 if (nack_module_)
1388 nack_module_->Process(); 1387 nack_module_->Process();
1389 } 1388 }
1390 } // namespace webrtc 1389 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698