Exemplo n.º 1
0
 def got_have(self, piece, connection=None):
     if DEBUG:
         print >> sys.stderr, 'pps::got_have: piece', piece
     self.maxhave = max(self.maxhave, piece)
     PiecePicker.got_have(self, piece, connection)
     if self.is_interesting(piece):
         self.peer_connections[connection]['interesting'][piece] = 1
Exemplo n.º 2
0
 def got_have(self, piece, connection = None):
     if DEBUG:
         print >> sys.stderr, 'pps::got_have: piece', piece
     self.maxhave = max(self.maxhave, piece)
     PiecePicker.got_have(self, piece, connection)
     if self.is_interesting(piece):
         self.peer_connections[connection]['interesting'][piece] = 1
Exemplo n.º 3
0
 def __init__(self,
              numpieces,
              rarest_first_cutoff=1,
              rarest_first_priority_cutoff=3,
              priority_step=20,
              helper=None,
              coordinator=None,
              rate_predictor=None,
              piecesize=0):
     PiecePicker.__init__(self, numpieces, rarest_first_cutoff,
                          rarest_first_priority_cutoff, priority_step,
                          helper, coordinator, rate_predictor)
     self.maxhave = 0
     self.stats = {}
     self.stats['high'] = 0
     self.stats['mid'] = 0
     self.stats['low'] = 0
     self.transporter = None
     self.outstanding_requests = {}
     self.playing_delay = (5, 20, -0.5)
     buffering_delay = globalConfig.get_value(
         'piece_picker_buffering_delay', None)
     if buffering_delay is not None:
         self.buffering_delay = buffering_delay
     else:
         self.buffering_delay = (7.5, 30, 10)
     self.is_interesting = self.is_interesting_normal
     self.extra_videostatus = []
Exemplo n.º 4
0
 def get_valid_range_iterator(self, skip_filter = False):
     if skip_filter:
         return PiecePicker.get_valid_range_iterator(self)
     if self.videostatus.live_streaming and self.videostatus.get_live_startpos() is None:
         if DEBUG:
             log('pps::get_valid_range_iterator: not hooked in, valid range set to total')
         return PiecePicker.get_valid_range_iterator(self)
     if DEBUG:
         log('pps::get_valid_range_iterator: live hooked in or VOD, valid range set to subset')
     return self.valid_range_generator()
Exemplo n.º 5
0
 def get_valid_range_iterator(self, skip_filter=False):
     if skip_filter:
         return PiecePicker.get_valid_range_iterator(self)
     if self.videostatus.live_streaming and self.videostatus.get_live_startpos(
     ) is None:
         if DEBUG:
             log('pps::get_valid_range_iterator: not hooked in, valid range set to total'
                 )
         return PiecePicker.get_valid_range_iterator(self)
     if DEBUG:
         log('pps::get_valid_range_iterator: live hooked in or VOD, valid range set to subset'
             )
     return self.valid_range_generator()
Exemplo n.º 6
0
    def next(self,
             haves,
             wantfunc,
             sdownload,
             complete_first=False,
             helper_con=False,
             slowpieces=[],
             willrequest=True,
             connection=None,
             proxyhave=None,
             shuffle=True):
        def newwantfunc(piece):
            return piece not in slowpieces and wantfunc(piece)

        p = PiecePicker.next(self,
                             haves,
                             newwantfunc,
                             sdownload,
                             complete_first,
                             helper_con,
                             slowpieces=slowpieces,
                             willrequest=willrequest,
                             connection=connection,
                             shuffle=shuffle)
        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 and self.am_I_complete(
        ) or TEST_VOD_OVERRIDE:
            if self.transporter is not None:
                self.transporter.notify_playable()
        return p
