def got_have(self, piece, connection=None):
        # if DEBUG:
        #     print >>sys.stderr,"PiecePickerStreaming: got_have:",piece
        self.maxhave = max(self.maxhave, piece)
        PiecePicker.got_have(self, piece, connection)
        if self.transporter:
            self.transporter.got_have(piece)

        if self.is_interesting(piece) and connection:
            self.peer_connections[connection]["interesting"][piece] = 1
Exemple #2
0
    def got_have(self, piece, connection=None):
        # if DEBUG:
        #     print >>sys.stderr,"PiecePickerStreaming: got_have:",piece
        self.maxhave = max(self.maxhave, piece)
        PiecePicker.got_have(self, piece, connection)
        if self.transporter:
            self.transporter.got_have(piece)

        if self.is_interesting(piece) and connection:
            self.peer_connections[connection]["interesting"][piece] = 1
    def got_have(self, piece, connection=None):
        # if DEBUG:
        #     print >>sys.stderr,"PiecePickerStreaming: got_have:",piece
        self.maxhave = max(self.maxhave,piece)

        # Arno, 2010-04-15: STBSPEED Disabled, does nothing but stats.
        #if self.transporter:
        #    self.transporter.got_have( piece )
        PiecePicker.got_have(self,piece,connection)

        if self.is_interesting(piece):
            self.peer_connections[connection]["interesting"][piece] = 1
    def complete(self, piece):
        # if DEBUG:
        #     print >>sys.stderr,"PiecePickerStreaming: complete:",piece
        PiecePicker.complete(self, piece)
        if self.transporter:
            self.transporter.complete(piece)

        for request in self.outstanding_requests.keys():
            if request[0] == piece:
                del self.outstanding_requests[request]

        # don't consider this piece anymore
        for d in self.peer_connections.itervalues():
            d["interesting"].pop(piece, 0)
Exemple #5
0
    def complete(self, piece):
        # if DEBUG:
        #     print >>sys.stderr,"PiecePickerStreaming: complete:",piece
        PiecePicker.complete(self, piece)
        if self.transporter:
            self.transporter.complete(piece)

        for request in self.outstanding_requests.keys():
            if request[0] == piece:
                del self.outstanding_requests[request]

        # don't consider this piece anymore
        for d in self.peer_connections.itervalues():
            d["interesting"].pop(piece, 0)
    def __init__(
        self,
        numpieces,
        rarest_first_cutoff=1,
        rarest_first_priority_cutoff=3,
        priority_step=20,
        helper=None,
        rate_predictor=None,
        piecesize=0,
    ):
        PiecePicker.__init__(
            self, numpieces, rarest_first_cutoff, rarest_first_priority_cutoff, priority_step, helper, rate_predictor
        )

        # maximum existing piece number, to avoid scanning beyond it in next()
        self.maxhave = 0

        # some statistics
        self.stats = {}
        self.stats["high"] = 0
        self.stats["mid"] = 0
        self.stats["low"] = 0

        # playback module
        self.transporter = None

        # self.outstanding_requests contains (piece-id, begin,
        # length):timestamp pairs for each outstanding request.
        self.outstanding_requests = {}

        # The playing_delay and buffering_delay give three values
        # (min, max, offeset) in seconds.
        #
        # The min tells how long before the cancel policy is allowed
        # to kick in. We can not expect to receive a piece instantly,
        # so we have to wait this time before having a download speed
        # estimation.
        #
        # The max tells how long before we cancel the request. The
        # request may also be canceled because the chunk will not be
        # completed given the current download speed.
        #
        # The offset gives a grace period that is taken into account
        # when choosing to cancel a request. For instance, when the
        # peer download speed is to low to receive the chunk within 10
        # seconds, a grace offset of 15 would ensure that the chunk is
        # NOT canceled (usefull while buffering)
        self.playing_delay = (5, 20, -0.5)
        self.buffering_delay = (7.5, 30, 10)
Exemple #7
0
    def next(self,
             haves,
             wantfunc,
             sdownload,
             complete_first=False,
             helper_con=False,
             slowpieces=[],
             willrequest=True,
             connection=None):
        def newwantfunc(piece):
            #print >>sys.stderr,"S",self.streaming_piece_filter( piece ),"!sP",not (piece in slowpieces),"w",wantfunc( piece )
            return not (piece in slowpieces) and wantfunc(piece)

        # fallback: original piece picker
        p = PiecePicker.next(self,
                             haves,
                             newwantfunc,
                             sdownload,
                             complete_first,
                             helper_con,
                             slowpieces=slowpieces,
                             willrequest=willrequest,
                             connection=connection)
        if DEBUGPP and self.videostatus.prebuffering:
            print >> sys.stderr, "PiecePickerStreaming: original PP.next returns", p
        if p is None and not self.videostatus.live_streaming:
            # When the file we selected from a multi-file torrent is complete,
            # we won't request anymore pieces, so the normal way of detecting
            # we're done is not working and we won't tell the video player
            # we're playable. Do it here instead.
            self.transporter.notify_playable()
        return p
