Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Is there a way of setting a latency parameter for SRT? #1673

Open
alexsafe opened this issue Dec 5, 2024 · 9 comments
Open

[Question] Is there a way of setting a latency parameter for SRT? #1673

alexsafe opened this issue Dec 5, 2024 · 9 comments

Comments

@alexsafe
Copy link

alexsafe commented Dec 5, 2024

I saw another issue about this and I think you were saying it needs to be set on the server/streaming cloud, but I was wondering if there is a way (in the works or doable) that you know of where I can set something up app-side.

Thanks!

@pedroSG94
Copy link
Owner

Hello,

I don't set a latency value in the stream, the latency is the minimal necessary to produce and send frames.
After that, in server/player side you will have latency too. For example, a player need create a cache to work so in most of cases the latency is mainly in player side.

@alexsafe
Copy link
Author

alexsafe commented Dec 5, 2024

ok thanks. So any setting regarding latency might be set just as a parameter for example that we can attach to the srt:// . Would it even make sense to add a variable latency in the stream for the library as an improvement ?

@pedroSG94
Copy link
Owner

Hello,

Can you explain the idea?
Do you want add a cache in seconds to the stream using that variable?

@alexsafe
Copy link
Author

alexsafe commented Dec 5, 2024

Hi,

I'm still trying to figure it out. So just food for thought for now.
It seems that the latency should be more of a server thing, the client should only request a certain value. So probably nothing to do on the library (maybe just the UrlParser to account for extra parameters). But I'm not 100% sure of this yet. The difference between buffer and latency would be smth like this(to quote from a reddit):

If a packet cannot be successfully retransmitted within the latency window, the packet is dropped. The buffer field is likely implemented as a helper for other protocols like TCP, where there is no fixed retransmit period.
It should help more to take any extra buffering (>200ms) and move it to the SRT latency field, where it can be used for retransmission.

Rtmp uses TCP , again, from what I currently understand that means that it would benefit more from a buffer.
SRT using UDP would benefit more from a latency setting. That would ofc need to be mirrored by the server like in this example . This too if you're interested.

@pedroSG94
Copy link
Owner

pedroSG94 commented Dec 6, 2024

Hello,

Let me try understand your request.
SRT have a feature that re send packets if the server notify the client that it is needed and I already have this implementation.

Do you want drop packets of that feature if the buffering is higher than a custom value set to the library?
Currently that is implemented in server side, because the server notify you the packets that should be restransmitted and the library drops old packets if the server request a newer packet:
https://github.com/pedroSG94/RootEncoder/blob/master/srt/src/main/java/com/pedro/srt/srt/CommandsManager.kt#L143
So the server decide if a packet should be dropped or not.

About the RTT using latency parameter in the url. I can check it, but I'm not sure what should I do with that value. Maybe change the TSBPD?
https://haivision.github.io/srt-rfc/draft-sharabayko-srt.html#name-timestamp-based-packet-deli

Currently it is hardcoded to 120ms because ffmpeg is using that value by default:
https://github.com/pedroSG94/RootEncoder/blob/master/srt/src/main/java/com/pedro/srt/srt/packets/control/handshake/extension/HandshakeExtension.kt#L31

@alexsafe
Copy link
Author

alexsafe commented Dec 6, 2024

Hi Pedro,

Yes I think you are right, the only way to it is to set is as parameter for the URL. I've done a few tests (maybe way more than I should have) and I think the conclusions converge to what you said about the hardcoded value.
This is the URL that works.
srt://srt-auto.millicast.com:10000/?streamid=mystreamId&latency=5000000
however when I use this with the library there is no latency, so it seems to be the default one hardcoded. I am using OBS software to benchmark and over there the same URL results in the desired delay/latency.

@pedroSG94
Copy link
Owner

Hello,

Try to compile this branch to test it:
#1676

@alexsafe
Copy link
Author

alexsafe commented Dec 9, 2024

Hi Pedro,

Edit: I used my own version of SrtClient and your solution seems to work perfectly :D.

Thanks. I'm having some trouble manually adding the dependency. I followed the guide, upgraded my grade to 8.71but I got caught in a dependency error loop. This would be the latest:

\common\build.gradle.kts' line: 1

Error resolving plugin [id: 'com.android.library', version: '8.7.1']
> The request for this plugin could not be satisfied because the plugin is already on the classpath with an unknown version, so compatibility cannot be checked.

Any quick ideas on how to exit this or another way to test?

@pedroSG94
Copy link
Owner

Hello,

I compiled the commit to test it:

  implementation 'com.github.pedroSG94.RootEncoder:library:3e5460166c'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants