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

Side by Side Diff: media/capture/video/fake_video_capture_device.cc

Issue 1983193002: Decouple capture timestamp and reference time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/capture/video/fake_video_capture_device.h" 5 #include "media/capture/video/fake_video_capture_device.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 void FakeVideoCaptureDevice::CaptureUsingOwnBuffers( 172 void FakeVideoCaptureDevice::CaptureUsingOwnBuffers(
173 base::TimeTicks expected_execution_time) { 173 base::TimeTicks expected_execution_time) {
174 DCHECK(thread_checker_.CalledOnValidThread()); 174 DCHECK(thread_checker_.CalledOnValidThread());
175 const size_t frame_size = capture_format_.ImageAllocationSize(); 175 const size_t frame_size = capture_format_.ImageAllocationSize();
176 memset(fake_frame_.get(), 0, frame_size); 176 memset(fake_frame_.get(), 0, frame_size);
177 177
178 DrawPacman(false /* use_argb */, fake_frame_.get(), elapsed_time_, 178 DrawPacman(false /* use_argb */, fake_frame_.get(), elapsed_time_,
179 fake_capture_rate_, capture_format_.frame_size); 179 fake_capture_rate_, capture_format_.frame_size);
180 180
181 // Give the captured frame to the client. 181 // Give the captured frame to the client.
182 base::TimeTicks now = base::TimeTicks::Now();
183 if (first_ref_time_.is_null())
184 first_ref_time_ = now;
182 client_->OnIncomingCapturedData(fake_frame_.get(), frame_size, 185 client_->OnIncomingCapturedData(fake_frame_.get(), frame_size,
183 capture_format_, 0 /* rotation */, 186 capture_format_, 0 /* rotation */, now,
184 base::TimeTicks::Now()); 187 now - first_ref_time_);
185 BeepAndScheduleNextCapture( 188 BeepAndScheduleNextCapture(
186 expected_execution_time, 189 expected_execution_time,
187 base::Bind(&FakeVideoCaptureDevice::CaptureUsingOwnBuffers, 190 base::Bind(&FakeVideoCaptureDevice::CaptureUsingOwnBuffers,
188 weak_factory_.GetWeakPtr())); 191 weak_factory_.GetWeakPtr()));
189 } 192 }
190 193
191 void FakeVideoCaptureDevice::CaptureUsingClientBuffers( 194 void FakeVideoCaptureDevice::CaptureUsingClientBuffers(
192 base::TimeTicks expected_execution_time) { 195 base::TimeTicks expected_execution_time) {
193 DCHECK(thread_checker_.CalledOnValidThread()); 196 DCHECK(thread_checker_.CalledOnValidThread());
194 197
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 // Don't accumulate any debt if we are lagging behind - just post the next 260 // Don't accumulate any debt if we are lagging behind - just post the next
258 // frame immediately and continue as normal. 261 // frame immediately and continue as normal.
259 const base::TimeTicks next_execution_time = 262 const base::TimeTicks next_execution_time =
260 std::max(current_time, expected_execution_time + frame_interval); 263 std::max(current_time, expected_execution_time + frame_interval);
261 const base::TimeDelta delay = next_execution_time - current_time; 264 const base::TimeDelta delay = next_execution_time - current_time;
262 base::MessageLoop::current()->PostDelayedTask( 265 base::MessageLoop::current()->PostDelayedTask(
263 FROM_HERE, base::Bind(next_capture, next_execution_time), delay); 266 FROM_HERE, base::Bind(next_capture, next_execution_time), delay);
264 } 267 }
265 268
266 } // namespace media 269 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698