frostwire / frostwire-jlibtorrent

A swig Java interface for libtorrent by the makers of FrostWire. Develop libtorrent based apps with the joy of coding in Java.
http://www.frostwire.com
MIT License
444 stars 137 forks source link

Sequential download only for selected file #209

Closed proninyaroslav closed 5 years ago

proninyaroslav commented 5 years ago

Hi. I'm trying to implement streaming for a user-selected file from the torrent. In this case, other files usually have NORMAL priority, and for the selected file, after reading byte and for reading the next bytes portion (if pieces not downloaded) I set pieces priority as SEVEN and call setPieceDeadline(1000), thereby creating the effect of a consistent and almost uninterrupted download on the HTTP-client side. But this approach does not work and the file download does not succeed sequentially, as if changing the priority to SEVEN is ignored. This prioritized pieces are not downloaded first. This only works if I set the priority of all files as IGNORE, except for the selected one. Is it possible to implement a sequential download for the selected file or are there pitfalls about which I know little?

aldenml commented 5 years ago

Well, I don't quite understand completely the logic inside piece_picker, but it's my understanding that none of this measures guarantee the sequential download, much less the piece download within the deadline. I never used setPieceDeadline, only the SEQUENTIAL_DOWNLOAD flag and not in a critical situation, only as a best effort to preview the file if it's a single file download. (https://github.com/frostwire/frostwire/blob/master/common/src/main/java/com/frostwire/bittorrent/BTDownload.java#L658)

My recommendation is that you post this question that is more on the libtorrent side there, and whatever the clarification you get, we can sort out some additional support here if needed.