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 } } } } }
/// <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(); //}); }
/// <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); } }