blob: 970c199e4d2b990def0f65b4d131068390f6b951 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// Copyright 2017 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_CAPTURE_VIDEO_CHROMEOS_VIDEO_CAPTURE_DEVICE_FACTORY_CHROMEOS_H_
#define MEDIA_CAPTURE_VIDEO_CHROMEOS_VIDEO_CAPTURE_DEVICE_FACTORY_CHROMEOS_H_
#include <memory>
#include "base/macros.h"
#include "base/single_thread_task_runner.h"
#include "components/chromeos_camera/common/mjpeg_decode_accelerator.mojom.h"
#include "media/capture/video/chromeos/camera_hal_delegate.h"
#include "media/capture/video/video_capture_device_factory.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
namespace media {
using MojoMjpegDecodeAcceleratorFactoryCB = base::RepeatingCallback<void(
mojo::PendingReceiver<chromeos_camera::mojom::MjpegDecodeAccelerator>)>;
class CAPTURE_EXPORT VideoCaptureDeviceFactoryChromeOS final
: public VideoCaptureDeviceFactory {
public:
explicit VideoCaptureDeviceFactoryChromeOS(
scoped_refptr<base::SingleThreadTaskRunner>
task_runner_for_screen_observer);
~VideoCaptureDeviceFactoryChromeOS() override;
// VideoCaptureDeviceFactory interface implementations.
std::unique_ptr<VideoCaptureDevice> CreateDevice(
const VideoCaptureDeviceDescriptor& device_descriptor) final;
void GetDevicesInfo(GetDevicesInfoCallback callback) override;
static gpu::GpuMemoryBufferManager* GetBufferManager();
static void SetGpuBufferManager(gpu::GpuMemoryBufferManager* buffer_manager);
private:
// Initializes the factory. The factory is functional only after this call
// succeeds.
bool Init();
const scoped_refptr<base::SingleThreadTaskRunner>
task_runner_for_screen_observer_;
// The thread that all the Mojo operations of |camera_hal_delegate_| take
// place. Started in Init and stopped when the class instance is destroyed.
base::Thread camera_hal_ipc_thread_;
// Communication interface to the camera HAL. |camera_hal_delegate_| is
// created on the thread on which Init is called. All the Mojo communication
// that |camera_hal_delegate_| issues and receives must be sequenced through
// |camera_hal_ipc_thread_|.
scoped_refptr<CameraHalDelegate> camera_hal_delegate_;
bool initialized_;
base::WeakPtrFactory<VideoCaptureDeviceFactoryChromeOS> weak_ptr_factory_{
this};
DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceFactoryChromeOS);
};
} // namespace media
#endif // MEDIA_CAPTURE_VIDEO_CHROMEOS_VIDEO_CAPTURE_DEVICE_FACTORY_CHROMEOS_H_
|