avatar-mixer resends to avoid stale avatar

This commit is contained in:
Andrew Meadows 2017-04-13 13:35:59 -07:00 committed by Chris Collins
parent e751080f64
commit eaefa3d3f2
2 changed files with 19 additions and 9 deletions

View file

@ -175,6 +175,7 @@ void AvatarMixerSlave::broadcastAvatarData(const SharedNodePointer& node) {
} }
}); });
const uint64_t MIN_KEEP_ALIVE_PERIOD_FOR_OTHER_AVATAR = (AVATAR_UPDATE_TIMEOUT - 1) * USECS_PER_SECOND;
AvatarSharedPointer thisAvatar = nodeData->getAvatarSharedPointer(); AvatarSharedPointer thisAvatar = nodeData->getAvatarSharedPointer();
ViewFrustum cameraView = nodeData->getViewFrustom(); ViewFrustum cameraView = nodeData->getViewFrustom();
std::priority_queue<AvatarPriority> sortedAvatars; std::priority_queue<AvatarPriority> sortedAvatars;
@ -262,11 +263,17 @@ void AvatarMixerSlave::broadcastAvatarData(const SharedNodePointer& node) {
// have 15 (45hz-30hz) duplicate frames. In this case, the stat // have 15 (45hz-30hz) duplicate frames. In this case, the stat
// avg_other_av_skips_per_second does report 15. // avg_other_av_skips_per_second does report 15.
// //
// make sure we haven't already sent this data from this sender to this receiver // make sure we haven't already sent this data from this sender to that receiver
// or that somehow we haven't sent // or that somehow we haven't sent
if (lastSeqToReceiver == lastSeqFromSender && lastSeqToReceiver != 0) { if (lastSeqToReceiver == lastSeqFromSender && lastSeqToReceiver != 0) {
++numAvatarsHeldBack; // don't ignore this avatar if we haven't sent any update for a long while
shouldIgnore = true; uint64_t lastBroadcastTime = nodeData->getLastBroadcastTime(avatarNode->getUUID());
const AvatarMixerClientData* otherNodeData = reinterpret_cast<const AvatarMixerClientData*>(avatarNode->getLinkedData());
if (lastBroadcastTime > otherNodeData->getIdentityChangeTimestamp() &&
lastBroadcastTime > startIgnoreCalculation - MIN_KEEP_ALIVE_PERIOD_FOR_OTHER_AVATAR) {
++numAvatarsHeldBack;
shouldIgnore = true;
}
} else if (lastSeqFromSender - lastSeqToReceiver > 1) { } else if (lastSeqFromSender - lastSeqToReceiver > 1) {
// this is a skip - we still send the packet but capture the presence of the skip so we see it happening // this is a skip - we still send the packet but capture the presence of the skip so we see it happening
++numAvatarsWithSkippedFrames; ++numAvatarsWithSkippedFrames;
@ -302,8 +309,12 @@ void AvatarMixerSlave::broadcastAvatarData(const SharedNodePointer& node) {
const AvatarMixerClientData* otherNodeData = reinterpret_cast<const AvatarMixerClientData*>(otherNode->getLinkedData()); const AvatarMixerClientData* otherNodeData = reinterpret_cast<const AvatarMixerClientData*>(otherNode->getLinkedData());
// If the time that the mixer sent AVATAR DATA about Avatar B to Avatar A is BEFORE OR EQUAL TO // If the time that the mixer sent AVATAR DATA about Avatar B to Avatar A is BEFORE OR EQUAL TO
// the time that Avatar B flagged an IDENTITY DATA change, send IDENTITY DATA about Avatar B to Avatar A. // the time that Avatar B flagged an IDENTITY DATA change
if (nodeData->getLastBroadcastTime(otherNode->getUUID()) <= otherNodeData->getIdentityChangeTimestamp()) { // or if no packet of any type has been sent for some time
// send IDENTITY DATA about Avatar B to Avatar A
uint64_t lastBroadcastTime = nodeData->getLastBroadcastTime(otherNode->getUUID());
if (lastBroadcastTime <= otherNodeData->getIdentityChangeTimestamp() ||
startAvatarDataPacking > lastBroadcastTime + MIN_KEEP_ALIVE_PERIOD_FOR_OTHER_AVATAR) {
identityBytesSent += sendIdentityPacket(otherNodeData, node); identityBytesSent += sendIdentityPacket(otherNodeData, node);
} }

View file

@ -110,6 +110,8 @@ const char LEFT_HAND_POINTING_FLAG = 1;
const char RIGHT_HAND_POINTING_FLAG = 2; const char RIGHT_HAND_POINTING_FLAG = 2;
const char IS_FINGER_POINTING_FLAG = 4; const char IS_FINGER_POINTING_FLAG = 4;
const qint64 AVATAR_UPDATE_TIMEOUT = 5 * USECS_PER_SECOND;
// AvatarData state flags - we store the details about the packet encoding in the first byte, // AvatarData state flags - we store the details about the packet encoding in the first byte,
// before the "header" structure // before the "header" structure
const char AVATARDATA_FLAGS_MINIMUM = 0; const char AVATARDATA_FLAGS_MINIMUM = 0;
@ -599,10 +601,7 @@ public:
} }
bool shouldDie() const { bool shouldDie() const { return _owningAvatarMixer.isNull() || getUsecsSinceLastUpdate() > AVATAR_UPDATE_TIMEOUT; }
const qint64 AVATAR_SILENCE_THRESHOLD_USECS = 5 * USECS_PER_SECOND;
return _owningAvatarMixer.isNull() || getUsecsSinceLastUpdate() > AVATAR_SILENCE_THRESHOLD_USECS;
}
static const float OUT_OF_VIEW_PENALTY; static const float OUT_OF_VIEW_PENALTY;