есть ли пример или документы API ORTC Lib на C# без UWP
Мне нужно написать клиент C# ORTC(webRTC) БЕЗ UWP, чтобы установить соединение между двумя узлами (двумя клиентами).
Я закончил писать signalling server
, а stun/turn server
с coturn
.
По какой-то причине мне приходится использовать C# ORTC lib
(это называется Ortc.NetStandard
в Nuget), а НЕ UWP ORTC lib.
Но все примеры и документы API, которые я нашел, были построены на UWP.
Фактически, единственными документами API являются http://draft.ortc.org/
, и он построен на JavaScript.
Я пытался вывести C# API из EXAMPLE 21&22
документов JavaScript API (http://draft.ortc.org/
), но я построил dtls object
не удалось, и я неt know how to build
сигнальщик`.
public class Node
{
public Signaller signaller_;
public string json_ = @"{'gatherPolicy':'all','iceServers':[{'urls':,'stun:stun1.example.net'}] }";
public Json optionsJson_;
public RTCIceGatherOptions gatherOptions_;
public RTCIceGatherer IceGatherer_;
RTCIceTransport ice_;
List<RTCCertificate> certs_;
RTCDtlsTransport dtls_;
RTCSctpTransport sctp_;
Org.Ortc.RTCDataChannelParameters parameters_;
public Node(Signaller signaller)
{
signaller_ = signaller;
optionsJson_ = new Json(json_);
gatherOptions_ = new RTCIceGatherOptions(optionsJson_);
IceGatherer_ = new RTCIceGatherer(gatherOptions_);
IceGatherer_.OnStateChange += IceGatherer_OnStateChange;
IceGatherer_.OnError += IceGatherer_OnError;
IceGatherer_.OnLocalCandidate += IceGatherer_OnLocalCandidate;
// Start gathering
IceGatherer_.Gather();
// Create ICE transport
ice_ = new RTCIceTransport(IceGatherer_);
// certs
certs_ = new List<RTCCertificate>();
var keygenAlgorithm = "{name:\"ECDSA\",namedCurve:\"P-256\"}";
Task<RTCCertificate> certificate = RTCCertificate.GenerateCertificate(keygenAlgorithm);
Task.WaitAll(certificate);
if (certificate.IsCompleted)
{
// certificate.Result is null
certs_.Add(certificate.Result);
}
dtls_ = new RTCDtlsTransport(ice_, certs_);
sctp_ = new RTCSctpTransport(dtls_);
parameters_ = new Org.Ortc.RTCDataChannelParameters();
parameters_.Label = "channel1";
parameters_.Ordered = true;
parameters_.Protocol = "ship";
parameters_.Negotiated = false;
}
public void onRemoteCandidate(Remote remote)
{
// RTCIceGathererCandidate
ice_.AddRemoteCandidate(remote.candidate);
}
public void sendInitiate()
{
JsonSendInitiate myJsonSendInitiate = new JsonSendInitiate();
myJsonSendInitiate.ice = IceGatherer_.LocalParameters;
// Exception
myJsonSendInitiate.dtls = dtls_.LocalParameters;
myJsonSendInitiate.sctpCapabilities = RTCSctpTransport.GetCapabilities();
myJsonSendInitiate.port = sctp_.Port;
string msgOnline = Newtonsoft.Json.JsonConvert.SerializeObject(myJsonSendInitiate, Newtonsoft.Json.Formatting.Indented);
// JsonSendInitiate json = Newtonsoft.Json.JsonConvert.DeserializeObject<JsonSendInitiate>(msgOnline);
}
}
// certificate.Result is null
certs_.Add(certificate.Result);
// Exception
myJsonSendInitiate.dtls = dtls_.LocalParameters;