|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectmultiverse.server.engine.EnginePlugin
multiverse.server.plugins.VoicePlugin
public class VoicePlugin
Plugin to handle voice channels
| Nested Class Summary | |
|---|---|
(package private) class |
VoicePlugin.DespawnedHook
DespawnedHook asks the conneciton manager if the message subject oid is a positional group member, and if it is, and it has an InterpolatedWorldNode, it calls the group's removeTrackedPerceiver method, and also removes the subject oid from the perception filter. |
(package private) class |
VoicePlugin.GetPluginStatusHook
|
(package private) class |
VoicePlugin.InstanceUnloadedHook
Used for both instance unloaded and instance deleted. |
(package private) class |
VoicePlugin.LoginHook
This is used exclusively to support voice bots for large-scale tests. |
(package private) class |
VoicePlugin.PerceptionHook
PerceptionHook processes PerceptionMessages, which incorporate lists of perceived objects gained and lost by the target object. |
(package private) class |
VoicePlugin.RelayUpdatePlayerIgnoreListHook
A hook to handle update ignore list message contents originating with the client, and passed on by the proxy. |
(package private) class |
VoicePlugin.SpawnedHook
SpawnedHook asks the conneciton manager if the message subject oid is a positional group member, and if it is, it calls trackNewPerceiver to add it to the set of members whose perceived oids are tracked. |
(package private) class |
VoicePlugin.Updater
A class containing a thread that interpolates the locations of all PositionalVoiceGroup members once every second. |
(package private) class |
VoicePlugin.UpdateWorldNodeHook
UpdateWorldNodeHook asks the conneciton manager if the message subject oid is a positional group member, and if it is, and it has an InterpolatedWorldNode, it calls the group's updateWorldNode method. |
(package private) class |
VoicePlugin.VoiceClientMessageHook
A hook to process ExtensionMessages whose msgType is VoiceClient.MSG_TYPE_VOICECLIENT. |
static class |
VoicePlugin.VoiceConManager
A class with locking to manage the Maps and Sets of connections. |
| Field Summary | |
|---|---|
protected static boolean |
allowVoiceBots
If this is true, we subscribe to login messages and pass on login notifications. |
private static float |
audibleRadius
Can hear positional sounds up to 20 meters away |
static boolean |
checkAuthToken
|
private ClientTCPMessageIO |
clientTCPMessageIO
The engine that handles TCP message traffic to all the clients. |
private VoicePlugin.VoiceConManager |
conMgr
|
static CountLogger.Counter |
countAllocateVoiceReceived
|
static CountLogger.Counter |
countAllocateVoiceSent
|
private static CountLogger.Counter |
countDataFramesReceived
|
private static CountLogger.Counter |
countDataFramesSent
|
static CountLogger.Counter |
countDeallocateVoiceReceived
|
static CountLogger.Counter |
countDeallocateVoiceSent
|
private CountLogger |
countLogger
Counters that get logged every second |
private static CountLogger.Counter |
countPacketsIgnored
|
private static CountLogger.Counter |
countPacketsReceived
|
private static CountLogger.Counter |
countPacketsSent
|
static CountLogger.Counter |
countSendLoginStatus
|
private static CountLogger.Counter |
countSeqNumGaps
|
protected static boolean |
createGroupWhenReferenced
If this is true, we'll synthesize the group and/or group member when an auth packet comes in. |
static TimeHistogram |
dataSendHistogram
|
protected static float |
hystericalMargin
The hysteresis constant: don't change whether a pair of positonal group members are in-radius of each other if the distance is within this distance of the audibleRadius. |
protected static VoicePlugin |
instance
singleton |
static int |
lengthBytes
There are two bytes in the length prefixed to a TCP message |
protected Lock |
lock
|
private Set<VoiceConnection> |
loginStatusEventReceivers
A map of connections that will receive login/logout events - - only used by the voice bot system. |
private short |
loginStatusSeqNum
The next sequence number for a login status message |
static int |
maxVoiceChannels
The server is supposed to run things so no client ever has more than this number of voice channels. |
static byte |
opcodeAggregatedData
An aggregated data packet contains a number of data packets. |
static byte |
opcodeAllocateCodec
Allocate a voice. |
static byte |
opcodeAllocatePositionalCodec
This has exactly the same payload as AllocateCodec, but says that the voice should be positional. |
static byte |
opcodeAuthenticate
The authenticate packet must be the first one received by the voice plugin on any new connection from a client. |
static byte |
opcodeChangeIgnoredStatus
An opcode sent exclusively from the client to the server that marks a collection of oids as ignored or not ignored. |
static byte |
opcodeData
A data packet, consisting of a 4-byte header followed by the bytes of the data frame. |
static byte |
opcodeDeallocate
Deallocate the voice number. |
static int |
opcodeHighest
|
static byte |
opcodeLoginStatus
An opcode sent exclusively from the server to the client, and used only to support synchronization between voice bots and test clients. |
static String[] |
opcodeNames
Used in logging messages |
static byte |
opcodeReconfirmCodec
This has exactly the same payload as AllocateCodec, but is with lossy transports like UDP to send the opcode parameters every second or so. |
static byte |
opcodeVoiceUnallocated
All voices start out unallocated |
protected PerceptionFilter |
perceptionFilter
|
protected long |
perceptionSubId
|
static TimeHistogram |
processPacketHistogram
|
private boolean |
recordVoices
Should we record all voices as we run? ??? TBD: We'll need to make this more selective in the production version, via an API call |
static boolean |
runHistograms
|
protected boolean |
running
|
private String |
serverVersion
The server version to send to clients |
static int[] |
speexNarrowBandFrameSize
This array is indexed by Speex narrow-band mode, and gives the narrow-band frame size for that mode. |
static int[] |
speexWideBandFrameSize
|
protected VoicePlugin.Updater |
updater
|
protected Thread |
updaterThread
|
static TimeHistogram |
voiceAllocHistogram
|
static TimeHistogram |
voiceDeallocHistogram
|
static int[] |
voiceMsgSize
This gives the number of bytes in the message excluding the length, except for the data case, where it gives the number of bytes in the header, but not including the data itself |
static byte |
voicePacketHeaderSize
All voice packets start with 4 bytes: o 16-bit sequence number, increased by one for each successive transmission for this voice. |
private Integer |
voicePort
The port number we're listening on |
| Fields inherited from interface multiverse.msgsys.MessageCallback |
|---|
NO_FLAGS, RESPONSE_EXPECTED |
| Constructor Summary | |
|---|---|
VoicePlugin()
The VoicePlugin accepts connections from game clients who have been supplied the IP and port number to contact by the initial game system login. |
|
| Method Summary | |
|---|---|
void |
acceptConnection(ClientConnection con)
The callback from ClientTCPIO invoked when a connection is established. |
void |
addGroup(long groupOid,
VoiceGroup group)
Inform the VoicePlugin about the existance of a voice group. |
protected void |
addToPerceptionFilter(long playerOid)
Internal method that adds the playerOid to the list of oids for which the perception filter will send perception messages. |
void |
connectionReset(ClientConnection con)
In response to a ClientConnection being closed, deallocate all voices in use by the connection, and remove the listeners, and close record stream if it's open. |
static int |
encodedFrameSizeForMode(int mode,
boolean wideBand)
Return the total frame size for narrow or wide-band mode given |
static int |
encodedFrameSizeFromFirstByte(byte b)
Return the frame size for the band/mode specified by the first byte of the Speex frame. |
protected void |
expungeVoiceClient(long playerOid)
Remove the voice client associated with the playerOid from the VoicePlugin data structures. |
protected void |
expungeVoiceClient(long playerOid,
VoiceConnection con)
Remove the voice client associated with the playerOid from the VoicePlugin data structures. |
protected VoiceGroup |
findVoiceGroup(long groupOid)
Return the group for groupOid, having checked to see that the group exists and contains the player. |
String |
formatCon(ClientConnection con)
Produce a string description of the ClientConnection object. |
VoiceConnection |
getConnectionData(ClientConnection con)
Get the VoiceConnection object associated with the ClientConnection. |
static VoicePlugin |
getInstance()
|
protected GroupMember |
getPlayerMember(long playerOid)
Get the GroupMember associated with the playerOid, or null if there is none. |
private void |
handleVoiceProperties()
A method to encache the voice-specific members of multiverse.properties. |
static short |
incSeqNum(short original)
Increment the short seqNum so that it wraps around properly. |
static short |
incSeqNum(short original,
int byWhat)
Increment the short seqNum so that it wraps around properly. |
protected void |
initializeIgnoreList(VoiceConnection playerCon)
|
void |
onActivate()
Register the hooks and create the subscriptions for the VoicePlugin. |
static String |
opcodeString(byte opcode)
Return a string representation of the opcode number; used for logging. |
protected BufferedOutputStream |
openSpeexVoiceFile(long oid)
Internal method used when writing Speex voice files. |
private Long |
parseLongOrNull(String s)
|
void |
processAuthenticationPacket(VoiceConnection playerCon,
MVByteBuffer buf)
Check to see of the auth packet contains the proper credentials, and if so, create a group member in the specified group. |
protected void |
processIgnoreListChangeMessage(VoiceConnection playerCon,
MVByteBuffer buf)
Change the ignored status of a set of potential speakers. |
void |
processPacket(ClientConnection con,
MVByteBuffer buf)
Process a packet received from a player. |
protected void |
removeFromPerceptionFilter(long playerOid)
Internal method that removes the playerOid from the list of oids for which the perception filter will send perception messages. |
void |
removeGroup(long groupOid)
Remove a group. |
void |
removePlayerFromGroup(VoiceConnection playerCon)
Remove the player identified by the argument from the group it belongs to. |
void |
sendAllocateVoice(VoiceConnection speaker,
VoiceConnection listener,
byte voiceNumber,
boolean positional)
Send an allocate voice packet to the listener, representing a voice channel from the speaker to the listener. |
void |
sendAllocateVoice(VoiceConnection speaker,
VoiceConnection listener,
byte voiceNumber,
byte opcode)
Send an allocate voice packet to the listener, representing a voice channel from the speaker to the listener. |
void |
sendDeallocateVoice(VoiceConnection speaker,
VoiceConnection listener,
byte voiceNumber)
Send a message to the connection deallocating the voice with the given number. |
void |
sendExtensionMessage(WorldManagerClient.ExtensionMessage msg)
Send an ExtensionMessage. |
void |
sendLoginStatus(VoiceConnection receiver,
long playerOid,
boolean login)
Send a login status message, telling the receiver that a player has logged in. |
protected void |
sendLoginStatusToReceivers(long playerOid,
boolean login)
Used only when running voice bots. |
private void |
sendPacketToListener(VoiceConnection listener,
MVByteBuffer buf)
Send a packet, whose contents is in the buf, to the listener. |
void |
sendVoiceFrame(VoiceConnection speaker,
VoiceConnection listener,
byte opcode,
byte voiceNumber,
MVByteBuffer sourceBuf,
short pktLength)
Send a message containing voice frame(s) to the listener. |
protected void |
trackNewPerceiver(PositionalGroupMember member)
Internal method to add the positional group member to the set of member whose perceived players will be tracked. |
protected void |
writeSpeexData(BufferedOutputStream recordSpeexStream,
byte[] buf,
int startIndex,
int byteCount)
Write a single Speex frame to the stream, from the byte array |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final byte voicePacketHeaderSize
public static final byte opcodeVoiceUnallocated
public static final byte opcodeAuthenticate
public static final byte opcodeAllocateCodec
public static final byte opcodeAllocatePositionalCodec
public static final byte opcodeReconfirmCodec
public static final byte opcodeDeallocate
public static final byte opcodeData
public static final byte opcodeAggregatedData
public static final byte opcodeLoginStatus
public static final byte opcodeChangeIgnoredStatus
public static final int opcodeHighest
public static String[] opcodeNames
public static int[] voiceMsgSize
public static int lengthBytes
public static int[] speexNarrowBandFrameSize
public static int[] speexWideBandFrameSize
public static int maxVoiceChannels
private CountLogger countLogger
private static CountLogger.Counter countPacketsIgnored
private static CountLogger.Counter countSeqNumGaps
public static CountLogger.Counter countSendLoginStatus
private static CountLogger.Counter countPacketsReceived
private static CountLogger.Counter countDataFramesReceived
public static CountLogger.Counter countAllocateVoiceReceived
public static CountLogger.Counter countDeallocateVoiceReceived
private static CountLogger.Counter countPacketsSent
private static CountLogger.Counter countDataFramesSent
public static CountLogger.Counter countAllocateVoiceSent
public static CountLogger.Counter countDeallocateVoiceSent
public static boolean runHistograms
public static TimeHistogram processPacketHistogram
public static TimeHistogram dataSendHistogram
public static TimeHistogram voiceAllocHistogram
public static TimeHistogram voiceDeallocHistogram
public static boolean checkAuthToken
private VoicePlugin.VoiceConManager conMgr
private Integer voicePort
private boolean recordVoices
private Set<VoiceConnection> loginStatusEventReceivers
private short loginStatusSeqNum
private ClientTCPMessageIO clientTCPMessageIO
protected static boolean createGroupWhenReferenced
protected static boolean allowVoiceBots
private static float audibleRadius
protected static float hystericalMargin
protected static VoicePlugin instance
private String serverVersion
protected PerceptionFilter perceptionFilter
protected long perceptionSubId
protected VoicePlugin.Updater updater
protected Thread updaterThread
protected boolean running
protected transient Lock lock
| Constructor Detail |
|---|
public VoicePlugin()
| Method Detail |
|---|
private void handleVoiceProperties()
private Long parseLongOrNull(String s)
public static VoicePlugin getInstance()
public void onActivate()
onActivate in class EnginePluginpublic void acceptConnection(ClientConnection con)
acceptConnection in interface ClientConnection.AcceptCallbackcon - The ClientConnection object for the new connection.
protected void sendLoginStatusToReceivers(long playerOid,
boolean login)
protected GroupMember getPlayerMember(long playerOid)
playerOid - The oid of the member returned.
public void processPacket(ClientConnection con,
MVByteBuffer buf)
processPacket in interface ClientConnection.MessageCallbackcon - The VoiceConnection object of the player sending the
packet.buf - The buffer containing the packet. The buf limit is
the size of the packet.
protected void writeSpeexData(BufferedOutputStream recordSpeexStream,
byte[] buf,
int startIndex,
int byteCount)
recordSpeexStream - The stream to which the voice frame(s) should be written.buf - The buffer containing the voice frame(s).startIndex - The index in the buf of the first byte to be written.byteCount - The number of bytes of frame data to be written.
public void processAuthenticationPacket(VoiceConnection playerCon,
MVByteBuffer buf)
playerCon - The VoiceConnection object for the player that
sent the auth packet.buf - The buffer containing the auth packet.protected void initializeIgnoreList(VoiceConnection playerCon)
protected void trackNewPerceiver(PositionalGroupMember member)
member - The positional group member to be tracked.
protected void processIgnoreListChangeMessage(VoiceConnection playerCon,
MVByteBuffer buf)
playerCon - The VoiceConnection object for the player that
sent the blacklist packet.buf - The buffer containing the blacklist message.protected void addToPerceptionFilter(long playerOid)
playerOid - The oid of the player to be added to the
perception filter.protected void removeFromPerceptionFilter(long playerOid)
playerOid - The oid of the player to be removed to the
perception filter.public void removePlayerFromGroup(VoiceConnection playerCon)
playerCon - The VoiceConnection object corresponding to the player.protected VoiceGroup findVoiceGroup(long groupOid)
groupOid - The oid of the group to be returned.
public void addGroup(long groupOid,
VoiceGroup group)
groupOid - The oid of the voice group to be added.group - The voice group to be added.public void removeGroup(long groupOid)
groupOid - The oid of the voice group to be removed.
private void sendPacketToListener(VoiceConnection listener,
MVByteBuffer buf)
listener - The VoiceConnection object for the listener.buf - The buffer containing the packet to be sent.
public void sendAllocateVoice(VoiceConnection speaker,
VoiceConnection listener,
byte voiceNumber,
boolean positional)
sendAllocateVoice in interface VoiceSenderspeaker - The VoiceConnection object for the speaker.listener - The VoiceConnection object for the listener.voiceNumber - The listener-specific number of the voice
channel that is created by this allocation.positional - If true, this voice channel is positional; if
false, non-positional.
public void sendAllocateVoice(VoiceConnection speaker,
VoiceConnection listener,
byte voiceNumber,
byte opcode)
sendAllocateVoice in interface VoiceSenderspeaker - The VoiceConnection object for the speaker.listener - The VoiceConnection object for the listener.voiceNumber - The listener-specific number of the voice
channel that is created by this allocation.opcode - The allocate opcode of the packet to be sent;
there are three kinds of allocate packets, each with different
opcodes, but at this time, only opcodeAllocateCodec is ever
sent.
public void sendDeallocateVoice(VoiceConnection speaker,
VoiceConnection listener,
byte voiceNumber)
sendDeallocateVoice in interface VoiceSenderspeaker - The VoiceConnection object for the speaker.listener - The VoiceConnection object for the listener.voiceNumber - The listener-specific number of the voice
channel that is removed by this deallocation.
public void sendVoiceFrame(VoiceConnection speaker,
VoiceConnection listener,
byte opcode,
byte voiceNumber,
MVByteBuffer sourceBuf,
short pktLength)
sendVoiceFrame in interface VoiceSenderspeaker - The VoiceConnection object for the speaker.listener - The VoiceConnection object for the listener.opcode - The opcode of the voice frame(s) packet. There
are two possible opcodes: opcodeData, which sends a single
frame, and opcodeAggregatedData, which sends multiple voice
frames.voiceNumber - The listener-specific number of the voice
channel that is removed by this deallocation.sourceBuf - The buffer containing the voice frame(s).pktLength - The number of bytes in the buffer.
public void sendLoginStatus(VoiceConnection receiver,
long playerOid,
boolean login)
receiver - The VoiceConnection object for the voice bot
manager to receive the packet.playerOid - The oid of the player whose login status
changed.login - If true, the playerOid logged in; if false, the
playerOid logged out.public void sendExtensionMessage(WorldManagerClient.ExtensionMessage msg)
sendExtensionMessage in interface VoiceSendermsg - The ExtensionMessage to be sent.protected BufferedOutputStream openSpeexVoiceFile(long oid)
oid - The oid used to look up the voice file.
public VoiceConnection getConnectionData(ClientConnection con)
con - The ClientConnection object whose VoiceConnection should be returned.
public String formatCon(ClientConnection con)
con - The ClientConnection object whose description is to be returned.
public void connectionReset(ClientConnection con)
connectionReset in interface ClientConnection.MessageCallbackcon - The ClientConnection object that was closed.protected void expungeVoiceClient(long playerOid)
playerOid - The oid of the player being expunged.
protected void expungeVoiceClient(long playerOid,
VoiceConnection con)
playerOid - The oid of the player being expunged.con - The VoiceConnection object for the player.public static short incSeqNum(short original)
original - The seqNum before being incremented.
public static short incSeqNum(short original,
int byWhat)
original - The seqNum before being incremented.byWhat - The amount to increment the seqNum by.
public static int encodedFrameSizeForMode(int mode,
boolean wideBand)
mode - The Speex mode number for the frame.wideBand - If true, the frame is wide-band; if false,
narrow-band.
public static int encodedFrameSizeFromFirstByte(byte b)
b - The first byte of the Speex frame.
public static String opcodeString(byte opcode)
opcode - The voice packet opcode.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||