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

Side by Side Diff: content/browser/renderer_host/media/web_contents_video_capture_device_unittest.cc

Issue 101843005: Convert video capture pipline to base::TimeTicks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 9890509b Rebase, Windows compile fixes Created 6 years, 11 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 | Annotate | Revision Log
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 "content/browser/renderer_host/media/web_contents_video_capture_device. h" 5 #include "content/browser/renderer_host/media/web_contents_video_capture_device. h"
6 6
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/debug/debugger.h" 8 #include "base/debug/debugger.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) OVERRIDE { 185 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) OVERRIDE {
186 subscriber_.reset(subscriber.release()); 186 subscriber_.reset(subscriber.release());
187 } 187 }
188 188
189 virtual void EndFrameSubscription() OVERRIDE { 189 virtual void EndFrameSubscription() OVERRIDE {
190 subscriber_.reset(); 190 subscriber_.reset();
191 } 191 }
192 192
193 // Simulate a compositor paint event for our subscriber. 193 // Simulate a compositor paint event for our subscriber.
194 void SimulateUpdate() { 194 void SimulateUpdate() {
195 const base::Time present_time = base::Time::Now(); 195 const base::TimeTicks present_time = base::TimeTicks::Now();
196 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback; 196 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback;
197 scoped_refptr<media::VideoFrame> target; 197 scoped_refptr<media::VideoFrame> target;
198 if (subscriber_ && subscriber_->ShouldCaptureFrame(present_time, 198 if (subscriber_ && subscriber_->ShouldCaptureFrame(present_time,
199 &target, &callback)) { 199 &target, &callback)) {
200 SkColor c = ConvertRgbToYuv(controller_->GetSolidColor()); 200 SkColor c = ConvertRgbToYuv(controller_->GetSolidColor());
201 media::FillYUV( 201 media::FillYUV(
202 target.get(), SkColorGetR(c), SkColorGetG(c), SkColorGetB(c)); 202 target.get(), SkColorGetR(c), SkColorGetG(c), SkColorGetB(c));
203 BrowserThread::PostTask(BrowserThread::UI, 203 BrowserThread::PostTask(BrowserThread::UI,
204 FROM_HERE, 204 FROM_HERE,
205 base::Bind(callback, present_time, true)); 205 base::Bind(callback, present_time, true));
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 void* data; 328 void* data;
329 size_t size; 329 size_t size;
330 buffer_pool_->GetBufferInfo(buffer_id, &data, &size); 330 buffer_pool_->GetBufferInfo(buffer_id, &data, &size);
331 return scoped_refptr<media::VideoCaptureDevice::Client::Buffer>( 331 return scoped_refptr<media::VideoCaptureDevice::Client::Buffer>(
332 new PoolBuffer(buffer_pool_, buffer_id, data, size)); 332 new PoolBuffer(buffer_pool_, buffer_id, data, size));
333 } 333 }
334 334
335 virtual void OnIncomingCapturedFrame( 335 virtual void OnIncomingCapturedFrame(
336 const uint8* data, 336 const uint8* data,
337 int length, 337 int length,
338 base::Time timestamp, 338 base::TimeTicks timestamp,
339 int rotation, 339 int rotation,
340 const media::VideoCaptureFormat& frame_format) OVERRIDE { 340 const media::VideoCaptureFormat& frame_format) OVERRIDE {
341 FAIL(); 341 FAIL();
342 } 342 }
343 343
344 virtual void OnIncomingCapturedBuffer(const scoped_refptr<Buffer>& buffer, 344 virtual void OnIncomingCapturedBuffer(const scoped_refptr<Buffer>& buffer,
345 media::VideoFrame::Format format, 345 media::VideoFrame::Format format,
346 const gfx::Size& dimensions, 346 const gfx::Size& dimensions,
347 base::Time timestamp, 347 base::TimeTicks timestamp,
348 int frame_rate) OVERRIDE { 348 int frame_rate) OVERRIDE {
349 EXPECT_EQ(gfx::Size(kTestWidth, kTestHeight), dimensions); 349 EXPECT_EQ(gfx::Size(kTestWidth, kTestHeight), dimensions);
350 EXPECT_EQ(media::VideoFrame::I420, format); 350 EXPECT_EQ(media::VideoFrame::I420, format);
351 uint8 yuv[3]; 351 uint8 yuv[3];
352 size_t offset = 0; 352 size_t offset = 0;
353 for (int plane = 0; plane < 3; ++plane) { 353 for (int plane = 0; plane < 3; ++plane) {
354 yuv[plane] = reinterpret_cast<uint8*>(buffer->data())[offset]; 354 yuv[plane] = reinterpret_cast<uint8*>(buffer->data())[offset];
355 offset += media::VideoFrame::PlaneAllocationSize( 355 offset += media::VideoFrame::PlaneAllocationSize(
356 media::VideoFrame::I420, plane, dimensions); 356 media::VideoFrame::I420, plane, dimensions);
357 } 357 }
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 source()->SetSolidColor(SK_ColorGREEN); 806 source()->SetSolidColor(SK_ColorGREEN);
807 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); 807 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN));
808 source()->SetSolidColor(SK_ColorRED); 808 source()->SetSolidColor(SK_ColorRED);
809 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED)); 809 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED));
810 810
811 device()->StopAndDeAllocate(); 811 device()->StopAndDeAllocate();
812 } 812 }
813 813
814 } // namespace 814 } // namespace
815 } // namespace content 815 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698