Exemplo n.º 7
0
 def __init__(self, numpieces, rarest_first_cutoff = 1, rarest_first_priority_cutoff = 3, priority_step = 20, helper = None, coordinator = None, rate_predictor = None, piecesize = 0):
     PiecePicker.__init__(self, numpieces, rarest_first_cutoff, rarest_first_priority_cutoff, priority_step, helper, coordinator, rate_predictor)
     self.maxhave = 0
     self.stats = {}
     self.stats['high'] = 0
     self.stats['mid'] = 0
     self.stats['low'] = 0
     self.transporter = None
     self.outstanding_requests = {}
     self.playing_delay = (5, 20, -0.5)
     buffering_delay = globalConfig.get_value('piece_picker_buffering_delay', None)
     if buffering_delay is not None:
         self.buffering_delay = buffering_delay
     else:
         self.buffering_delay = (7.5, 30, 10)
     self.is_interesting = self.is_interesting_normal
     self.extra_videostatus = []
Exemplo n.º 8
0
    def next(self, haves, wantfunc, sdownload, complete_first = False, helper_con = False, slowpieces = [], willrequest = True, connection = None, proxyhave = None, shuffle = True):

        def newwantfunc(piece):
            return piece not in slowpieces and wantfunc(piece)

        p = PiecePicker.next(self, haves, newwantfunc, sdownload, complete_first, helper_con, slowpieces=slowpieces, willrequest=willrequest, connection=connection, shuffle=shuffle)
        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 and self.am_I_complete() or TEST_VOD_OVERRIDE:
            if self.transporter is not None:
                self.transporter.notify_playable()
        return p
Exemplo n.º 9
0
    def complete(self, piece):
        if DEBUG:
            log('PiecePickerStreaming: complete:', piece)
        if not PiecePicker.complete(self, piece):
            return False
        if self.transporter:
            self.transporter.complete(piece)
        for request in self.outstanding_requests.keys():
            if request[0] == piece:
                del self.outstanding_requests[request]

        for d in self.peer_connections.itervalues():
            d['interesting'].pop(piece, 0)

        check_interests = False
        for vs in self.extra_videostatus:
            start_new_file = vs.got_piece(piece)
            if start_new_file and not check_interests:
                self.downloader.check_interests()
                check_interests = True

        return True
Exemplo n.º 10
0
    def complete(self, piece):
        if DEBUG:
            log('PiecePickerStreaming: complete:', piece)
        if not PiecePicker.complete(self, piece):
            return False
        if self.transporter:
            self.transporter.complete(piece)
        for request in self.outstanding_requests.keys():
            if request[0] == piece:
                del self.outstanding_requests[request]

        for d in self.peer_connections.itervalues():
            d['interesting'].pop(piece, 0)

        check_interests = False
        for vs in self.extra_videostatus:
            start_new_file = vs.got_piece(piece)
            if start_new_file and not check_interests:
                self.downloader.check_interests()
                check_interests = True

        return True
Exemplo n.º 11
0
 def requested(self, *request):
     self.outstanding_requests[request] = time.time()
     return PiecePicker.requested(self, *request)
Exemplo n.º 12
0
 def lost_peer(self, connection):
     PiecePicker.lost_peer(self, connection)
Exemplo n.º 13
0
 def got_peer(self, connection):
     PiecePicker.got_peer(self, connection)
     self.peer_connections[connection]['interesting'] = odict()
Exemplo n.º 14
0
 def lost_have(self, piece):
     PiecePicker.lost_have(self, piece)
Exemplo n.º 15
0
 def got_peer(self, connection):
     PiecePicker.got_peer(self, connection)
     self.peer_connections[connection]['interesting'] = odict()
Exemplo n.º 16
0
 def got_seed(self):
     self.maxhave = self.numpieces
     PiecePicker.got_seed(self)
Exemplo n.º 17
0
 def requested(self, *request):
     self.outstanding_requests[request] = time.time()
     return PiecePicker.requested(self, *request)
Exemplo n.º 18
0
 def lost_peer(self, connection):
     PiecePicker.lost_peer(self, connection)
Exemplo n.º 19
0
 def got_seed(self):
     self.maxhave = self.numpieces
     PiecePicker.got_seed(self)
Exemplo n.º 20
0
 def lost_have(self, piece):
     PiecePicker.lost_have(self, piece)