Exemple #8
0
    def __init__(self,
                 numpieces,
                 rarest_first_cutoff=1,
                 rarest_first_priority_cutoff=3,
                 priority_step=20,
                 helper=None,
                 rate_predictor=None,
                 piecesize=0):
        PiecePicker.__init__(self, numpieces, rarest_first_cutoff,
                             rarest_first_priority_cutoff, priority_step,
                             helper, rate_predictor)

        # maximum existing piece number, to avoid scanning beyond it in next()
        self.maxhave = 0

        # some statistics
        self.stats = {}
        self.stats["high"] = 0
        self.stats["mid"] = 0
        self.stats["low"] = 0

        # playback module
        self.transporter = None

        # self.outstanding_requests contains (piece-id, begin,
        # length):timestamp pairs for each outstanding request.
        self.outstanding_requests = {}

        # The playing_delay and buffering_delay give three values
        # (min, max, offeset) in seconds.
        #
        # The min tells how long before the cancel policy is allowed
        # to kick in. We can not expect to receive a piece instantly,
        # so we have to wait this time before having a download speed
        # estimation.
        #
        # The max tells how long before we cancel the request. The
        # request may also be canceled because the chunk will not be
        # completed given the current download speed.
        #
        # The offset gives a grace period that is taken into account
        # when choosing to cancel a request. For instance, when the
        # peer download speed is to low to receive the chunk within 10
        # seconds, a grace offset of 15 would ensure that the chunk is
        # NOT canceled (usefull while buffering)
        self.playing_delay = (5, 20, -0.5)
        self.buffering_delay = (7.5, 30, 10)
    def get_valid_range_iterator(self):
        if self.videostatus.live_streaming and self.videostatus.get_live_startpos() is None:
            # Not hooked in, so cannot provide a sensible download range
            # print >>sys.stderr,"PiecePickerStreaming: Not hooked in, valid range set to total"
            return PiecePicker.get_valid_range_iterator(self)

        # print >>sys.stderr,"PiecePickerStreaming: Live hooked in, or VOD, valid range set to subset"
        first, last = self.videostatus.download_range()
        return self.videostatus.generate_range((first, last))
Exemple #10
0
    def get_valid_range_iterator(self):
        if self.videostatus.live_streaming and self.videostatus.get_live_startpos(
        ) is None:
            # Not hooked in, so cannot provide a sensible download range
            #print >>sys.stderr,"PiecePickerStreaming: Not hooked in, valid range set to total"
            return PiecePicker.get_valid_range_iterator(self)

        #print >>sys.stderr,"PiecePickerStreaming: Live hooked in, or VOD, valid range set to subset"
        first, last = self.videostatus.download_range()
        return self.videostatus.generate_range((first, last))
Exemple #11
0
    def next(self, haves, wantfunc, sdownload, complete_first = False, helper_con = False, slowpieces=[], willrequest=True,connection=None,proxyhave=None):
        def newwantfunc( piece ):
            #print >>sys.stderr,time.asctime(),'-', "S",self.streaming_piece_filter( piece ),"!sP",not (piece in slowpieces),"w",wantfunc( piece )
            return not (piece in slowpieces) and wantfunc( piece )

        # fallback: original piece picker
        p = PiecePicker.next(self, haves, newwantfunc, sdownload, complete_first, helper_con, slowpieces=slowpieces, willrequest=willrequest,connection=connection)
        if DEBUGPP and self.videostatus.prebuffering:
            print >>sys.stderr,time.asctime(),'-', "PiecePickerStreaming: original PP.next returns",p
        if p is None and not self.videostatus.live_streaming:
            # When the file we selected from a multi-file torrent is complete,
            # we won't request anymore pieces, so the normal way of detecting 
            # we're done is not working and we won't tell the video player 
            # we're playable. Do it here instead.
            self.transporter.notify_playable()
        return p
 def requested(self, *request):
     self.outstanding_requests[request] = time.time()
     return PiecePicker.requested(self, *request)
Exemple #13
0
 def got_seed(self):
     self.maxhave = self.numpieces
     PiecePicker.got_seed(self)
 def lost_peer(self, connection):
     PiecePicker.lost_peer(self, connection)
    def got_peer(self, connection):
        PiecePicker.got_peer(self, connection)

        self.peer_connections[connection]["interesting"] = {}
 def lost_have(self, piece):
     PiecePicker.lost_have(self, piece)
 def got_seed(self):
     self.maxhave = self.numpieces
     PiecePicker.got_seed(self)
Exemple #18
0
 def lost_have(self, piece):
     PiecePicker.lost_have(self, piece)
Exemple #19
0
 def requested(self, *request):
     self.outstanding_requests[request] = time.time()
     return PiecePicker.requested(self, *request)
Exemple #20
0
    def got_peer(self, connection):
        PiecePicker.got_peer(self, connection)

        self.peer_connections[connection]["interesting"] = {}
Exemple #21
0
 def lost_peer(self, connection):
     PiecePicker.lost_peer(self, connection)