aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/VoiceChat/VoicePacket.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/VoiceChat/VoicePacket.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/VoiceChat/VoicePacket.cs116
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 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using libsecondlife; 4using libsecondlife;
5 5
6namespace OpenSim.Region.Environment.Modules.VoiceChat 6namespace 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}