Go-based FM stereo transmitter with RDS, Windows-first and cross-platform
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

55 行
1.2KB

  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. Sequence uint64
  19. }
  20. // BackendConfig describes the properties for a backend instance.
  21. type BackendConfig struct {
  22. SampleRateHz float64
  23. Channels int
  24. IQLevel float32
  25. Metadata map[string]string
  26. }
  27. // BackendCapabilities advertise what a backend can do.
  28. type BackendCapabilities struct {
  29. SupportsComposite bool
  30. FixedRate bool
  31. MaxSamplesPerWrite int
  32. }
  33. // BackendInfo exposes runtime metadata about a backend.
  34. type BackendInfo struct {
  35. Name string
  36. Description string
  37. Capabilities BackendCapabilities
  38. }
  39. // Backend defines the contract that all output backends must satisfy.
  40. type Backend interface {
  41. Configure(ctx context.Context, cfg BackendConfig) error
  42. Write(ctx context.Context, frame *CompositeFrame) (int, error)
  43. Flush(ctx context.Context) error
  44. Close(ctx context.Context) error
  45. Info() BackendInfo
  46. }