问题
I have libstreaming RTSP server on Android device (open some port and wait for client p2p connection).
I'm able to connect to the server via local network. For outside p2p connection I have to use STUN / TURN.
I read a lot about Twilio. They wrote about TURN server: NETWORK TRAVERSAL, but didn't actually provide clear example of how to use it. They have some ready solutions I don't need.
Is it possible to use Twilio directly as TURN server for video streaming, without any additional functionality?
If no, what alternatives I have?
回答1:
Twilio developer evangelist here.
In order to use the TURN server you need to generate an access token which then contains all the details of the Network Traversal Service servers with credentials for accessing them.
You will need a server with which to generate this token, so that you don't expose your Twilio account credentials. The server will need to make a request to Twilio to generate the token. In curl, this would look like this:
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Tokens.json \
-u "YOUR_ACCOUNT_SID:YOUR_AUTH_TOKEN
The response then looks like this:
{
"account_sid": "YOUR_ACCOUNT_SID",
"date_created": "Mon, 17 Nov 2014 23:55:19 +0000",
"date_updated": "Mon, 17 Nov 2014 23:55:19 +0000",
"ice_servers": [
{
"url": "stun:global.stun.twilio.com:3478?transport=udp"
},
{
"credential": "M87Dd74GbNfyrAydvEKiDR43go52fo6ldoJBHB6gim0=",
"url": "turn:global.turn.twilio.com:3478?transport=udp",
"username": "b759d275ddc641cd379f329882abe3c0618c8afdfc5e24be1b4d59482244240f"
}
],
"password": "M87Dd74GbNfyrAydvEKiDR43go52fo6ldoJBHB6gim0=",
"registrars": null,
"ttl": "86400",
"username": "b759d275ddc641cd379f329882abe3c0618c8afdfc5e24be1b4d59482244240f"
}
You can then use the TURN server URL and credentials to access the TURN service. Check out the documentation for this here.
来源:https://stackoverflow.com/questions/40862574/how-to-directly-use-twilio-turn-server-for-android-server-client