-
Notifications
You must be signed in to change notification settings - Fork 127
Adapter Developer Guide
Note: This page is meant for developers who are interested in creating/maintaining new/current adapters. If you're only interested in using them, you probably want to visit the driver usage page instead.
The design for adapter/driver is heavily based on unix design principle, everything is a file. Therefore, you can always think of any adapter as a file, you open the adapter, read from it, and then close it:
First of all, any adapter has to implement the Adapter interface,
type Adapter interface {
Open() error
Close() error
Properties() []prop.Media
}
This interface is being used to generalize different kinds of adapters. We use this interface so that we can store it in the driver manager (I'll talk about this more later).
As you've seen from the driver lifecycle diagram above, Adapter
interface contains 2 out of 3 mentioned methods, and Properties
.
This method opens the underlying hardware through an OS interface. At this point, the adapter user can start getting its Properties
and get data from it through, VideoRecord
or AudioRecord
(I'll talk more in the next section).
Close is a cleanup method to free all used resources and stop the underlying hardware from transmitting data.
Properties return a list of prop.Media
that the adapter supports. These values will later be chosen by the adapter user for VideoRecord
or AudioRecord
.
Usage
Developer Guide