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

Side by Side Diff: media/cast/framer/frame_id_map.cc

Issue 289483003: Cast: Only ACK decodable frames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor formatting change Created 6 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
« no previous file with comments | « media/cast/framer/frame_id_map.h ('k') | media/cast/framer/framer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cast/framer/frame_id_map.h" 5 #include "media/cast/framer/frame_id_map.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/cast/rtp_receiver/rtp_receiver_defines.h" 8 #include "media/cast/rtp_receiver/rtp_receiver_defines.h"
9 9
10 namespace media { 10 namespace media {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 for (it = frame_map_.begin(); it != frame_map_.end(); ++it) { 131 for (it = frame_map_.begin(); it != frame_map_.end(); ++it) {
132 if (it->second->Complete() && ContinuousFrame(it->second.get())) { 132 if (it->second->Complete() && ContinuousFrame(it->second.get())) {
133 *frame_id = it->first; 133 *frame_id = it->first;
134 return true; 134 return true;
135 } 135 }
136 } 136 }
137 return false; 137 return false;
138 } 138 }
139 139
140 bool FrameIdMap::HaveMultipleDecodableFrames() const {
141 // Find the oldest decodable frame.
142 FrameMap::const_iterator it;
143 bool found_one = false;
144 for (it = frame_map_.begin(); it != frame_map_.end(); ++it) {
145 if (it->second->Complete() && DecodableFrame(it->second.get())) {
146 if (found_one) {
147 return true;
148 } else {
149 found_one = true;
150 }
151 }
152 }
153 return false;
154 }
155
140 uint32 FrameIdMap::LastContinuousFrame() const { 156 uint32 FrameIdMap::LastContinuousFrame() const {
141 uint32 last_continuous_frame_id = last_released_frame_; 157 uint32 last_continuous_frame_id = last_released_frame_;
142 uint32 next_expected_frame = last_released_frame_; 158 uint32 next_expected_frame = last_released_frame_;
143 159
144 FrameMap::const_iterator it; 160 FrameMap::const_iterator it;
145 161
146 do { 162 do {
147 next_expected_frame++; 163 next_expected_frame++;
148 it = frame_map_.find(next_expected_frame); 164 it = frame_map_.find(next_expected_frame);
149 if (it == frame_map_.end()) 165 if (it == frame_map_.end())
150 break; 166 break;
151 if (!it->second->Complete()) 167 if (!it->second->Complete())
152 break; 168 break;
153 169
154 // We found the next continuous frame. 170 // We found the next continuous frame.
155 last_continuous_frame_id = it->first; 171 last_continuous_frame_id = it->first;
156 } while (next_expected_frame != newest_frame_id_); 172 } while (next_expected_frame != newest_frame_id_);
157 return last_continuous_frame_id; 173 return last_continuous_frame_id;
158 } 174 }
159 175
160 bool FrameIdMap::NextAudioFrameAllowingMissingFrames(uint32* frame_id) const { 176 bool FrameIdMap::NextFrameAllowingSkippingFrames(uint32* frame_id) const {
161 // First check if we have continuous frames.
162 if (NextContinuousFrame(frame_id))
163 return true;
164
165 // Find the oldest frame.
166 FrameMap::const_iterator it_best_match = frame_map_.end();
167 FrameMap::const_iterator it;
168
169 // Find first complete frame.
170 for (it = frame_map_.begin(); it != frame_map_.end(); ++it) {
171 if (it->second->Complete()) {
172 it_best_match = it;
173 break;
174 }
175 }
176 if (it_best_match == frame_map_.end())
177 return false; // No complete frame.
178
179 ++it;
180 for (; it != frame_map_.end(); ++it) {
181 if (it->second->Complete() &&
182 IsOlderFrameId(it->first, it_best_match->first)) {
183 it_best_match = it;
184 }
185 }
186 *frame_id = it_best_match->first;
187 return true;
188 }
189
190 bool FrameIdMap::NextVideoFrameAllowingSkippingFrames(uint32* frame_id) const {
191 // Find the oldest decodable frame. 177 // Find the oldest decodable frame.
192 FrameMap::const_iterator it_best_match = frame_map_.end(); 178 FrameMap::const_iterator it_best_match = frame_map_.end();
193 FrameMap::const_iterator it; 179 FrameMap::const_iterator it;
194 for (it = frame_map_.begin(); it != frame_map_.end(); ++it) { 180 for (it = frame_map_.begin(); it != frame_map_.end(); ++it) {
195 if (it->second->Complete() && DecodableVideoFrame(it->second.get())) { 181 if (it->second->Complete() && DecodableFrame(it->second.get())) {
196 it_best_match = it; 182 if (it_best_match == frame_map_.end() ||
183 IsOlderFrameId(it->first, it_best_match->first)) {
184 it_best_match = it;
185 }
197 } 186 }
198 } 187 }
199 if (it_best_match == frame_map_.end()) 188 if (it_best_match == frame_map_.end())
200 return false; 189 return false;
201 190
202 *frame_id = it_best_match->first; 191 *frame_id = it_best_match->first;
203 return true; 192 return true;
204 } 193 }
205 194
206 bool FrameIdMap::Empty() const { return frame_map_.empty(); } 195 bool FrameIdMap::Empty() const { return frame_map_.empty(); }
(...skipping 23 matching lines...) Expand all
230 it->second->GetMissingPackets(last_frame, missing_packets); 219 it->second->GetMissingPackets(last_frame, missing_packets);
231 } 220 }
232 221
233 bool FrameIdMap::ContinuousFrame(FrameInfo* frame) const { 222 bool FrameIdMap::ContinuousFrame(FrameInfo* frame) const {
234 DCHECK(frame); 223 DCHECK(frame);
235 if (waiting_for_key_ && !frame->is_key_frame()) 224 if (waiting_for_key_ && !frame->is_key_frame())
236 return false; 225 return false;
237 return static_cast<uint32>(last_released_frame_ + 1) == frame->frame_id(); 226 return static_cast<uint32>(last_released_frame_ + 1) == frame->frame_id();
238 } 227 }
239 228
240 bool FrameIdMap::DecodableVideoFrame(FrameInfo* frame) const { 229 bool FrameIdMap::DecodableFrame(FrameInfo* frame) const {
241 if (frame->is_key_frame()) 230 if (frame->is_key_frame())
242 return true; 231 return true;
243 if (waiting_for_key_ && !frame->is_key_frame()) 232 if (waiting_for_key_ && !frame->is_key_frame())
244 return false; 233 return false;
234 // Self-reference?
235 if (frame->referenced_frame_id() == frame->frame_id())
236 return true;
245 237
246 // Current frame is not necessarily referencing the last frame. 238 // Current frame is not necessarily referencing the last frame.
247 // Do we have the reference frame? 239 // Do we have the reference frame?
248 if (IsOlderFrameId(frame->referenced_frame_id(), last_released_frame_)) { 240 if (IsOlderFrameId(frame->referenced_frame_id(), last_released_frame_)) {
249 return true; 241 return true;
250 } 242 }
251 return frame->referenced_frame_id() == last_released_frame_; 243 return frame->referenced_frame_id() == last_released_frame_;
252 } 244 }
253 245
254 } // namespace cast 246 } // namespace cast
255 } // namespace media 247 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/framer/frame_id_map.h ('k') | media/cast/framer/framer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698