Version: 2.1 (using KDE KDE 3.5.6) Installed from: Ubuntu Packages Compiler: gcc 4.1.2 OS: Linux When downloading exceptionally long AVIs (such as TV programs), there are not enough beginning and ending chunks downloaded to get an idea of the video quality. On one torrent, I had over 90% of the file downloaded, but could not watch more than 3 to 4 seconds of the video. I notice that chunk priority has been addressed before, but I don't think ktorrent accounts for the large number of chunks needed by such large files to successfully preview them. By way of example, the above torrent I mentioned had over 2700 chunks. Chunk numbers 2, 3, and 6 were some of the last 20 chunks downloaded. Another torrent I'm downloading right now is almost 700 MB and nearly 55% done, but I have less than one second of video. I'd much rather have, say, the first and last 10 chunks of such a large file so I can get a good idea of what I'm seeing.
Created attachment 21489 [details] Patch to download first and last 1 percent of file chunks This is probably a somewhat naive attempt, but I tried it out and, for the size files I'm downloading, it does what I want. With this in place, I can easily preview 700 MB files in a short amount of time. Perhaps some tweaking could be done to allow the user to select the percentage of the end chunks to prioritize (maybe from 1 to 5 percent).
SVN commit 706964 by guisson: Prioritise at least 1 % of multimedia files instead of the 1 chunk we currently do. Initial patch was provided by Byte Smythe with some modifications from myself. BUG: 149248 M +32 -10 chunkmanager.cpp --- branches/extragear/kde3/network/ktorrent/libktorrent/torrent/chunkmanager.cpp #706963:706964 @@ -93,22 +93,38 @@ for(Uint32 i=0; i<tor.getNumFiles(); ++i) { bt::TorrentFile & file = tor.getFile(i); - if (file.isMultimedia() && file.getPriority() != bt::ONLY_SEED_PRIORITY) + if (!file.isMultimedia() || file.getPriority() == bt::ONLY_SEED_PRIORITY) + continue; + + if (file.getFirstChunk() == file.getLastChunk()) { - prioritise(file.getFirstChunk(), file.getFirstChunk()+1, PREVIEW_PRIORITY); - if (file.getLastChunk() - file.getFirstChunk() > 2) - prioritise(file.getLastChunk() -1,file.getLastChunk(), PREVIEW_PRIORITY); + // prioritise whole file + prioritise(file.getFirstChunk(),file.getLastChunk(),PREVIEW_PRIORITY); } + else + { + Uint32 chunkOffset; + chunkOffset = ((file.getLastChunk() - file.getFirstChunk()) / 100) + 1; + prioritise(file.getFirstChunk(), file.getFirstChunk()+chunkOffset, PREVIEW_PRIORITY); + if (file.getLastChunk() - file.getFirstChunk() > chunkOffset) + { + prioritise(file.getLastChunk() - chunkOffset, file.getLastChunk(), PREVIEW_PRIORITY); + } + } } } else { if(tor.isMultimedia()) { - prioritise(0,1,PREVIEW_PRIORITY); - if (tor.getNumChunks() > 2) - prioritise(tor.getNumChunks() - 2,tor.getNumChunks() - 1,PREVIEW_PRIORITY); - //this->prioritise(getNumChunks()-2, getNumChunks()-1); + Uint32 chunkOffset; + chunkOffset = (tor.getNumChunks() / 100) + 1; + + prioritise(0,chunkOffset,PREVIEW_PRIORITY); + if (tor.getNumChunks() > chunkOffset) + { + prioritise(tor.getNumChunks() - chunkOffset, tor.getNumChunks() - 1,PREVIEW_PRIORITY); + } } } } @@ -791,9 +807,15 @@ // if it is a multimedia file, prioritise first and last chunks of file if (tf->isMultimedia()) { - prioritise(first,first+1,PREVIEW_PRIORITY); + Uint32 chunkOffset; + chunkOffset = ((last - first) / 100) + 1; + + prioritise(first,first+chunkOffset,PREVIEW_PRIORITY); if (last - first > 2) - prioritise(last -1,last, PREVIEW_PRIORITY); + { + prioritise(last - chunkOffset, last, PREVIEW_PRIORITY); + //prioritise(last -1,last, PREVIEW_PRIORITY); + } } } else