| 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 26 matching lines...) Expand all Loading... |
| 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 GetHandleForTransit(int buffer_id) = 0; |
| 46 | 46 |
| 47 // Try and obtain a BufferHandle for |buffer_id|. | 47 // Try and obtain a read/write access to the buffer. |
| 48 virtual std::unique_ptr<VideoCaptureBufferHandle> GetBufferHandle( | 48 virtual std::unique_ptr<VideoCaptureBufferHandle> GetReadWriteAccess( |
| 49 int buffer_id) = 0; | 49 int buffer_id) = 0; |
| 50 | 50 |
| 51 // 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 |
| 52 // 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 |
| 53 // 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 |
| 54 // 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. |
| 55 // | 55 // |
| 56 // If successful, the reserved buffer remains reserved (and writable by the | 56 // If successful, the reserved buffer remains reserved (and writable by the |
| 57 // producer) until ownership is transferred either to the consumer via | 57 // producer) until ownership is transferred either to the consumer via |
| 58 // 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... |
| 101 protected: | 101 protected: |
| 102 virtual ~VideoCaptureBufferPool() {} | 102 virtual ~VideoCaptureBufferPool() {} |
| 103 | 103 |
| 104 private: | 104 private: |
| 105 friend class base::RefCountedThreadSafe<VideoCaptureBufferPool>; | 105 friend class base::RefCountedThreadSafe<VideoCaptureBufferPool>; |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 } // namespace media | 108 } // namespace media |
| 109 | 109 |
| 110 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_BUFFER_POOL_H_ | 110 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_BUFFER_POOL_H_ |
| OLD | NEW |