| 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 GetHandleForTransit(int buffer_id) = 0; | 45 virtual mojo::ScopedSharedBufferHandle GetHandleForInterProcessTransit( |
| 46 int buffer_id) = 0; |
| 46 | 47 |
| 47 // Try and obtain a BufferHandle for |buffer_id|. | 48 virtual base::SharedMemoryHandle GetNonOwnedSharedMemoryHandleForLegacyIPC( |
| 48 virtual std::unique_ptr<VideoCaptureBufferHandle> GetBufferHandle( | 49 int buffer_id) = 0; |
| 50 |
| 51 // Try and obtain a read/write access to the buffer. |
| 52 virtual std::unique_ptr<VideoCaptureBufferHandle> GetHandleForInProcessAccess( |
| 49 int buffer_id) = 0; | 53 int buffer_id) = 0; |
| 50 | 54 |
| 51 // Reserve or allocate a buffer to support a packed frame of |dimensions| of | 55 // Reserve or allocate a buffer to support a packed frame of |dimensions| of |
| 52 // pixel |format| and return its id. This will fail (returning kInvalidId) if | 56 // pixel |format| and return its id. This will fail (returning kInvalidId) if |
| 53 // the pool already is at its |count| limit of the number of allocations, and | 57 // the pool already is at its |count| limit of the number of allocations, and |
| 54 // all allocated buffers are in use by the producer and/or consumers. | 58 // all allocated buffers are in use by the producer and/or consumers. |
| 55 // | 59 // |
| 56 // If successful, the reserved buffer remains reserved (and writable by the | 60 // If successful, the reserved buffer remains reserved (and writable by the |
| 57 // producer) until ownership is transferred either to the consumer via | 61 // producer) until ownership is transferred either to the consumer via |
| 58 // HoldForConsumers(), or back to the pool with | 62 // HoldForConsumers(), or back to the pool with |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 protected: | 105 protected: |
| 102 virtual ~VideoCaptureBufferPool() {} | 106 virtual ~VideoCaptureBufferPool() {} |
| 103 | 107 |
| 104 private: | 108 private: |
| 105 friend class base::RefCountedThreadSafe<VideoCaptureBufferPool>; | 109 friend class base::RefCountedThreadSafe<VideoCaptureBufferPool>; |
| 106 }; | 110 }; |
| 107 | 111 |
| 108 } // namespace media | 112 } // namespace media |
| 109 | 113 |
| 110 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_BUFFER_POOL_H_ | 114 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_BUFFER_POOL_H_ |
| OLD | NEW |