XRCameraSubsystemDescriptor.cs
13.3 KB
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
using System;
namespace UnityEngine.XR.ARSubsystems
{
/// <summary>
/// Encapsulates the parameters for creating a new <see cref="XRCameraSubsystemDescriptor"/>.
/// </summary>
public struct XRCameraSubsystemCinfo : IEquatable<XRCameraSubsystemCinfo>
{
/// <summary>
/// Specifies an identifier for the provider implementation of the subsystem.
/// </summary>
/// <value>
/// The identifier for the provider implementation of the subsystem.
/// </value>
public string id { get; set; }
/// <summary>
/// Specifies the provider implementation type to use for instantiation.
/// </summary>
/// <value>
/// The provider implementation type to use for instantiation.
/// </value>
public Type implementationType { get; set; }
/// <summary>
/// Specifies if current subsystem is allowed to provide average brightness.
/// </summary>
/// <value>
/// <c>true</c> if current subsystem is allowed to provide average brightness. Otherwise, <c>false</c>.
/// </value>
public bool supportsAverageBrightness { get; set; }
/// <summary>
/// Specifies if current subsystem is allowed to provide average camera temperature.
/// </summary>
/// <value>
/// <c>true</c> if current subsystem is allowed to provide average camera temperature. Otherwise, <c>false</c>.
/// </value>
public bool supportsAverageColorTemperature { get; set; }
/// <summary>
/// True if color correction is supported.
/// </summary>
public bool supportsColorCorrection { get; set; }
/// <summary>
/// Specifies if current subsystem is allowed to provide display matrix.
/// </summary>
/// <value>
/// <c>true</c> if current subsystem is allowed to provide display matrix. Otherwise, <c>false</c>.
/// </value>
public bool supportsDisplayMatrix { get; set; }
/// <summary>
/// Specifies if current subsystem is allowed to provide projection matrix.
/// </summary>
/// <value>
/// <c>true</c> if current subsystem is allowed to provide projection matrix. Otherwise, <c>false</c>.
/// </value>
public bool supportsProjectionMatrix { get; set; }
/// <summary>
/// Specifies if current subsystem is allowed to provide timestamp.
/// </summary>
/// <value>
/// <c>true</c> if current subsystem is allowed to provide timestamp. Otherwise, <c>false</c>.
/// </value>
public bool supportsTimestamp { get; set; }
/// <summary>
/// Specifies if the current subsystem supports camera configurations.
/// </summary>
/// <value>
/// <c>true</c> if the current subsystem supports camera configurations. Otherwise, <c>false</c>.
/// </value>
public bool supportsCameraConfigurations { get; set; }
/// <summary>
/// Specifies if the current subsystem is allowed to provide camera images.
/// </summary>
/// <value>
/// <c>true</c> if the current subsystem is allowed to provide camera images. Otherwise, <c>false</c>.
/// </value>
public bool supportsCameraImage { get; set; }
/// <summary>
/// Specifies if current subsystem is allowed to provide average intensity in lumens.
/// </summary>
/// <value>
/// <c>true</c> if current subsystem is allowed to provide average intensity in lumens. Otherwise, <c>false</c>.
/// </value>
public bool supportsAverageIntensityInLumens { get; set; }
/// <summary>
/// Specifies whether the subsystem supports setting the camera's focus mode.
/// </summary>
public bool supportsFocusModes { get; set; }
public bool Equals(XRCameraSubsystemCinfo other)
{
return
(id == other.id)
&& (implementationType == other.implementationType)
&& supportsAverageBrightness.Equals(other.supportsAverageBrightness)
&& supportsAverageColorTemperature.Equals(other.supportsAverageColorTemperature)
&& supportsDisplayMatrix.Equals(other.supportsDisplayMatrix)
&& supportsProjectionMatrix.Equals(other.supportsProjectionMatrix)
&& supportsTimestamp.Equals(other.supportsTimestamp)
&& supportsCameraConfigurations.Equals(other.supportsCameraConfigurations)
&& supportsCameraImage.Equals(other.supportsCameraImage)
&& supportsAverageIntensityInLumens.Equals(other.supportsAverageIntensityInLumens)
&& supportsFocusModes.Equals(other.supportsFocusModes);
}
public override bool Equals(System.Object obj)
{
return ((obj is XRCameraSubsystemCinfo) && Equals((XRCameraSubsystemCinfo)obj));
}
public static bool operator ==(XRCameraSubsystemCinfo lhs, XRCameraSubsystemCinfo rhs)
{
return lhs.Equals(rhs);
}
public static bool operator !=(XRCameraSubsystemCinfo lhs, XRCameraSubsystemCinfo rhs)
{
return !lhs.Equals(rhs);
}
public override int GetHashCode()
{
int hashCode = 486187739;
unchecked
{
hashCode = (hashCode * 486187739) + (ReferenceEquals(id, null) ? 0 : id.GetHashCode());
hashCode = (hashCode * 486187739) + (ReferenceEquals(implementationType, null) ? 0 : implementationType.GetHashCode());
hashCode = (hashCode * 486187739) + supportsAverageBrightness.GetHashCode();
hashCode = (hashCode * 486187739) + supportsAverageColorTemperature.GetHashCode();
hashCode = (hashCode * 486187739) + supportsDisplayMatrix.GetHashCode();
hashCode = (hashCode * 486187739) + supportsProjectionMatrix.GetHashCode();
hashCode = (hashCode * 486187739) + supportsTimestamp.GetHashCode();
hashCode = (hashCode * 486187739) + supportsCameraConfigurations.GetHashCode();
hashCode = (hashCode * 486187739) + supportsCameraImage.GetHashCode();
hashCode = (hashCode * 486187739) + supportsAverageIntensityInLumens.GetHashCode();
hashCode = (hashCode * 486187739) + supportsFocusModes.GetHashCode();
}
return hashCode;
}
}
/// <summary>
/// Specifies a functionality description that may be registered for each implementation that provides the
/// <see cref="XRCameraSubsystem"/> interface.
/// </summary>
public sealed class XRCameraSubsystemDescriptor : SubsystemDescriptor<XRCameraSubsystem>
{
/// <summary>
/// Constructs a <c>XRCameraSubsystemDescriptor</c> based on the given parameters.
/// </summary>
/// <param name="cameraSubsystemParams">The parameters required to initialize the descriptor.</param>
XRCameraSubsystemDescriptor(XRCameraSubsystemCinfo cameraSubsystemParams)
{
id = cameraSubsystemParams.id;
subsystemImplementationType = cameraSubsystemParams.implementationType;
supportsAverageBrightness = cameraSubsystemParams.supportsAverageBrightness;
supportsAverageColorTemperature = cameraSubsystemParams.supportsAverageColorTemperature;
supportsDisplayMatrix = cameraSubsystemParams.supportsDisplayMatrix;
supportsProjectionMatrix = cameraSubsystemParams.supportsProjectionMatrix;
supportsTimestamp = cameraSubsystemParams.supportsTimestamp;
supportsCameraConfigurations = cameraSubsystemParams.supportsCameraConfigurations;
supportsCameraImage = cameraSubsystemParams.supportsCameraImage;
supportsAverageIntensityInLumens = cameraSubsystemParams.supportsAverageIntensityInLumens;
supportsFocusModes = cameraSubsystemParams.supportsFocusModes;
}
/// <summary>
/// Specifies if current subsystem is allowed to provide average brightness.
/// </summary>
/// <value>
/// <c>true</c> if current subsystem is allowed to provide average brightness. Otherwise, <c>false</c>.
/// </value>
public bool supportsAverageBrightness { get; private set; }
/// <summary>
/// Specifies if current subsystem is allowed to provide average camera temperature.
/// </summary>
/// <value>
/// <c>true</c> if current subsystem is allowed to provide average camera temperature. Otherwise, <c>false</c>.
/// </value>
public bool supportsAverageColorTemperature { get; private set; }
/// <summary>
/// Specifies if current subsystem is allowed to provide display matrix.
/// </summary>
/// <value>
/// <c>true</c> if current subsystem is allowed to provide display matrix. Otherwise, <c>false</c>.
/// </value>
public bool supportsDisplayMatrix { get; private set; }
/// <summary>
/// Specifies if current subsystem is allowed to provide projection matrix.
/// </summary>
/// <value>
/// <c>true</c> if current subsystem is allowed to provide projection matrix. Otherwise, <c>false</c>.
/// </value>
public bool supportsProjectionMatrix { get; private set; }
/// <summary>
/// Specifies if current subsystem is allowed to provide timestamp.
/// </summary>
/// <value>
/// <c>true</c> if current subsystem is allowed to provide timestamp. Otherwise, <c>false</c>.
/// </value>
public bool supportsTimestamp { get; private set; }
/// <summary>
/// Specifies if the current subsystem supports camera configurations.
/// </summary>
/// <value>
/// <c>true</c> if the current subsystem supports camera configurations. Otherwise, <c>false</c>.
/// </value>
public bool supportsCameraConfigurations { get; private set; }
/// <summary>
/// Specifies if the current subsystem is allowed to provide camera images.
/// </summary>
/// <value>
/// <c>true</c> if the current subsystem is allowed to provide camera images. Otherwise, <c>false</c>.
/// </value>
public bool supportsCameraImage { get; private set; }
/// <summary>
/// Specifies if current subsystem is allowed to provide average intensity in lumens.
/// </summary>
/// <value>
/// <c>true</c> if current subsystem is allowed to provide average intensity in lumens. Otherwise, <c>false</c>.
/// </value>
public bool supportsAverageIntensityInLumens { get; private set; }
/// <summary>
/// Specifies whether the subsystem supports setting the camera's focus mode.
/// </summary>
public bool supportsFocusModes { get; private set; }
/// <summary>
/// Creates a <c>XRCameraSubsystemDescriptor</c> based on the given parameters validating that the
/// <see cref="XRCameraSubsystemCinfo.id"/> and <see cref="XRCameraSubsystemCinfo.implementationType"/>
/// properties are properly specified.
/// </summary>
/// <param name="cameraSubsystemParams">The parameters defining how to initialize the descriptor.</param>
/// <returns>
/// The created <c>XRCameraSubsystemDescriptor</c>.
/// </returns>
/// <exception cref="System.ArgumentException">Thrown when the values specified in the
/// <see cref="XRCameraSubsystemCinfo"/> parameter are invalid. Typically, this will occur
/// <list type="bullet">
/// <item>
/// <description>if <see cref="XRCameraSubsystemCinfo.id"/> is <c>null</c> or empty</description>
/// </item>
/// <item>
/// <description>if <see cref="XRCameraSubsystemCinfo.implementationType"/> is <c>null</c></description>
/// </item>
/// <item>
/// <description>if <see cref="XRCameraSubsystemCinfo.implementationType"/> does not derive from the
/// <see cref="XRCameraSubsystem"/> class
/// </description>
/// </item>
/// </list>
/// </exception>
internal static XRCameraSubsystemDescriptor Create(XRCameraSubsystemCinfo cameraSubsystemParams)
{
if (String.IsNullOrEmpty(cameraSubsystemParams.id))
{
throw new ArgumentException("Cannot create camera subsystem descriptor because id is invalid",
"cameraSubsystemParams");
}
if ((cameraSubsystemParams.implementationType == null)
|| !cameraSubsystemParams.implementationType.IsSubclassOf(typeof(XRCameraSubsystem)))
{
throw new ArgumentException("Cannot create camera subsystem descriptor because implementationType is invalid",
"cameraSubsystemParams");
}
return new XRCameraSubsystemDescriptor(cameraSubsystemParams);
}
}
}