public Classes.RTCCertificate GenerateCertificate(EncryptionKeyType keyType, long expires)
 {
     return(RTCCertificate.GenerateCertificateWithParams(new NSDictionary <NSString, NSObject>(
                                                             new[] { "expires".ToNative(), "name".ToNative() },
                                                             new NSObject[] { new NSNumber(expires), keyType.ToStringNative() }
                                                             )).ToNet());
 }
        private async Task InitializeORTC()
        {
            var gatherOptions = new RTCIceGatherOptions()
            {
                IceServers = new List <RTCIceServer>()
                {
                    new RTCIceServer {
                        Urls = new string[] { "stun.l.google.com:19302" }
                    },
                    new RTCIceServer {
                        Username = "******", Credential = "redmond123", CredentialType = RTCIceGathererCredentialType.Password, Urls = new string[] { "turn:turn-testdrive.cloudapp.net:3478?transport=udp" }
                    }
                }
            };

            _gatherer = new RTCIceGatherer(gatherOptions);
            _gatherer.OnStateChange += IceGatherer_OnStateChange;

            _gatherer.OnLocalCandidate += async(candidate) =>
            {
                await _signaler.SendToPeer(RemotePeer.Id, candidate.Candidate.ToJsonString());
            };

            var cert = await RTCCertificate.GenerateCertificate();

            _ice = new RTCIceTransport(_gatherer);
            _ice.OnStateChange += IceTransport_OnStateChange;

            _dtls = new RTCDtlsTransport(_ice, new RTCCertificate[] { cert });
            _dtls.OnStateChange += Dtls_OnStateChange;

            _sctp = new RTCSctpTransport(_dtls);
        }
        private async Task InitializeORTC()
        {
            var gatherOptions = new RTCIceGatherOptions()
            {
                IceServers = new List <RTCIceServer>()
                {
                    new RTCIceServer
                    {
                        Urls = new string[] { _stunUrl }
                    },
                    new RTCIceServer
                    {
                        Username       = _turnUsername,
                        Credential     = _turnCredential,
                        CredentialType = RTCIceCredentialType.Password,
                        Urls           = new string[] { _turnUrl }
                    }
                }
            };

            _gatherer = new RTCIceGatherer(gatherOptions);

            _gatherer.OnStateChange += IceGatherer_OnStateChange;

            _gatherer.OnLocalCandidate += (@event) =>
            {
                OnSignalMessageToPeer(@event.Candidate.ToJson().ToString());
            };
            _gatherer.OnLocalCandidateComplete += (@event) =>
            {
                OnSignalMessageToPeer(@event.Candidate.ToJson().ToString());
            };

            _ice = new RTCIceTransport(_gatherer);
            _ice.OnStateChange += IceTransport_OnStateChange;

            _dtls = new RTCDtlsTransport(_ice, new RTCCertificate[]
            {
                await RTCCertificate.GenerateCertificate()
            });
            _dtls.OnStateChange += Dtls_OnStateChange;

            _sctp = new RTCSctpTransport(_dtls);

            _gatherer.Gather(null);
        }
 public Core.RTCCertificate CreateCertificate(EncryptionKeyType encryptionKeyType, long expiries)
 {
     return(RTCCertificate.GenerateCertificateWithParams(new NSDictionary <NSString, NSObject>(new[] { "expires".ToPlatformNative(), "name".ToPlatformNative() }, new NSObject[] { new NSNumber(expiries), encryptionKeyType.ToStringNative() })).ToNativePort());
 }
Example #5
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            RTCIceGatherOptions options = new RTCIceGatherOptions();
            RTCIceServer        server  = new RTCIceServer();

            server.UserName   = "******";
            server.Credential = "12345";
            server.Urls       = new List <String>();
            server.Urls.Add("stun:stun.vline.com");
            options.IceServers = new List <RTCIceServer>();
            options.IceServers.Add(server);

            _iceGatherer = new RTCIceGatherer(options);
            _iceGatherer.OnStateChange            += this.RTCIceGatherer_onICEGathererStateChanged;
            _iceGatherer.OnLocalCandidate         += this.RTCIceGatherer_onICEGathererLocalCandidate;
            _iceGatherer.OnLocalCandidateComplete += this.RTCIceGatherer_onICEGathererCandidateComplete;
            _iceGatherer.OnLocalCandidateGone     += this.RTCIceGatherer_onICEGathererLocalCandidateGone;
            _iceGatherer.OnError += this.RTCIceGatherer_onICEGathererError;


            _iceGatherer2 = new RTCIceGatherer(options);
            _iceGatherer2.OnStateChange            += this.RTCIceGatherer_onICEGathererStateChanged2;
            _iceGatherer2.OnLocalCandidate         += this.RTCIceGatherer_onICEGathererLocalCandidate2;
            _iceGatherer2.OnLocalCandidateComplete += this.RTCIceGatherer_onICEGathererCandidateComplete2;
            _iceGatherer2.OnLocalCandidateGone     += this.RTCIceGatherer_onICEGathererLocalCandidateGone2;
            _iceGatherer2.OnError += this.RTCIceGatherer_onICEGathererError;

            _iceTransport = new RTCIceTransport(_iceGatherer);
            _iceTransport.OnStateChange            += RTCIceTransport_onICETransportStateChanged;
            _iceTransport.OnCandidatePairAvailable += RTCIceTransport_onICETransportCandidatePairAvailable;
            _iceTransport.OnCandidatePairGone      += RTCIceTransport_onICETransportCandidatePairGone;
            _iceTransport.OnCandidatePairChange    += RTCIceTransport_onICETransportCandidatePairChanged;

            _iceTransport2 = new RTCIceTransport(_iceGatherer);
            _iceTransport2.OnStateChange            += RTCIceTransport_onICETransportStateChanged2;
            _iceTransport2.OnCandidatePairAvailable += RTCIceTransport_onICETransportCandidatePairAvailable2;
            _iceTransport2.OnCandidatePairGone      += RTCIceTransport_onICETransportCandidatePairGone2;
            _iceTransport2.OnCandidatePairChange    += RTCIceTransport_onICETransportCandidatePairChanged2;

            RTCCertificate.GenerateCertificate().AsTask <RTCCertificate>().ContinueWith((cert) =>
            {
                String str = cert.Result.Expires.ToString();
                List <RTCCertificate> certs = new List <RTCCertificate>();
                certs.Add(cert.Result);
                _dtlsTransport = new RTCDtlsTransport(_iceTransport, certs);
                MediaStreamConstraints constraints = new MediaStreamConstraints();

                constraints.Audio = new MediaTrackConstraints();
                constraints.Video = new MediaTrackConstraints();

                MediaDevices.GetUserMedia(constraints).AsTask().ContinueWith <IList <MediaStreamTrack> >((temp) =>
                {
                    if (temp.Result != null && temp.Result.Count() > 0)
                    {
                        List <MediaStreamTrack> ret = new List <MediaStreamTrack>(temp.Result);
                        List <RTCRtpSender> senders = new List <RTCRtpSender>();
                        foreach (MediaStreamTrack track in temp.Result)
                        {
                            RTCRtpSender rtpSender = new RTCRtpSender(track, _dtlsTransport);
                            senders.Add(rtpSender);
                        }

                        return(ret);
                    }

                    return(null);
                });
            });

            RTCCertificate.GenerateCertificate().AsTask <RTCCertificate>().ContinueWith((cert) =>
            {
                var certs = new List <RTCCertificate>();
                certs.Add(cert.Result);
                _dtlsTransport2 = new RTCDtlsTransport(_iceTransport2, certs);
            });

            MediaDevices.EnumerateDevices().AsTask().ContinueWith <MediaDeviceInfo>((temp) =>
            {
                foreach (MediaDeviceInfo info in temp.Result)
                {
                    if (info.DeviceId != null)
                    {
                        System.Diagnostics.Debug.WriteLine("DeviceID: {0}", info.DeviceId);
                    }
                }
                return(null);
            });
        }
 public static Abstraction.RTCCertificate ToNet(this RTCCertificate self) =>
 new Abstraction.RTCCertificate(self.Private_key, self.Certificate);
Example #7
0
 public static RtcCertificatePem ToNative(this RTCCertificate self) =>
 new RtcCertificatePem(self.PrivateKey, self.Certificate);
Example #8
0
        public static Classes.RTCCertificate ToNet(this RTCCertificate self) =>

        new Classes.RTCCertificate(self.Private_key, self.Certificate);
Example #9
0
 public static Core.RTCCertificate ToNativePort(this RTCCertificate nativePort) =>
 new Core.RTCCertificate(nativePort.Private_key, nativePort.Certificate);