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