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

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