| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/video/capture/file_video_capture_device.h" | 5 #include "media/video/capture/file_video_capture_device.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
| 13 #include "media/video/capture/video_capture_types.h" | |
| 14 | 13 |
| 15 namespace media { | 14 namespace media { |
| 16 static const int kY4MHeaderMaxSize = 200; | 15 static const int kY4MHeaderMaxSize = 200; |
| 17 static const char kY4MSimpleFrameDelimiter[] = "FRAME"; | 16 static const char kY4MSimpleFrameDelimiter[] = "FRAME"; |
| 18 static const int kY4MSimpleFrameDelimiterSize = 6; | 17 static const int kY4MSimpleFrameDelimiterSize = 6; |
| 19 | 18 |
| 20 int ParseY4MInt(const base::StringPiece& token) { | 19 int ParseY4MInt(const base::StringPiece& token) { |
| 21 int temp_int; | 20 int temp_int; |
| 22 CHECK(base::StringToInt(token, &temp_int)) << token; | 21 CHECK(base::StringToInt(token, &temp_int)) << token; |
| 23 return temp_int; | 22 return temp_int; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 DCHECK(thread_checker_.CalledOnValidThread()); | 162 DCHECK(thread_checker_.CalledOnValidThread()); |
| 164 CHECK(capture_thread_.IsRunning()); | 163 CHECK(capture_thread_.IsRunning()); |
| 165 | 164 |
| 166 capture_thread_.message_loop()->PostTask( | 165 capture_thread_.message_loop()->PostTask( |
| 167 FROM_HERE, | 166 FROM_HERE, |
| 168 base::Bind(&FileVideoCaptureDevice::OnStopAndDeAllocate, | 167 base::Bind(&FileVideoCaptureDevice::OnStopAndDeAllocate, |
| 169 base::Unretained(this))); | 168 base::Unretained(this))); |
| 170 capture_thread_.Stop(); | 169 capture_thread_.Stop(); |
| 171 } | 170 } |
| 172 | 171 |
| 173 int FileVideoCaptureDevice::CalculateFrameSize() const { | 172 int FileVideoCaptureDevice::CalculateFrameSize() { |
| 174 DCHECK_EQ(capture_format_.pixel_format, PIXEL_FORMAT_I420); | 173 DCHECK_EQ(capture_format_.pixel_format, PIXEL_FORMAT_I420); |
| 175 DCHECK_EQ(capture_thread_.message_loop(), base::MessageLoop::current()); | 174 DCHECK_EQ(capture_thread_.message_loop(), base::MessageLoop::current()); |
| 176 return capture_format_.ImageAllocationSize(); | 175 return capture_format_.frame_size.GetArea() * 12 / 8; |
| 177 } | 176 } |
| 178 | 177 |
| 179 void FileVideoCaptureDevice::OnAllocateAndStart( | 178 void FileVideoCaptureDevice::OnAllocateAndStart( |
| 180 const VideoCaptureParams& params, | 179 const VideoCaptureParams& params, |
| 181 scoped_ptr<VideoCaptureDevice::Client> client) { | 180 scoped_ptr<VideoCaptureDevice::Client> client) { |
| 182 DCHECK_EQ(capture_thread_.message_loop(), base::MessageLoop::current()); | 181 DCHECK_EQ(capture_thread_.message_loop(), base::MessageLoop::current()); |
| 183 | 182 |
| 184 client_ = client.Pass(); | 183 client_ = client.Pass(); |
| 185 | 184 |
| 186 // Open the file and parse the header. Get frame size and format. | 185 // Open the file and parse the header. Get frame size and format. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 next_on_capture_timedelta = frame_interval; | 248 next_on_capture_timedelta = frame_interval; |
| 250 } | 249 } |
| 251 base::MessageLoop::current()->PostDelayedTask( | 250 base::MessageLoop::current()->PostDelayedTask( |
| 252 FROM_HERE, | 251 FROM_HERE, |
| 253 base::Bind(&FileVideoCaptureDevice::OnCaptureTask, | 252 base::Bind(&FileVideoCaptureDevice::OnCaptureTask, |
| 254 base::Unretained(this)), | 253 base::Unretained(this)), |
| 255 next_on_capture_timedelta); | 254 next_on_capture_timedelta); |
| 256 } | 255 } |
| 257 | 256 |
| 258 } // namespace media | 257 } // namespace media |
| OLD | NEW |