Skip to content

Commit

Permalink
added Stream.load()
Browse files Browse the repository at this point in the history
  • Loading branch information
futzu authored Aug 20, 2023
1 parent e5bee38 commit 7e99da7
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions threefive/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,9 @@ def __init__(self, tsdata, show_null=True):
strm.decode()
"""
if isinstance(tsdata, str):
self._tsdata = reader(tsdata)
else:
self._tsdata = tsdata
self._tsdata = None
self.tsdata=tsdata
# self.load(tsdata)
self.show_null = show_null
self.start = {}
self.info = None
Expand All @@ -162,12 +161,22 @@ def __init__(self, tsdata, show_null=True):
def __repr__(self):
return str(self.__dict__)

def load(self,tsdata=None):
if not tsdata:
tsdata = self.tsdata
if isinstance(tsdata, str):
self._tsdata = reader(tsdata)
else:
self._tsdata = tsdata


def _find_start(self):
"""
_find_start locates the first SYNC_BYTE
parses 1 packet and returns a iterator
of packets
"""
self.load()
while self._tsdata:
one = self._tsdata.read(1)
if not one:
Expand Down Expand Up @@ -242,6 +251,7 @@ def decode_fu(self, func=show_cue):
Super Fast with pypy3.
"""
num_pkts = 1000
self.load()
for chunk in self.iter_pkts(num_pkts):
_ = [func(cue) for cue in self._mk_pkts(chunk) if cue]
del _
Expand Down Expand Up @@ -289,6 +299,7 @@ def show(self):
displays streams that will be
parsed for SCTE-35.
"""
self.load()
self.info = True
for pkt in self._find_start():
self._parse_info(pkt)
Expand Down

0 comments on commit 7e99da7

Please sign in to comment.