IMediaDevice
interface NatML.Devices.IMediaDevice<TSampleBuffer> : System.IEquatable<IMediaDevice>
This is the fundamental interface that all media devices--camera or microphone--inherit from.
This interface has a non-generic counterpart which does not define the StartRunning
method.
Identifying the Device
Media devices can be identified in several ways:
Unique Identifier
Most IMediaDevice
instances will abstract a hardware media device, and as such these hardware devices can be uniquely identified by their ID.
Multiple IMediaDevice
instances can refer to the same hardware device. As such, you must not use multiple IMediaDevice
instances for the same hardware device.
Device Name
Media devices provide a localized, display-friendly name to present to the user. This can be useful for building device selection UI's.
Device Location
Media devices can report their location relative to their host device:
Default Device
Media devices can report whether they are the default device for their type. This can be useful for preserving a user's existing audio configuration when streaming.
For a given media device type, a default device is not guaranteed to exist. As a result, do not expect to always discover a default device.
Checking the Device State
This property reports whether the media device is running.
Streaming Sample Buffers
Media devices work by streaming sample buffers to a provided delegate function. The type of the sample buffer TSampleBuffer
is generic, and specified by implementations of the IMediaDevice
interface.
This method is only defined on the generic IMediaDevice<T>
interface. The non-generic IMediaDevice
interface does not define this method.
Stopping the Stream
When you are done streaming, you must stop the device.
NatDevice does not automatically stop and restart media devices when the app is suspended and resumed, so you must manage this yourself.
Handling Device Disconnection
Media devices expose an event which is raised when the device is disconnected or becomes otherwise unavailable. NatDevice automatically handles any shut down operations required, so that no action is needed from the client when the event is raised.
This event is not guaranteed to be raised on the Unity main thread.
Last updated