First steps, holding off til Howard finishes

This commit is contained in:
Zach Fox 2016-12-22 12:42:50 -08:00
parent 800389cf20
commit 46e8bf5283
9 changed files with 178 additions and 12 deletions

View file

@ -66,6 +66,8 @@ AudioMixer::AudioMixer(ReceivedMessage& message) :
packetReceiver.registerListener(PacketType::MuteEnvironment, this, "handleMuteEnvironmentPacket");
packetReceiver.registerListener(PacketType::NodeIgnoreRequest, this, "handleNodeIgnoreRequestPacket");
packetReceiver.registerListener(PacketType::NodeUnignoreRequest, this, "handleNodeUnignoreRequestPacket");
packetReceiver.registerListener(PacketType::NodePersonalMuteRequest, this, "handleNodePersonalMuteRequestPacket");
packetReceiver.registerListener(PacketType::NodePersonalMuteStatusRequest, this, "handleNodePersonalMuteStatusRequestPacket");
packetReceiver.registerListener(PacketType::KillAvatar, this, "handleKillAvatarPacket");
packetReceiver.registerListener(PacketType::NodeMuteRequest, this, "handleNodeMuteRequestPacket");
packetReceiver.registerListener(PacketType::RadiusIgnoreRequest, this, "handleRadiusIgnoreRequestPacket");
@ -230,6 +232,54 @@ void AudioMixer::handleNodeUnignoreRequestPacket(QSharedPointer<ReceivedMessage>
sendingNode->parseUnignoreRequestMessage(packet);
}
void AudioMixer::handleNodePersonalMuteRequestPacket(QSharedPointer<ReceivedMessage> packet, SharedNodePointer sendingNode) {
// parse out the UUID being muted from the packet
QUuid ignoredUUID = QUuid::fromRfc4122(packet->readWithoutCopy(NUM_BYTES_RFC4122_UUID));
bool enabled;
packet->readPrimitive(&enabled);
if (!ignoredUUID.isNull() && ignoredUUID != _uuid) {
if (enabled) {
qDebug() << "Adding" << uuidStringWithoutCurlyBraces(ignoredUUID) << "to personally muted set for"
<< uuidStringWithoutCurlyBraces(_uuid);
// Add the session UUID to the set of personally muted ones for this listening node
sendingNode->addIgnoredNode(ignoredUUID);
} else {
qDebug() << "Removing" << uuidStringWithoutCurlyBraces(ignoredUUID) << "from personally muted set for"
<< uuidStringWithoutCurlyBraces(_uuid);
// Remove the session UUID to the set of personally muted ones for this listening node
sendingNode->_ignoredNodeIDSet.unsafe_erase(ignoredUUID);
}
} else {
qWarning() << "Node::addPersonalMutedNode called with null ID or ID of personal muting node.";
}
}
void AudioMixer::handleNodePersonalMuteStatusRequestPacket(QSharedPointer<ReceivedMessage> packet, SharedNodePointer sendingNode) {
// parse out the UUID whose personal mute status is being requested from the packet
QUuid UUIDToCheck = QUuid::fromRfc4122(message->readWithoutCopy(NUM_BYTES_RFC4122_UUID));
if (!UUIDToCheck.isNull()) {
// First, make sure we actually have a node with this UUID
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
auto matchingNode = limitedNodeList->nodeWithUUID(UUIDToCheck);
// If we do have a matching node...
if (matchingNode) {
auto personalMuteStatusPacket = NLPacket::create(PacketType::NodePersonalMuteStatusReply, NUM_BYTES_RFC4122_UUID + sizeof(bool), true);
// write the node ID to the packet
personalMuteStatusPacket->write(UUIDToCheck.toRfc4122());
personalMuteStatusPacket->writePrimitive(isIgnoringNodeWithID(UUIDToCheck));
qCDebug(networking) << "Sending Personal Mute Status Request Packet for node" << uuidStringWithoutCurlyBraces(nodeID);
limitedNodeList->sendPacket(std::move(personalMuteStatusPacket), *sendingNode);
}
}
}
void AudioMixer::handleRadiusIgnoreRequestPacket(QSharedPointer<ReceivedMessage> packet, SharedNodePointer sendingNode) {
sendingNode->parseIgnoreRadiusRequestMessage(packet);
}

