aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/VoiceChat/VoicePacket.cs
diff options
context:
space:
mode:
authorAdam Frisby2008-02-26 10:46:59 +0000
committerAdam Frisby2008-02-26 10:46:59 +0000
commit16d63d9fb8783e8352bb29cda272f4f224c67863 (patch)
tree3257bdd47f7bd5ac43f9d645c1feb9c9ae1241af /OpenSim/Region/Environment/Modules/VoiceChat/VoicePacket.cs
parent* Added base thread pool based presence informing to the message server. (diff)
downloadopensim-SC_OLD-16d63d9fb8783e8352bb29cda272f4f224c67863.zip
opensim-SC_OLD-16d63d9fb8783e8352bb29cda272f4f224c67863.tar.gz
opensim-SC_OLD-16d63d9fb8783e8352bb29cda272f4f224c67863.tar.bz2
opensim-SC_OLD-16d63d9fb8783e8352bb29cda272f4f224c67863.tar.xz
* Added support for RealXtend Voice Chat as a Region Module to OpenSim Trunk. Enabled via [VoiceChat] enabled=true in OpenSim.ini
Diffstat (limited to 'OpenSim/Region/Environment/Modules/VoiceChat/VoicePacket.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/VoiceChat/VoicePacket.cs58
1 files changed, 58 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/VoiceChat/VoicePacket.cs b/OpenSim/Region/Environment/Modules/VoiceChat/VoicePacket.cs
new file mode 100644
index 0000000..e92fa43
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/VoiceChat/VoicePacket.cs
@@ -0,0 +1,58 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5
6namespace OpenSim.Region.Environment.Modules.VoiceChat
7{
8 public enum VoiceCodec
9 {
10 None = 0,
11 PCM8 = 1 << 0,
12 PCM16 = 1 << 1,
13 PCM32 = 1 << 2,
14 Speex = 1 << 3,
15 }
16
17 public class VoicePacket
18 {
19 public LLUUID m_clientId;
20 byte[] m_audioData;
21 public int m_codec;
22
23 public VoicePacket(byte[] data)
24 {
25 int pos = 0;
26 m_codec = data[pos++];
27 m_codec |= data[pos++] << 8;
28 m_codec |= data[pos++] << 16;
29 m_codec |= data[pos++] << 24;
30
31 m_audioData = new byte[data.Length - pos];
32 Buffer.BlockCopy(data, pos, m_audioData, 0, data.Length - pos);
33 }
34
35 public byte[] GetBytes()
36 {
37 VoicePacketHeader header = new VoicePacketHeader();
38 byte[] bytes = new byte[5+16+4+m_audioData.Length];
39
40 header.length = bytes.Length-5;
41
42 //ToClient packets are type 2
43 header.type = 2;
44
45 int pos = 0;
46 header.CopyTo(bytes, pos); pos += 5;
47 m_clientId.GetBytes().CopyTo(bytes, pos); pos += 16;
48
49 bytes[pos++] = (byte)((m_codec) % 256);
50 bytes[pos++] = (byte)((m_codec << 8) % 256);
51 bytes[pos++] = (byte)((m_codec << 16) % 256);
52 bytes[pos++] = (byte)((m_codec << 24) % 256);
53
54 m_audioData.CopyTo(bytes, pos);
55 return bytes;
56 }
57 }
58}