void HandleSdp(string message)
        {
            var msg = JsonConvert.DeserializeObject <dynamic>(message);

            if (msg.sdp != null)
            {
                var sdp = msg.sdp;
                if (sdp.type != null && sdp.type != "answer")
                {
                    throw new Exception("Not an answer");
                }
                string sdpAns = sdp.sdp;
                Console.WriteLine($"received answer:\n{sdpAns}");
                var res = SDPMessage.New(out SDPMessage sdpMsg);
                SDPMessage.ParseBuffer(ASCIIEncoding.Default.GetBytes(sdpAns), (uint)sdpAns.Length, sdpMsg);
                var answer  = WebRTCSessionDescription.New(WebRTCSDPType.Answer, sdpMsg);
                var promise = new Promise();
                _webRtc.Emit("set-remote-description", answer, promise);
            }
            else if (msg.ice != null)
            {
                var    ice           = msg.ice;
                string candidate     = ice.candidate;
                uint   sdpMLineIndex = ice.sdpMLineIndex;
                _webRtc.Emit("add-ice-candidate", sdpMLineIndex, candidate);
            }
        }
Пример #2
0
        void LinkRemoteOfferAnswer(LinkOfferAnswerArgs e)
        {
            var sdp = SDPMessage.Parse(e.OfferAnswer.SdpMessage);

            foreach (var md in sdp.MediaDescriptions)
            {
                if (md.Media.MediaType == SDPMediaType.Video)
                {
                    foreach (var ma in md.MediaAttributes)
                    {
                        if (ma is SDPReceiveOnlyAttribute || ma is SDPInactiveAttribute)
                        {
                            IS_CALL_VIDEO = true;
                            // Remote participant is NOT sending video.
                            // ReceiveOnly: not sending video, but willing to receive video
                            // Inactive: not sending video, and doesn't want to receive video either
                        }
                        else if (ma is SDPSendOnlyAttribute || ma is SDPSendReceiveAttribute)
                        {
                            //is call audio
                            IS_CALL_VIDEO = true;
                            // Remote participant IS sending video.
                            // SendOnly: sending video, but doesn't want to receive video
                            // SendReceive: sending video, and willing to receive video
                        }
                    }
                }
            }
        }
        public JsonResult PostSDP(string sdp, string roomToken, string userToken)
        {
            if (sdp.IsEmpty() || roomToken.IsEmpty() || userToken.IsEmpty())
            {
                return(Json(false));
            }

            var sdpMessage = new SDPMessage
            {
                SDP         = sdp,
                IsProcessed = false,
                RoomToken   = roomToken,
                Sender      = userToken
            };

            _db.SDPMessages.InsertOnSubmit(sdpMessage);
            _db.SubmitChanges();

            return(Json(true));
        }
