summaryrefslogtreecommitdiff
path: root/src/hub/src/spreadspace.org/sfive/s5typesApi.go
blob: 525b6d386795658d64a2b8e00cdb3b8feb0b8eca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package sfive

import "time"

const (
	QualityLow    = "low"
	QualityMedium = "medium"
	QualityHigh   = "high"
)

type StreamId struct {
	ContentId string `json:"content-id"`
	Format    string `json:"format"`
	Quality   string `json:"quality"`
}

type SourceId struct {
	Version  uint     `json:"version" db:"-"`
	Hostname string   `json:"hostname"`
	StreamId StreamId `json:"streamer-id" db:"-"`
	Tags     []string `json:"tags" db:"-"`
}

type ClientData struct {
	Ip        string `json:"ip"`
	UserAgent string `json:"user-agent,omitempty"`
	BytesSent uint   `json:"bytes-sent"`
}

type SourceData struct {
	ClientCount   uint         `json:"client-count"`
	BytesReceived uint         `json:"bytes-received,omitempty"`
	BytesSent     uint         `json:"bytes-sent"`
	Clients       []ClientData `json:"clients,omitempty"`
}

type DataUpdate struct {
	StartTime time.Time  `json:"start-time"`
	Duration  int64      `json:"duration-ms"`
	Data      SourceData `json:"data"`
}

type StatisticsData struct {
	SourceHubUuid         *string
	SourceHubDataUpdateId *int
	SourceId
	DataUpdate
}

type DataContainer struct {
	Data interface{} `json:"data"`
}

type StatisticsDataContainer struct {
	Data []StatisticsData `json:"data"`
}

func (self *StatisticsData) CopyFromSourceId(id *SourceId) {
	self.Hostname = id.Hostname
	self.StreamId = id.StreamId
	self.Tags = id.Tags
	self.Version = id.Version
}

func (self *StatisticsData) CopyFromUpdate(id *DataUpdate) {
	self.StartTime = id.StartTime
	self.Duration = id.Duration
	self.Data = id.Data
}