Exemple #1
0
    def iter_segments(self):
        init = True
        back_off_factor = 1
        while not self.closed:
            # find the representation by ID
            representation = self.get_representation(
                self.mpd, self.reader.representation_id, self.reader.mime_type)
            refresh_wait = max(
                self.mpd.minimumUpdatePeriod.total_seconds(),
                self.mpd.periods[0].duration.total_seconds()) or 5

            if self.mpd.type == "static":
                refresh_wait = 5

            with sleeper(refresh_wait * back_off_factor):
                if representation:
                    for segment in representation.segments(init=init):
                        if self.closed:
                            break
                        yield segment
                        # log.debug(f"Adding segment {segment.url} to queue")

                    if self.mpd.type == "dynamic":
                        if not self.reload():
                            back_off_factor = max(back_off_factor * 1.3, 10.0)
                        else:
                            back_off_factor = 1
                    else:
                        return
                    init = False
Exemple #2
0
    def iter_segments(self):
        init = True
        back_off_factor = 1
        while not self.closed:
            # find the representation by ID
            representation = None
            for aset in self.mpd.periods[0].adaptationSets:
                for rep in aset.representations:
                    if rep.id == self.reader.representation_id:
                        representation = rep
            refresh_wait = max(
                self.mpd.minimumUpdatePeriod.total_seconds(),
                self.mpd.periods[0].duration.total_seconds()) or 5
            with sleeper(refresh_wait * back_off_factor):
                if representation:
                    for segment in representation.segments(init=init):
                        if self.closed:
                            break
                        yield segment
                        # log.debug("Adding segment {0} to queue", segment.url)

                    if self.mpd.type == "dynamic":
                        if not self.reload():
                            back_off_factor = max(back_off_factor * 1.3, 10.0)
                        else:
                            back_off_factor = 1
                    else:
                        return
                    init = False
Exemple #3
0
    def iter_segments(self):
        init = True
        back_off_factor = 1
        while not self.closed:
            # find the representation by ID
            representation = self.get_representation(self.mpd, self.reader.representation_id, self.reader.mime_type)
            refresh_wait = max(self.mpd.minimumUpdatePeriod.total_seconds(),
                               self.mpd.periods[0].duration.total_seconds()) or 5
            with sleeper(refresh_wait * back_off_factor):
                if representation:
                    for segment in representation.segments(init=init):
                        if self.closed:
                            break
                        yield segment
                        # log.debug("Adding segment {0} to queue", segment.url)

                    if self.mpd.type == "dynamic":
                        if not self.reload():
                            back_off_factor = max(back_off_factor * 1.3, 10.0)
                        else:
                            back_off_factor = 1
                    else:
                        return
                    init = False