-
Notifications
You must be signed in to change notification settings - Fork 517
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
UDP problem with live streaming #133
Comments
Interesting. We'll investigate how to obtain shared access instead of exclusive access to the socket. |
setsockopt so_reuseaddr and let ksoftirqd to do it's job |
Forgive my ignorance but is there a parameter I can add to the udp link (something like udp://224.0.0.1:2014/?so_reuseaddr) to instruct shaka-packager to obtain shared access? Thanks. |
Unfortunately not. It must be set with setsockopt() on the udp socket in the shaka source and recompile. I have never tested it here btw, because this usage isn't good for production use because highter ksoftirqd load. |
so_reuseaddr is used by any and all other UDP listening applications in our PRODUCTION environment and we see no performance impact. The point of multicast udp input is to be able to open it from multiple applications at the same time. Without this flag, you cannot. Here is the patch that we use on our version of the packager for anyone that is brave enough to compile their own: commit 8c9c6ca84ce20426f3fe262babf3fb57cf5ea748
diff --git a/packager/media/file/udp_file_posix.cc b/packager/media/file/udp_file_posix.cc
|
Here is the patch as an attachment: |
@sammirata Cool. Thanks for working on this. Would you like to contribute this patch to shaka packager? You can send a pull request! It will be good to make it configurable though, e.g. enabled only if having "reuse" in udp url, something like "udp://224.0.0.1:2014?reuse=1" (Feel free to work on it if you want; If not, I can work on it after your change is merged) Thanks! |
Yes, I would like to contribute a patch. I have never done it before using github pull requests. I did not see the config parser inside the udp module. Where is it defined? |
Cool. Thanks! Right now the port address is assumed to contain only ip address and port number, which is parsed in https://cs.corp.google.com/github/google/shaka-packager/packager/media/file/udp_file_posix.cc?rcl=52cbcb321df0cb2c831516f20b05edbc7dcd6828&l=57 To support configurable options, we can extract the strings after "?" and split the strings using base::SplitStringIntoKeyValuePairs: https://cs.chromium.org/chromium/src/base/strings/string_split.h?rcl=0&l=86 |
@sammirata are you still working on it? You may just submit a pull request for your original patch first. I'll make it configurable later. |
I just submitted a pull request for the original patch |
Hi, |
The patch is already merged, with socket reuse enabled by default. I'll submit another patch shortly - in the new patch, socket reuse is configurable with reuse flag in the url string, something like: udp://224.1.2.30:88?reuse=1 (reuse is set to 0 by default) |
I have a stream source (created with ffmpeg) which plays fine in VLC. The problem is that if I already have a client connected to that stream shaka-packager cannot connect to it. For example I open the stream with VLC and then run shaka-packager I will receive this error:
[0802/112146:INFO:demuxer.cc(60)] Initialize Demuxer for file 'udp://224.0.0.1:2014'.
[0802/112146:ERROR:udp_file_posix.cc(193)] Could not bind UDP socket
[0802/112146:ERROR:packager_main.cc(301)] Demuxer failed to initialize: 5 (FILE_FAILURE): Cannot open file for reading udp://224.0.0.1:2014
If I close VLC and nothing is connected to the stream then shaka-packager will work. This conflict is related only to shaka-packager as I am able to open multiple VLC instances or other players or even ffmpeg. On the other hand if I manage to open the stream with shaka-packager then I cannot open it with VLC or anything else in parallel.
Is there a way to open the stream with shaka-packager just as a client? Maybe some flags that I missed?
Thanks.
The text was updated successfully, but these errors were encountered: