-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtrack_header_stream.go
39 lines (34 loc) · 979 Bytes
/
track_header_stream.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
package moqtransport
import "github.com/mengelbart/moqtransport/internal/wire"
type trackHeaderStream struct {
stream SendStream
}
func newTrackHeaderStream(stream SendStream, subscribeID, trackAlias uint64, publisherPriority uint8) (*trackHeaderStream, error) {
shtm := &wire.StreamHeaderTrackMessage{
SubscribeID: subscribeID,
TrackAlias: trackAlias,
PublisherPriority: publisherPriority,
}
buf := make([]byte, 0, 32)
buf = shtm.Append(buf)
_, err := stream.Write(buf)
if err != nil {
return nil, err
}
return &trackHeaderStream{
stream: stream,
}, nil
}
func (s *trackHeaderStream) writeObject(groupID, objectID uint64, payload []byte) (int, error) {
shto := wire.StreamHeaderTrackObject{
GroupID: groupID,
ObjectID: objectID,
ObjectPayload: payload,
}
buf := make([]byte, 0, 32+len(payload))
buf = shto.Append(buf)
return s.stream.Write(buf)
}
func (s *trackHeaderStream) Close() error {
return s.stream.Close()
}