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/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 158 } |
159 | 159 |
160 void SetReturnReceivedDibs(bool enable) { | 160 void SetReturnReceivedDibs(bool enable) { |
161 return_buffers_ = enable; | 161 return_buffers_ = enable; |
162 } | 162 } |
163 | 163 |
164 // Return Dibs we currently have received. | 164 // Return Dibs we currently have received. |
165 void ReturnReceivedDibs(int device_id) { | 165 void ReturnReceivedDibs(int device_id) { |
166 int handle = GetReceivedDib(); | 166 int handle = GetReceivedDib(); |
167 while (handle) { | 167 while (handle) { |
168 this->OnReceiveEmptyBuffer(device_id, handle, 0); | 168 this->OnRendererFinishedWithBuffer(device_id, handle, 0, -1.0); |
169 handle = GetReceivedDib(); | 169 handle = GetReceivedDib(); |
170 } | 170 } |
171 } | 171 } |
172 | 172 |
173 int GetReceivedDib() { | 173 int GetReceivedDib() { |
174 if (filled_dib_.empty()) | 174 if (filled_dib_.empty()) |
175 return 0; | 175 return 0; |
176 std::map<int, base::SharedMemory*>::iterator it = filled_dib_.begin(); | 176 std::map<int, base::SharedMemory*>::iterator it = filled_dib_.begin(); |
177 int h = it->first; | 177 int h = it->first; |
178 delete it->second; | 178 delete it->second; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 if (dumper_.coded_size().IsEmpty()) | 240 if (dumper_.coded_size().IsEmpty()) |
241 dumper_.StartDump(params.coded_size); | 241 dumper_.StartDump(params.coded_size); |
242 ASSERT_TRUE(dumper_.coded_size() == params.coded_size) | 242 ASSERT_TRUE(dumper_.coded_size() == params.coded_size) |
243 << "Dump format does not handle variable resolution."; | 243 << "Dump format does not handle variable resolution."; |
244 dumper_.NewVideoFrame(dib->memory()); | 244 dumper_.NewVideoFrame(dib->memory()); |
245 } | 245 } |
246 | 246 |
247 OnBufferFilled(params.device_id, params.buffer_id, params.coded_size, | 247 OnBufferFilled(params.device_id, params.buffer_id, params.coded_size, |
248 params.visible_rect, params.timestamp, params.metadata); | 248 params.visible_rect, params.timestamp, params.metadata); |
249 if (return_buffers_) { | 249 if (return_buffers_) { |
250 VideoCaptureHost::OnReceiveEmptyBuffer( | 250 VideoCaptureHost::OnRendererFinishedWithBuffer( |
251 params.device_id, params.buffer_id, 0); | 251 params.device_id, params.buffer_id, 0, -1.0); |
252 } | 252 } |
253 } | 253 } |
254 | 254 |
255 void OnMailboxBufferFilledDispatch( | 255 void OnMailboxBufferFilledDispatch( |
256 const VideoCaptureMsg_MailboxBufferReady_Params& params) { | 256 const VideoCaptureMsg_MailboxBufferReady_Params& params) { |
257 OnMailboxBufferFilled(params.device_id, params.buffer_id, | 257 OnMailboxBufferFilled(params.device_id, params.buffer_id, |
258 params.mailbox_holder, params.packed_frame_size, | 258 params.mailbox_holder, params.packed_frame_size, |
259 params.timestamp, params.metadata); | 259 params.timestamp, params.metadata); |
260 if (return_buffers_) { | 260 if (return_buffers_) { |
261 VideoCaptureHost::OnReceiveEmptyBuffer( | 261 VideoCaptureHost::OnRendererFinishedWithBuffer( |
262 params.device_id, params.buffer_id, 0); | 262 params.device_id, params.buffer_id, 0, -1.0); |
263 } | 263 } |
264 } | 264 } |
265 | 265 |
266 void OnStateChangedDispatch(int device_id, VideoCaptureState state) { | 266 void OnStateChangedDispatch(int device_id, VideoCaptureState state) { |
267 OnStateChanged(device_id, state); | 267 OnStateChanged(device_id, state); |
268 } | 268 } |
269 | 269 |
270 std::map<int, base::SharedMemory*> filled_dib_; | 270 std::map<int, base::SharedMemory*> filled_dib_; |
271 bool return_buffers_; | 271 bool return_buffers_; |
272 bool dump_video_; | 272 bool dump_video_; |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 #ifdef DUMP_VIDEO | 558 #ifdef DUMP_VIDEO |
559 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { | 559 TEST_F(VideoCaptureHostTest, CaptureAndDumpVideoVga) { |
560 CaptureAndDumpVideo(640, 480, 30); | 560 CaptureAndDumpVideo(640, 480, 30); |
561 } | 561 } |
562 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { | 562 TEST_F(VideoCaptureHostTest, CaptureAndDump720P) { |
563 CaptureAndDumpVideo(1280, 720, 30); | 563 CaptureAndDumpVideo(1280, 720, 30); |
564 } | 564 } |
565 #endif | 565 #endif |
566 | 566 |
567 } // namespace content | 567 } // namespace content |
OLD | NEW |