void ChunkManager::Private::doPreviewPriority(TorrentFile & file)
	{
		if (file.getPriority() == EXCLUDED || file.getPriority() == ONLY_SEED_PRIORITY)
			return;
		
		if (file.getFirstChunk() == file.getLastChunk())
		{
			// prioritise whole file 
			p->prioritise(file.getFirstChunk(),file.getLastChunk(),PREVIEW_PRIORITY);
			return;
		}
		
		Uint32 nchunks = p->previewChunkRangeSize(file);
		if (!nchunks)
			return;
		
		p->prioritise(file.getFirstChunk(), file.getFirstChunk()+nchunks, PREVIEW_PRIORITY);
		if (file.getLastChunk() - file.getFirstChunk() > nchunks)
		{
			p->prioritise(file.getLastChunk() - nchunks, file.getLastChunk(), PREVIEW_PRIORITY);
		}	
	}
Exemple #2
0
	TorrentFile::TorrentFile(const TorrentFile & tf)
		: TorrentFileInterface(tf.getIndex(),QString(),0)
	{
		setUnencodedPath(tf.unencoded_path); 
		index = tf.getIndex();
		path = tf.getPath();
		size = tf.getSize();
		cache_offset = tf.getCacheOffset();
		first_chunk = tf.getFirstChunk();
		first_chunk_off = tf.getFirstChunkOffset();
		last_chunk = tf.getLastChunk();
		last_chunk_size = tf.getLastChunkSize();
		old_priority = priority = tf.getPriority();
		missing = tf.isMissing();
		tor = tf.tor;
		filetype = UNKNOWN;
	}
	Uint32 ChunkManager::previewChunkRangeSize(const TorrentFile & file) const
	{
		if (!file.isMultimedia())
			return 0;
		
		if (file.getFirstChunk() == file.getLastChunk())
			return 1;
		
		Uint32 preview_size = 0;
		if (file.isVideo())
			preview_size = preview_size_video;
		else
			preview_size = preview_size_audio;
			
		Uint32 nchunks = preview_size / tor.getChunkSize();
		if (nchunks == 0)
			nchunks = 1;
		
		return nchunks;
	}