aboutsummaryrefslogtreecommitdiff
path: root/pkg/messages/types/svcSounds.go
blob: 5391af1de48f6afd555c373b67f5f8e7a061faf2 (plain) (blame)
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
package messages

import (
	"github.com/pektezol/bitreader"
	"github.com/pektezol/sdp.go/pkg/writer"
)

type SvcSounds struct {
	ReliableSound bool
	SoundCount    uint8
	Length        uint16
	Data          []byte
}

func ParseSvcSounds(reader *bitreader.Reader) SvcSounds {
	svcSounds := SvcSounds{
		ReliableSound: reader.TryReadBool(),
	}
	if svcSounds.ReliableSound {
		svcSounds.SoundCount = 1
		svcSounds.Length = uint16(reader.TryReadUInt8())
	} else {
		svcSounds.SoundCount = reader.TryReadUInt8()
		svcSounds.Length = reader.TryReadUInt16()
	}
	svcSounds.Data = reader.TryReadBitsToSlice(uint64(svcSounds.Length))
	writer.TempAppendLine("\t\tReliable Sound: %t", svcSounds.ReliableSound)
	writer.TempAppendLine("\t\tSound Count: %d", svcSounds.SoundCount)
	writer.TempAppendLine("\t\tData: %v", svcSounds.Data)
	return svcSounds
}