aboutsummaryrefslogtreecommitdiff
path: root/pkg/messages/types/svcVoiceInit.go
blob: a6d711a26f527117694dbc69b2ab3fb75c6d2c9e (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
package messages

import "github.com/pektezol/bitreader"

type SvcVoiceInit struct {
	Codec      string
	Quality    uint8
	SampleRate int32
}

func ParseSvcVoiceInit(reader *bitreader.Reader) SvcVoiceInit {
	svcVoiceInit := SvcVoiceInit{
		Codec:   reader.TryReadString(),
		Quality: reader.TryReadUInt8(),
	}
	if svcVoiceInit.Quality == 0b11111111 {
		svcVoiceInit.SampleRate = reader.TryReadSInt32()
	} else {
		if svcVoiceInit.Codec == "vaudio_celt" {
			svcVoiceInit.SampleRate = 22050
		} else {
			svcVoiceInit.SampleRate = 11025
		}
	}
	return svcVoiceInit
}