mirror of
				https://github.com/pion/mediadevices.git
				synced 2025-10-31 20:02:36 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			60 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package driver
 | |
| 
 | |
| import (
 | |
| 	"github.com/pion/mediadevices/pkg/driver/availability"
 | |
| 	"github.com/pion/mediadevices/pkg/io/audio"
 | |
| 	"github.com/pion/mediadevices/pkg/io/video"
 | |
| 	"github.com/pion/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
 | |
| }
 | 