View file

@ -63,6 +63,8 @@ private slots:
void handleNodeKilled(SharedNodePointer killedNode);
void handleNodeIgnoreRequestPacket(QSharedPointer<ReceivedMessage> packet, SharedNodePointer sendingNode);
void handleNodeUnignoreRequestPacket(QSharedPointer<ReceivedMessage> packet, SharedNodePointer sendingNode);
void handleNodePersonalMuteRequestPacket(QSharedPointer<ReceivedMessage> packet, SharedNodePointer sendingNode);
void handleNodePersonalMuteStatusRequestPacket(QSharedPointer<ReceivedMessage> packet, SharedNodePointer sendingNode);
void handleRadiusIgnoreRequestPacket(QSharedPointer<ReceivedMessage> packet, SharedNodePointer sendingNode);
void handleKillAvatarPacket(QSharedPointer<ReceivedMessage> packet, SharedNodePointer sendingNode);
void handleNodeMuteRequestPacket(QSharedPointer<ReceivedMessage> packet, SharedNodePointer sendingNode);

View file

@ -210,22 +210,28 @@ Item {
var newValue = !model[styleData.role]
var datum = userData[model.userIndex]
datum[styleData.role] = model[styleData.role] = newValue
var key = styleData.role;
if (!newValue) {
key = 'un' + key;
}
if (styleData.role === 'ignore') {
if (styleData.role === "personalMute") {
Users[styleData.role](model.sessionId, newValue)
} else if (styleData.role === 'ignore') {
var key = styleData.role;
if (!newValue) {
key = 'un' + key;
}
if (newValue) {
ignored[datum.sessionId] = datum;
console.log('fixme hrs adding to ignored', JSON.stringify(datum), 'at', datum.sessionId);
} else {
delete ignored[datum.sessionId];
}
}
console.log('fixme hrs pal action', key, model.sessionId);
Users[key](model.sessionId);
} else {
Users[styleData.role](model.sessionId)
// Just for now, while we cannot undo things:
userData.splice(model.userIndex, 1)
sortModel()
}
console.log('fixme hrs pal action', key, model.sessionId);
Users[key](model.sessionId);
}
}
}
}
// Refresh button
@ -422,7 +428,14 @@ Item {
}
}
break;
default:
case 'updateMuted':
var userId = message.params[0];
var enabled = message.params[1];
var userIndex = findSessionIndex(userId);
userModel.get(userIndex).personalMute.property = enabled;
userData[userIndex].personalMute.property = enabled; // Defensive programming
break;
default:
console.log('Unrecognized message:', JSON.stringify(message));
}
}

View file

