Пример #1
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);
        }
Пример #2
0
        public IRTCRtpTransceiver AddTransceiver(IMediaStreamTrack track, RTCRtpTransceiverInit init)
        {
            object nativeInit = init;

            if (init is not null && init.Streams is not null)
            {
                // Convert Streams to native.
                var nativeStreams = init.Streams.Select(s => ((MediaStream)s).NativeObject).ToArray();
                nativeInit = new
                {
                    init.Direction,
                    init.SendEncodings,
                    nativeStreams
                };
            }
            return(RTCRtpTransceiver.Create(JsRuntime, JsRuntime.CallJsMethod <JsObjectRef>(NativeObject,
                                                                                            "addTransceiver",
                                                                                            new object[]
            {
                ((MediaStreamTrack)track).NativeObject,
                nativeInit
            })));
        }