| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/capture/video/video_capture_buffer_pool_impl.h" | 5 #include "media/capture/video/video_capture_buffer_pool_impl.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 if (!tracker) { | 40 if (!tracker) { |
| 41 NOTREACHED() << "Invalid buffer_id."; | 41 NOTREACHED() << "Invalid buffer_id."; |
| 42 return false; | 42 return false; |
| 43 } | 43 } |
| 44 if (tracker->ShareToProcess(process_handle, new_handle)) | 44 if (tracker->ShareToProcess(process_handle, new_handle)) |
| 45 return true; | 45 return true; |
| 46 DPLOG(ERROR) << "Error mapping memory"; | 46 DPLOG(ERROR) << "Error mapping memory"; |
| 47 return false; | 47 return false; |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool VideoCaptureBufferPoolImpl::ShareToProcess2( | |
| 51 int buffer_id, | |
| 52 int plane, | |
| 53 base::ProcessHandle process_handle, | |
| 54 gfx::GpuMemoryBufferHandle* new_handle) { | |
| 55 base::AutoLock lock(lock_); | |
| 56 | |
| 57 VideoCaptureBufferTracker* tracker = GetTracker(buffer_id); | |
| 58 if (!tracker) { | |
| 59 NOTREACHED() << "Invalid buffer_id."; | |
| 60 return false; | |
| 61 } | |
| 62 if (tracker->ShareToProcess2(plane, process_handle, new_handle)) | |
| 63 return true; | |
| 64 DPLOG(ERROR) << "Error mapping memory"; | |
| 65 return false; | |
| 66 } | |
| 67 | |
| 68 std::unique_ptr<VideoCaptureBufferHandle> | 50 std::unique_ptr<VideoCaptureBufferHandle> |
| 69 VideoCaptureBufferPoolImpl::GetBufferHandle(int buffer_id) { | 51 VideoCaptureBufferPoolImpl::GetBufferHandle(int buffer_id) { |
| 70 base::AutoLock lock(lock_); | 52 base::AutoLock lock(lock_); |
| 71 | 53 |
| 72 VideoCaptureBufferTracker* tracker = GetTracker(buffer_id); | 54 VideoCaptureBufferTracker* tracker = GetTracker(buffer_id); |
| 73 if (!tracker) { | 55 if (!tracker) { |
| 74 NOTREACHED() << "Invalid buffer_id."; | 56 NOTREACHED() << "Invalid buffer_id."; |
| 75 return std::unique_ptr<VideoCaptureBufferHandle>(); | 57 return std::unique_ptr<VideoCaptureBufferHandle>(); |
| 76 } | 58 } |
| 77 | 59 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 return buffer_id; | 234 return buffer_id; |
| 253 } | 235 } |
| 254 | 236 |
| 255 VideoCaptureBufferTracker* VideoCaptureBufferPoolImpl::GetTracker( | 237 VideoCaptureBufferTracker* VideoCaptureBufferPoolImpl::GetTracker( |
| 256 int buffer_id) { | 238 int buffer_id) { |
| 257 TrackerMap::const_iterator it = trackers_.find(buffer_id); | 239 TrackerMap::const_iterator it = trackers_.find(buffer_id); |
| 258 return (it == trackers_.end()) ? NULL : it->second; | 240 return (it == trackers_.end()) ? NULL : it->second; |
| 259 } | 241 } |
| 260 | 242 |
| 261 } // namespace media | 243 } // namespace media |
| OLD | NEW |