@ -875,6 +875,64 @@ void NodeList::maybeSendIgnoreSetToNode(SharedNodePointer newNode) {
}
}
void NodeList::personalMuteNodeBySessionID(const QUuid& nodeID, bool enabled) {
// cannot personal mute yourself, or nobody
if (!nodeID.isNull() && _sessionUUID != nodeID) {
auto audioMixer = soloNodeOfType(NodeType::AudioMixer);
if (audioMixer) {
// setup the packet
auto personalMutePacket = NLPacket::create(PacketType::NodePersonalMuteRequest, NUM_BYTES_RFC4122_UUID + sizeof(bool), true);
// write the node ID to the packet
personalMutePacket->write(nodeID.toRfc4122());
personalMutePacket->writePrimitive(enabled);
qCDebug(networking) << "Sending Personal Mute Packet to" << (enabled ? "mute" : "unmute") << "node" << uuidStringWithoutCurlyBraces(nodeID);
sendPacket(std::move(personalMutePacket), *audioMixer);
} else {
qWarning() << "Couldn't find audio mixer to send node personal mute request";
}
} else {
qWarning() << "NodeList::personalMuteNodeBySessionID called with an invalid ID or an ID which matches the current session ID.";
}
}
void NodeList::requestPersonalMuteStatus(const QUuid& nodeID) {
// cannot personal mute yourself, or nobody; don't bother checking the status
if (!nodeID.isNull() && _sessionUUID != nodeID) {
auto audioMixer = soloNodeOfType(NodeType::AudioMixer);
if (audioMixer) {
// send a request to the audio mixer to get the personal mute status associated with the given session ID
// setup the packet
auto personalMuteStatusPacket = NLPacket::create(PacketType::NodePersonalMuteStatusRequest, NUM_BYTES_RFC4122_UUID, true);
// write the node ID to the packet
personalMuteStatusPacket->write(nodeID.toRfc4122());
qCDebug(networking) << "Sending Personal Mute Status Request Packet for node" << uuidStringWithoutCurlyBraces(nodeID);
sendPacket(std::move(personalMuteStatusPacket), *audioMixer);
} else {
qWarning() << "Couldn't find audio mixer to send node personal mute status request";
}
} else {
qWarning() << "NodeList::requestPersonalMuteStatus called with an invalid ID or an ID which matches the current session ID.";
}
}
void NodeList::processPersonalMuteStatusReply(QSharedPointer<ReceivedMessage> message) {
// read the UUID from the packet
QString nodeUUIDString = (QUuid::fromRfc4122(message->readWithoutCopy(NUM_BYTES_RFC4122_UUID))).toString();
// read the personal mute status
bool isPersonalMuted;
message->readPrimitive(&isPersonalMuted);
qCDebug(networking) << "Got personal muted status" << isPersonalMuted << "for node" << nodeUUIDString;
emit personalMuteStatusReply(nodeUUIDString, isPersonalMuted);
}
void NodeList::kickNodeBySessionID(const QUuid& nodeID) {
// send a request to domain-server to kick the node with the given session ID
// the domain-server will handle the persistence of the kick (via username or IP)

View file

@ -79,12 +79,14 @@ public:
void ignoreNodeBySessionID(const QUuid& nodeID);
void unignoreNodeBySessionID(const QUuid& nodeID);
bool isIgnoringNode(const QUuid& nodeID) const;
void personalMuteNodeBySessionID(const QUuid& nodeID, bool enabled);
void kickNodeBySessionID(const QUuid& nodeID);
void muteNodeBySessionID(const QUuid& nodeID);
void requestUsernameFromSessionID(const QUuid& nodeID);
bool getRequestsDomainListData() { return _requestsDomainListData; }
void setRequestsDomainListData(bool isRequesting);
void requestPersonalMuteStatus(const QUuid& nodeID);
public slots:
void reset();
@ -104,6 +106,7 @@ public slots:
void processICEPingPacket(QSharedPointer<ReceivedMessage> message);
void processUsernameFromIDReply(QSharedPointer<ReceivedMessage> message);
void processPersonalMuteStatusReply(QSharedPointer<ReceivedMessage> message);
#if (PR_BUILD || DEV_BUILD)
void toggleSendNewerDSConnectVersion(bool shouldSendNewerVersion) { _shouldSendNewerVersion = shouldSendNewerVersion; }
@ -116,6 +119,7 @@ signals:
void unignoredNode(const QUuid& nodeID);
void ignoreRadiusEnabledChanged(bool isIgnored);
void usernameFromIDReply(const QString& nodeID, const QString& username, const QString& machineFingerprint);
void personalMuteStatusReply(const QString& nodeID, bool isPersonalMuted);
private slots:
void stopKeepalivePingTimer();

View file

@ -106,7 +106,10 @@ public:
ViewFrustum,
RequestsDomainListData,
NodeUnignoreRequest,
LAST_PACKET_TYPE = NodeUnignoreRequest
NodePersonalMuteRequest,
NodePersonalMuteStatusRequest,
NodePersonalMuteStatusReply,
LAST_PACKET_TYPE = NodePersonalMuteStatusReply
};
};
@ -245,6 +248,7 @@ enum class AudioVersion : PacketVersion {
Exactly10msAudioPackets,
TerminatingStreamStats,
SpaceBubbleChanges,
HasPersonalMute,
};
#endif // hifi_PacketHeaders_h

