bugfix
This commit is contained in:
parent
8b89abfbea
commit
b74c2f9b2a
@ -1,4 +1,5 @@
|
||||
import random
|
||||
from traceback import print_exc
|
||||
from aiortc.contrib.media import MediaBlackhole, MediaPlayer, MediaRecorder, MediaRelay
|
||||
from aiortc import MediaStreamTrack, VideoStreamTrack, AudioStreamTrack
|
||||
|
||||
@ -43,11 +44,18 @@ class MyAudioStreamTrack(AudioStreamTrack):
|
||||
print(f'{self.kind=}, {self.__class__.__name__}, {dir(self)}')
|
||||
|
||||
async def recv(self):
|
||||
print(f'============{self.__class__.__name__}, {self.source.duration=}, {self.source.time=}')
|
||||
try:
|
||||
return await self._recv()
|
||||
except MediaStreamError:
|
||||
self.source_reload()
|
||||
return await self._recv()
|
||||
except Exception as e:
|
||||
print_exc()
|
||||
raise e
|
||||
|
||||
async def _recv(self):
|
||||
if self.source is None:
|
||||
return None
|
||||
if self.track.readyState != 'live':
|
||||
self.source_reload()
|
||||
f = await self.track.recv()
|
||||
return f
|
||||
|
||||
@ -73,11 +81,18 @@ class MyVideoStreamTrack(VideoStreamTrack):
|
||||
print(f'{self.kind=}, {self.__class__.__name__}, {dir(self)}')
|
||||
|
||||
async def recv(self):
|
||||
print(f'============{self.__class__.__name__}, {self.source.duration=}, {self.source.time=}')
|
||||
try:
|
||||
return await self._recv()
|
||||
except MediaStreamError:
|
||||
self.source_reload()
|
||||
return self._recv()
|
||||
except Exception as e:
|
||||
print_exc()
|
||||
raise e
|
||||
|
||||
async def _recv(self):
|
||||
if self.source is None:
|
||||
return None
|
||||
if self.track.readyState != 'live':
|
||||
self.source_reload()
|
||||
f = await self.track.recv()
|
||||
return f
|
||||
|
||||
@ -107,7 +122,6 @@ class LoopingVideoTrack(VideoStreamTrack):
|
||||
|
||||
async def recv(self):
|
||||
frame = await self.player.video.recv()
|
||||
print(f'{self.__class__.__name__}, {self.source.duration=}, {self.source.time=}')
|
||||
if self.player.video.readyState != 'live':
|
||||
self.player = MyMediaPlayer(self.player._file_path)
|
||||
frame = await self.player.video.recv()
|
||||
|
@ -127,8 +127,8 @@ class RTCLLM:
|
||||
'pc':pc
|
||||
})
|
||||
pc.addTrack(MyAudioStreamTrack(player))
|
||||
pc.addTrack(LoopingVideoTrack('./1.mp4'))
|
||||
# pc.addTrack(MyVideoStreamTrack(player))
|
||||
pc.addTrack(MyVideoStreamTrack(player))
|
||||
# pc.addTrack(LoopingVideoTrack('./1.mp4'))
|
||||
# pc.addTrack(player.video)
|
||||
await self.ws_send(json.dumps({'type':'callAccepted', 'to':data['from']}))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user