Go-based FM stereo transmitter with RDS, Windows-first and cross-platform
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

59 řádky
1.3KB

  1. package output
  2. import (
  3. "context"
  4. "errors"
  5. "time"
  6. )
  7. var ErrBackendClosed = errors.New("backend already closed")
  8. // IQSample is a normalized interleaved I/Q sample pair.
  9. type IQSample struct {
  10. I float32
  11. Q float32
  12. }
  13. // CompositeFrame carries a block of MPX/IQ samples along with timing metadata.
  14. type CompositeFrame struct {
  15. Samples []IQSample
  16. SampleRateHz float64
  17. Timestamp time.Time
  18. GeneratedAt time.Time
  19. EnqueuedAt time.Time
  20. DequeuedAt time.Time
  21. WriteStartedAt time.Time
  22. Sequence uint64
  23. }
  24. // BackendConfig describes the properties for a backend instance.
  25. type BackendConfig struct {
  26. SampleRateHz float64
  27. Channels int
  28. IQLevel float32
  29. Metadata map[string]string
  30. }
  31. // BackendCapabilities advertise what a backend can do.
  32. type BackendCapabilities struct {
  33. SupportsComposite bool
  34. FixedRate bool
  35. MaxSamplesPerWrite int
  36. }
  37. // BackendInfo exposes runtime metadata about a backend.
  38. type BackendInfo struct {
  39. Name string
  40. Description string
  41. Capabilities BackendCapabilities
  42. }
  43. // Backend defines the contract that all output backends must satisfy.
  44. type Backend interface {
  45. Configure(ctx context.Context, cfg BackendConfig) error
  46. Write(ctx context.Context, frame *CompositeFrame) (int, error)
  47. Flush(ctx context.Context) error
  48. Close(ctx context.Context) error
  49. Info() BackendInfo
  50. }