Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: media/capture/video/video_capture_buffer_pool_impl.cc

Issue 2573223002: [Mojo Video Capture] Simplify media::VideoCaptureDevice::Client:Buffer to a struct (Closed)
Patch Set: mcasas comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "media/capture/video/video_capture_buffer_handle.h" 12 #include "media/capture/video/video_capture_buffer_handle.h"
13 #include "media/capture/video/video_capture_buffer_tracker.h" 13 #include "media/capture/video/video_capture_buffer_tracker.h"
14 #include "ui/gfx/buffer_format_util.h" 14 #include "ui/gfx/buffer_format_util.h"
15 15
16 namespace media { 16 namespace media {
17 17
18 VideoCaptureBufferPoolImpl::VideoCaptureBufferPoolImpl( 18 VideoCaptureBufferPoolImpl::VideoCaptureBufferPoolImpl(
19 std::unique_ptr<VideoCaptureBufferTrackerFactory> buffer_tracker_factory, 19 std::unique_ptr<VideoCaptureBufferTrackerFactory> buffer_tracker_factory,
20 int count) 20 int count)
21 : count_(count), 21 : count_(count),
22 next_buffer_id_(0), 22 next_buffer_id_(0),
23 last_relinquished_buffer_id_(kInvalidId), 23 last_relinquished_buffer_id_(kInvalidId),
24 buffer_tracker_factory_(std::move(buffer_tracker_factory)) { 24 buffer_tracker_factory_(std::move(buffer_tracker_factory)) {
25 DCHECK_GT(count, 0); 25 DCHECK_GT(count, 0);
26 } 26 }
27 27
28 VideoCaptureBufferPoolImpl::~VideoCaptureBufferPoolImpl() {} 28 VideoCaptureBufferPoolImpl::~VideoCaptureBufferPoolImpl() {}
29 29
30 mojo::ScopedSharedBufferHandle VideoCaptureBufferPoolImpl::GetHandleForTransit( 30 mojo::ScopedSharedBufferHandle
31 int buffer_id) { 31 VideoCaptureBufferPoolImpl::GetHandleForInterProcessTransit(int buffer_id) {
32 base::AutoLock lock(lock_); 32 base::AutoLock lock(lock_);
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::GetHandleForInProcessAccess(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->GetMemoryMappedAccess();
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
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
OLDNEW
« no previous file with comments | « media/capture/video/video_capture_buffer_pool_impl.h ('k') | media/capture/video/video_capture_buffer_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698