Exemplo n.º 1
0
        public void OnCreatedConnection(SignalingEventData data)
        {
            if (data.connectionId != connectionId)
            {
                return;
            }

            // Send offer explicitly when the media source is nothing
            if (!streams.OfType <IStreamSource>().Any() && !streams.OfType <IDataChannel>().Any())
            {
                SendOffer(connectionId);
            }
            else
            {
                foreach (var source in streams.OfType <IStreamSource>())
                {
                    var transceiver = AddTrack(connectionId, source.Track);
                    source.SetSender(connectionId, transceiver.Sender);
                }
                foreach (var channel in streams.OfType <IDataChannel>().Where(c => c.IsLocal))
                {
                    var _channel = CreateChannel(connectionId, channel.Label);
                    channel.SetChannel(connectionId, _channel);
                }
            }
        }
Exemplo n.º 2
0
        public void OnAddReceiver(SignalingEventData data)
        {
            var receiver = streams.OfType <IStreamReceiver>().
                           FirstOrDefault(r => r.Track == null);

            receiver?.SetReceiver(data.connectionId, data.receiver);
        }
Exemplo n.º 3
0
        public void OnAddChannel(SignalingEventData data)
        {
            var channel = streams.OfType <IDataChannel>().
                          FirstOrDefault(r => !r.IsConnected && !r.IsLocal);

            channel?.SetChannel(data.connectionId, data.channel);
        }
Exemplo n.º 4
0
 public void OnOffer(SignalingEventData data)
 {
     if (data.connectionId != connectionId)
     {
         return;
     }
     SendAnswer(data.connectionId);
 }
 public void OnDeletedConnection(SignalingEventData data)
 {
     if (data.connectionId != connectionId)
     {
         return;
     }
     Disconnect(connectionId);
     connectionId = null;
 }
Exemplo n.º 6
0
        private void OnDeletedConnection(string connectionId)
        {
            var data = new SignalingEventData(EventSystem.current)
            {
                connectionId = connectionId
            };

            ExecuteEventToAllTargets(data, ExecuteSignalingEvents.deletedConnectionHandler);
        }
Exemplo n.º 7
0
        private void OnAddReceiver(string connectionId, RTCRtpReceiver receiver)
        {
            var data = new SignalingEventData(EventSystem.current)
            {
                connectionId = connectionId,
                receiver     = receiver
            };

            ExecuteEventToAllTargets(data, ExecuteSignalingEvents.addReceiverHandler);
        }
Exemplo n.º 8
0
        private void OnAddChannel(string connectionId, RTCDataChannel channel)
        {
            var data = new SignalingEventData(EventSystem.current)
            {
                connectionId = connectionId,
                channel      = channel
            };

            ExecuteEventToAllTargets(data, ExecuteSignalingEvents.addChannelHandler);
        }
Exemplo n.º 9
0
        private void OnGotAnswer(string connectionId, string sdp)
        {
            var data = new SignalingEventData(EventSystem.current)
            {
                connectionId = connectionId,
                sdp          = sdp
            };

            ExecuteEventToAllTargets(data, ExecuteSignalingEvents.answerHandler);
        }
Exemplo n.º 10
0
        public void OnAddChannel(SignalingEventData data)
        {
            if (data.connectionId != connectionId)
            {
                return;
            }
            var channel = streams.OfType <IDataChannel>().
                          FirstOrDefault(r => r.Channel == null && !r.IsLocal);

            channel?.SetChannel(connectionId, data.channel);
        }
        public void OnAddReceiver(SignalingEventData data)
        {
            if (data.connectionId != connectionId)
            {
                return;
            }

            var receiver = streams.OfType <IStreamReceiver>()
                           .FirstOrDefault((r => r.Track == null && r.Kind == data.receiver.Track.Kind && data.receiver.Track.Enabled));

            receiver?.SetReceiver(connectionId, data.receiver);
        }
