/// <summary> /// Write out a voice packet. Mutate this writer to represent the position after the write. /// </summary> /// <param name="session"></param> /// <param name="senderId">Local player ID</param> /// <param name="sequenceNumber">Sequence number (monotonically increases with audio frames)</param> /// <param name="channelSession"></param> /// <param name="channels">List of local open channels</param> /// <param name="encodedAudio">The encoded audio data</param> /// <returns>A copy of this writer (after the write has been applied)</returns> internal PacketWriter WriteVoiceData(uint session, ushort senderId, ushort sequenceNumber, byte channelSession, [NotNull] IList <OpenChannel> channels, ArraySegment <byte> encodedAudio) { if (channels == null) { throw new ArgumentNullException("channels"); } if (encodedAudio.Array == null) { throw new ArgumentNullException("encodedAudio"); } WriteMagic(); Write((byte)MessageTypes.VoiceData); Write(session); Write(senderId); Write(VoicePacketOptions.Pack(channelSession).Bitfield); Write(sequenceNumber); //Write out a list of channels this packet is for Write((ushort)channels.Count); for (var i = 0; i < channels.Count; i++) { var channel = channels[i]; Write(channel.Bitfield); Write(channel.Recipient); } //Write out the encoded audio Write(encodedAudio); return(this); }
public void ReadVoicePacketHeader2(out VoicePacketOptions options, out ushort sequenceNumber, out ushort numChannels) { options = VoicePacketOptions.Unpack(ReadByte()); sequenceNumber = ReadUInt16(); numChannels = ReadUInt16(); }