Exemplo n.º 1
0
        public async Task <RTCSessionDescriptionInit> CreateOffer(RTCOfferOptions options)
        {
            var jsObjectRef = await JsRuntime.CallJsMethodAsync <JsObjectRef>(NativeObject,
                                                                              "createOffer", options);

            var descriptor = JsRuntime.GetJsPropertyValue <RTCSessionDescriptionInit>(jsObjectRef, null);

            JsRuntime.DeleteJsObjectRef(jsObjectRef.JsObjectRefId);
            return(descriptor);
        }
Exemplo n.º 2
0
        public IRTCIceCandidate[] GetRemoteCandidates()
        {
            var jsObjectRefGetRemoteCandidates = JsRuntime.CallJsMethod <JsObjectRef>(NativeObject, "getRemoteCandidates");
            var jsObjectRefIceCandidateArray   = JsRuntime.GetJsPropertyArray(jsObjectRefGetRemoteCandidates);
            var iceCandidates = jsObjectRefIceCandidateArray
                                .Select(jsObjectRef => RTCIceCandidate.Create(JsRuntime, jsObjectRef))
                                .ToArray();

            JsRuntime.DeleteJsObjectRef(jsObjectRefGetRemoteCandidates.JsObjectRefId);
            return(iceCandidates);
        }
Exemplo n.º 3
0
        public IRTCRtpTransceiver[] GetTransceivers()
        {
            var jsObjectRefGetTransceivers     = JsRuntime.CallJsMethod <JsObjectRef>(NativeObject, "getTransceivers");
            var jsObjectRefRtpTransceiverArray = JsRuntime.GetJsPropertyArray(jsObjectRefGetTransceivers);
            var rtpTransceivers = jsObjectRefRtpTransceiverArray
                                  .Select(jsObjectRef => RTCRtpTransceiver.Create(JsRuntime, jsObjectRef))
                                  .ToArray();

            JsRuntime.DeleteJsObjectRef(jsObjectRefGetTransceivers.JsObjectRefId);
            return(rtpTransceivers);
        }
Exemplo n.º 4
0
        public RTCIceServer[] GetDefaultIceServers()
        {
            var iceServers = new List <RTCIceServer>();
            var jsObjectRefGetDefaultIceServers =
                JsRuntime.CallJsMethod <JsObjectRef>(NativeObject, "getDefaultIceServers");
            var jsObjectRefIceServerArray = JsRuntime.GetJsPropertyArray(jsObjectRefGetDefaultIceServers);

            foreach (var jsObjectRefIceServer in jsObjectRefIceServerArray)
            {
                iceServers.Add(JsRuntime.GetJsPropertyValue <RTCIceServer>(jsObjectRefIceServer, null));
                JsRuntime.DeleteJsObjectRef(jsObjectRefIceServer.JsObjectRefId);
            }
            JsRuntime.DeleteJsObjectRef(jsObjectRefGetDefaultIceServers.JsObjectRefId);
            return(iceServers.ToArray());
        }
Exemplo n.º 5
0
        public RTCRtpContributingSource[] GetContributingSources()
        {
            var rtpContributingSources            = new List <RTCRtpContributingSource>();
            var jsObjectRefGetContributingSources =
                JsRuntime.CallJsMethod <JsObjectRef>(NativeObject, "getContributingSources");
            var jsObjectRefRtpContributingSourceArray = JsRuntime.GetJsPropertyArray(jsObjectRefGetContributingSources);

            foreach (var jsObjectRefRtpContributingSource in jsObjectRefRtpContributingSourceArray)
            {
                rtpContributingSources.Add(JsRuntime.GetJsPropertyValue <RTCRtpContributingSource>(
                                               jsObjectRefRtpContributingSource, null));
                JsRuntime.DeleteJsObjectRef(jsObjectRefRtpContributingSource.JsObjectRefId);
            }
            JsRuntime.DeleteJsObjectRef(jsObjectRefGetContributingSources.JsObjectRefId);
            return(rtpContributingSources.ToArray());
        }
Exemplo n.º 6
0
        public async Task <MediaDeviceInfo[]> EnumerateDevices()
        {
            var mediaDeviceInfos = new List <MediaDeviceInfo>();
            var jsObjectRef      = await JsRuntime.CallJsMethodAsync <JsObjectRef>(NativeObject, "enumerateDevices");

            var jsObjectRefMediaDeviceInfoArray = JsRuntime.GetJsPropertyArray(jsObjectRef);

            foreach (var jsObjectRefMediaDeviceInfo in jsObjectRefMediaDeviceInfoArray)
            {
                mediaDeviceInfos.Add(JsRuntime.GetJsPropertyValue <MediaDeviceInfo>
                                         (jsObjectRefMediaDeviceInfo, null));
                JsRuntime.DeleteJsObjectRef(jsObjectRefMediaDeviceInfo.JsObjectRefId);
            }
            JsRuntime.DeleteJsObjectRef(jsObjectRef.JsObjectRefId);
            return(mediaDeviceInfos.ToArray());
        }