Esempio n. 1
0
        /// <summary>
        /// Update loop used to process any connection events.
        /// </summary>
        protected override void Update()
        {
            for (int i = 0; i < Instance.connections.Count; ++i)
            {
                MLWebRTC.PeerConnection connection = Instance.connections[i];
                if (MagicLeapNativeBindings.MLHandleIsValid(connection.Handle))
                {
                    // Polls for connection events.
                    DidNativeCallSucceed(MLWebRTC.PeerConnection.NativeBindings.MLWebRTCConnectionProcessEvents(connection.Handle), "MLWebRTCConnectionProcessEvents()");
                }
            }

            if (!IsProcessingSinks)
            {
                _ = ProcessVideoSinksAsync();
            }
        }
Esempio n. 2
0
            /// <summary>
            /// Creates an initialized DataChannel object.
            /// </summary>
            /// <param name="connection">The connection to create the data channel with.</param>
            /// <param name="label">The label to give the data channel.</param>
            /// <param name="result">The MLResult object of the inner platform call(s).</param>
            /// <returns> An initialized DataChannel object.</returns>
            public static DataChannel CreateLocal(MLWebRTC.PeerConnection connection, out MLResult result, string label = "local")
            {
                DataChannel dataChannel = null;

                if (connection == null)
                {
                    result = MLResult.Create(MLResult.Code.InvalidParam, "PeerConnection is null.");
                    return(dataChannel);
                }

                ulong dataChannelHandle = MagicLeapNativeBindings.InvalidHandle;

                MLResult.Code resultCode = NativeBindings.MLWebRTCDataChannelCreate(connection.Handle, label, out dataChannelHandle);
                if (!DidNativeCallSucceed(resultCode, "MLWebRTCDataChannelCreate()"))
                {
                    result = MLResult.Create(resultCode);
                    return(dataChannel);
                }

                dataChannel = new DataChannel(dataChannelHandle)
                {
                    Label            = label,
                    ParentConnection = connection
                };

                resultCode = NativeBindings.SetCallbacks(dataChannel);

                if (!DidNativeCallSucceed(resultCode, "MLWebRTCDataChannelSetCallbacks()"))
                {
                    result = MLResult.Create(resultCode);
                    return(dataChannel);
                }

                connection.LocalDataChannels.Add(dataChannel);
                result = MLResult.Create(resultCode);
                return(dataChannel);
            }