Пример #4
0
        /// <summary>
        /// Handle incoming call
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void Xmpp_OnReceiveSessionInitiate(object sender, Messaging.Jingle.JingleSdpEventArgs e)
        {
            //UpdateListView("<Incoming call");
            Activity actualActivity;

            if (myActivity.Window.DecorView.IsShown)
            {
                actualActivity = myActivity;
            }
            else
            {
                return;
            }

            App.Jid = e.From;
            App.Sdp = e.Sdp;
            var sdp = SDPMessage.Parse(e.Sdp);

            foreach (var md in sdp.MediaDescriptions)
            {
                if (md.Media.MediaType == SDPMediaType.Video)
                {
                    foreach (var ma in md.MediaAttributes)
                    {
                        if (ma is SDPReceiveOnlyAttribute)
                        {
                            Log.Info("ma is SDPReceiveOnlyAttribute ");
                        }
                        if (ma is SDPInactiveAttribute)
                        {
                            Log.Info("ma is SDPInactiveAttribute");
                        }
                        if (ma is SDPSendOnlyAttribute)
                        {
                            Log.Info("ma is SDPSendOnlyAttribute");
                        }
                        if (ma is SDPSendReceiveAttribute)
                        {
                            Log.Info("ma is SDPSendReceiveAttribute");
                        }

                        //if (ma is SDPReceiveOnlyAttribute || ma is SDPInactiveAttribute)
                        //{

                        //	Signalling.IS_CALL_VIDEO = false;
                        //	// Remote participant is NOT sending video.
                        //	// ReceiveOnly: not sending video, but willing to receive video
                        //	// Inactive: not sending video, and doesn't want to receive video either
                        //}
                        //else if (ma is SDPSendOnlyAttribute || ma is SDPSendReceiveAttribute)
                        //{
                        //	//is call audio
                        //	Signalling.IS_CALL_VIDEO = true;
                        //	// Remote participant IS sending video.
                        //	// SendOnly: sending video, but doesn't want to receive video
                        //	// SendReceive: sending video, and willing to receive video
                        //}
                    }
                }
            }

            // Prompt to answer call
            //this.RunOnUiThread(() =>
            //{
            new AlertDialog.Builder(actualActivity)
            .SetPositiveButton("Yes", (s, args) =>
            {
                Intent intent = null;
                if (Signalling.IS_CALL_VIDEO)
                {
                    //intent = new Intent(ApplicationContext, typeof(VideoActivity));
                }
                else
                {
                    //intent = new Intent(ApplicationContext, typeof(VoiceCallActivity));
                }

                intent.PutExtra("callType", "incoming");
                intent.PutExtra("userChat", App.Jid);
                //StartActivity(intent);
            })
            .SetNegativeButton("No", (s, args) =>
            {
                App.Instance.Xmpp.SendSessionTerminate(e.From);
            })
            .SetTitle("Incoming Call")
            .SetMessage("Would you like to answer?")
            .Show();
            //});
        }
Пример #5
0
        /// <summary>
        /// Handle incoming call
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void Xmpp_OnReceiveSessionInitiate(object sender, Messaging.Jingle.JingleSdpEventArgs e)
        {
            foreach (string jidWithHash in LIST_USERS_ONLINE)
            {
                if (jidWithHash.Contains(e.From))
                {
                    e.From = jidWithHash;
                }
            }

            this.App.Jid = e.From;
            this.App.Sdp = e.Sdp;
            var sdp = SDPMessage.Parse(e.Sdp);

            /*
             *              foreach (var md in sdp.MediaDescriptions)
             *              {
             *                      if (md.Media.MediaType == SDPMediaType.Video)
             *                      {
             *                              foreach (var ma in md.MediaAttributes)
             *                              {
             *
             *                                      if (ma is SDPReceiveOnlyAttribute)
             *                                      {
             *                                              Log.Info("ma is SDPReceiveOnlyAttribute ");
             *                                      }
             *                                      if (ma is SDPInactiveAttribute)
             *                                      {
             *                                              Log.Info("ma is SDPInactiveAttribute");
             *                                      }
             *                                      if (ma is SDPSendOnlyAttribute)
             *                                      {
             *                                              Log.Info("ma is SDPSendOnlyAttribute");
             *                                      }
             *                                      if (ma is SDPSendReceiveAttribute)
             *                                      {
             *                                              Log.Info("ma is SDPSendReceiveAttribute");
             *                                      }
             *
             *                                      //if (ma is SDPReceiveOnlyAttribute || ma is SDPInactiveAttribute)
             *                                      //{
             *
             *                                      //	Signalling.IS_CALL_VIDEO = false;
             *                                      //	// Remote participant is NOT sending video.
             *                                      //	// ReceiveOnly: not sending video, but willing to receive video
             *                                      //	// Inactive: not sending video, and doesn't want to receive video either
             *                                      //}
             *                                      //else if (ma is SDPSendOnlyAttribute || ma is SDPSendReceiveAttribute)
             *                                      //{
             *                                      //	//is call audio
             *                                      //	Signalling.IS_CALL_VIDEO = true;
             *                                      //	// Remote participant IS sending video.
             *                                      //	// SendOnly: sending video, but doesn't want to receive video
             *                                      //	// SendReceive: sending video, and willing to receive video
             *                                      //}
             *                              }
             *                      }
             *              } */

            if (context != null)
            {
                BaseAppCompatActivity o = (BaseAppCompatActivity)context;
                o.Xmpp_OnReceiveSessionInitiate(sender, e);
            }
        }