/// <summary> /// Notify application on incoming call. /// </summary> ///<param name="sender">The current sender.</param> /// <param name="e">The event parameter.</param> private void _voipManager_OnIncomingCall(object sender, OnIncomingCallParam e) { // Is valid call. if (e.CallId >= 0) { // Create a new call. Call call = _voipManager.CreateCall(e.CallId); Param.CallParam callInfo = new Param.CallParam(call, _voipManager.MediaManager, _recordFilename); // Create the call settings. CallSetting setting = new CallSetting(true); CallOpParam parm = new CallOpParam(true); setting.AudioCount = 1; parm.Setting = setting; // Continue ringing. parm.Code = StatusCode.SC_RINGING; call.Answer(parm); // Send a notification to the call. Param.OnIncomingCallParam param = new Param.OnIncomingCallParam(); param.CallID = e.CallId; param.Info = e.RxData.Info; param.SrcAddress = e.RxData.SrcAddress; param.WholeMsg = e.RxData.WholeMsg; param.Call = callInfo; param.Contact = FindContact(param); // Call the event handler. OnIncomingCall?.Invoke(this, param); } }
/// <summary> /// Make outgoing call to the specified URI. /// </summary> /// <param name="callId">An index call id (0 - 3).</param> /// <param name="uri">URI to be put in the To header (normally is the same as the target URI).</param> /// <param name="recordFilename">The path and filename where the conversation is to be recorded to. Currently ".wav" is supported on all platforms.</param> /// <returns>The call information.</returns> public Param.CallParam MakeCall(int callId, string uri, string recordFilename = null) { // If created. if (_created) { // Create a new call. Call call = new Call(_account, callId); // Create the call settings. CallSetting setting = new CallSetting(true); CallOpParam parm = new CallOpParam(true); setting.AudioCount = 1; parm.Setting = setting; // Make the call. call.MakeCall(uri, parm); // return the call information. Param.CallParam callInfo = new Param.CallParam(call, _mediaManager, recordFilename); return(callInfo); } else { throw new Exception("Create the account first."); } }
/// <summary> /// Remove the conference call contact. /// </summary> /// <param name="id">The call to remove.</param> public void RemoveConferenceCallContact(string id) { // Remove the contact. if (_conferenceCall != null) { Param.CallParam caller = null; try { // Find the caller. caller = _conferenceCall.First(u => u.ID == id); bool ret = _conferenceCall.Remove(caller); if (!ret) { caller = null; } } catch { } // If call has been found. if (caller != null) { // Start the conversation between the caller and all other callers. foreach (Param.CallParam call in _conferenceCall) { try { // The current callers. caller.StopConversation(call); } catch { } } } } }
/// <summary> /// Add the conference call contact. /// </summary> /// <param name="caller">The contact to add.</param> public void AddConferenceCallContact(Param.CallParam caller) { if (_conferenceCall == null) { _conferenceCall = new List <Param.CallParam>(); } // Add the contact. if (_conferenceCall != null) { // Start the conversation between the caller and all other callers. foreach (Param.CallParam call in _conferenceCall) { try { // The current callers. caller.StartConversation(call); } catch { } } // Add the contact. _conferenceCall.Add(caller); } }
/// <summary> /// Stop the conversationbetween callers. /// </summary> /// <param name="caller">The caller to stop the conversation with.</param> public void StopConversation(CallParam caller) { // Combine the audio media. List <AudioMedia> local = new List <AudioMedia>(); local.AddRange(_audioMedias); local.AddRange(caller.AudioMedia); // For each call. for (int i = 0; i < local.Count; i++) { // Get first group. AudioMedia mediaCall_1 = local[i]; // For each call. for (int j = 0; j < local.Count; j++) { // Get second group. AudioMedia mediaCall_2 = local[j]; // If the two audio media are not equal. if (mediaCall_1.GetPortId() != mediaCall_2.GetPortId()) { // Stop these two calls from communicating. mediaCall_1.StopTransmit(mediaCall_2); } } } }
/// <summary> /// Send DTMF digits to remote using RFC 2833 payload formats. /// </summary> /// <param name="call">The current call.</param> /// <param name="digits">DTMF string digits to be sent.</param> public void DialDtmf(Param.CallParam call, string digits) { // If created. if (_created) { call.DialDtmf(digits); } else { throw new Exception("Create the account first."); } }
/// <summary> /// Send DTMF digits to remote using RFC 2833 payload formats. /// </summary> /// <param name="call">The current call.</param> /// <param name="digits">DTMF string digits to be sent.</param> public void DialDtmf(Param.CallParam call, string digits) { call.DialDtmf(digits); }