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

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

Issue 2361173002: Move classses VideoCaptureDeviceClient and VideoCaptureBufferPool to media/capture/video (Closed)
Patch Set: 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 2016 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_H_
6 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_BUFFER_POOL_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "media/base/video_capture_types.h"
10 #include "media/capture/capture_export.h"
11 #include "media/capture/video/video_capture_buffer_handle.h"
12 #include "ui/gfx/geometry/size.h"
13 #include "ui/gfx/gpu_memory_buffer.h"
14
15 namespace media {
16
17 class CAPTURE_EXPORT VideoCaptureBufferPool
18 : public base::RefCountedThreadSafe<VideoCaptureBufferPool> {
19 public:
20 static constexpr int kInvalidId = -1;
21
22 // One-time (per client/per-buffer) initialization to share a particular
23 // buffer to a process. The shared handle is returned as |new_handle|.
24 virtual bool ShareToProcess(int buffer_id,
25 base::ProcessHandle process_handle,
26 base::SharedMemoryHandle* new_handle) = 0;
27 virtual bool ShareToProcess2(int buffer_id,
28 int plane,
29 base::ProcessHandle process_handle,
30 gfx::GpuMemoryBufferHandle* new_handle) = 0;
31
32 // Try and obtain a BufferHandle for |buffer_id|.
33 virtual std::unique_ptr<VideoCaptureBufferHandle> GetBufferHandle(
34 int buffer_id) = 0;
35
36 // Reserve or allocate a buffer to support a packed frame of |dimensions| of
37 // pixel |format| and return its id. This will fail (returning kInvalidId) if
38 // the pool already is at its |count| limit of the number of allocations, and
39 // all allocated buffers are in use by the producer and/or consumers.
40 //
41 // If successful, the reserved buffer remains reserved (and writable by the
42 // producer) until ownership is transferred either to the consumer via
43 // HoldForConsumers(), or back to the pool with
44 // RelinquishProducerReservation().
45 //
46 // On occasion, this call will decide to free an old buffer to make room for a
47 // new allocation at a larger size. If so, the ID of the destroyed buffer is
48 // returned via |buffer_id_to_drop|.
49 virtual int ReserveForProducer(const gfx::Size& dimensions,
50 media::VideoPixelFormat format,
51 media::VideoPixelStorage storage,
52 int* buffer_id_to_drop) = 0;
53
54 // Indicate that a buffer held for the producer should be returned back to the
55 // pool without passing on to the consumer. This effectively is the opposite
56 // of ReserveForProducer().
57 virtual void RelinquishProducerReservation(int buffer_id) = 0;
58
59 // Attempt to reserve the same buffer that was relinquished in the last call
60 // to RelinquishProducerReservation(). If the buffer is not still being
61 // consumed, and has not yet been re-used since being consumed, and the
62 // specified |dimensions|, |format|, and |storage| agree with its last
63 // reservation, this will succeed. Otherwise, |kInvalidId| will be returned.
64 //
65 // A producer may assume the content of the buffer has been preserved and may
66 // also make modifications.
67 virtual int ResurrectLastForProducer(const gfx::Size& dimensions,
68 media::VideoPixelFormat format,
69 media::VideoPixelStorage storage) = 0;
70
71 // Returns a snapshot of the current number of buffers in-use divided by the
72 // maximum |count_|.
73 virtual double GetBufferPoolUtilization() const = 0;
74
75 // Transfer a buffer from producer to consumer ownership.
76 // |buffer_id| must be a buffer index previously returned by
77 // ReserveForProducer(), and not already passed to HoldForConsumers().
78 virtual void HoldForConsumers(int buffer_id, int num_clients) = 0;
79
80 // Indicate that one or more consumers are done with a particular buffer. This
81 // effectively is the opposite of HoldForConsumers(). Once the consumers are
82 // done, a buffer is returned to the pool for reuse.
83 virtual void RelinquishConsumerHold(int buffer_id, int num_clients) = 0;
84
85 protected:
86 virtual ~VideoCaptureBufferPool() {}
87
88 private:
89 friend class base::RefCountedThreadSafe<VideoCaptureBufferPool>;
90 };
91
92 } // namespace media
93
94 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_BUFFER_POOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698