adding feature sendUserState and voice target for whisper.
This commit is contained in:
parent
b7720cc7f3
commit
24e8ec4964
3
.gitignore
vendored
3
.gitignore
vendored
@ -32,3 +32,6 @@ build/
|
||||
# IntelliJ
|
||||
*.iml
|
||||
.idea/
|
||||
|
||||
# Boost
|
||||
include/boost/
|
||||
|
@ -50,10 +50,18 @@ namespace mumlib {
|
||||
|
||||
void sendAudioData(int16_t *pcmData, int pcmLength);
|
||||
|
||||
void sendAudioDataTarget(int targetId, int16_t *pcmData, int pcmLength);
|
||||
|
||||
void sendTextMessage(std::string message);
|
||||
|
||||
void joinChannel(int channelId);
|
||||
|
||||
void sendVoiceTarget(int targetId, int channelId);
|
||||
|
||||
void sendUserState(mumlib::UserState state, bool val);
|
||||
|
||||
void sendUserState(mumlib::UserState state, std::string value);
|
||||
|
||||
private:
|
||||
_Mumlib_Private *impl;
|
||||
};
|
||||
|
@ -45,4 +45,14 @@ namespace mumlib {
|
||||
OPUS
|
||||
};
|
||||
|
||||
enum class UserState {
|
||||
MUTE,
|
||||
DEAF,
|
||||
SUPPRESS,
|
||||
SELF_MUTE,
|
||||
SELF_DEAF,
|
||||
COMMENT,
|
||||
PRIORITY_SPEAKER,
|
||||
RECORDING
|
||||
};
|
||||
}
|
@ -181,7 +181,8 @@ bool mumlib::CryptState::decrypt(const unsigned char *source, unsigned char *dst
|
||||
#define SHIFTBITS 63
|
||||
typedef uint64_t subblock;
|
||||
|
||||
#define SWAP64(x) ({register uint64_t __out, __in = (x); __asm__("bswap %q0" : "=r"(__out) : "0"(__in)); __out;})
|
||||
// #define SWAP64(x) ({register uint64_t __out, __in = (x); __asm__("bswap %q0" : "=r"(__out) : "0"(__in)); __out;})
|
||||
#define SWAP64(x) (__builtin_bswap64(x))
|
||||
#define SWAPPED(x) SWAP64(x)
|
||||
|
||||
typedef subblock keyblock[BLOCKSIZE];
|
||||
|
@ -152,7 +152,7 @@ namespace mumlib {
|
||||
links_remove.push_back(channelState.links_remove(i));
|
||||
}
|
||||
|
||||
this->channelId = channel_id;
|
||||
// this->channelId = channel_id;
|
||||
|
||||
callback.channelState(
|
||||
channelState.name(),
|
||||
@ -369,7 +369,7 @@ namespace mumlib {
|
||||
|
||||
void Mumlib::disconnect() {
|
||||
if (not impl->externalIoService) {
|
||||
impl->ioService.reset();
|
||||
impl->ioService.stop();
|
||||
}
|
||||
if (impl->transport.getConnectionState() != ConnectionState::NOT_CONNECTED) {
|
||||
impl->transport.disconnect();
|
||||
@ -390,6 +390,12 @@ namespace mumlib {
|
||||
impl->transport.sendEncodedAudioPacket(encodedData, length);
|
||||
}
|
||||
|
||||
void Mumlib::sendAudioDataTarget(int targetId, int16_t *pcmData, int pcmLength) {
|
||||
uint8_t encodedData[5000];
|
||||
int length = impl->audio.encodeAudioPacket(targetId, pcmData, pcmLength, encodedData, 5000);
|
||||
impl->transport.sendEncodedAudioPacket(encodedData, length);
|
||||
}
|
||||
|
||||
void Mumlib::sendTextMessage(string message) {
|
||||
MumbleProto::TextMessage textMessage;
|
||||
textMessage.set_actor(impl->sessionId);
|
||||
@ -404,4 +410,63 @@ namespace mumlib {
|
||||
impl->transport.sendControlMessage(MessageType::USERSTATE, userState);
|
||||
impl->channelId = channelId;
|
||||
}
|
||||
|
||||
void Mumlib::sendVoiceTarget(int targetId, int channelId) {
|
||||
MumbleProto::VoiceTarget voiceTarget;
|
||||
MumbleProto::VoiceTarget_Target voiceTargetTarget;
|
||||
voiceTargetTarget.set_channel_id(channelId);
|
||||
voiceTargetTarget.set_children(true);
|
||||
voiceTarget.set_id(targetId);
|
||||
voiceTarget.add_targets()->CopyFrom(voiceTargetTarget);
|
||||
impl->transport.sendControlMessage(MessageType::VOICETARGET, voiceTarget);
|
||||
}
|
||||
|
||||
void Mumlib::sendUserState(mumlib::UserState field, bool val) {
|
||||
MumbleProto::UserState userState;
|
||||
|
||||
switch (field) {
|
||||
case UserState::MUTE:
|
||||
userState.set_mute(val);
|
||||
break;
|
||||
case UserState::DEAF:
|
||||
userState.set_deaf(val);
|
||||
break;
|
||||
case UserState::SUPPRESS:
|
||||
userState.set_suppress(val);
|
||||
break;
|
||||
case UserState::SELF_MUTE:
|
||||
userState.set_self_mute(val);
|
||||
break;
|
||||
case UserState::SELF_DEAF:
|
||||
userState.set_self_deaf(val);
|
||||
break;
|
||||
case UserState::PRIORITY_SPEAKER:
|
||||
userState.set_priority_speaker(val);
|
||||
break;
|
||||
case UserState::RECORDING:
|
||||
userState.set_recording(val);
|
||||
break;
|
||||
default:
|
||||
// in any other case, just ignore the command
|
||||
return;
|
||||
}
|
||||
|
||||
impl->transport.sendControlMessage(MessageType::USERSTATE, userState);
|
||||
}
|
||||
|
||||
void Mumlib::sendUserState(mumlib::UserState field, std::string val) {
|
||||
MumbleProto::UserState userState;
|
||||
|
||||
switch (field) {
|
||||
case UserState::COMMENT:
|
||||
// TODO: if comment longer than 128 bytes, we need to set the SHA1 hash
|
||||
userState.set_comment(val);
|
||||
break;
|
||||
default:
|
||||
// in any other case, just ignore the command
|
||||
return;
|
||||
}
|
||||
|
||||
impl->transport.sendControlMessage(MessageType::USERSTATE, userState);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user