A:如何由RTCOfferAnswerOptions生成cricket::MediaSessionOptions?
、MEDIA_TYPE_VIDEO、MEDIA_TYPE_DATA。transceivers_决定了是否要在MediaSessionOptions存在声音、视频。但数据靠的不是这种方法,而是HasDataChannels()。
我现在还没有找到让HasDataChannels()返回true的办法。 传输数据或是rtp(enable_rtp_data_channel=true)或是sctp。 |
本帖最后由 ancientcc 于 2017-1-10 11:18 编辑 配置stun/turn服务器 在控制ICE模块上,app要做的是设置RTCConfiguration,然后把它作为参数传给PeerConnectionFactory::CreatePeerConnection。对RTCConfiguration,其它可用默认值,除了配置stun/turn服务器,即当中的servers字段。servers字段的类型是IceServer。
IceServer中有两个和服务器域名有关的url:uri、urls。当urls不空时,只解析urls,忽略uri。当urls空时,才解析uri。当urls、uri都是空时,参数错误。看webrtc写的,它是建议用urls,废弃uri。 urls是std::vector,也就是说一次会话可同时指定多个stun服务器,或多个turn服务器。接下说说字符串格式。[]表示可选,<>表示变量。
注:<webrtc>/api/peerconnection.cc的ParseIceServers负责解析IceServer。 查看收集/连接状态 到现在,我不知道app层如何判断正使用的连接是中继还是穿透。
app可通过重载这两函数查看收集/连接状态。注:以下提到的Channel指P2PTransportChannel。 IceGatheringState指示收集对端候选地址到了什么状态,它有三个值。
不论IceGatheringState,还是IceConnectionState, 改变状态主要发生在TransportController::UpdateAggregateStates_n()。 对gathering_state,它查询P2PTransportChannel::gathering_state_变量,如果有一条Channel的gathering_state_不是kIceGatheringNew(或kIceGatheringGathering,或kIceGatheringComplete),那就是kIceGatheringGathering,如果都是kIceGatheringComplete,则就是kIceGatheringComplete。 Channel是什么时候从kIceGatheringNew到kIceGatheringGathering?PeerConnection::SetLocalDescription退出前。kIceGatheringGathering何时到kIceGatheringComplete?非relay类型,通过了Stun检查;relay时,收到一个中继地址。 IceGatheringState对调试有用,但对使用app的人来说,可能没啥用。它们可能应该关心IceConnectionState。
注:webrtc原码存在两处IceConnectionState定义,<webrtc>/api/peerconnectioninterface.h和<webrtc>/p2p/base/jseptransport.h。它们定义的值不一样,将来应该会统一。 由于webrtc默认开启绑定,这使得整会话就存在一条Channel。一旦该Channel有了可用的Connection,则是所有Channel都有了,这就让kIceConnectionConnected基于等同kIceConnectionCompleted。
|