OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_BUFFER_POOL_H_ | 5 #ifndef MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_BUFFER_POOL_H_ |
6 #define MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_BUFFER_POOL_H_ | 6 #define MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_BUFFER_POOL_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "media/capture/capture_export.h" | 9 #include "media/capture/capture_export.h" |
10 #include "media/capture/video_capture_types.h" | 10 #include "media/capture/video_capture_types.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 // some methods to indicate failure. The active set of buffer ids may change | 35 // some methods to indicate failure. The active set of buffer ids may change |
36 // over the lifetime of the buffer pool, as existing buffers are freed and | 36 // over the lifetime of the buffer pool, as existing buffers are freed and |
37 // reallocated at larger size. When reallocation occurs, new buffer IDs will | 37 // reallocated at larger size. When reallocation occurs, new buffer IDs will |
38 // circulate. | 38 // circulate. |
39 class CAPTURE_EXPORT VideoCaptureBufferPool | 39 class CAPTURE_EXPORT VideoCaptureBufferPool |
40 : public base::RefCountedThreadSafe<VideoCaptureBufferPool> { | 40 : public base::RefCountedThreadSafe<VideoCaptureBufferPool> { |
41 public: | 41 public: |
42 static constexpr int kInvalidId = -1; | 42 static constexpr int kInvalidId = -1; |
43 | 43 |
44 // One-time (per client/per-buffer) call to allow sharing |buffer_id|. | 44 // One-time (per client/per-buffer) call to allow sharing |buffer_id|. |
45 virtual mojo::ScopedSharedBufferHandle GetHandleForInterProcessTransit( | 45 virtual mojo::ScopedSharedBufferHandle GetHandleForTransit(int buffer_id) = 0; |
46 int buffer_id) = 0; | |
47 | 46 |
48 // Try and obtain a read/write access to the buffer. | 47 // Try and obtain a BufferHandle for |buffer_id|. |
49 virtual std::unique_ptr<VideoCaptureBufferHandle> GetHandleForInProcessAccess( | 48 virtual std::unique_ptr<VideoCaptureBufferHandle> GetBufferHandle( |
50 int buffer_id) = 0; | 49 int buffer_id) = 0; |
51 | 50 |
52 // Reserve or allocate a buffer to support a packed frame of |dimensions| of | 51 // Reserve or allocate a buffer to support a packed frame of |dimensions| of |
53 // pixel |format| and return its id. This will fail (returning kInvalidId) if | 52 // pixel |format| and return its id. This will fail (returning kInvalidId) if |
54 // the pool already is at its |count| limit of the number of allocations, and | 53 // the pool already is at its |count| limit of the number of allocations, and |
55 // all allocated buffers are in use by the producer and/or consumers. | 54 // all allocated buffers are in use by the producer and/or consumers. |
56 // | 55 // |
57 // If successful, the reserved buffer remains reserved (and writable by the | 56 // If successful, the reserved buffer remains reserved (and writable by the |
58 // producer) until ownership is transferred either to the consumer via | 57 // producer) until ownership is transferred either to the consumer via |
59 // HoldForConsumers(), or back to the pool with | 58 // HoldForConsumers(), or back to the pool with |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 protected: | 101 protected: |
103 virtual ~VideoCaptureBufferPool() {} | 102 virtual ~VideoCaptureBufferPool() {} |
104 | 103 |
105 private: | 104 private: |
106 friend class base::RefCountedThreadSafe<VideoCaptureBufferPool>; | 105 friend class base::RefCountedThreadSafe<VideoCaptureBufferPool>; |
107 }; | 106 }; |
108 | 107 |
109 } // namespace media | 108 } // namespace media |
110 | 109 |
111 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_BUFFER_POOL_H_ | 110 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_BUFFER_POOL_H_ |
OLD | NEW |