View file

@ -21,6 +21,7 @@ UsersScriptingInterface::UsersScriptingInterface() {
connect(nodeList.data(), &NodeList::usernameFromIDReply, this, &UsersScriptingInterface::usernameFromIDReply);
connect(nodeList.data(), &NodeList::ignoredNode, this, &UsersScriptingInterface::ignoredNode);
connect(nodeList.data(), &NodeList::unignoredNode, this, &UsersScriptingInterface::unignoredNode);
connect(nodeList.data(), &NodeList::personalMuteStatusReply, this, &UsersScriptingInterface::personalMuteStatusReply);
}
void UsersScriptingInterface::ignore(const QUuid& nodeID) {
@ -33,6 +34,17 @@ void UsersScriptingInterface::unignore(const QUuid& nodeID) {
DependencyManager::get<NodeList>()->unignoreNodeBySessionID(nodeID);
}
void UsersScriptingInterface::personalMute(const QUuid& nodeID, bool enabled) {
// ask the NodeList to mute the user with the given session ID
// "Personal Mute" only applies one way and is not global
DependencyManager::get<NodeList>()->personalMuteNodeBySessionID(nodeID, enabled);
}
void UsersScriptingInterface::requestPersonalMuteStatus(const QUuid& nodeID) {
// ask the Audio Mixer via the NodeList for the Personal Mute status associated with the given session ID
DependencyManager::get<NodeList>()->requestPersonalMuteStatus(nodeID);
}
void UsersScriptingInterface::kick(const QUuid& nodeID) {
// ask the NodeList to kick the user with the given session ID

View file

@ -39,6 +39,21 @@ public slots:
void ignore(const QUuid& nodeID);
void unignore(const QUuid& nodeID);
/**jsdoc
* Mute another user for you and you only.
* @function Users.personalMute
* @param {nodeID} nodeID The node or session ID of the user you want to mute.
* @param {bool} enable True for enabled; false for disabled.
*/
void personalMute(const QUuid& nodeID, bool enabled);
/**jsdoc
* Requests a bool containing whether you have given the given Avatar UUID.
* @function Users.requestPersonalMuteStatus
* @param {nodeID} nodeID The node or session ID of the user whose personal mute status you want.
*/
void requestPersonalMuteStatus(const QUuid& nodeID);
/**jsdoc
* Kick another user.
* @function Users.kick
@ -47,7 +62,7 @@ public slots:
void kick(const QUuid& nodeID);
/**jsdoc
* Mute another user.
* Mute another user for everyone.
* @function Users.mute
* @param {nodeID} nodeID The node or session ID of the user you want to mute.
*/
@ -110,6 +125,12 @@ signals:
*/
void usernameFromIDReply(const QString& nodeID, const QString& username, const QString& machineFingerprint);
/**jsdoc
* Notifies scripts of the Personal Mute status associated with a UUID.
* @function Users.usernameFromIDReply
*/
void personalMuteStatusReply(const QString& nodeID, bool isPersonalMuted);
private:
bool getRequestsDomainListData();
void setRequestsDomainListData(bool requests);

View file

@ -132,6 +132,8 @@ function populateUserList() {
// Request the username from the given UUID
Users.requestUsernameFromID(id);
}
// Request personal mute status from AudioMixer
Users.requestPersonalMuteStatus(id);
data.push(avatarPalDatum);
if (id) { // No overlay for ourself.
addAvatarNode(id);