package ingest

import "time"

type SourceStats struct {
	State           string    `json:"state"`
	Connected       bool      `json:"connected"`
	LastChunkAt     time.Time `json:"lastChunkAt,omitempty"`
	LastMetaAt      time.Time `json:"lastMetaAt,omitempty"`
	StreamTitle     string    `json:"streamTitle,omitempty"`
	MetadataUpdates uint64    `json:"metadataUpdates,omitempty"`
	IcyMetaInt      int       `json:"icyMetaInt,omitempty"`
	ChunksIn        uint64    `json:"chunksIn"`
	SamplesIn       uint64    `json:"samplesIn"`
	BufferedSeconds float64   `json:"bufferedSeconds"`
	Overflows       uint64    `json:"overflows"`
	Underruns       uint64    `json:"underruns"`
	Reconnects      uint64    `json:"reconnects"`
	Discontinuities uint64    `json:"discontinuities"`
	TransportLoss   uint64    `json:"transportLoss"`
	Reorders        uint64    `json:"reorders"`
	JitterDepth     int       `json:"jitterDepth"`
	LastError       string    `json:"lastError,omitempty"`
}

type RuntimeStats struct {
	State           string    `json:"state"`
	Prebuffering    bool      `json:"prebuffering"`
	Buffered        float64   `json:"buffered"`
	BufferedSeconds float64   `json:"bufferedSeconds"`
	LastChunkAt     time.Time `json:"lastChunkAt,omitempty"`
	DroppedFrames   uint64    `json:"droppedFrames"`
	ConvertErrors   uint64    `json:"convertErrors"`
	WriteBlocked    bool      `json:"writeBlocked"`
}

type Stats struct {
	Active  SourceDescriptor `json:"active"`
	Source  SourceStats      `json:"source"`
	Runtime RuntimeStats     `json:"runtime"`
}
