te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>javascript - How does WebRTC decide which TURN Servers to Use - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How does WebRTC decide which TURN Servers to Use - Stack Overflow

programmeradmin3浏览0评论

Branching off this question WebRTC - How many STUN/TURN servers do I need to specify?

How does WebRTC determine which TURN servers to use when more than one is provided?

Branching off this question WebRTC - How many STUN/TURN servers do I need to specify?

How does WebRTC determine which TURN servers to use when more than one is provided?

Share Improve this question edited May 23, 2017 at 12:09 CommunityBot 11 silver badge asked Oct 13, 2014 at 14:38 TernaryTernary 2,4214 gold badges31 silver badges54 bronze badges 2
  • 3 It organizes the ICE candidates gathered by each one given their priority set during the ice gathering stage and this is implementation specific I believe(meaning FF and Chrome prefer different candidate types). – Benjamin Trent Commented Oct 13, 2014 at 19:48
  • @BenjaminTrent thank you very much, I had not stumbled upon that priority value in the RFC. If you like, add this as an answer and I'll accept it. – Ternary Commented Oct 15, 2014 at 14:03
Add a ment  | 

1 Answer 1

Reset to default 16

Every Ice candidate is given a priority when it is gathered. It is a mixture of a couple of things and I believe that each platform(Chrome, FireFox, etc.) has their own preferences.

Here is a link to the RFC explaining how priorities are to be generated. Each priority is guaranteed to be unique as the candidate ID should be unique(if the RFC is followed). So, you should never have a tie in priorities. Those with higher priorities are tried first, if a connection cannot be made with them, then the next in line is used.

Quote from the RFC Regarding priority:

When using the formula, an agent putes the priority by determining a preference for each type of candidate (server reflexive, peer
reflexive, relayed, and host), and, when the agent is multihomed,
choosing a preference for its IP addresses. These two preferences
are then bined to pute the priority for a candidate. That
priority is puted using the following formula:

    priority = (2^24)*(type preference) +
               (2^8)*(local preference) +
               (2^0)*(256 - ponent ID)

The type preference MUST be an integer from 0 to 126 inclusive, and represents the preference for the type of the candidate (where the
types are local, server reflexive, peer reflexive, and relayed). A
126 is the highest preference, and a 0 is the lowest. Setting the
value to a 0 means that candidates of this type will only be used as
a last resort. The type preference MUST be identical for all
candidates of the same type and MUST be different for candidates of
different types. The type preference for peer reflexive candidates
MUST be higher than that of server reflexive candidates. Note that
candidates gathered based on the procedures of Section 4.1.1 will
never be peer reflexive candidates; candidates of these type are
learned from the connectivity checks performed by ICE.

The local preference MUST be an integer from 0 to 65535 inclusive. It represents a preference for the particular IP address from which
the candidate was obtained, in cases where an agent is multihomed.
65535 represents the highest preference, and a zero, the lowest.
When there is only a single IP address, this value SHOULD be set to 65535. More generally, if there are multiple candidates for a particular ponent for a particular media stream that have the same type, the local preference MUST be unique for each one. In this
specification, this only happens for multihomed hosts. If a host is
multihomed because it is dual stack, the local preference SHOULD be
set equal to the precedence value for IP addresses described in RFC
3484 [RFC3484].

The ponent ID is the ponent ID for the candidate, and MUST be between 1 and 256 inclusive.

You can see the turn server ip and port is shown in a relay candidate. The following is derived from the RFC page 82 and webrtc hacks.

a=candidate:2157334355<ID> 2<Component> udp<NetType> 33562367<Prioirty> 180.6.6.6<NAT pub IP> 54278<NAT pub Port> typ relay<Means it needs to be relayed through Turn> raddr 46.2.2.2<Relay address of turn> rport 38135<relay port of turn> generation 0
发布评论

评论列表(0)

  1. 暂无评论