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

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

Issue 2361173002: Move classses VideoCaptureDeviceClient and VideoCaptureBufferPool to media/capture/video (Closed)
Patch Set: mcasas@ comments Created 4 years, 2 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_BUFFER_POOL_IMPL_H_
6 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_BUFFER_POOL_IMPL_H_
7
8 #include <stddef.h>
9
10 #include <map>
11
12 #include "base/files/file.h"
13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/shared_memory.h"
16 #include "base/process/process.h"
17 #include "base/synchronization/lock.h"
18 #include "build/build_config.h"
19 #include "media/base/video_capture_types.h"
20 #include "media/base/video_frame.h"
21 #include "media/capture/capture_export.h"
22 #include "media/capture/video/video_capture_buffer_handle.h"
23 #include "media/capture/video/video_capture_buffer_pool.h"
24 #include "media/capture/video/video_capture_buffer_tracker_factory.h"
25 #include "ui/gfx/geometry/size.h"
26 #include "ui/gfx/gpu_memory_buffer.h"
27
28 namespace media {
29
30 class CAPTURE_EXPORT VideoCaptureBufferPoolImpl
31 : public VideoCaptureBufferPool {
32 public:
33 explicit VideoCaptureBufferPoolImpl(
34 std::unique_ptr<VideoCaptureBufferTrackerFactory> buffer_tracker_factory,
35 int count);
36
37 // Implementation of VideoCaptureBufferPool interface:
38 bool ShareToProcess(int buffer_id,
39 base::ProcessHandle process_handle,
40 base::SharedMemoryHandle* new_handle) override;
41 bool ShareToProcess2(int buffer_id,
42 int plane,
43 base::ProcessHandle process_handle,
44 gfx::GpuMemoryBufferHandle* new_handle) override;
45 std::unique_ptr<VideoCaptureBufferHandle> GetBufferHandle(
46 int buffer_id) override;
47 int ReserveForProducer(const gfx::Size& dimensions,
48 media::VideoPixelFormat format,
49 media::VideoPixelStorage storage,
50 int* buffer_id_to_drop) override;
51 void RelinquishProducerReservation(int buffer_id) override;
52 int ResurrectLastForProducer(const gfx::Size& dimensions,
53 media::VideoPixelFormat format,
54 media::VideoPixelStorage storage) override;
55 double GetBufferPoolUtilization() const override;
56 void HoldForConsumers(int buffer_id, int num_clients) override;
57 void RelinquishConsumerHold(int buffer_id, int num_clients) override;
58
59 private:
60 friend class base::RefCountedThreadSafe<VideoCaptureBufferPoolImpl>;
61 ~VideoCaptureBufferPoolImpl() override;
62
63 int ReserveForProducerInternal(const gfx::Size& dimensions,
64 media::VideoPixelFormat format,
65 media::VideoPixelStorage storage,
66 int* tracker_id_to_drop);
67
68 VideoCaptureBufferTracker* GetTracker(int buffer_id);
69
70 // The max number of buffers that the pool is allowed to have at any moment.
71 const int count_;
72
73 // Protects everything below it.
74 mutable base::Lock lock_;
75
76 // The ID of the next buffer.
77 int next_buffer_id_;
78
79 // The ID of the buffer last relinquished by the producer (a candidate for
80 // resurrection).
81 int last_relinquished_buffer_id_;
82
83 // The buffers, indexed by the first parameter, a buffer id.
84 using TrackerMap = std::map<int, VideoCaptureBufferTracker*>;
85 TrackerMap trackers_;
86
87 const std::unique_ptr<VideoCaptureBufferTrackerFactory>
88 buffer_tracker_factory_;
89
90 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureBufferPoolImpl);
91 };
92
93 } // namespace media
94
95 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_BUFFER_POOL_IMPL_H_
OLDNEW
« no previous file with comments | « media/capture/video/video_capture_buffer_pool.h ('k') | media/capture/video/video_capture_buffer_pool_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698