-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add stun to server * Squashed commit of the following: commit 5b3a562 Author: Michael Sobrepera <[email protected]> Date: Mon Apr 27 13:04:01 2020 -0400 more stupid typos commit aa364a2 Author: Michael Sobrepera <[email protected]> Date: Mon Apr 27 13:02:19 2020 -0400 fixed the same typo in the rest of the file commit 4257019 Author: Michael Sobrepera <[email protected]> Date: Mon Apr 27 13:01:03 2020 -0400 fixed typo in python import of service commit 165c0d3 Author: Michael Sobrepera <[email protected]> Date: Mon Apr 27 12:59:02 2020 -0400 fixed launch file wrong name in param commit 9d7189b Author: Michael Sobrepera <[email protected]> Date: Mon Apr 27 12:58:19 2020 -0400 made python node runable commit 39a51e7 Author: Michael Sobrepera <[email protected]> Date: Mon Apr 27 11:38:35 2020 -0400 changed to using a service and made a python demo source * fixed missing package dependencies * fixed problems in cmakelists
- Loading branch information
Showing
7 changed files
with
150 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0"?> | ||
<launch> | ||
<!--ICE servers are used to resolve remote connections over the internet. If you--> | ||
<!--are in a single network where the devices can find each other by IP address,--> | ||
<!--this is not needed:--> | ||
<node name="ice_server_provider" pkg="webrtc_ros" type="ice_server_service.py"> | ||
<!--These are the servers used for resolving remote addresses, google provides--> | ||
<!--some free to use ones, here as defaults. You could setup your own or use--> | ||
<!--another provider--> | ||
<rosparam param="stun_servers"> | ||
['stun:stun1.l.google.com:19302', 'stun:stun2.l.google.com:19302'] | ||
</rosparam> | ||
<!--Turn servers are used to route traffic from behind challenging networks.--> | ||
<!--Not always needed, but in some corporate environments it might be. --> | ||
<!--This is the url of the turn server (Ex: coturn)--> | ||
<rosparam param="turn_server_uris"> | ||
[] | ||
</rosparam> | ||
<!--You need credentials to access your turn server. The best way to do--> | ||
<!--that (the way we support) is to use a seperate rest api with a shared--> | ||
<!--secret with coturn. This is the uri, username, and password that will --> | ||
<!--be passed to that endpoint. They will be passed to the enpoint as a --> | ||
<!--post request with fields username and password in the request body--> | ||
<!--It expects the server to respond with the username and password for--> | ||
<!--the turn server in fields username and password held in the response--> | ||
<!--data--> | ||
<param name="turn_server_creds_uri" value=""/> | ||
<param name="turn_server_creds_username" value=""/> | ||
<param name="turn_server_creds_password" value=""/> | ||
</node> | ||
<node name="webrtc_server" pkg="webrtc_ros" type="webrtc_ros_server_node"> | ||
<param name="port" value="9090"/> | ||
</node> | ||
</launch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
string uri | ||
string username | ||
string password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env python | ||
|
||
import json | ||
import rospy | ||
import requests | ||
from webrtc_ros.msg import IceServer | ||
from webrtc_ros.srv import GetIceServers, GetIceServersResponse | ||
|
||
|
||
class IceServerManager(object): | ||
""" Manages providing ice server information to the webrtc system """ | ||
|
||
def __init__(self): | ||
rospy.init_node('ice_server_provider') | ||
|
||
self.stun_servers = rospy.get_param('stun_servers', [ | ||
'stun:stun1.l.google.com:19302', 'stun:stun2.l.google.com:19302']) | ||
self.turn_server_uris = rospy.get_param('turn_server_uris', '') | ||
self.turn_creds_uri = rospy.get_param('turn_server_creds_uri', '') | ||
self.turn_creds_username = rospy.get_param( | ||
'turn_server_creds_username', '') | ||
self.turn_creds_password = rospy.get_param( | ||
'turn_server_creds_password', '') | ||
|
||
self.get_ice_servers_service = rospy.Service( | ||
'get_ice_servers', GetIceServers, self.get_ice_servers) | ||
|
||
rospy.loginfo('Ice Server Provider Up') | ||
rospy.spin() | ||
|
||
def get_turn_creds(self): | ||
"""Get the credentials from the turn server.""" | ||
if self.turn_creds_uri: | ||
resp = requests.post(self.turn_creds_uri, | ||
{'username': self.turn_creds_username, | ||
'password': self.turn_creds_password}) | ||
if(('username' in resp.data) and ('password' in resp.data)): | ||
return resp.data | ||
return False | ||
|
||
def get_ice_servers(self, _): | ||
"""Callback for service. Returns the ice servers""" | ||
resp = GetIceServersResponse() | ||
turn_creds = self.get_turn_creds() | ||
if turn_creds: | ||
for uri in self.turn_server_uris: | ||
serv = IceServer() | ||
serv.username = turn_creds['username'] | ||
serv.password = turn_creds['password'] | ||
resp.servers.append(serv) | ||
for suri in self.stun_servers: | ||
serv = IceServer() | ||
serv.uri = suri | ||
resp.servers.append(serv) | ||
return resp | ||
|
||
|
||
if __name__ == '__main__': | ||
IceServerManager() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## args | ||
--- | ||
## Resp | ||
IceServer[] servers |