add caller pin for entering mumble session
caller must enter pin before being unmuted/undeafened in mumble room
This commit is contained in:
parent
e0a3a67410
commit
dc77504338
@ -144,7 +144,16 @@ namespace sip {
|
|||||||
|
|
||||||
communicator.logger.notice(msgText);
|
communicator.logger.notice(msgText);
|
||||||
communicator.onStateChange(msgText);
|
communicator.onStateChange(msgText);
|
||||||
communicator.onMuteDeafChange(0);
|
|
||||||
|
communicator.got_dtmf = "";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* if no pin is set, go ahead and turn off mute/deaf
|
||||||
|
* otherwise, wait for pin to be entered
|
||||||
|
*/
|
||||||
|
if ( communicator.pin.length() == 0 ) {
|
||||||
|
communicator.onMuteDeafChange(0);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (ci.state == PJSIP_INV_STATE_DISCONNECTED) {
|
} else if (ci.state == PJSIP_INV_STATE_DISCONNECTED) {
|
||||||
auto &acc = dynamic_cast<_Account &>(account);
|
auto &acc = dynamic_cast<_Account &>(account);
|
||||||
@ -183,7 +192,31 @@ namespace sip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _Call::onDtmfDigit(pj::OnDtmfDigitParam &prm) {
|
void _Call::onDtmfDigit(pj::OnDtmfDigitParam &prm) {
|
||||||
communicator.logger.notice("DTMF digit '%s' (call %d).", prm.digit.c_str(), getId());
|
communicator.logger.notice("DTMF digit '%s' (call %d).",
|
||||||
|
prm.digit.c_str(), getId());
|
||||||
|
pj::CallOpParam param;
|
||||||
|
|
||||||
|
if ( communicator.pin.length() > 0 ) {
|
||||||
|
if ( prm.digit == "#" ) {
|
||||||
|
communicator.logger.notice("DTMF got string command %s",
|
||||||
|
communicator.got_dtmf.c_str());
|
||||||
|
if ( communicator.got_dtmf == communicator.pin ) {
|
||||||
|
communicator.logger.notice("Caller entered correct PIN");
|
||||||
|
communicator.onMuteDeafChange(0);
|
||||||
|
} else {
|
||||||
|
communicator.logger.notice("Caller entered wrong PIN");
|
||||||
|
param.statusCode = PJSIP_SC_SERVICE_UNAVAILABLE;
|
||||||
|
this->hangup(param);
|
||||||
|
}
|
||||||
|
communicator.got_dtmf = "";
|
||||||
|
} else {
|
||||||
|
communicator.logger.notice("DTMF append %s to %s",
|
||||||
|
prm.digit.c_str(), communicator.got_dtmf.c_str());
|
||||||
|
communicator.got_dtmf = communicator.got_dtmf + prm.digit;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
communicator.logger.notice("DTMF ignoring %s", prm.digit.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _Account::onRegState(pj::OnRegStateParam &prm) {
|
void _Account::onRegState(pj::OnRegStateParam &prm) {
|
||||||
@ -324,3 +357,4 @@ void sip::PjsuaCommunicator::registerAccount(string host, string user, string pa
|
|||||||
account.reset(new _Account(*this));
|
account.reset(new _Account(*this));
|
||||||
account->create(accountConfig);
|
account->create(accountConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +76,9 @@ namespace sip {
|
|||||||
int16_t *samples,
|
int16_t *samples,
|
||||||
unsigned int length);
|
unsigned int length);
|
||||||
|
|
||||||
|
std::string pin;
|
||||||
|
std::string got_dtmf;
|
||||||
|
|
||||||
std::function<void(int16_t *, int)> onIncomingPcmSamples;
|
std::function<void(int16_t *, int)> onIncomingPcmSamples;
|
||||||
|
|
||||||
std::function<void(std::string)> onStateChange;
|
std::function<void(std::string)> onStateChange;
|
||||||
|
@ -28,6 +28,11 @@ channelNameExpression =
|
|||||||
# in the same group
|
# in the same group
|
||||||
autodeaf = 0
|
autodeaf = 0
|
||||||
|
|
||||||
|
# Caller PIN needed to authenticate the phone call itself. The caller presses
|
||||||
|
# the PIN, followed by the hash '#' key. On success, the caller is
|
||||||
|
# unmuted/undeafened. On failure, the SIP call is hung up.
|
||||||
|
pin = 4321
|
||||||
|
|
||||||
# Bitrate of Opus encoder in B/s
|
# Bitrate of Opus encoder in B/s
|
||||||
# Adjust it if you need to meet the specific bandwidth requirements of Murmur server
|
# Adjust it if you need to meet the specific bandwidth requirements of Murmur server
|
||||||
opusEncoderBitrate = 16000
|
opusEncoderBitrate = 16000
|
||||||
|
7
main.cpp
7
main.cpp
@ -96,6 +96,13 @@ int main(int argc, char *argv[]) {
|
|||||||
mumbleConf.autodeaf = false;
|
mumbleConf.autodeaf = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* default to <no pin> */
|
||||||
|
try {
|
||||||
|
pjsuaCommunicator.pin = conf.getString("mumble.pin");
|
||||||
|
} catch (...) {
|
||||||
|
pjsuaCommunicator.pin = "";
|
||||||
|
}
|
||||||
|
|
||||||
mumbleCommunicator.connect(mumbleConf);
|
mumbleCommunicator.connect(mumbleConf);
|
||||||
|
|
||||||
pjsuaCommunicator.connect(
|
pjsuaCommunicator.connect(
|
||||||
|
Loading…
Reference in New Issue
Block a user