summaryrefslogtreecommitdiff
path: root/chromium/media/capture/video/chromeos/mojom/cros_camera_service.mojom
blob: dec0a5017ff70516c9650dd4ec7c9834505d32d4 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// 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.

// Next min version: 6

module cros.mojom;

import "components/chromeos_camera/common/jpeg_encode_accelerator.mojom";
import "components/chromeos_camera/common/mjpeg_decode_accelerator.mojom";
import "media/capture/video/chromeos/mojom/camera_common.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";

// CameraClientType indicates the type of a CameraHalClient.
// It should be kept in sync with the ChromeOSCameraClientType enum in
// tools/metrics/histograms/enums.xml
[Extensible]
enum CameraClientType{
  UNKNOWN = 0,
  TESTING = 1,
  CHROME = 2,
  ANDROID = 3,
  PLUGINVM = 4,
  ASH_CHROME = 5,
  LACROS_CHROME = 6,
};

// CameraPrivacySwitchState indicates the state of the camera privacy switch.
enum CameraPrivacySwitchState{
  // For devices which can only read the privacy switch status while the camera
  // is streaming, it is possible that the state of privacy switch is currently
  // unknown.
  UNKNOWN = 0,

  // State when the privacy switch is on, which means the black frames will be
  // delivered when streaming.
  ON = 1,

  // State when the privacy switch is off, which means camera should stream
  // normally.
  OFF = 2,
};

// The CrOS camera HAL v3 Mojo dispatcher.  The dispatcher acts as a proxy and
// waits for the server and the clients to register.  There can only be one
// server registered, with multiple clients requesting connections to the
// server.  For each client, the dispatcher is responsible for creating a Mojo
// channel to the server and pass the established Mojo channel to the client in
// order to set up a Mojo channel between the client and the server.
//
// Next method ID: 6
interface CameraHalDispatcher {
  // [Deprecated in version 4]
  // A CameraHalServer calls RegisterServer to register itself with the
  // dispatcher.
  RegisterServer@0(pending_remote<CameraHalServer> server);

  // [Deprecated in version 4]
  // A CameraHalClient calls RegisterClient to register itself with the
  // dispatcher.
  RegisterClient@1(pending_remote<CameraHalClient> client);

  // Get JpegDecodeAccelerator from dispatcher.
  [MinVersion=1] GetJpegDecodeAccelerator@2(
    pending_receiver<chromeos_camera.mojom.MjpegDecodeAccelerator>
        jda_receiver);

  // Get JpegEncodeAccelerator from dispatcher.
  [MinVersion=2] GetJpegEncodeAccelerator@3(
    pending_receiver<chromeos_camera.mojom.JpegEncodeAccelerator> jea_receiver);

  // A CameraHalServer calls RegisterServerWithToken to register itself with the
  // dispatcher. CameraHalDispatcher would authenticate the server with the
  // supplied |auth_token|. |callbacks| is fired by CameraHalServer to notify
  // CameraHalDispatcher about CameraHalClient updates, for example when a
  // CameraHalClient opens or closes a camera device.
  [MinVersion=4] RegisterServerWithToken@4(
      pending_remote<CameraHalServer> server,
      mojo_base.mojom.UnguessableToken auth_token) =>
      (int32 result, pending_remote<CameraHalServerCallbacks> callbacks);

  // A CameraHalClient calls RegisterClient to register itself with the
  // dispatcher. CameraHalDispatcher would authenticate the client with the
  // given |type| and |auth_token|.
  [MinVersion=4] RegisterClientWithToken@5(
      pending_remote<CameraHalClient> client,
      CameraClientType type,
      mojo_base.mojom.UnguessableToken auth_token) => (int32 result);

};

// The CrOS camera HAL v3 Mojo server.
//
// Next method ID: 2
interface CameraHalServer {
  // A caller calls CreateChannel to create a new Mojo channel to the camera
  // HAL v3 adapter.  Upon successfully binding of |camera_module_request|, the
  // caller will have a established Mojo channel to the camera HAL v3 adapter
  // process.
  CreateChannel@0(pending_receiver<CameraModule> camera_module_request,
                  [MinVersion=4] CameraClientType type);

  // Enable or disable tracing.
  [MinVersion=3]
  SetTracingEnabled@1(bool enabled);
};

// CameraHalServerCallbacks is an interface for CameraHalServer to notify
// CameraHalDispatcher for any changes on the server side, for example when a
// CameraHalClient opens or closes a camera device.
//
// Next method ID: 2
interface CameraHalServerCallbacks {
  // Fired when a CameraHalClient opens or closes a camera device. When a
  // CameraHalClient loses mojo connection to CameraHalServer, CameraHalServer
  // would also use this to notify that cameras are closed (not being used).
  CameraDeviceActivityChange@0(int32 camera_id,
                               bool opened,
                               CameraClientType type);

  // Fired when the camera privacy switch status is changed. If the device has
  // such switch, this callback will be fired immediately for once to notify its
  // current status when the callbacks are registered.
  [MinVersion=5]
  CameraPrivacySwitchStateChange@1(CameraPrivacySwitchState state);
};

// The CrOS camera HAL v3 Mojo client.
//
// Next method ID: 1
interface CameraHalClient {
  // A caller calls SetUpChannel to dispatch the established Mojo channel
  // |camera_module_ptr| to the client.  The CameraHalClient can create a
  // Mojo channel to the camera HAL v3 adapter process with |camera_module_ptr|.
  // SetUpChannel may be called multiple times.  In cases such as the
  // CameraHalServer which holds the original Mojo channel crashes,
  // CameraHalDispatcher will call SetUpChannel again once a new CameraHalServer
  // reconnects.
  SetUpChannel@0(pending_remote<CameraModule> camera_module_ptr);
};