OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // Unit test for VideoCaptureBufferPool. | 5 // Unit test for VideoCaptureBufferPool. |
6 | 6 |
7 #include "content/browser/renderer_host/media/video_capture_buffer_pool.h" | 7 #include "content/browser/renderer_host/media/video_capture_buffer_pool.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "content/browser/renderer_host/media/video_capture_controller.h" | 12 #include "content/browser/renderer_host/media/video_capture_controller.h" |
13 #include "media/base/video_frame.h" | 13 #include "media/base/video_frame.h" |
14 #include "media/base/video_util.h" | 14 #include "media/base/video_util.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 | 18 |
19 TEST(VideoCaptureBufferPoolTest, BufferPool) { | 19 TEST(VideoCaptureBufferPoolTest, BufferPool) { |
20 const gfx::Size size = gfx::Size(640, 480); | 20 const gfx::Size size = gfx::Size(640, 480); |
21 scoped_refptr<media::VideoFrame> non_pool_frame = | 21 scoped_refptr<media::VideoFrame> non_pool_frame = |
22 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, size, | 22 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, size, |
23 gfx::Rect(size), size, base::TimeDelta()); | 23 gfx::Rect(size), size, base::TimeDelta()); |
24 scoped_refptr<VideoCaptureBufferPool> pool = | 24 scoped_refptr<VideoCaptureBufferPool> pool = new VideoCaptureBufferPool( |
25 new VideoCaptureBufferPool(size.GetArea() * 3 / 2, 3); | 25 media::VideoFrame::AllocationSize(media::VideoFrame::I420, size), 3); |
26 | 26 |
27 ASSERT_EQ(460800u, pool->GetMemorySize()); | 27 ASSERT_EQ(460800u, pool->GetMemorySize()); |
28 ASSERT_TRUE(pool->Allocate()); | 28 ASSERT_TRUE(pool->Allocate()); |
29 | 29 |
30 scoped_refptr<media::VideoFrame> frame1 = | 30 scoped_refptr<media::VideoFrame> frame1 = |
31 pool->ReserveI420VideoFrame(size, 0); | 31 pool->ReserveI420VideoFrame(size, 0); |
32 ASSERT_TRUE(NULL != frame1.get()); | 32 ASSERT_TRUE(NULL != frame1.get()); |
33 ASSERT_EQ(size, frame1->coded_size()); | 33 ASSERT_EQ(size, frame1->coded_size()); |
34 scoped_refptr<media::VideoFrame> frame2 = | 34 scoped_refptr<media::VideoFrame> frame2 = |
35 pool->ReserveI420VideoFrame(size, 0); | 35 pool->ReserveI420VideoFrame(size, 0); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 media::FillYUV(frame1.get(), 0x11, 0x22, 0x33); | 150 media::FillYUV(frame1.get(), 0x11, 0x22, 0x33); |
151 media::FillYUV(frame4.get(), 0x44, 0x55, 0x66); | 151 media::FillYUV(frame4.get(), 0x44, 0x55, 0x66); |
152 | 152 |
153 frame1 = NULL; | 153 frame1 = NULL; |
154 | 154 |
155 media::FillYUV(frame4.get(), 0x44, 0x55, 0x66); | 155 media::FillYUV(frame4.get(), 0x44, 0x55, 0x66); |
156 frame4 = NULL; | 156 frame4 = NULL; |
157 } | 157 } |
158 | 158 |
159 } // namespace content | 159 } // namespace content |
OLD | NEW |