def open(self): self.buffer = RingBuffer(self.session.get_option("ringbuffer-size")) conn = create_ums_connection("channel", self.stream.channel_id, self.stream.page_url, exception=StreamError) self.filler = UHSStreamFiller(self, conn, self.stream.provider, self.stream.stream_index) self.filler.start()
class UHSStreamIO(IOBase): def __init__(self, session, stream, timeout=30): self.session = session self.stream = stream self.timeout = timeout self.logger = session.logger.new_module("stream.uhs") self.buffer = None def open(self): self.buffer = RingBuffer(self.session.get_option("ringbuffer-size")) conn = create_ums_connection("channel", self.stream.channel_id, self.stream.page_url, self.stream.password, exception=StreamError) self.filler = UHSStreamFiller(self, conn, self.stream.provider, self.stream.stream_index) self.filler.start() def read(self, size=-1): if not self.buffer: return b"" return self.buffer.read(size, block=self.filler.is_alive(), timeout=self.timeout) def close(self): self.filler.stop() if self.filler.is_alive(): self.filler.join()
class UHSStreamIO(IOBase): def __init__(self, session, stream, timeout=30): self.session = session self.stream = stream self.timeout = timeout self.logger = session.logger.new_module("stream.uhs") self.buffer = None def open(self): self.buffer = RingBuffer(self.session.get_option("ringbuffer-size")) conn = create_ums_connection("channel", self.stream.channel_id, self.stream.page_url, exception=StreamError) self.filler = UHSStreamFiller(self, conn, self.stream.provider, self.stream.stream_index) self.filler.start() def read(self, size=-1): if not self.buffer: return b"" return self.buffer.read(size, block=self.filler.is_alive(), timeout=self.timeout) def close(self): self.filler.stop() if self.filler.is_alive(): self.filler.join()