Add audio forwarding to crosslink
This commit is contained in:
parent
aaeca932b8
commit
9540837e7a
41
crosslink.py
41
crosslink.py
|
@ -10,9 +10,15 @@ from frn.user import FRNUser
|
||||||
from twisted.python import log
|
from twisted.python import log
|
||||||
|
|
||||||
clients = []
|
clients = []
|
||||||
|
talking = None
|
||||||
|
|
||||||
class FRNCrosslinkClient(FRNClient):
|
class FRNCrosslinkClient(FRNClient):
|
||||||
|
|
||||||
|
def connectionMade(self):
|
||||||
|
self.txOk = False
|
||||||
|
self.txReq = False
|
||||||
|
FRNClient.connectionMade(self)
|
||||||
|
|
||||||
def getClientName(self, client_id):
|
def getClientName(self, client_id):
|
||||||
if self.clientsById.has_key(client_id):
|
if self.clientsById.has_key(client_id):
|
||||||
return self.clientsById[client_id]['on']
|
return self.clientsById[client_id]['on']
|
||||||
|
@ -20,6 +26,7 @@ class FRNCrosslinkClient(FRNClient):
|
||||||
return client_id
|
return client_id
|
||||||
|
|
||||||
def textMessageReceived(self, client, message, target):
|
def textMessageReceived(self, client, message, target):
|
||||||
|
global clients
|
||||||
if target == 'A':
|
if target == 'A':
|
||||||
for _, _, _, factory in clients:
|
for _, _, _, factory in clients:
|
||||||
if factory != self.factory:
|
if factory != self.factory:
|
||||||
|
@ -34,17 +41,45 @@ class FRNCrosslinkClient(FRNClient):
|
||||||
for c in factory.connection.clients:
|
for c in factory.connection.clients:
|
||||||
cl.append("(%s)" % (c['on'],))
|
cl.append("(%s)" % (c['on'],))
|
||||||
reply = ' '.join(cl)
|
reply = ' '.join(cl)
|
||||||
factory.connection.sendTextMessage(client, reply)
|
self.sendTextMessage(client, reply)
|
||||||
|
|
||||||
|
def decodeTX(self, my_id):
|
||||||
|
log.msg("Got TX ack for %s" % self.user.ON)
|
||||||
|
self.txOk = True
|
||||||
|
|
||||||
def stopTransmission(self):
|
def stopTransmission(self):
|
||||||
FRNClient.stopTransmission(self)
|
FRNClient.stopTransmission(self)
|
||||||
log.msg("Stopped playback.")
|
log.msg("Stopped TX on %s" % self.user.ON)
|
||||||
|
|
||||||
|
def goIdle(self):
|
||||||
|
global talking
|
||||||
|
self.txReq = False
|
||||||
|
self.txOk = False
|
||||||
|
talking = None
|
||||||
|
self.stopTransmission()
|
||||||
|
|
||||||
def audioFrameReceived(self, from_id, frames):
|
def audioFrameReceived(self, from_id, frames):
|
||||||
|
global clients, talking
|
||||||
|
if talking is None or talking == self:
|
||||||
|
talking = self
|
||||||
|
for _, _, _, factory in clients:
|
||||||
|
conn = factory.connection
|
||||||
|
if conn != self:
|
||||||
|
if conn.txOk:
|
||||||
|
conn.txReq = False
|
||||||
|
conn.sendAudioFrame(frames)
|
||||||
|
conn.busyTimer.reset(5.0)
|
||||||
|
else:
|
||||||
|
if not conn.txReq:
|
||||||
|
log.msg("Requesting TX for %s" % conn.user.ON)
|
||||||
|
conn.startTransmission()
|
||||||
|
conn.txReq = True
|
||||||
|
conn.busyTimer = conn.factory.reactor.callLater(
|
||||||
|
7.0, conn.goIdle)
|
||||||
self.pong()
|
self.pong()
|
||||||
|
|
||||||
def loginResponse(self, info):
|
def loginResponse(self, info):
|
||||||
log.msg("Login: %s" % info['al'])
|
log.msg("%s login: %s" % (self.user.ON, info['al']))
|
||||||
|
|
||||||
def clientsListUpdated(self, clients):
|
def clientsListUpdated(self, clients):
|
||||||
self.clients = clients
|
self.clients = clients
|
||||||
|
|
Loading…
Reference in New Issue