Chromium Code Reviews| Index: media/capture/video/video_capture_buffer_pool.h |
| diff --git a/content/browser/renderer_host/media/video_capture_buffer_pool.h b/media/capture/video/video_capture_buffer_pool.h |
| similarity index 62% |
| rename from content/browser/renderer_host/media/video_capture_buffer_pool.h |
| rename to media/capture/video/video_capture_buffer_pool.h |
| index 4dc59acb146831ee11b1d58bd424d8a9796bac2b..2a61940a71499df2e2f6923a96f1aecddfe87000 100644 |
| --- a/content/browser/renderer_host/media/video_capture_buffer_pool.h |
| +++ b/media/capture/video/video_capture_buffer_pool.h |
| @@ -1,33 +1,40 @@ |
| -// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_BUFFER_POOL_H_ |
| -#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_BUFFER_POOL_H_ |
| +#ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_BUFFER_POOL_H_ |
| +#define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_BUFFER_POOL_H_ |
| -#include <stddef.h> |
| - |
| -#include <map> |
| - |
| -#include "base/files/file.h" |
| -#include "base/macros.h" |
| #include "base/memory/ref_counted.h" |
| -#include "base/memory/shared_memory.h" |
| -#include "base/process/process.h" |
| -#include "base/synchronization/lock.h" |
| -#include "build/build_config.h" |
| -#include "content/common/content_export.h" |
| #include "media/base/video_capture_types.h" |
| -#include "media/base/video_frame.h" |
| +#include "media/capture/capture_export.h" |
| +#include "media/capture/video/video_capture_buffer_handle.h" |
|
mcasas
2016/09/27 00:12:57
Nit: VideoCaptureBufferHandle can be fwd declared?
chfremer
2016/09/27 22:32:27
Done.
|
| #include "ui/gfx/geometry/size.h" |
| #include "ui/gfx/gpu_memory_buffer.h" |
| -namespace content { |
| +namespace media { |
| -class VideoCaptureBufferHandle; |
| -class VideoCaptureBufferTracker; |
| - |
| -class CONTENT_EXPORT VideoCaptureBufferPool |
| +// A thread-safe class that does the bookkeeping and lifetime management for a |
| +// pool of pixel buffers cycled between an in-process producer (e.g. a |
| +// VideoCaptureDevice) and a set of out-of-process consumers. The pool is |
| +// intended to be orchestrated by a VideoCaptureDevice::Client, but is designed |
| +// to outlive the controller if necessary. The pixel buffers may be backed by a |
| +// SharedMemory, but this is not compulsory. |
| +// |
| +// Producers get a buffer by calling ReserveForProducer(), and may pass on their |
| +// ownership to the consumer by calling HoldForConsumers(), or drop the buffer |
| +// (without further processing) by calling RelinquishProducerReservation(). |
| +// Consumers signal that they are done with the buffer by calling |
| +// RelinquishConsumerHold(). |
| +// |
| +// Buffers are allocated on demand, but there will never be more than |count| |
| +// buffers in existence at any time. Buffers are identified by an int value |
| +// called |buffer_id|. -1 (kInvalidId) is never a valid ID, and is returned by |
| +// some methods to indicate failure. The active set of buffer ids may change |
| +// over the lifetime of the buffer pool, as existing buffers are freed and |
| +// reallocated at larger size. When reallocation occurs, new buffer IDs will |
| +// circulate. |
| +class CAPTURE_EXPORT VideoCaptureBufferPool |
| : public base::RefCountedThreadSafe<VideoCaptureBufferPool> { |
| public: |
| static constexpr int kInvalidId = -1; |
| @@ -102,84 +109,6 @@ class CONTENT_EXPORT VideoCaptureBufferPool |
| friend class base::RefCountedThreadSafe<VideoCaptureBufferPool>; |
| }; |
| -// A thread-safe class that does the bookkeeping and lifetime management for a |
| -// pool of pixel buffers cycled between an in-process producer (e.g. a |
| -// VideoCaptureDevice) and a set of out-of-process consumers. The pool is |
| -// intended to be orchestrated by a VideoCaptureDevice::Client, but is designed |
| -// to outlive the controller if necessary. The pixel buffers may be backed by a |
| -// SharedMemory, but this is not compulsory. |
| -// |
| -// Producers get a buffer by calling ReserveForProducer(), and may pass on their |
| -// ownership to the consumer by calling HoldForConsumers(), or drop the buffer |
| -// (without further processing) by calling RelinquishProducerReservation(). |
| -// Consumers signal that they are done with the buffer by calling |
| -// RelinquishConsumerHold(). |
| -// |
| -// Buffers are allocated on demand, but there will never be more than |count| |
| -// buffers in existence at any time. Buffers are identified by an int value |
| -// called |buffer_id|. -1 (kInvalidId) is never a valid ID, and is returned by |
| -// some methods to indicate failure. The active set of buffer ids may change |
| -// over the lifetime of the buffer pool, as existing buffers are freed and |
| -// reallocated at larger size. When reallocation occurs, new buffer IDs will |
| -// circulate. |
| -class CONTENT_EXPORT VideoCaptureBufferPoolImpl |
| - : public VideoCaptureBufferPool { |
| - public: |
| - explicit VideoCaptureBufferPoolImpl(int count); |
| - |
| - // Implementation of VideoCaptureBufferPool interface: |
| - bool ShareToProcess(int buffer_id, |
| - base::ProcessHandle process_handle, |
| - base::SharedMemoryHandle* new_handle) override; |
| - bool ShareToProcess2(int buffer_id, |
| - int plane, |
| - base::ProcessHandle process_handle, |
| - gfx::GpuMemoryBufferHandle* new_handle) override; |
| - std::unique_ptr<VideoCaptureBufferHandle> GetBufferHandle( |
| - int buffer_id) override; |
| - int ReserveForProducer(const gfx::Size& dimensions, |
| - media::VideoPixelFormat format, |
| - media::VideoPixelStorage storage, |
| - int* buffer_id_to_drop) override; |
| - void RelinquishProducerReservation(int buffer_id) override; |
| - int ResurrectLastForProducer(const gfx::Size& dimensions, |
| - media::VideoPixelFormat format, |
| - media::VideoPixelStorage storage) override; |
| - double GetBufferPoolUtilization() const override; |
| - void HoldForConsumers(int buffer_id, int num_clients) override; |
| - void RelinquishConsumerHold(int buffer_id, int num_clients) override; |
| - |
| - private: |
| - friend class base::RefCountedThreadSafe<VideoCaptureBufferPoolImpl>; |
| - ~VideoCaptureBufferPoolImpl() override; |
| - |
| - int ReserveForProducerInternal(const gfx::Size& dimensions, |
| - media::VideoPixelFormat format, |
| - media::VideoPixelStorage storage, |
| - int* tracker_id_to_drop); |
| - |
| - VideoCaptureBufferTracker* GetTracker(int buffer_id); |
| - |
| - // The max number of buffers that the pool is allowed to have at any moment. |
| - const int count_; |
| - |
| - // Protects everything below it. |
| - mutable base::Lock lock_; |
| - |
| - // The ID of the next buffer. |
| - int next_buffer_id_; |
| - |
| - // The ID of the buffer last relinquished by the producer (a candidate for |
| - // resurrection). |
| - int last_relinquished_buffer_id_; |
| - |
| - // The buffers, indexed by the first parameter, a buffer id. |
| - using TrackerMap = std::map<int, VideoCaptureBufferTracker*>; |
| - TrackerMap trackers_; |
| - |
| - DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureBufferPoolImpl); |
| -}; |
| - |
| -} // namespace content |
| +} // namespace media |
| -#endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_BUFFER_POOL_H_ |
| +#endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_BUFFER_POOL_H_ |