Exemplo n.º 12
0
        public void OnAddReceiver(SignalingEventData data)
        {
            if (data.connectionId != connectionId)
            {
                return;
            }
            if (data.receiver.Track.Kind != TrackKind.Video)
            {
                return;
            }
            var receiver = streams.OfType <IStreamReceiver>().
                           FirstOrDefault(r => r.Track == null);

            receiver?.SetReceiver(connectionId, data.receiver);
        }
        public void OnCreatedConnection(SignalingEventData data)
        {
            if (data.connectionId != connectionId)
            {
                return;
            }

            foreach (var sender in streams.OfType <IStreamSender>())
            {
                AddSender(connectionId, sender);
            }
            foreach (var channel in streams.OfType <IDataChannel>().Where(c => c.IsLocal))
            {
                AddChannel(connectionId, channel);
            }
        }
Exemplo n.º 14
0
        public void OnOffer(SignalingEventData data)
        {
            if (connectionIds.Contains(data.connectionId))
            {
                Debug.Log($"Already answered this connectionId : {data.connectionId}");
                return;
            }
            connectionIds.Add(data.connectionId);

            foreach (var source in streams.OfType <IStreamSender>())
            {
                AddSender(data.connectionId, source);
            }
            foreach (var channel in streams.OfType <IDataChannel>().Where(c => c.IsLocal))
            {
                AddChannel(data.connectionId, channel);
            }
            SendAnswer(data.connectionId);
        }
Exemplo n.º 15
0
 public void OnDeletedConnection(SignalingEventData data)
 {
     if (data.connectionId != connectionId)
     {
         return;
     }
     foreach (var source in streams.OfType <IStreamSource>())
     {
         source.SetSender(connectionId, null);
     }
     foreach (var receiver in streams.OfType <IStreamReceiver>())
     {
         receiver.SetReceiver(connectionId, null);
     }
     foreach (var channel in streams.OfType <IDataChannel>())
     {
         channel.SetChannel(connectionId, null);
     }
     connectionId = null;
 }
Exemplo n.º 16
0
        public void OnOffer(SignalingEventData data)
        {
            if (connectionIds.Contains(data.connectionId))
            {
                Debug.Log($"Already answered this connectionId : {data.connectionId}");
                return;
            }
            connectionIds.Add(data.connectionId);

            foreach (var source in streams.OfType <IStreamSource>())
            {
                var transceiver = AddTrack(data.connectionId, source.Track);
                source.SetSender(data.connectionId, transceiver.Sender);
            }
            foreach (var channel in streams.OfType <IDataChannel>().Where(c => c.IsLocal))
            {
                var _channel = CreateChannel(data.connectionId, channel.Label);
                channel.SetChannel(data.connectionId, _channel);
            }
            SendAnswer(data.connectionId);
        }
Exemplo n.º 17
0
        public void OnCreatedConnection(SignalingEventData data)
        {
            if (data.connectionId != connectionId)
            {
                return;
            }

            foreach (var source in streams.OfType <IStreamSource>())
            {
                var transceiver = AddTransceiver(connectionId, source.Track, RTCRtpTransceiverDirection.SendOnly);
                source.SetSender(connectionId, transceiver.Sender);
            }
            foreach (var receiver in streams.OfType <IStreamReceiver>())
            {
                AddTransceiver(data.connectionId, receiver.Kind, RTCRtpTransceiverDirection.RecvOnly);
            }
            foreach (var channel in streams.OfType <IDataChannel>().Where(c => c.IsLocal))
            {
                var _channel = CreateChannel(connectionId, channel.Label);
                channel.SetChannel(connectionId, _channel);
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="data"></param>
 public virtual void SetChannel(SignalingEventData data)
 {
     SetChannel(data.connectionId, data.channel);
 }
Exemplo n.º 19
0
 public void OnDisconnect(SignalingEventData eventData)
 {
     Disconnect(eventData.connectionId);
 }