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