bugfix
This commit is contained in:
parent
7f62f1163c
commit
c3799eda8c
@ -35,14 +35,63 @@ class MyTrackBase:
|
|||||||
return f
|
return f
|
||||||
|
|
||||||
|
|
||||||
class MyAudioStreamTrack(MyTrackBase, AudioStreamTrack):
|
class MyAudioStreamTrack(AudioStreamTrack):
|
||||||
def __init__(self, source=None):
|
def __init__(self, source=None):
|
||||||
AudioStreamTrack.__init__(self)
|
AudioStreamTrack.__init__(self)
|
||||||
MyTrackBase.__init__(self, source)
|
self.source = source
|
||||||
print(dir(self), self.__class__.__name__)
|
self.set_source_track()
|
||||||
|
print(f'{self.kind=}, {self.__class__.__name__}, {dir(self)}')
|
||||||
|
|
||||||
class MyVideoStreamTrack(MyTrackBase, VideoStreamTrack):
|
async def recv(self):
|
||||||
|
print(f'============{self.__class__.__name__}, {self.source.duration=}, {self.source.time=}')
|
||||||
|
if self.source is None:
|
||||||
|
return None
|
||||||
|
if self.track.readyState != 'live':
|
||||||
|
self.source_reload()
|
||||||
|
f = await self.track.recv()
|
||||||
|
return f
|
||||||
|
|
||||||
|
def set_source_track(self):
|
||||||
|
if self.kind == 'audio':
|
||||||
|
self.track = self.source.audio
|
||||||
|
else:
|
||||||
|
self.track = self.source.video
|
||||||
|
|
||||||
|
def source_reload(self):
|
||||||
|
print(f'reload the source----{self.source._file_path}')
|
||||||
|
self.set_source(MyMediaPlayer(self.source._file_path))
|
||||||
|
|
||||||
|
def set_source(self, source):
|
||||||
|
self.source = source
|
||||||
|
self.set_source_track()
|
||||||
|
|
||||||
|
class MyVideoStreamTrack(VideoStreamTrack):
|
||||||
def __init__(self, source=None):
|
def __init__(self, source=None):
|
||||||
VideoStreamTrack.__init__(self)
|
VideoStreamTrack.__init__(self)
|
||||||
MyTrackBase.__init__(self, source)
|
self.source = source
|
||||||
print(dir(self), self.__class__.__name__)
|
self.set_source_track()
|
||||||
|
print(f'{self.kind=}, {self.__class__.__name__}, {dir(self)}')
|
||||||
|
|
||||||
|
async def recv(self):
|
||||||
|
print(f'============{self.__class__.__name__}, {self.source.duration=}, {self.source.time=}')
|
||||||
|
if self.source is None:
|
||||||
|
return None
|
||||||
|
if self.track.readyState != 'live':
|
||||||
|
self.source_reload()
|
||||||
|
f = await self.track.recv()
|
||||||
|
return f
|
||||||
|
|
||||||
|
def set_source_track(self):
|
||||||
|
if self.kind == 'audio':
|
||||||
|
self.track = self.source.audio
|
||||||
|
else:
|
||||||
|
self.track = self.source.video
|
||||||
|
|
||||||
|
def source_reload(self):
|
||||||
|
print(f'reload the source----{self.source._file_path}')
|
||||||
|
self.set_source(MyMediaPlayer(self.source._file_path))
|
||||||
|
|
||||||
|
def set_source(self, source):
|
||||||
|
self.source = source
|
||||||
|
self.set_source_track()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user