-
Notifications
You must be signed in to change notification settings - Fork 8
/
object_stream.go
37 lines (32 loc) · 903 Bytes
/
object_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
package moqtransport
import "github.com/mengelbart/moqtransport/internal/wire"
type objectStream struct {
stream SendStream
}
func newObjectStream(stream SendStream, subscribeID, trackAlias, groupID, objectID uint64, publisherPriority uint8) (*objectStream, error) {
osm := &wire.ObjectMessage{
Type: wire.ObjectStreamMessageType,
SubscribeID: subscribeID,
TrackAlias: trackAlias,
GroupID: groupID,
ObjectID: objectID,
PublisherPriority: publisherPriority,
ObjectStatus: 0,
ObjectPayload: nil,
}
buf := make([]byte, 0, 48)
buf = osm.Append(buf)
_, err := stream.Write(buf)
if err != nil {
return nil, err
}
return &objectStream{
stream: stream,
}, nil
}
func (s *objectStream) Write(payload []byte) (int, error) {
return s.stream.Write(payload)
}
func (s *objectStream) Close() error {
return s.stream.Close()
}