refactor: refactor operators

This commit is contained in:
acgnhik 2022-06-05 22:31:02 +08:00
parent 875cd3c785
commit b17dcae713
3 changed files with 17 additions and 17 deletions

View File

@ -92,13 +92,13 @@ class Cutter:
self, observer: abc.ObserverBase[FLVStreamItem]
) -> None:
assert self._last_flv_header is not None
assert self._last_audio_sequence_header is not None
assert self._last_video_sequence_header is not None
observer.on_next(self._last_flv_header)
if self._last_metadata_tag is not None:
observer.on_next(self._last_metadata_tag)
observer.on_next(self._last_audio_sequence_header)
observer.on_next(self._last_video_sequence_header)
if self._last_video_sequence_header is not None:
observer.on_next(self._last_video_sequence_header)
if self._last_audio_sequence_header is not None:
observer.on_next(self._last_audio_sequence_header)
def _check_cut_point(self, tag: FlvTag) -> None:
self._last_timestamp = tag.timestamp

View File

@ -72,21 +72,21 @@ class Limiter:
self, observer: abc.ObserverBase[FLVStreamItem]
) -> None:
assert self._last_flv_header is not None
assert self._last_audio_sequence_header is not None
assert self._last_video_sequence_header is not None
observer.on_next(self._last_flv_header)
if self._last_metadata_tag is not None:
observer.on_next(self._last_metadata_tag)
observer.on_next(self._last_audio_sequence_header)
observer.on_next(self._last_video_sequence_header)
if self._last_video_sequence_header is not None:
observer.on_next(self._last_video_sequence_header)
if self._last_audio_sequence_header is not None:
observer.on_next(self._last_audio_sequence_header)
self._filesize = (
self._last_flv_header.size
+ self._last_audio_sequence_header.tag_size
+ self._last_video_sequence_header.tag_size
)
self._filesize = self._last_flv_header.size
if self._last_metadata_tag is not None:
self._filesize += self._last_metadata_tag.tag_size
if self._last_video_sequence_header is not None:
self._filesize += self._last_video_sequence_header.tag_size
if self._last_audio_sequence_header is not None:
self._filesize += self._last_audio_sequence_header.tag_size
self._duration = 0.0
self._first_keyframe_tag = self._last_keyframe_tag

View File

@ -39,13 +39,13 @@ def split() -> Callable[[FLVStream], FLVStream]:
def insert_header_and_tags() -> None:
assert last_flv_header is not None
assert last_audio_sequence_header is not None
assert last_video_sequence_header is not None
observer.on_next(last_flv_header)
if last_metadata_tag is not None:
observer.on_next(last_metadata_tag)
observer.on_next(last_audio_sequence_header)
observer.on_next(last_video_sequence_header)
if last_video_sequence_header is not None:
observer.on_next(last_video_sequence_header)
if last_audio_sequence_header is not None:
observer.on_next(last_audio_sequence_header)
def on_next(item: FLVStreamItem) -> None:
nonlocal changed