-
Notifications
You must be signed in to change notification settings - Fork 18
/
trackinfo.go
119 lines (86 loc) · 2.19 KB
/
trackinfo.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package sdp
import (
"strings"
)
type TrackInfo struct {
id string
mID string
mediaType string // "audio" | "video"
ssrcs []uint
groups []*SourceGroupInfo
encodings [][]*TrackEncodingInfo
}
func NewTrackInfo(id, mediaType string) *TrackInfo {
info := &TrackInfo{
id: id,
mediaType: mediaType,
ssrcs: []uint{},
groups: []*SourceGroupInfo{},
encodings: [][]*TrackEncodingInfo{},
}
return info
}
func (t *TrackInfo) Clone() *TrackInfo {
cloned := &TrackInfo{
id: t.id,
mID: t.mID,
mediaType: t.mediaType,
ssrcs: make([]uint, len(t.ssrcs)),
groups: make([]*SourceGroupInfo, 0),
encodings: make([][]*TrackEncodingInfo, len(t.encodings)),
}
copy(cloned.ssrcs, t.ssrcs)
for _, group := range t.groups {
cloned.groups = append(cloned.groups, group.Clone())
}
for i := range t.encodings {
for _, v := range t.encodings[i] {
cloned.encodings[i] = append(cloned.encodings[i], v.Clone())
}
}
return cloned
}
func (t *TrackInfo) GetMediaType() string {
return t.mediaType
}
func (t *TrackInfo) SetMID(mediaID string) {
t.mID = mediaID
}
func (t *TrackInfo) GetMID() string {
return t.mID
}
func (t *TrackInfo) GetID() string {
return t.id
}
func (t *TrackInfo) AddSSRC(ssrc uint) {
t.ssrcs = append(t.ssrcs, ssrc)
}
func (t *TrackInfo) GetSSRCS() []uint {
return t.ssrcs
}
func (t *TrackInfo) AddSourceGroup(group *SourceGroupInfo) {
t.groups = append(t.groups, group)
}
func (t *TrackInfo) GetSourceGroup(schematics string) *SourceGroupInfo {
for _, group := range t.groups {
if strings.ToLower(group.GetSemantics()) == strings.ToLower(schematics) {
return group
}
}
return nil
}
func (t *TrackInfo) GetSourceGroupS() []*SourceGroupInfo {
return t.groups
}
func (t *TrackInfo) GetEncodings() [][]*TrackEncodingInfo {
return t.encodings
}
func (t *TrackInfo) AddEncoding(encoding *TrackEncodingInfo) {
t.encodings = append(t.encodings, []*TrackEncodingInfo{encoding})
}
func (t *TrackInfo) AddAlternativeEncodings(alternatives []*TrackEncodingInfo) {
t.encodings = append(t.encodings, alternatives)
}
func (t *TrackInfo) SetEncodings(encodings [][]*TrackEncodingInfo) {
t.encodings = encodings
}