Does set_piece_deadline() exclusively support bittorrent-integrated media players? #6273
Replies: 2 comments 5 replies
-
@AllSeeingEyeTolledEweSew consider a situation when media player requests |
Beta Was this translation helpful? Give feedback.
-
You will meet many walls trying to get "30 seconds". Usually players operate the buffer size, depending on the approximate bitrate or even a fixed-size buffer to store readahead bytes. Usually, you should have own Also you need to take in mind that it is typical to have more that 1 connection from your player, one is usually reading the video stream, second is reading audio stream, so you will have multiple You can see my example here: https://github.com/ElementumOrg/lt2http/blob/master/src/bittorrent/torrent.cpp#L809 |
Beta Was this translation helpful? Give feedback.
-
How is the caller meant to calculate the
deadline
forset_piece_deadline()
?I can imagine the scenario where the caller is streaming a media file, and wants a time-based readahead buffer ("buffer the next 30 seconds of data") and parses enough metadata to reliably calculate this, such as decoding/presentation timestamps and stream bitrates.
This seems like a very narrow case, and I want to understand if it's just narrow, or I missed something about the usage.
I'm building an http/bittorrent bridge, which is content-agnostic, so it can't predict when an http client will need a piece. The best it can do is measure the rate at which the client is streaming. To make use of this I'd have to continuously readjust deadlines, calling
set_piece_deadline()
for every piece, every second-or-something.Is there another way to use
set_piece_deadline()
I'm not thinking about? Should I try to make the API more generic?EDIT: I dug deeper into how I might use
set_piece_deadline()
by measuring a stream consumption rate to calculate deadlines. I found this to be an extremely hard problem.In particular, when using a media player like
mplayer
andvlc
to stream an http source, I see that stream throughput has very irregular spikes. The players seem to fill the tail of their cache on some kind of timer, so the throughput drops to zero for several seconds. If I use a moving average to figure out stream rate, the period would have to be quite long, and would be slow to respond if the user seeks the media. I'm not a good enough statistician to find any better way to measure stream rate, and therefore deadlines.I conclude that
set_piece_deadline()
is only useful when a real-time media player is tightly coupled to its torrent client. Change my mind!Beta Was this translation helpful? Give feedback.
All reactions