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

[core] Run the accept hook before opening caller's socket #1652

Merged
merged 1 commit into from
Jan 14, 2021

Conversation

xhaakon
Copy link
Contributor

@xhaakon xhaakon commented Nov 9, 2020

In listener mode, open the socket created for a connecting caller only after its accept hook has been run. This gives the hook an opportunity to set some 'pre' options (like SRTO_RCVBUF) on the socket before it gets passed to srt_accept().

In listener mode, open the socket created for a connecting caller only
after its accept hook has been run. This gives the hook an opportunity
to set some 'pre' options (like SRTO_RCVBUF) on the socket before it
gets passed to srt_accept().
@maxsharabayko
Copy link
Collaborator

maxsharabayko commented Nov 16, 2020

Hi @xhaakon
In your suggestion the "accept" hook gets a chance to set socket options with "PRE" binding, like SRTO_RCVBUF.
Before the change, setting e.g. SRTO_RCVBUF inside the hook is impossible, and will return the MJ_NOTSUP, MN_ISBOUND error.

Could you please elaborate a bit on a possible use case? I wonder why would a listener need to change the settings it had configured. I see, for example, a possible need to set receiver buffer size per connection when e.g. the streaming bitrate is known from the connection, maybe read from StreamID... 🤔

TODO

  • Check if setting a different SRTO_ENFORCEDENCRYPTION from inside the accept callback is handled properly.

@xhaakon
Copy link
Contributor Author

xhaakon commented Nov 16, 2020

Hi @maxsharabayko

I see, for example, a possible need to set receiver buffer size per connection

Yes, what you're hinting at is basically our desired use case.

Our application would like to tune the receive buffer based on the formulas you laid down in #703. The sender (caller) would measure the link bandwidth and RTT, do the calculations and remember the resulting buffer sizes. Next time it connects to the receiver (listener), it would request the desired buffer size by putting it into StreamID.

Setting SRTO_RCVBUF beforehand on the listening socket is not useful here, because each connecting caller has a different link quality and so the buffer size we want to use for each individual client will also differ.

@maxsharabayko maxsharabayko added [core] Area: Changes in SRT library core Type: Maintenance Work required to maintain or clean up the code labels Jan 14, 2021
@maxsharabayko maxsharabayko added this to the v1.4.3 milestone Jan 14, 2021
@maxsharabayko maxsharabayko merged commit 6e78ecb into Haivision:master Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[core] Area: Changes in SRT library core Type: Maintenance Work required to maintain or clean up the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants