コード例 #1
0
ファイル: IceServer.cs プロジェクト: khuangyl/sipsorcery
        /// <summary>
        /// Gets an ICE candidate for this ICE server once the required server responses have been received.
        /// Note the related address and port are deliberately not set to avoid leaking information about
        /// internal network configuration.
        /// </summary>
        /// <param name="init">The initialisation parameters for the ICE candidate (mainly local username).</param>
        /// <param name="type">The type of ICE candidate to get, must be srflx or relay.</param>
        /// <returns>An ICE candidate that can be sent to the remote peer.</returns>
        internal RTCIceCandidate GetCandidate(RTCIceCandidateInit init, RTCIceCandidateType type)
        {
            RTCIceCandidate candidate = new RTCIceCandidate(init);

            if (type == RTCIceCandidateType.srflx && ServerReflexiveEndPoint != null)
            {
                candidate.SetAddressProperties(RTCIceProtocol.udp, ServerReflexiveEndPoint.Address, (ushort)ServerReflexiveEndPoint.Port,
                                               type, null, 0);
                candidate.IceServer = this;

                return(candidate);
            }
            else if (type == RTCIceCandidateType.relay && RelayEndPoint != null)
            {
                candidate.SetAddressProperties(RTCIceProtocol.udp, RelayEndPoint.Address, (ushort)RelayEndPoint.Port,
                                               type, null, 0);
                candidate.IceServer = this;

                return(candidate);
            }
            else
            {
                logger.LogWarning($"Could not get ICE server candidate for {_uri} and type {type}.");
                return(null);
            }
        }
コード例 #2
0
 /// <summary>
 /// Convenience constructor for cases when the application wants
 /// to create an ICE candidate,
 /// </summary>
 public RTCIceCandidate(
     RTCIceProtocol cProtocol,
     IPAddress cAddress,
     ushort cPort,
     RTCIceCandidateType cType)
 {
     SetAddressProperties(cProtocol, cAddress, cPort, cType, null, 0);
 }
コード例 #3
0
ファイル: RTCIceCandidate.cs プロジェクト: sdwflmw/sipsorcery
        public void SetAddressProperties(
            RTCIceProtocol cProtocol,
            IPAddress cAddress,
            ushort cPort,
            RTCIceCandidateType cType,
            IPAddress cRelatedAddress,
            ushort cRelatedPort)
        {
            protocol       = cProtocol;
            address        = cAddress.ToString();
            port           = cPort;
            type           = cType;
            relatedAddress = cRelatedAddress?.ToString();
            relatedPort    = cRelatedPort;

            foundation = GetFoundation();
            priority   = GetPriority();
        }