From 8cad240efcff64d7184427f85a0ba4319f056066 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 4 Oct 2020 01:40:44 +0100 Subject: [PATCH] disconnected voice --- bridge_master.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/bridge_master.py b/bridge_master.py index c6510d5..a072acf 100755 --- a/bridge_master.py +++ b/bridge_master.py @@ -201,6 +201,8 @@ def rule_timer_loop(): if _system['TIMER'] < _now: _system['ACTIVE'] = False logger.info('(ROUTER) Conference Bridge TIMEOUT: DEACTIVATE System: %s, Bridge: %s, TS: %s, TGID: %s', _system['SYSTEM'], _bridge, _system['TS'], int_id(_system['TGID'])) + if _bridge[0:1] == '#': + callInThread(disconnectedVoice,_system['SYSTEM']) else: timeout_in = _system['TIMER'] - _now logger.info('(ROUTER) Conference Bridge ACTIVE (ON timer running): System: %s Bridge: %s, TS: %s, TGID: %s, Timeout in: %.2fs,', _system['SYSTEM'], _bridge, _system['TS'], int_id(_system['TGID']), timeout_in) @@ -269,6 +271,31 @@ def stream_trimmer_loop(): else: logger.error('(%s) Attemped to remove OpenBridge Stream ID %s not in the Stream ID list: %s', system, int_id(stream_id), [id for id in systems[system].STATUS]) +def disconnectedVoice(system): + logger.info('(%s) Sending disconnected voice',system) + _say = [words['silence']] + if CONFIG['SYSTEMS'][system]['DEFAULT_REFLECTOR'] > 0: + for number in CONFIG['SYSTEMS'][system]['DEFAULT_REFLECTOR']: + _say.append[number] + _say.append['silence'] + else: + _say.append = words['notlinked'] + + speech = pkt_gen(bytes_3(tg), bytes_3(tg), bytes_4(tg), 1, _say) + + sleep(1) + while True: + try: + pkt = next(speech) + except StopIteration: + break + #Packet every 60ms + sleep(0.058) + #Twisted is not thread safe. We need to call this in the reactor main thread + reactor.callFromThread(systems[system].send_system,pkt) + #systems[system].send_system(pkt) + + def threadIdent(): logger.debug('(IDENT) starting ident thread') reactor.callInThread(ident)