| 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 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 VideoCaptureBufferTracker* tracker = GetTracker(buffer_id); | 34 VideoCaptureBufferTracker* tracker = GetTracker(buffer_id); |
| 35 if (!tracker) { | 35 if (!tracker) { |
| 36 NOTREACHED() << "Invalid buffer_id."; | 36 NOTREACHED() << "Invalid buffer_id."; |
| 37 return mojo::ScopedSharedBufferHandle(); | 37 return mojo::ScopedSharedBufferHandle(); |
| 38 } | 38 } |
| 39 return tracker->GetHandleForTransit(); | 39 return tracker->GetHandleForTransit(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 std::unique_ptr<VideoCaptureBufferHandle> | 42 std::unique_ptr<VideoCaptureBufferHandle> |
| 43 VideoCaptureBufferPoolImpl::GetBufferHandle(int buffer_id) { | 43 VideoCaptureBufferPoolImpl::GetReadWriteAccess(int buffer_id) { |
| 44 base::AutoLock lock(lock_); | 44 base::AutoLock lock(lock_); |
| 45 | 45 |
| 46 VideoCaptureBufferTracker* tracker = GetTracker(buffer_id); | 46 VideoCaptureBufferTracker* tracker = GetTracker(buffer_id); |
| 47 if (!tracker) { | 47 if (!tracker) { |
| 48 NOTREACHED() << "Invalid buffer_id."; | 48 NOTREACHED() << "Invalid buffer_id."; |
| 49 return std::unique_ptr<VideoCaptureBufferHandle>(); | 49 return nullptr; |
| 50 } | 50 } |
| 51 | 51 |
| 52 DCHECK(tracker->held_by_producer()); | 52 return tracker->GetReadWriteAccess(); |
| 53 return tracker->GetBufferHandle(); | |
| 54 } | 53 } |
| 55 | 54 |
| 56 int VideoCaptureBufferPoolImpl::ReserveForProducer( | 55 int VideoCaptureBufferPoolImpl::ReserveForProducer( |
| 57 const gfx::Size& dimensions, | 56 const gfx::Size& dimensions, |
| 58 media::VideoPixelFormat format, | 57 media::VideoPixelFormat format, |
| 59 media::VideoPixelStorage storage, | 58 media::VideoPixelStorage storage, |
| 60 int frame_feedback_id, | 59 int frame_feedback_id, |
| 61 int* buffer_id_to_drop) { | 60 int* buffer_id_to_drop) { |
| 62 base::AutoLock lock(lock_); | 61 base::AutoLock lock(lock_); |
| 63 return ReserveForProducerInternal(dimensions, format, storage, | 62 return ReserveForProducerInternal(dimensions, format, storage, |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 return buffer_id; | 228 return buffer_id; |
| 230 } | 229 } |
| 231 | 230 |
| 232 VideoCaptureBufferTracker* VideoCaptureBufferPoolImpl::GetTracker( | 231 VideoCaptureBufferTracker* VideoCaptureBufferPoolImpl::GetTracker( |
| 233 int buffer_id) { | 232 int buffer_id) { |
| 234 auto it = trackers_.find(buffer_id); | 233 auto it = trackers_.find(buffer_id); |
| 235 return (it == trackers_.end()) ? nullptr : it->second.get(); | 234 return (it == trackers_.end()) ? nullptr : it->second.get(); |
| 236 } | 235 } |
| 237 | 236 |
| 238 } // namespace media | 237 } // namespace media |
| OLD | NEW |