Beispiel #1
0
        async def download_next():
            # Save some statistical data
            self.save_statistical_data()

            monitor.BufferMonitor().feed_segment(
                DownloadManager().representation.durations[DownloadManager().video_ind])
            log.info("Current Buffer Level: %.3f" % self.buffer_level)
            self.current_video_representation_ind = self.abr_controller.choose('video')
            DownloadManager().representation = self.mpd.videoAdaptationSet.representations[
                self.current_video_representation_ind]
            DownloadManager().video_ind += 1
            await events.EventBridge().trigger(events.Events.DownloadStart)
Beispiel #2
0
        async def stall():
            if self.task_update_playback_time is not None:
                self.task_update_playback_time.cancel()
            if self.task_check_buffer_sufficient is not None:
                self.task_check_buffer_sufficient.cancel()

            log.debug("Stall happened")
            self.switch_state("STALLING")
            before_stall = time.time()
            while True:
                await asyncio.sleep(self.cfg.update_interval)
                if monitor.BufferMonitor().buffer - self.playback_time > self.mpd.minBufferTime:
                    break
            log.debug("Stall ends, duration: %.3f" % (time.time() - before_stall))
            await events.EventBridge().trigger(events.Events.Play)
Beispiel #3
0
    def __init__(self, args):
        self.args = args  # type: Dict[str, str]
        self.config = config.Config(args)
        self.mpd = None  # type: Optional[mpd.MPD]

        # Init the speed monitor
        speed_monitor = monitor.SpeedMonitor()  # type: monitor.SpeedMonitor
        speed_monitor.init(self.config)

        # Init the buffer monitor
        buffer_monitor = monitor.BufferMonitor()  # type: monitor.BufferMonitor
        buffer_monitor.init(self.config)

        self.abr_controller = None  # type: Optional[abr.ABRController]

        # Tasks
        # downloading task
        self.task = None  # type: Optional[asyncio.Task]
        self.segment_content_length = 0  # type: int
Beispiel #4
0
 def buffer_level(self):
     return (monitor.BufferMonitor().buffer - self.playback_time) * 1000
Beispiel #5
0
 async def ctrl_c_handler():
     print("Fast-forward to the end")
     # Change current time to 0.5 seconds before the end
     self.playback_time = monitor.BufferMonitor().buffer - 0.5
     asyncio.get_event_loop().remove_signal_handler(signal.SIGINT)