The types that say what the connected camera is and can do now: what getCapabilities() returns, what setControl takes, and which model was identified. This is one of the 5 pages of the types reference, which names every type. A field ending in ? may be absent: Slate leaves out what a camera does not report, and never guesses it.
import type { CameraCapabilities, CameraControlState } from '@darkgrade/slate'Capabilities and controls
What getCapabilities() returns and setControl takes.
CameraRecordingState
What getRecordingState resolves to. unknown never counts as idle.
type CameraRecordingState =
| 'idle'
| 'recording'
| 'starting'
| 'stopping'
| 'unknown'OperationAvailability
One operation's availability now: an unsupported one says why, in words a user can act on. options covers optional parts of an operation, such as a live-view overlay.
interface OperationAvailability {
supported: boolean
reason?: string
options?: Partial<Record<string, OperationAvailability>>
}Show OperationAvailability fieldsHide OperationAvailability fields
Whether the operation can run now.
Why not, when it cannot.
The same for the operation's optional parts, by name.
CameraCapabilities
What getCapabilities resolves to: every setting, the lens, and which operations work now.
interface CameraCapabilities {
observedAt: number
controls: Partial<Record<CameraControlId, CameraControlState>>
advertisedOperations: number[] | null
lens?: CameraLens
operations?: Partial<
Record<CameraOperationName, OperationAvailability>
>
}Show CameraCapabilities fieldsHide CameraCapabilities fields
When the camera was read, in milliseconds since the Unix epoch (Date.now()).
Every setting the camera has now, by id. It is what the camera reports at this moment, not a promise for the model: a mode, lens or card change can add or remove one.
The PTP operation codes the camera lists in its DeviceInfo, or null when it gives none. A listed code does not prove the operation works: operations says what does.
The attached lens, from the same observation as controls; absent when the camera reports neither field.
See CameraLens.
Whether each public operation is possible right now, with the reason when it is not. Camera fills this from its driver's capability groups; an operation absent here has no availability report yet, and a call still answers CameraUnsupportedError when it cannot run.
CameraControlId
A setting id, such as iso or shutterSpeed. The settings reference lists every one.
type CameraControlId = keyof typeof cameraControlDefinitionsEvery value (33)
Every value (33)
shutterSpeed aperture iso exposureMode exposureCompensation meteringMode photoVideoMode driveMode whiteBalance colorTemperature pictureStyle pictureProfile focusMode focusArea subjectDetection continuousAutofocus imageStabilization audioLevel shutterType detectionSubject eyeSelection photoFormat photoSize aspectRatio jpegQuality rawCompression flashMode videoFormat videoQuality frameRate audioRecording digitalZoom liveViewQuality
CameraControlInputs
What setControl accepts as a value, by setting id: an ExposureTimeInput for shutterSpeed, a number for colorTemperature and audioLevel, and a string for every other setting.
type CameraControlInputs = {
[Id in CameraControlId]: Id extends 'shutterSpeed'
? ExposureTimeInput
: Id extends NumericControlId
? number
: string
}Uses CameraControlId.
CameraControlState
One setting as the camera reports it now: its value, the values it offers, and whether it can be written.
interface CameraControlState {
id: CameraControlId
label: string
aliases: readonly string[]
source: {
name: string
code: number
protocol: 'ptp' | 'sony-sdk'
}
value?: string
allowedValues?: string[]
writable: boolean
enabled: boolean
range?: {
minimum: number
maximum: number
step: number
}
exposureTime?: ExposureTime
unrecognized?: UnrecognizedValues
}Show CameraControlState fieldsHide CameraControlState fields
The setting's id.
See CameraControlId.
Its name for a person, such as Shutter speed.
Other words for it, for search.
The protocol property behind this setting on the connected camera, kept for diagnostics. Write by id, never by this.
The current value in Slate's spelling. Absent when the control does not apply now (enabled: false, no choices, the raw reading in unrecognized.value): colour temperature under a white balance preset, Sony drive mode in movie mode.
The values the camera offers now, in Slate's spelling. Only these can be written.
Whether the camera accepts a write to it now.
Whether it applies in the camera's current mode.
For a numeric setting: the lowest and highest value and the step between them.
Shutter speed only: the value as a duration or an angle.
See ExposureTime.
Raw values the camera reported that Slate has no name for.
See UnrecognizedValues.
CameraControlSession
The same control contract on an already-connected native PTP or vendor SDK session, including one typed getter and setter per typed setting (getShutterSpeed, setShutterSpeed, ...).
interface CameraControlSession extends TypedSettingMethods {
getCapabilities: () => Promise<CameraCapabilities>
setControl: <Id extends CameraControlId>(
id: Id,
value: CameraControlInputs[Id],
context?: ExposureContext,
) => Promise<CameraControlState>
}Show CameraControlSession fieldsHide CameraControlSession fields
The same read as Camera.getCapabilities.
See CameraCapabilities.
The same write as Camera.setControl.
See CameraControlId, CameraControlInputs, ExposureContext, CameraControlState.
Extends TypedSettingMethods.
UnrecognizedValues
Raw values the camera reported that Slate has no name for. They are shown and never written.
interface UnrecognizedValues {
value?: string
choices?: string[]
}Show UnrecognizedValues fieldsHide UnrecognizedValues fields
The current raw value. The control is then read-only and its value reads Unrecognized (<raw>), or, when it does not apply now, has no value at all.
Advertised choices left out of allowedValues; they are never writable.
CameraLens
The attached lens as the camera reports it. Each field is null when the camera does not report it.
interface CameraLens {
name: string | null
focalLengthMillimetres: number | null
}Show CameraLens fieldsHide CameraLens fields
The lens's name.
The current focal length, in millimetres.
Identification
Which model a camera is, and whether Slate has validated it.
VerifiedFeature
A vendor feature confirmed on specific bodies on Darkgrade's benches, for isVerifiedFeature.
type VerifiedFeature = keyof typeof verifiedFeatureModelsEvery value (3)
Every value (3)
sony-wireless sony-card-fallback nikon-wireless-status
CameraIdentification
What identifyCamera makes of a USB vendor and product ID, without opening the device. Recognising an ID proves no control.
interface CameraIdentification {
usb: { vendorId: number; productId: number }
status: 'unknown'
| 'matched'
| 'ambiguous'
| 'identity-mismatch'
candidates: CameraIdentityCandidate[]
}Show CameraIdentification fieldsHide CameraIdentification fields
The USB vendor and product ID that were asked about.
matched: one camera line is known for the ID. ambiguous: several share it. identity-mismatch: a model was given and none of them names it. unknown: the ID is not in Slate's list.
The camera lines known for the ID; when a model was given and matched, only those that name it.
CameraIdentityCandidate
A camera line and model aliases that a cited source associates with one USB vendor/product ID.
interface CameraIdentityCandidate {
manufacturer: string
line: string
models: string[]
sources: string[]
}Show CameraIdentityCandidate fieldsHide CameraIdentityCandidate fields
The make.
The camera line, as the source names it.
The model names and aliases of the line.
The sources that associate the line with the USB ID.
Other types
The types you pass to Camera: its constructor options, and the options and choices of its methods.
The types Camera hands back: what each method resolves to, what an event carries, and what recover() reports.
One type per setting: the values its getter returns and its setter takes, with the types the typed getters and setters are declared with.
The types around Camera: the workflows built on it, the connection under it, and the host that shares cameras between callers.
Related
The class: constructor, every method, what each returns and throws.
Every setting id with its values, getter, setter and vendor properties.
Every exported type, field by field.
Every error class: when it is thrown and what to do.
Every import path of the package and what it exports.