diff options
author | Jeff Ames | 2008-02-26 15:36:17 +0000 |
---|---|---|
committer | Jeff Ames | 2008-02-26 15:36:17 +0000 |
commit | 74940c7b1dbd44dc236b6b1bf6a7d03ce8e6ea43 (patch) | |
tree | 219db5a8e80858c28ee7c2a4173ffe71fd93d382 /OpenSim/Region/Environment/Modules/VoiceChat/VoicePacket.cs | |
parent | * Hooked up replacment TerrainModule, raising land will now be weird as both ... (diff) | |
download | opensim-SC_OLD-74940c7b1dbd44dc236b6b1bf6a7d03ce8e6ea43.zip opensim-SC_OLD-74940c7b1dbd44dc236b6b1bf6a7d03ce8e6ea43.tar.gz opensim-SC_OLD-74940c7b1dbd44dc236b6b1bf6a7d03ce8e6ea43.tar.bz2 opensim-SC_OLD-74940c7b1dbd44dc236b6b1bf6a7d03ce8e6ea43.tar.xz |
Update svn properties.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Modules/VoiceChat/VoicePacket.cs | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/OpenSim/Region/Environment/Modules/VoiceChat/VoicePacket.cs b/OpenSim/Region/Environment/Modules/VoiceChat/VoicePacket.cs index e92fa43..db62f45 100644 --- a/OpenSim/Region/Environment/Modules/VoiceChat/VoicePacket.cs +++ b/OpenSim/Region/Environment/Modules/VoiceChat/VoicePacket.cs | |||
@@ -1,58 +1,58 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using libsecondlife; | 4 | using libsecondlife; |
5 | 5 | ||
6 | namespace OpenSim.Region.Environment.Modules.VoiceChat | 6 | namespace OpenSim.Region.Environment.Modules.VoiceChat |
7 | { | 7 | { |
8 | public enum VoiceCodec | 8 | public enum VoiceCodec |
9 | { | 9 | { |
10 | None = 0, | 10 | None = 0, |
11 | PCM8 = 1 << 0, | 11 | PCM8 = 1 << 0, |
12 | PCM16 = 1 << 1, | 12 | PCM16 = 1 << 1, |
13 | PCM32 = 1 << 2, | 13 | PCM32 = 1 << 2, |
14 | Speex = 1 << 3, | 14 | Speex = 1 << 3, |
15 | } | 15 | } |
16 | 16 | ||
17 | public class VoicePacket | 17 | public class VoicePacket |
18 | { | 18 | { |
19 | public LLUUID m_clientId; | 19 | public LLUUID m_clientId; |
20 | byte[] m_audioData; | 20 | byte[] m_audioData; |
21 | public int m_codec; | 21 | public int m_codec; |
22 | 22 | ||
23 | public VoicePacket(byte[] data) | 23 | public VoicePacket(byte[] data) |
24 | { | 24 | { |
25 | int pos = 0; | 25 | int pos = 0; |
26 | m_codec = data[pos++]; | 26 | m_codec = data[pos++]; |
27 | m_codec |= data[pos++] << 8; | 27 | m_codec |= data[pos++] << 8; |
28 | m_codec |= data[pos++] << 16; | 28 | m_codec |= data[pos++] << 16; |
29 | m_codec |= data[pos++] << 24; | 29 | m_codec |= data[pos++] << 24; |
30 | 30 | ||
31 | m_audioData = new byte[data.Length - pos]; | 31 | m_audioData = new byte[data.Length - pos]; |
32 | Buffer.BlockCopy(data, pos, m_audioData, 0, data.Length - pos); | 32 | Buffer.BlockCopy(data, pos, m_audioData, 0, data.Length - pos); |
33 | } | 33 | } |
34 | 34 | ||
35 | public byte[] GetBytes() | 35 | public byte[] GetBytes() |
36 | { | 36 | { |
37 | VoicePacketHeader header = new VoicePacketHeader(); | 37 | VoicePacketHeader header = new VoicePacketHeader(); |
38 | byte[] bytes = new byte[5+16+4+m_audioData.Length]; | 38 | byte[] bytes = new byte[5+16+4+m_audioData.Length]; |
39 | 39 | ||
40 | header.length = bytes.Length-5; | 40 | header.length = bytes.Length-5; |
41 | 41 | ||
42 | //ToClient packets are type 2 | 42 | //ToClient packets are type 2 |
43 | header.type = 2; | 43 | header.type = 2; |
44 | 44 | ||
45 | int pos = 0; | 45 | int pos = 0; |
46 | header.CopyTo(bytes, pos); pos += 5; | 46 | header.CopyTo(bytes, pos); pos += 5; |
47 | m_clientId.GetBytes().CopyTo(bytes, pos); pos += 16; | 47 | m_clientId.GetBytes().CopyTo(bytes, pos); pos += 16; |
48 | 48 | ||
49 | bytes[pos++] = (byte)((m_codec) % 256); | 49 | bytes[pos++] = (byte)((m_codec) % 256); |
50 | bytes[pos++] = (byte)((m_codec << 8) % 256); | 50 | bytes[pos++] = (byte)((m_codec << 8) % 256); |
51 | bytes[pos++] = (byte)((m_codec << 16) % 256); | 51 | bytes[pos++] = (byte)((m_codec << 16) % 256); |
52 | bytes[pos++] = (byte)((m_codec << 24) % 256); | 52 | bytes[pos++] = (byte)((m_codec << 24) % 256); |
53 | 53 | ||
54 | m_audioData.CopyTo(bytes, pos); | 54 | m_audioData.CopyTo(bytes, pos); |
55 | return bytes; | 55 | return bytes; |
56 | } | 56 | } |
57 | } | 57 | } |
58 | } | 58 | } |