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