private void OnIceCandidateReadyToSend(string candidate, int sdpMlineindex, string sdpMid)
        {
            var message = new NodeDssSignaler.Message
            {
                MessageType      = NodeDssSignaler.Message.WireMessageType.Ice,
                Data             = $"{candidate}|{sdpMlineindex}|{sdpMid}", // see DssSignaler_OnMessage
                IceDataSeparator = "|"
            };

            NodeDssSignaler.SendMessageAsync(message);
        }
        private void OnLocalSdpReadyToSend(string type, string sdp)
        {
            Logger.Log($"Local {type} ready to be sent to remote peer.");
            if (type == "offer")
            {
                NotifyLocalOfferApplied();
            }
            else if (type == "answer")
            {
                NotifyLocalAnswerApplied();
            }
            var message = new NodeDssSignaler.Message
            {
                MessageType      = NodeDssSignaler.Message.WireMessageTypeFromString(type),
                Data             = sdp,
                IceDataSeparator = "|"
            };

            NodeDssSignaler.SendMessageAsync(message);
            //RunOnMainThread(() => negotiationStatusText.Text = (type == "offer" ? "Sending local offer" : "Idle (answer sent)"));
        }
        private async void DssSignaler_OnMessage(NodeDssSignaler.Message message)
        {
            Logger.Log($"DSS received message: {message.MessageType}");

            // Ensure that the filtering values are up to date before passing the message on.
            //UpdateCodecFilters();
            //_peerConnection.PreferredAudioCodec = PreferredAudioCodec;
            //_peerConnection.PreferredAudioCodecExtraParamsRemote = PreferredAudioCodecExtraParamsRemoteTextBox.Text;
            //_peerConnection.PreferredAudioCodecExtraParamsLocal = PreferredAudioCodecExtraParamsLocalTextBox.Text;
            //_peerConnection.PreferredVideoCodec = PreferredVideoCodec;
            //_peerConnection.PreferredVideoCodecExtraParamsRemote = PreferredVideoCodecExtraParamsRemoteTextBox.Text;
            //_peerConnection.PreferredVideoCodecExtraParamsLocal = PreferredVideoCodecExtraParamsLocalTextBox.Text;

            switch (message.MessageType)
            {
            case NodeDssSignaler.Message.WireMessageType.Offer:
                await ApplyRemoteOfferAsync(message.Data);

                // If we get an offer, we immediately send an answer back once the offer is applied
                _peerConnection.CreateAnswer();
                break;

            case NodeDssSignaler.Message.WireMessageType.Answer:
                await ApplyRemoteAnswerAsync(message.Data);

                break;

            case NodeDssSignaler.Message.WireMessageType.Ice:
                // TODO - This is NodeDSS-specific
                // this "parts" protocol is defined above, in OnIceCandidateReadyToSend listener
                var parts = message.Data.Split(new string[] { message.IceDataSeparator }, StringSplitOptions.RemoveEmptyEntries);
                // Note the inverted arguments; candidate is last here, but first in OnIceCandidateReadyToSend
                _peerConnection.AddIceCandidate(parts[2], int.Parse(parts[1]), parts[0]);
                break;

            default:
                throw new InvalidOperationException($"Unhandled signaler message type '{message.MessageType}'");
            }
        }
Beispiel #4
0
        private async void DssSignaler_OnMessage(NodeDssSignaler.Message message)
        {
            Logger.Log($"DSS received message: {message.MessageType}");

            // Ensure that the filtering values are up to date before passing the message on.
            //UpdateCodecFilters();
            //_peerConnection.PreferredAudioCodec = PreferredAudioCodec;
            //_peerConnection.PreferredAudioCodecExtraParamsRemote = PreferredAudioCodecExtraParamsRemoteTextBox.Text;
            //_peerConnection.PreferredAudioCodecExtraParamsLocal = PreferredAudioCodecExtraParamsLocalTextBox.Text;
            //_peerConnection.PreferredVideoCodec = PreferredVideoCodec;
            //_peerConnection.PreferredVideoCodecExtraParamsRemote = PreferredVideoCodecExtraParamsRemoteTextBox.Text;
            //_peerConnection.PreferredVideoCodecExtraParamsLocal = PreferredVideoCodecExtraParamsLocalTextBox.Text;

            switch (message.MessageType)
            {
            case NodeDssSignaler.Message.WireMessageType.Offer:
                await ApplyRemoteOfferAsync(message.Data);

                // If we get an offer, we immediately send an answer back once the offer is applied
                _peerConnection.CreateAnswer();
                break;

            case NodeDssSignaler.Message.WireMessageType.Answer:
                await ApplyRemoteAnswerAsync(message.Data);

                break;

            case NodeDssSignaler.Message.WireMessageType.Ice:
                // TODO - This is NodeDSS-specific
                _peerConnection.AddIceCandidate(message.ToIceCandidate());
                break;

            default:
                throw new InvalidOperationException($"Unhandled signaler message type '{message.MessageType}'");
            }
        }