push various PACKET_TYPES, repairs to Agent for UUID setup

This commit is contained in:
Stephen Birarda 2013-10-17 13:35:53 -07:00
parent 0ae825d761
commit 74e66dfd35
6 changed files with 45 additions and 30 deletions

View file

@ -155,35 +155,42 @@ void Agent::run() {
NodeList::getInstance()->sendDomainServerCheckIn();
}
if (firstDomainCheckIn) {
// find the audio-mixer in the NodeList so we can inject audio at it
Node* audioMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
// find the audio-mixer in the NodeList so we can inject audio at it
Node* audioMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
if (audioMixer && audioMixer->getActiveSocket()) {
emit willSendAudioDataCallback();
if (audioMixer && scriptedAudioInjector.hasSamplesToInject()) {
if (scriptedAudioInjector.hasSamplesToInject()) {
int usecToSleep = usecTimestamp(&startTime) + (thisFrame++ * INJECT_INTERVAL_USECS) - usecTimestampNow();
if (usecToSleep > 0) {
usleep(usecToSleep);
}
scriptedAudioInjector.injectAudio(NodeList::getInstance()->getNodeSocket(), audioMixer->getPublicSocket());
scriptedAudioInjector.injectAudio(NodeList::getInstance()->getNodeSocket(), audioMixer->getActiveSocket());
// clear out the audio injector so that it doesn't re-send what we just sent
scriptedAudioInjector.clear();
}
} else if (audioMixer) {
int usecToSleep = usecTimestamp(&startTime) + (thisFrame++ * INJECT_INTERVAL_USECS) - usecTimestampNow();
if (usecToSleep > 0) {
usleep(usecToSleep);
}
// allow the scripter's call back to setup visual data
emit willSendVisualDataCallback();
// release the queue of edit voxel messages.
voxelScripter.getVoxelPacketSender()->releaseQueuedMessages();
// since we're in non-threaded mode, call process so that the packets are sent
voxelScripter.getVoxelPacketSender()->process();
// don't have an active socket for the audio-mixer, ping it now
NodeList::getInstance()->pingPublicAndLocalSocketsForInactiveNode(audioMixer);
}
// allow the scripter's call back to setup visual data
emit willSendVisualDataCallback();
// release the queue of edit voxel messages.
voxelScripter.getVoxelPacketSender()->releaseQueuedMessages();
// since we're in non-threaded mode, call process so that the packets are sent
voxelScripter.getVoxelPacketSender()->process();
if (engine.hasUncaughtException()) {
int line = engine.uncaughtExceptionLineNumber();
qDebug() << "Uncaught exception at line" << line << ":" << engine.uncaughtException().toString() << "\n";

View file

@ -9,6 +9,7 @@
#include <cstring>
#include <PacketHeaders.h>
#include <UUID.h>
#include "InjectedAudioRingBuffer.h"
@ -22,6 +23,9 @@ InjectedAudioRingBuffer::InjectedAudioRingBuffer() :
int InjectedAudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) {
unsigned char* currentBuffer = sourceBuffer + numBytesForPacketHeader(sourceBuffer);
// push past the UUID for this injector
currentBuffer += NUM_BYTES_RFC4122_UUID;
// use parsePositionalData in parent PostionalAudioRingBuffer class to pull common positional data
currentBuffer += parsePositionalData(currentBuffer, numBytes - (currentBuffer - sourceBuffer));

View file

@ -28,7 +28,7 @@ PositionalAudioRingBuffer::~PositionalAudioRingBuffer() {
int PositionalAudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) {
unsigned char* currentBuffer = sourceBuffer + numBytesForPacketHeader(sourceBuffer);
currentBuffer += NUM_BYTES_RFC4122_UUID; // the source ID
currentBuffer += NUM_BYTES_RFC4122_UUID; // the source UUID
currentBuffer += parsePositionalData(currentBuffer, numBytes - (currentBuffer - sourceBuffer));
currentBuffer += parseAudioSamples(currentBuffer, numBytes - (currentBuffer - sourceBuffer));

View file

@ -589,12 +589,10 @@ void NodeList::pingPublicAndLocalSocketsForInactiveNode(Node* node) const {
Node* NodeList::addOrUpdateNode(const QUuid& uuid, char nodeType, sockaddr* publicSocket, sockaddr* localSocket) {
NodeList::iterator node = end();
if (publicSocket) {
for (node = begin(); node != end(); node++) {
if (node->matches(publicSocket, localSocket, nodeType)) {
// we already have this node, stop checking
break;
}
for (node = begin(); node != end(); node++) {
if (node->getUUID() == uuid) {
// we already have this node, stop checking
break;
}
}

View file

@ -17,24 +17,25 @@ PACKET_VERSION versionForPacketType(PACKET_TYPE type) {
case PACKET_TYPE_MICROPHONE_AUDIO_NO_ECHO:
case PACKET_TYPE_MICROPHONE_AUDIO_WITH_ECHO:
return 1;
return 2;
case PACKET_TYPE_HEAD_DATA:
return 9;
return 10;
case PACKET_TYPE_AVATAR_URLS:
return 1;
return 2;
case PACKET_TYPE_AVATAR_FACE_VIDEO:
return 1;
return 2;
case PACKET_TYPE_VOXEL_STATS:
return 2;
case PACKET_TYPE_DOMAIN:
case PACKET_TYPE_DOMAIN_LIST_REQUEST:
case PACKET_TYPE_DOMAIN_REPORT_FOR_DUTY:
return 1;
default:
return 0;
}

View file

@ -102,10 +102,15 @@ void VoxelEditPacketSender::queuePacketToNode(const QUuid& nodeUUID, unsigned ch
NodeList* nodeList = NodeList::getInstance();
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
// only send to the NodeTypes that are NODE_TYPE_VOXEL_SERVER
if (node->getActiveSocket() != NULL && node->getType() == NODE_TYPE_VOXEL_SERVER &&
if (node->getType() == NODE_TYPE_VOXEL_SERVER &&
((node->getUUID() == nodeUUID) || (nodeUUID.isNull()))) {
sockaddr* nodeAddress = node->getActiveSocket();
queuePacketForSending(*nodeAddress, buffer, length);
if (node->getActiveSocket()) {
sockaddr* nodeAddress = node->getActiveSocket();
queuePacketForSending(*nodeAddress, buffer, length);
} else {
// we don't have an active socket for this node, ping it
nodeList->pingPublicAndLocalSocketsForInactiveNode(&(*node));
}
}
}
}