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