/
models.go
65 lines (53 loc) · 1.85 KB
/
models.go
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
package db
import (
"time"
"github.com/alwitt/livemix/common"
)
// videoSource a single HLS video source
type videoSource struct {
common.VideoSource
// Segments associated video segments
Segments []liveStreamVideoSegment `gorm:"foreignKey:SourceID" validate:"-"`
}
// TableName hard code table name
func (videoSource) TableName() string {
return "video_sources"
}
// liveStreamVideoSegment MPEG-TS video segment belonging to a live stream which the system
// will clear out periodically.
type liveStreamVideoSegment struct {
common.VideoSegment
Source videoSource `gorm:"constraint:OnDelete:CASCADE;foreignKey:SourceID" validate:"-"`
}
// TableName hard code table name
func (liveStreamVideoSegment) TableName() string {
return "live_video_segments"
}
// recordingSession a single video recording session
type recordingSession struct {
common.Recording
}
// TableName hard code table name
func (recordingSession) TableName() string {
return "recording_sessions"
}
// recordingVideoSegment MPEG-TS video segment belonging to a video recording session
type recordingVideoSegment struct {
common.VideoSegment
}
// TableName hard code table name
func (recordingVideoSegment) TableName() string {
return "recorded_segments"
}
// segmentToRecordingAssociation segment to recording association
type segmentToRecordingAssociation struct {
SegmentID string `gorm:"column:segment_id;primaryKey"`
Segment recordingVideoSegment `gorm:"foreignKey:segment_id;constraint:OnDelete:CASCADE;"`
RecordingID string `gorm:"column:recording_id;primaryKey"`
Recording recordingSession `gorm:"foreignKey:recording_id;constraint:OnDelete:CASCADE;"`
CreatedAt time.Time `json:"created_at"`
}
// TableName hard code table name
func (segmentToRecordingAssociation) TableName() string {
return "segment_to_recording_association"
}