|
@@ -661,6 +661,57 @@ void IceTransport::LogCallback(const gchar *logDomain, GLogLevelFlags logLevel,
|
|
|
PLOG(severity) << "nice: " << message;
|
|
|
}
|
|
|
|
|
|
+bool IceTransport::getSelectedCandidatePair(CandidateInfo *localInfo, CandidateInfo *remoteInfo) {
|
|
|
+ NiceCandidate *local, *remote;
|
|
|
+ gboolean result = nice_agent_get_selected_pair(mNiceAgent.get(), mStreamId, 1, &local, &remote);
|
|
|
+
|
|
|
+ if (!result)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ char ipaddr[INET6_ADDRSTRLEN];
|
|
|
+ nice_address_to_string(&local->addr, ipaddr);
|
|
|
+ localInfo->address = std::string(ipaddr);
|
|
|
+ localInfo->port = nice_address_get_port(&local->addr);
|
|
|
+ localInfo->type = IceTransport::NiceTypeToCandidateType(local->type);
|
|
|
+ localInfo->transportType = IceTransport::NiceTransportTypeToCandidateTransportType(local->transport);
|
|
|
+
|
|
|
+ nice_address_to_string(&remote->addr, ipaddr);
|
|
|
+ remoteInfo->address = std::string(ipaddr);
|
|
|
+ remoteInfo->port = nice_address_get_port(&remote->addr);
|
|
|
+ remoteInfo->type = IceTransport::NiceTypeToCandidateType(remote->type);
|
|
|
+ remoteInfo->transportType = IceTransport::NiceTransportTypeToCandidateTransportType(remote->transport);
|
|
|
+
|
|
|
+ nice_candidate_free(local);
|
|
|
+ nice_candidate_free(remote);
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+const CandidateType IceTransport::NiceTypeToCandidateType(NiceCandidateType type) {
|
|
|
+ switch (type) {
|
|
|
+ case NiceCandidateType::NICE_CANDIDATE_TYPE_HOST:
|
|
|
+ return CandidateType::Host;
|
|
|
+ case NiceCandidateType::NICE_CANDIDATE_TYPE_PEER_REFLEXIVE:
|
|
|
+ return CandidateType::PeerReflexive;
|
|
|
+ case NiceCandidateType::NICE_CANDIDATE_TYPE_RELAYED:
|
|
|
+ return CandidateType::Relayed;
|
|
|
+ case NiceCandidateType::NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE:
|
|
|
+ return CandidateType::ServerReflexive;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const CandidateTransportType IceTransport::NiceTransportTypeToCandidateTransportType(NiceCandidateTransport type) {
|
|
|
+ switch (type) {
|
|
|
+ case NiceCandidateTransport::NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE:
|
|
|
+ return CandidateTransportType::TcpActive;
|
|
|
+ case NiceCandidateTransport::NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE:
|
|
|
+ return CandidateTransportType::TcpPassive;
|
|
|
+ case NiceCandidateTransport::NICE_CANDIDATE_TRANSPORT_TCP_SO:
|
|
|
+ return CandidateTransportType::TcpSo;
|
|
|
+ case NiceCandidateTransport::NICE_CANDIDATE_TRANSPORT_UDP:
|
|
|
+ return CandidateTransportType::Udp;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
} // namespace rtc
|
|
|
|
|
|
#endif
|