bugfix
This commit is contained in:
parent
8edfd26796
commit
6694af192e
@ -22,15 +22,17 @@ from aav import MyAudioTrack, MyVideoTrack
|
||||
videos = ['./1.mp4', './2.mp4']
|
||||
|
||||
async def pc_get_local_candidates(pc, peer):
|
||||
ts = pc.getTransceivers()
|
||||
coros = map(lambda t: t.iceGatherer.gather(), ts)
|
||||
its = pc.__dict__.get('_RTCPeerConnection__iceTransports')
|
||||
coros = map(lambda t: t.iceGatherer.gather(), its )
|
||||
await asyncio.gather(*coros)
|
||||
ss = pc.__dict__.get('_RTCPeerConnection__iceTransport')
|
||||
|
||||
if not peer.l_candidates:
|
||||
peer.l_candidates = []
|
||||
for t in ts:
|
||||
for c in t.local_candidates():
|
||||
for t in its:
|
||||
for c in t._connection.local_candidates:
|
||||
if c not in peer.l_candidates:
|
||||
print(f'{c=}, {dir(c)}')
|
||||
peer.l_candidates.append(c)
|
||||
pc.emit('icecandidate', c)
|
||||
|
||||
@ -76,19 +78,13 @@ class RTCLLM:
|
||||
'info':self.info
|
||||
}))
|
||||
|
||||
async def on_icecandidate(self, pc, candidate):
|
||||
print('******************** on_icecandidate()', self, pc, candidate)
|
||||
async def on_icecandidate(self, pc, to, candidate):
|
||||
print('******************** on_icecandidate()', self, pc, candidate, candidate.__class__.__name__)
|
||||
if candidate:
|
||||
await self.ws_send(json.dumps({
|
||||
"type":"candidate",
|
||||
"candidate":candidate,
|
||||
}))
|
||||
async def send_candidate(self, to, candidate):
|
||||
print(f'send_candidate():{candidate=}')
|
||||
await self.ws_send(json.dumps({
|
||||
'type':'candidate',
|
||||
'to':to,
|
||||
'candidate':candidate
|
||||
"type":"iceCandidate",
|
||||
"to":to,
|
||||
"candidate":{'candidate':candidate.to_sdp(), 'type': candidate.type}
|
||||
}))
|
||||
|
||||
async def save_onlineList(self, data):
|
||||
@ -173,7 +169,7 @@ class RTCLLM:
|
||||
return
|
||||
pc.on("connectionstatechange", partial(self.pc_connectionState_changed, data['from'].id))
|
||||
pc.on('track', partial(self.pc_track, data['from'].id))
|
||||
pc.on('icecandidate', partial(self.on_icecandidate, pc))
|
||||
pc.on('icecandidate', partial(self.on_icecandidate, pc, data['from']))
|
||||
# self.play_video(data)
|
||||
|
||||
offer = RTCSessionDescription(** data.offer)
|
||||
@ -186,8 +182,6 @@ class RTCLLM:
|
||||
'to':data['from']
|
||||
}))
|
||||
cands = await pc.get_local_candidates(peer)
|
||||
for c in cands:
|
||||
await self.send_candidate(data['from'], c)
|
||||
|
||||
"""
|
||||
offer = await pc.createOffer()
|
||||
@ -207,13 +201,7 @@ class RTCLLM:
|
||||
async def accept_iceCandidate(self, data):
|
||||
pc = self.get_pc(data)
|
||||
candidate = data.candidate
|
||||
ip = candidate['candidate'].split(' ')[4]
|
||||
port = candidate['candidate'].split(' ')[5]
|
||||
protocol = candidate['candidate'].split(' ')[7]
|
||||
priority = candidate['candidate'].split(' ')[3]
|
||||
foundation = candidate['candidate'].split(' ')[0]
|
||||
component = candidate['candidate'].split(' ')[1]
|
||||
type = candidate['candidate'].split(' ')[7]
|
||||
print('accepted candidate=', candidate)
|
||||
"""
|
||||
rtc_candidate = RTCIceCandidate(
|
||||
ip=ip,
|
||||
@ -245,8 +233,8 @@ async def main():
|
||||
hf_socks5proxy()
|
||||
agent = RTCLLM(ws_url='wss://sage.opencomputing.cn/wss/ws/rtc_signaling.ws',
|
||||
iceServers=[{
|
||||
'urls':'stun:stun.opencomputing.cn'},{
|
||||
'urls':'turn:stun.opencomputing.cn',
|
||||
'urls':'stun:stun.opencomputing.cn:13478'},{
|
||||
'urls':'turn:stun.opencomputing.cn:13479',
|
||||
'username':'turn',
|
||||
'credential':'server'
|
||||
}])
|
||||
|
@ -117,7 +117,7 @@ class AudioTrackVad(MediaStreamTrack):
|
||||
fs = self.resample(f, sample_rate=16000)
|
||||
lst += fs
|
||||
audio_data = b''.join([self.frame2bytes(f) for f in lst])
|
||||
return to_mono16000_data
|
||||
return audio_data
|
||||
|
||||
async def gen_base64(self):
|
||||
audio_data = self.to_mono16000_data()
|
||||
|
Loading…
Reference in New Issue
Block a user