This commit is contained in:
yumoqing 2024-09-04 18:45:15 +08:00
parent 2227fd3360
commit 3cd51e3465

View File

@ -135,11 +135,6 @@ class RTCLLM:
peer = self.peers[peerid]
pc = peer.pc
print(f'conn_state={pc.connectionState} ...........')
peer.audiotrack = MyAudioTrack()
peer.videotrack = MyVideoTrack()
pc.addTrack(peer.audiotrack)
pc.addTrack(peer.videotrack)
self.play_random_media(peer.videotrack, peer.audiotrack)
if pc.connectionState == 'connected':
peer.dc = pc.createDataChannel(peer.info.name)
return
@ -156,20 +151,6 @@ class RTCLLM:
}
self.peers = peers
def play_video(self, peerid):
print('play video ........................')
pc = self.peers[peerid].pc
"""
player = MediaPlayer(videos[0])
if player:
pc.addTrack(player.audio)
pc.addTrack(player.video)
"""
player = MediaPlayer(videos[1])
if player:
pc.addTrack(player.audio)
pc.addTrack(player.video)
async def response_offer(self, data):
pc = self.get_pc(data)
peer = self.peers[data['from'].id]
@ -179,7 +160,11 @@ class RTCLLM:
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, data['from']))
# self.play_video(data)
peer.audiotrack = MyAudioTrack()
peer.videotrack = MyVideoTrack()
pc.addTrack(peer.audiotrack)
pc.addTrack(peer.videotrack)
self.play_random_media(peer.videotrack, peer.audiotrack)
offer = RTCSessionDescription(** data.offer)
await pc.setRemoteDescription(offer)