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