mirror of
https://github.com/pion/webrtc.git
synced 2025-10-28 09:41:35 +08:00
47 lines
904 B
Go
47 lines
904 B
Go
package sctp
|
|
|
|
func chunkTypeIntersect(l, r []ChunkType) (c []ChunkType) {
|
|
m := make(map[ChunkType]bool)
|
|
|
|
for _, ct := range l {
|
|
m[ct] = true
|
|
}
|
|
|
|
for _, ct := range r {
|
|
if _, ok := m[ct]; ok {
|
|
c = append(c, ct)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func NewEmptySupportedExtensions() *ParamSupportedExtensions {
|
|
return &ParamSupportedExtensions{}
|
|
}
|
|
|
|
type ParamSupportedExtensions struct {
|
|
ParamHeader
|
|
ChunkTypes []ChunkType
|
|
}
|
|
|
|
func (s *ParamSupportedExtensions) Marshal() ([]byte, error) {
|
|
r := make([]byte, len(s.ChunkTypes))
|
|
for i, c := range s.ChunkTypes {
|
|
r[i] = byte(c)
|
|
}
|
|
|
|
return s.ParamHeader.Marshal(SupportedExt, r)
|
|
}
|
|
|
|
func (s *ParamSupportedExtensions) Unmarshal(raw []byte) (Param, error) {
|
|
s.ParamHeader.Unmarshal(raw)
|
|
|
|
for t := range s.raw {
|
|
s.ChunkTypes = append(s.ChunkTypes, ChunkType(t))
|
|
}
|
|
|
|
return s, nil
|
|
}
|
|
|
|
func (s *ParamSupportedExtensions) Types() []ChunkType { return s.Types() }
|