From 3cd51e34650ae1ee571da9923cb7a89fa6809474 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 4 Sep 2024 18:45:15 +0800 Subject: [PATCH] bugfix --- rtcllm/rtc.py | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/rtcllm/rtc.py b/rtcllm/rtc.py index 44ce877..fe28b5c 100644 --- a/rtcllm/rtc.py +++ b/rtcllm/rtc.py @@ -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)