OLD | NEW |
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 <map> | 5 #include <map> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 144 } |
145 | 145 |
146 void SetReturnReceivedDibs(bool enable) { | 146 void SetReturnReceivedDibs(bool enable) { |
147 return_buffers_ = enable; | 147 return_buffers_ = enable; |
148 } | 148 } |
149 | 149 |
150 // Return Dibs we currently have received. | 150 // Return Dibs we currently have received. |
151 void ReturnReceivedDibs(int device_id) { | 151 void ReturnReceivedDibs(int device_id) { |
152 int handle = GetReceivedDib(); | 152 int handle = GetReceivedDib(); |
153 while (handle) { | 153 while (handle) { |
154 this->OnReceiveEmptyBuffer(device_id, handle, 0); | 154 this->OnReceiveEmptyBuffer(device_id, handle, std::vector<uint32>()); |
155 handle = GetReceivedDib(); | 155 handle = GetReceivedDib(); |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 int GetReceivedDib() { | 159 int GetReceivedDib() { |
160 if (filled_dib_.empty()) | 160 if (filled_dib_.empty()) |
161 return 0; | 161 return 0; |
162 std::map<int, base::SharedMemory*>::iterator it = filled_dib_.begin(); | 162 std::map<int, base::SharedMemory*>::iterator it = filled_dib_.begin(); |
163 int h = it->first; | 163 int h = it->first; |
164 delete it->second; | 164 delete it->second; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 } | 232 } |
233 ASSERT_EQ(format_.frame_size.width(), frame_format.frame_size.width()) | 233 ASSERT_EQ(format_.frame_size.width(), frame_format.frame_size.width()) |
234 << "Dump format does not handle variable resolution."; | 234 << "Dump format does not handle variable resolution."; |
235 ASSERT_EQ(format_.frame_size.height(), frame_format.frame_size.height()) | 235 ASSERT_EQ(format_.frame_size.height(), frame_format.frame_size.height()) |
236 << "Dump format does not handle variable resolution."; | 236 << "Dump format does not handle variable resolution."; |
237 dumper_.NewVideoFrame(dib->memory()); | 237 dumper_.NewVideoFrame(dib->memory()); |
238 } | 238 } |
239 | 239 |
240 OnBufferFilled(device_id, buffer_id, frame_format, timestamp); | 240 OnBufferFilled(device_id, buffer_id, frame_format, timestamp); |
241 if (return_buffers_) { | 241 if (return_buffers_) { |
242 VideoCaptureHost::OnReceiveEmptyBuffer(device_id, buffer_id, 0); | 242 VideoCaptureHost::OnReceiveEmptyBuffer( |
| 243 device_id, buffer_id, std::vector<uint32>()); |
243 } | 244 } |
244 } | 245 } |
245 | 246 |
246 void OnMailboxBufferFilledDispatch(int device_id, | 247 void OnMailboxBufferFilledDispatch(int device_id, |
247 int buffer_id, | 248 int buffer_id, |
248 const gpu::MailboxHolder& mailbox_holder, | 249 const gpu::MailboxHolder& mailbox_holder, |
249 const media::VideoCaptureFormat& format, | 250 const media::VideoCaptureFormat& format, |
250 base::TimeTicks timestamp) { | 251 base::TimeTicks timestamp) { |
251 OnMailboxBufferFilled( | 252 OnMailboxBufferFilled( |
252 device_id, buffer_id, mailbox_holder, format, timestamp); | 253 device_id, buffer_id, mailbox_holder, format, timestamp); |
253 if (return_buffers_) { | 254 if (return_buffers_) { |
254 VideoCaptureHost::OnReceiveEmptyBuffer( | 255 VideoCaptureHost::OnReceiveEmptyBuffer( |
255 device_id, buffer_id, mailbox_holder.sync_point); | 256 device_id, buffer_id, std::vector<uint32>()); |
256 } | 257 } |
257 } | 258 } |
258 | 259 |
259 void OnStateChangedDispatch(int device_id, VideoCaptureState state) { | 260 void OnStateChangedDispatch(int device_id, VideoCaptureState state) { |
260 OnStateChanged(device_id, state); | 261 OnStateChanged(device_id, state); |
261 } | 262 } |
262 | 263 |
263 std::map<int, base::SharedMemory*> filled_dib_; | 264 std::map<int, base::SharedMemory*> filled_dib_; |
264 bool return_buffers_; | 265 bool return_buffers_; |
265 bool dump_video_; | 266 bool dump_video_; |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 #ifdef DUMP_VIDEO | 533 #ifdef DUMP_VIDEO |
533 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { | 534 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { |
534 CaptureAndDumpVideo(640, 480, 30); | 535 CaptureAndDumpVideo(640, 480, 30); |
535 } | 536 } |
536 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { | 537 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { |
537 CaptureAndDumpVideo(1280, 720, 30); | 538 CaptureAndDumpVideo(1280, 720, 30); |
538 } | 539 } |
539 #endif | 540 #endif |
540 | 541 |
541 } // namespace content | 542 } // namespace content |
OLD | NEW |