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

Configure pion port range #54

Closed
mattyg opened this issue Sep 25, 2023 · 5 comments · Fixed by #55
Closed

Configure pion port range #54

mattyg opened this issue Sep 25, 2023 · 5 comments · Fixed by #55

Comments

@mattyg
Copy link
Contributor

mattyg commented Sep 25, 2023

I'm trying to run a conductor from a docker container and I need to be able to limit the range of ports used by pion. It looks like pion supports configuring a min & max port via the SettingEngine, which gets passed into the initial webrtc.NewAPI call.

See https://github.com/pion/webrtc/blob/37c7e3c55136c7699e58d7335eec0488020eb6c4/settingengine.go#L30

The go-rust binding is a bit over my head, but I'm guessing there will need to be some refactoring needed to manually call webrtc.NewAPI as part of setting up tx5-go-pion, so SettingEngine configuration can be passed in, instead of using a static configuration defined in it's init() function.

It would also be nice to specify a demuxed single port which seems possible, but likely more complicated: https://github.com/pion/webrtc/blob/master/examples/ice-single-port/main.go

@neonphog
Copy link
Collaborator

Interesting.

We're currently setting up the setting engine in go's static initializer:

func init() {
webrtc_api = webrtc.NewAPI(webrtc.WithSettingEngine(webrtc.SettingEngine{
LoggerFactory: customLoggerFactory{},
}))
}

We also have a required once function to set up the event emitter callback for the library:

// register the MessageCb that will be invoked for events
//
//export OnEvent
func OnEvent(
// the callback to invoke
event_cb C.MessageCb,
// the user data to forward to the callback
event_usr unsafe.Pointer,
) unsafe.Pointer {

I wonder if that should be renamed and made to take config json that could configure the pion settings engine.

@neonphog
Copy link
Collaborator

Alternately, we could wrap everything in a settings engine abstraction, and require all further calls be made through that abstraction.

@mattyg
Copy link
Contributor Author

mattyg commented Sep 25, 2023

Okay, I'll see if I can take a stab at it.

Another workaround could be to just statically define an arbitrary min port, and define the max port to min + max_conn_count -- not sure if that would make it any simpler to implement

edit: nevermind it would still require this refactoring to modify setting engine outside of init that doesn't makes sense.

@mattyg
Copy link
Contributor Author

mattyg commented Sep 26, 2023

yeah this is way over my head. Hopefully you have some bandwidth to take this on. Otherwise I'll try to figure out an alternative deployment setup.

@neonphog
Copy link
Collaborator

@mattyg - let me know if this works: #55

I'm not really sure how to unit test this.

@neonphog neonphog linked a pull request Sep 26, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants