forked from pion/mediadevices
-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver.go
59 lines (49 loc) · 1.24 KB
/
driver.go
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
package driver
import (
"github.com/carbonrobotics/mediadevices/pkg/driver/availability"
"github.com/carbonrobotics/mediadevices/pkg/io/audio"
"github.com/carbonrobotics/mediadevices/pkg/io/video"
"github.com/carbonrobotics/mediadevices/pkg/prop"
)
type VideoRecorder interface {
VideoRecord(p prop.Media) (r video.Reader, err error)
}
type AudioRecorder interface {
AudioRecord(p prop.Media) (r audio.Reader, err error)
}
// Priority represents device selection priority level
type Priority float32
const (
// PriorityHigh is a value for system default devices
PriorityHigh Priority = 0.1
// PriorityNormal is a value for normal devices
PriorityNormal Priority = 0.0
// PriorityLow is a value for unrecommended devices
PriorityLow Priority = -0.1
)
type Info struct {
Label string
DeviceType DeviceType
Priority Priority
Name string
}
type Adapter interface {
Open() error
Close() error
Properties() []prop.Media
}
type Driver interface {
Adapter
ID() string
Info() Info
Status() State
}
type AvailabilityAdapter interface {
IsAvailable() (bool, error)
}
func IsAvailable(d Driver) (bool, error) {
if aa, ok := d.(AvailabilityAdapter); ok {
return aa.IsAvailable()
}
return false, availability.ErrUnimplemented
}