如何直接在Android上使用Twilio TURN服务器(服务器,客户端) [英] How to directly use Twilio TURN server for Android (Server, Client)

查看:341
本文介绍了如何直接在Android上使用Twilio TURN服务器(服务器,客户端)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 libstreaming Android设备上的 RTSP 服务器(打开一些端口,然后等待客户端 p2p连接,我必须使用 TURN .
我读了很多有关 Twilio 的内容.他们撰写了有关 TURN 服务器的信息: Twilio 直接用作

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?

推荐答案

此处是Twilio开发人员的福音.

Twilio developer evangelist here.

要使用TURN服务器,您需要生成访问令牌,然后包含网络遍历服务服务器的所有详细信息以及用于访问它们的凭据.

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.

您将需要用于生成此令牌的服务器,以免暴露Twilio帐户凭据.服务器将需要向Twilio发出请求以生成令牌.在卷曲中,它看起来像这样:

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

然后,响应如下所示:

{
    "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"
}

然后,您可以使用TURN服务器URL和凭据来访问TURN服务. 在此处查看文档.

You can then use the TURN server URL and credentials to access the TURN service. Check out the documentation for this here.

这篇关于如何直接在Android上使用Twilio TURN服务器(服务器,客户端)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