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
68
69
70
71
72
content / renderer / pepper / pepper_camera_device_host.h [blame]
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_RENDERER_PEPPER_PEPPER_CAMERA_DEVICE_HOST_H_
#define CONTENT_RENDERER_PEPPER_PEPPER_CAMERA_DEVICE_HOST_H_
#include <stdint.h>
#include <memory>
#include "base/memory/raw_ptr.h"
#include "content/public/renderer/renderer_ppapi_host.h"
#include "content/renderer/pepper/ppb_buffer_impl.h"
#include "ppapi/c/pp_size.h"
#include "ppapi/c/private/pp_video_capture_format.h"
#include "ppapi/host/host_message_context.h"
#include "ppapi/host/resource_host.h"
namespace content {
class PepperPlatformCameraDevice;
class RendererPpapiHostImpl;
class PepperCameraDeviceHost : public ppapi::host::ResourceHost {
public:
PepperCameraDeviceHost(RendererPpapiHostImpl* host,
PP_Instance instance,
PP_Resource resource);
PepperCameraDeviceHost(const PepperCameraDeviceHost&) = delete;
PepperCameraDeviceHost& operator=(const PepperCameraDeviceHost&) = delete;
~PepperCameraDeviceHost() override;
bool Init();
int32_t OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) override;
// These methods are called by PepperPlatformCameraDevice only.
// Called when camera device is initialized.
void OnInitialized(bool succeeded);
// Called when the video capture formats are enumerated.
void OnVideoCaptureFormatsEnumerated(
const std::vector<PP_VideoCaptureFormat>& formats);
private:
// Plugin -> host message handlers.
int32_t OnOpen(ppapi::host::HostMessageContext* context,
const std::string& device_id);
int32_t OnClose(ppapi::host::HostMessageContext* context);
int32_t OnGetSupportedVideoCaptureFormats(
ppapi::host::HostMessageContext* context);
// Utility methods.
void DetachPlatformCameraDevice();
std::unique_ptr<PepperPlatformCameraDevice> platform_camera_device_;
raw_ptr<RendererPpapiHostImpl> renderer_ppapi_host_;
ppapi::host::ReplyMessageContext open_reply_context_;
ppapi::host::ReplyMessageContext video_capture_formats_reply_context_;
};
} // namespace content
#endif // CONTENT_RENDERER_PEPPER_PEPPER_CAMERA_DEVICE_HOST_H_