package playback import ( "fmt" "time" ) type Unit uint8 const ( UnitVideo Unit = iota UnitAudio UnitSync ) type State uint8 const ( StateIdle State = iota StateConnecting StatePlaying StateReconnecting StateFailed StateStopping ) type Status struct { Unit Unit State State Attempt int FailedAttempts int RetryIn time.Duration Err error } type StatusObserver func(Status) func (u Unit) String() string { switch u { case UnitVideo: return "video" case UnitAudio: return "audio" case UnitSync: return "sync" default: return fmt.Sprintf("Unit(%d)", uint8(u)) } } func (s State) String() string { switch s { case StateIdle: return "idle" case StateConnecting: return "connecting" case StatePlaying: return "playing" case StateReconnecting: return "reconnecting" case StateFailed: return "failed" case StateStopping: return "stopping" default: return fmt.Sprintf("State(%d)", uint8(s)) } }