refactor: workaround for negative timestamp

This commit is contained in:
acgnhik 2022-07-02 23:03:08 +08:00
parent e546b47e29
commit e5277510c2
3 changed files with 4 additions and 3 deletions

View File

@ -28,6 +28,7 @@ class ExceptionHandler(AsyncCooperationMixin):
scheduler: Optional[abc.SchedulerBase] = None,
) -> abc.DisposableBase:
def on_error(exc: Exception) -> None:
logger.exception(repr(exc))
self._submit_exception(exc)
try:
raise exc

View File

@ -197,6 +197,9 @@ class FlvDumper:
self._writer.write_ui32(size)
def dump_tag(self, tag: FlvTag) -> None:
if tag.timestamp < 0:
raise FlvDataError(f'Incorrect timestamp: {tag.timestamp}', tag)
self.dump_flv_tag_header(tag)
if tag.is_audio_tag():

View File

@ -90,9 +90,6 @@ class Dumper:
self._timestamp_updates.on_next(0)
else:
if self._flv_writer is not None:
# XXX: negative timestamp will cause
# `struct.error: ubyte format requires 0 <= number <= 255`
assert item.timestamp >= 0, item
size = self._flv_writer.write_tag(item)
self._size_updates.on_next(size)
self._timestamp_updates.on_next(item.timestamp)