This commit is contained in:
yumoqing 2024-09-02 10:36:07 +08:00
parent 64fee77657
commit dae6e9a431

View File

@ -84,7 +84,7 @@ class RTCLLM:
pc = peer.pc pc = peer.pc
print(f'************************************{pc.connectionState=}') print(f'************************************{pc.connectionState=}')
if pc.connectionState == 'connected': if pc.connectionState == 'connected':
peer.dc = await pc.createDataChannel(peer.info.name) peer.dc = pc.createDataChannel(peer.info.name)
return return
if pc.connectionState == 'closed': if pc.connectionState == 'closed':
await pc.close() await pc.close()
@ -103,9 +103,14 @@ class RTCLLM:
if pc is None: if pc is None:
print(f'{self.peers=}, {data=}') print(f'{self.peers=}, {data=}')
return return
pc.on("connectionstate", partial(self.pc_connectionState_changed, data['from'].id)) pc.on("connectionstatechange", partial(self.pc_connectionState_changed, data['from'].id))
pc.on('track', partial(self.pc_track, 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))
player = MediaPlayer('/Users/ymq/v/1.mp4')
if player:
pc.addTrack(player.audio)
pc.addTrack(player.video)
offer = RTCSessionDescription(** data.offer) offer = RTCSessionDescription(** data.offer)
await pc.setRemoteDescription(offer) await pc.setRemoteDescription(offer)
answer = await pc.createAnswer() answer = await pc.createAnswer()