| Index: media/capture/video/video_capture_buffer_pool_impl.h
|
| diff --git a/media/capture/video/video_capture_buffer_pool_impl.h b/media/capture/video/video_capture_buffer_pool_impl.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..aa9436703a2a363189cfa982501bd6f85a6d2ffd
|
| --- /dev/null
|
| +++ b/media/capture/video/video_capture_buffer_pool_impl.h
|
| @@ -0,0 +1,95 @@
|
| +// Copyright (c) 2013 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 MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_BUFFER_POOL_IMPL_H_
|
| +#define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_BUFFER_POOL_IMPL_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 "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"
|
| +#include "media/capture/video/video_capture_buffer_pool.h"
|
| +#include "media/capture/video/video_capture_buffer_tracker_factory.h"
|
| +#include "ui/gfx/geometry/size.h"
|
| +#include "ui/gfx/gpu_memory_buffer.h"
|
| +
|
| +namespace media {
|
| +
|
| +class CAPTURE_EXPORT VideoCaptureBufferPoolImpl
|
| + : public VideoCaptureBufferPool {
|
| + public:
|
| + explicit VideoCaptureBufferPoolImpl(
|
| + std::unique_ptr<VideoCaptureBufferTrackerFactory> buffer_tracker_factory,
|
| + 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_;
|
| +
|
| + const std::unique_ptr<VideoCaptureBufferTrackerFactory>
|
| + buffer_tracker_factory_;
|
| +
|
| + DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureBufferPoolImpl);
|
| +};
|
| +
|
| +} // namespace media
|
| +
|
| +#endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_BUFFER_POOL_IMPL_H_
|
|
|