Registered Member
|
Hi
Let me first describe what I intend to do: I recently got this idea into my head, how BT should be suited to playback video files even during download. The download speeds I achieve easily would allow that. Doing some research I stumbled onto a paper describing all necessary changes to the the chunk selection procedure. That's when I decided trying to implement something similar in a ktorrent plugin myself and started digging through the ktorrent source code. Now to my problem: Since the ChunkSelector gets created by the Downloader, I thought about supplying a custom ChunkSelectorFactory to the constructor of Downloader. Then I found out, that the Downloader gets created by TorrentControl in its setupData method, which is called by its init method. And the init method gets called by TorrentCreator and the Core (which creates the TorrentCreator). So it seems to me, that it is only possible to supply a ChunkSelectorFactory by rewriting the Core class. I don't know, if I missed anything, but this looks like a flaw in the class design to me. So that leaves switching the ChunkSelector after the construction of the Downloader. But since the ChunkSelector is private to the Downloader and the Downloader private to the TorrentControl, there's no way I can do that either. Any ideas on how to get my own ChunkSelector into the Downloader? EDIT: I started out with the stable source and then switched to the 4.0beta1 snapshot to check if anything related to my problem changed |
Moderator
|
The ChunkSelectorFactory was added upon request of the KGet people, which have an own Core implementation
So at the moment this is impossible to do from a plugin. However given the fact that I'm planning to add a streaming plugin, like you want to do, the api will need to change. I have no objection to do these changes now, certainly if you would make the plugin. Saves me some work. |
Registered Member
|
Yes, when the api allows plugins to supply their own ChunkSelector, I'll be working on a streaming plugin. So I guess I'll have to check out the svn sources
|
Moderator
|
I'm gonna make the necessary changes tomorrow.
Will keep you informed. |
Moderator
|
OK there is a now a new method in the TorrentInterface class named setChunkSelector.
This allows you to set your own custom ChunkSelector, the passed object must be allocated on the heap, and the TorrentControl will take ownership of it. Passing a 0 pointer will trigger a reset to the default ChunkSelector. |
Registered Member
|
Is there any progress made on this plugin? It would be a really nice feature :)
|
Registered Member
|
It has been quite a while now, but I am finally making progress.
This is actually my first KDE/Qt project, so I had some trouble with getting started, and then I have been on vacation for two weeks. Hopefully I'll have the first running version of my plugin soon. It's kind of embarassing, but I only realized now, that using the new setChunkSelector method is a bit tricky. Since I don't see a straightforward way to provide ChunkManager, Downloader and PeerManager for the constructor of the ChunkSelector class, I cannot use the new method like I intended. For now I'll work around that issue by first providing my own ChunkSelectorFactory and then calling setChunkSelector(0). |
Registered Member
|
Today I managed to compile the first version of my plugin, which actually modifies ktorrent's chunk-selection behaviour.
In order to get the plugin running, there are two patches, which need to be applied to libktorrent: Since TorrentControl takes ownership of the ChunkSelectorFactory:
And in order to make linking against libktorrent work:
Moreover after adding the code inside the archive to the plugin folder, the CMakeLists.txt file has to be adjusted:
There are still a few issues though.
|
Moderator
|
Seth, I will try out your plugin probably tomorrow when I have some more time.
GUI wise it would make a lot of sense to put the actual GUI stuff in the mediaplayer plugin. You see ideally you want to be able to play a video while you are downloading with the mediaplayer plugin, and you want to be able to pause the video if the next chunk which needs to be played is not there yet. So if you start playing an incomplete file you could then add your custom chunk selector, and then feed phonon the video data as it comes in. If the next part of the video isn't available, you could then do like youtube and stop playing until the data is there. |
Registered Member
|
Yes I agree. In the long run it makes the most sense to integrate the new chunk selector into the mediaplayer plugin. Especially because that should make pausing the playback for missing pieces possible. I tried to keep the gui stuff minimal for now, just enough to test the actual algorithm, but somehow it got messed up anyhow.
Still, I'm far from being satisfied with the current state of my chunk selection algorithm (mainly because of the above mentioned issue). I don't have much time today, but I'll start to further improve it tomorrow.
Last edited by imported4-seth on Sat Apr 17, 2010 9:18 pm, edited 1 time in total.
|
Registered Member
|
Ok, so I adjusted the algorithm. It's working better now. I still couldn't figure out the gui issue though. And there's another issue:
The selection algorithm currently seems to waste some bandwidth. I'm guessing that happens, when multiple peers work on the same chunk? I already reduced the number of peers allowed to work on the same chunk, but still... Also it would be really cool to take into account the average downloadspeed of the peer for choosing the chunks. That could prevent slow peers getting assigned early chunks and thereby blocking their download. |
Moderator
|
I think calling setChecked triggers the toggled signal, causing your plugin to enable or disable the streaming mode. By doing this, it doesn't seem to happen anymore:
Yes multiple peers will result in wasting bandwidth, the trouble is that you want to finish the chunk as fast as possible, but you don't know how fast a peer is going to upload it to you. So the current algorithm is to assign the same piece to multiple peers when more then one is assigned to a chunk. This is acceptable for the end of the torrent (the wasted bandwidth is the price to pay to get things downloaded faster). However for streaming mode we need something better it will probably become to much.
We could keep track of the average speed since the last unchoke, and work with that. That would probably be a good means of choosing which peer to assign to what chunk. To get the best results, we probably need to assess the situation continuously and move the best peers around to the most critical chunks. |
Moderator
|
I will add some code to keep track of the average download speed since the last unchoke.
|
Registered Member
|
Has there been any further development on this plugin?
|
Registered Member
|
Hey guys, how's it going? Any noticeable achievements so far?
|
Registered users: abc72656, Bing [Bot], daret, Google [Bot], lockheed, Sogou [Bot], Yahoo [Bot]