typedef.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package usbcapture
  2. import (
  3. "context"
  4. "github.com/vladimirvivien/go4vl/device"
  5. "github.com/vladimirvivien/go4vl/v4l2"
  6. )
  7. // The capture resolution to open video device
  8. type CaptureResolution struct {
  9. Width int
  10. Height int
  11. FPS int
  12. }
  13. type AudioConfig struct {
  14. SampleRate int
  15. Channels int
  16. FrameSize int
  17. BytesPerSample int
  18. }
  19. type Config struct {
  20. VideoDeviceName string // The video device name, e.g., /dev/video0
  21. AudioDeviceName string // The audio device name, e.g., /dev/snd
  22. AudioConfig *AudioConfig // The audio configuration
  23. }
  24. type Instance struct {
  25. /* Runtime configuration */
  26. Config *Config
  27. SupportedResolutions []FormatInfo //The supported resolutions of the video device
  28. Capturing bool
  29. /* Internals */
  30. /* Video capture device */
  31. camera *device.Device
  32. cameraStartContext context.CancelFunc
  33. frames_buff <-chan []byte
  34. pixfmt v4l2.FourCCType
  35. width int
  36. height int
  37. streamInfo string
  38. /* audio capture device */
  39. isAudioStreaming bool // Whether audio is currently being captured
  40. audiostopchan chan bool // Channel to stop audio capture
  41. /* Concurrent access */
  42. accessCount int // The number of current access, in theory each instance should at most have 1 access
  43. videoTakeoverChan chan bool // Channel to signal video takeover request
  44. }