Documentation
¶
Overview ¶
package voice contains the types used by the SRS audio protocol to send and receive audio data over the network.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Frequency ¶
type Frequency struct {
// Frequency is the transmission frequency in Hz.
// Example: 249.500MHz is encoded as 249500000.0
//
// Length: 8 bytes
Frequency float64
// Modulation is the transmission modulation mode.
//
// Length: 1 byte
Modulation byte
// Encryption is the transmission encryption mode.
//
// Length: 1 byte
Encryption byte
}
Frequency describes an audio transmission channel. This struct is only for use in VoicePacket. For client information, use types.Radio instead. Length: 10 bytes.
type VoicePacket ¶
type VoicePacket struct {
// PacketLength is the total packet length in bytes.
//
// Bytes: 0:2
//
// Length: 2 bytes
PacketLength uint16
// AudioSegmentLength is the length of the Audio segment struct.
//
// Bytes: 2:4
//
// Length: 2 bytes
AudioSegmentLength uint16
// FrequenciesSegmentLength is the length of the Frequencies segment.
//
// Bytes: 4:6
//
// Length: 2 bytes
FrequenciesSegmentLength uint16
/* Audio segment */
// AudioBytes is the AudioPart1 byte array. This is the audio data as an Opus bitstream, encoded as 16KHz Mono in 40ms frames.
// The upstream name is directly mirrored from the IDirectSoundBuffer::Lock function in the legacy DirectSound API - Part2 is not used by SRS.
//
// Bytes: 6:6+AudioSegmentLength
//
// Length: AudioSegmentLength
AudioBytes []byte
// Frequencies is an array of information for each frequency, modulation and encryption combination the audio is transmitted on.
//
// Bytes: 6+AudioSegmentLength:6+AudioSegmentLength+FrequenciesSegmentLength
//
// Length: FrequenciesSegmentLength
Frequencies []Frequency
// UnitID is the ID of the in-game unit that originated the packet.
//
// Bytes: PacketLength-58:PacketLength-53
//
// Length: 4 bytes
UnitID uint32
// PacketID is the ID of this packet. Packets from the same transmitter increment by 1 for each transmission.
//
// Bytes: PacketLength-53:PacketLength-45
//
// Length: 8 bytes
PacketID uint64
// Hops is the number of retransmissions. This value is checked in SRS to limit retransmisisons.
//
// Bytes: PacketLength-45:PacketLength-44
//
// Length: 1 byte
Hops byte
// RelayGUID is the GUID of the last transmitter. This may differ from OriginGUID if this is a retransmission.
//
// Bytes: PacketLength-44:PacketLength-22
//
// Length: 22 bytes
RelayGUID []byte
// OriginGUID is the GUID of the original transmitter.
//
// Bytes: PacketLength-22:PacketLength
//
// Length: 22 bytes
OriginGUID []byte
}
VoicePacket is a network packet containing: A header segment with packet and segment length headers An audio segment containing Opus audio A frequency segment containing each frequency the audio is transmitted on A fixed segment containing metadata
See SRS source code for packet encoding: https://github.com/ciribob/DCS-SimpleRadioStandalone/blob/master/DCS-SR-Common/Network/UDPVoicePacket.cs
func NewVoicePacket ¶
func NewVoicePacketFrom ¶
func NewVoicePacketFrom(b []byte) VoicePacket
newVoicePacketFrom deserializes a voice packet from bytes to struct.
func (*VoicePacket) Encode ¶
func (vp *VoicePacket) Encode() []byte
Encode serializes a VoicePacket into a byte array.
func (*VoicePacket) String ¶
func (vp *VoicePacket) String() string