OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 VCMTiming* timing) | 45 VCMTiming* timing) |
46 : clock_(clock), | 46 : clock_(clock), |
47 frame_inserted_event_(false, false), | 47 frame_inserted_event_(false, false), |
48 jitter_estimator_(jitter_estimator), | 48 jitter_estimator_(jitter_estimator), |
49 timing_(timing), | 49 timing_(timing), |
50 inter_frame_delay_(clock_->TimeInMilliseconds()), | 50 inter_frame_delay_(clock_->TimeInMilliseconds()), |
51 newest_picture_id_(-1), | 51 newest_picture_id_(-1), |
52 stopped_(false), | 52 stopped_(false), |
53 protection_mode_(kProtectionNack) {} | 53 protection_mode_(kProtectionNack) {} |
54 | 54 |
55 std::unique_ptr<FrameObject> FrameBuffer::NextFrame(int64_t max_wait_time_ms) { | 55 std::pair<FrameBuffer::ReturnReason, std::unique_ptr<FrameObject>> |
| 56 FrameBuffer::NextFrame(int64_t max_wait_time_ms) { |
56 int64_t latest_return_time = clock_->TimeInMilliseconds() + max_wait_time_ms; | 57 int64_t latest_return_time = clock_->TimeInMilliseconds() + max_wait_time_ms; |
57 int64_t now = clock_->TimeInMilliseconds(); | 58 int64_t now = clock_->TimeInMilliseconds(); |
58 int64_t wait_ms = max_wait_time_ms; | 59 int64_t wait_ms = max_wait_time_ms; |
59 while (true) { | 60 while (true) { |
60 std::map<FrameKey, std::unique_ptr<FrameObject>, FrameComp>::iterator | 61 std::map<FrameKey, std::unique_ptr<FrameObject>, FrameComp>::iterator |
61 next_frame_it; | 62 next_frame_it; |
62 { | 63 { |
63 rtc::CritScope lock(&crit_); | 64 rtc::CritScope lock(&crit_); |
64 frame_inserted_event_.Reset(); | 65 frame_inserted_event_.Reset(); |
65 if (stopped_) | 66 if (stopped_) |
66 return std::unique_ptr<FrameObject>(); | 67 return std::make_pair(kStopped, nullptr); |
67 | 68 |
68 now = clock_->TimeInMilliseconds(); | 69 now = clock_->TimeInMilliseconds(); |
69 wait_ms = max_wait_time_ms; | 70 wait_ms = max_wait_time_ms; |
70 next_frame_it = frames_.end(); | 71 next_frame_it = frames_.end(); |
71 for (auto frame_it = frames_.begin(); frame_it != frames_.end(); | 72 for (auto frame_it = frames_.begin(); frame_it != frames_.end(); |
72 ++frame_it) { | 73 ++frame_it) { |
73 const FrameObject& frame = *frame_it->second; | 74 const FrameObject& frame = *frame_it->second; |
74 if (IsContinuous(frame)) { | 75 if (IsContinuous(frame)) { |
75 next_frame_it = frame_it; | 76 next_frame_it = frame_it; |
76 int64_t render_time = | 77 int64_t render_time = |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 next_frame_it->second->size); | 109 next_frame_it->second->size); |
109 } | 110 } |
110 float rtt_mult = protection_mode_ == kProtectionNackFEC ? 0.0 : 1.0; | 111 float rtt_mult = protection_mode_ == kProtectionNackFEC ? 0.0 : 1.0; |
111 timing_->SetJitterDelay(jitter_estimator_->GetJitterEstimate(rtt_mult)); | 112 timing_->SetJitterDelay(jitter_estimator_->GetJitterEstimate(rtt_mult)); |
112 timing_->UpdateCurrentDelay(next_frame_it->second->RenderTime(), | 113 timing_->UpdateCurrentDelay(next_frame_it->second->RenderTime(), |
113 clock_->TimeInMilliseconds()); | 114 clock_->TimeInMilliseconds()); |
114 | 115 |
115 decoded_frames_.insert(next_frame_it->first); | 116 decoded_frames_.insert(next_frame_it->first); |
116 std::unique_ptr<FrameObject> frame = std::move(next_frame_it->second); | 117 std::unique_ptr<FrameObject> frame = std::move(next_frame_it->second); |
117 frames_.erase(frames_.begin(), ++next_frame_it); | 118 frames_.erase(frames_.begin(), ++next_frame_it); |
118 return frame; | 119 return std::make_pair(kFrameFound, std::move(frame)); |
119 } else { | 120 } else { |
120 return std::unique_ptr<FrameObject>(); | 121 return std::make_pair(kTimeout, nullptr); |
121 } | 122 } |
122 } | 123 } |
123 } | 124 } |
124 } | 125 } |
125 | 126 |
126 void FrameBuffer::SetProtectionMode(VCMVideoProtection mode) { | 127 void FrameBuffer::SetProtectionMode(VCMVideoProtection mode) { |
127 rtc::CritScope lock(&crit_); | 128 rtc::CritScope lock(&crit_); |
128 protection_mode_ = mode; | 129 protection_mode_ = mode; |
129 } | 130 } |
130 | 131 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 FrameKey ref_key(frame.picture_id, frame.spatial_layer - 1); | 186 FrameKey ref_key(frame.picture_id, frame.spatial_layer - 1); |
186 if (decoded_frames_.find(ref_key) == decoded_frames_.end()) | 187 if (decoded_frames_.find(ref_key) == decoded_frames_.end()) |
187 return false; | 188 return false; |
188 } | 189 } |
189 | 190 |
190 return true; | 191 return true; |
191 } | 192 } |
192 | 193 |
193 } // namespace video_coding | 194 } // namespace video_coding |
194 } // namespace webrtc | 195 } // namespace webrtc |
OLD | NEW |