public void RedirectCall(LinphoneCall linphoneCall, string redirect_uri) { if (linphoneCall.IsExist() && LinphoneCore.IsNonZero()) { CallModule.linphone_call_redirect(LinphoneCore, linphoneCall.LinphoneCallPtr, redirect_uri); } }
public void HoldCall(LinphoneCall linphoneCall) { if (linphoneCall.IsExist() && LinphoneCore.IsNonZero()) { CallModule.linphone_core_pause_call(LinphoneCore, linphoneCall.LinphoneCallPtr); } }
public void ResumeCall(LinphoneCall linphoneCall) { if (linphoneCall.IsExist() && LinphoneCore.IsNonZero()) { CallModule.linphone_core_resume_call(LinphoneCore, linphoneCall.LinphoneCallPtr); } }
public void TerminateCall(LinphoneCall linphoneCall) { if (linphoneCall.IsExist() && LinphoneCore.IsNonZero()) { CallModule.linphone_core_terminate_call(LinphoneCore, linphoneCall.LinphoneCallPtr); } }
public void SendDTMFs(LinphoneCall linphoneCall, string dtmfs) { if (linphoneCall.IsExist() && LinphoneCore.IsNonZero() && !string.IsNullOrWhiteSpace(dtmfs)) { CallModule.linphone_call_send_dtmfs(linphoneCall.LinphoneCallPtr, dtmfs); } }
public void MakeCallAndRecord(string uri, string filename, bool startRecordInstantly) { if (LinphoneCore.IsNonZero()) { var callParams = CreateCallParameters(); if (!string.IsNullOrWhiteSpace(filename)) { CallModule.linphone_call_params_set_record_file(callParams, filename); } IntPtr call = CallModule.linphone_core_invite_with_params(LinphoneCore, uri, callParams); if (call.IsZero()) { #if (DEBUG) ErrorEvent?.Invoke(null, "Can't call!"); #endif return; } CallModule.linphone_call_ref(call); if (startRecordInstantly) { GenericModules.linphone_call_start_recording(call); } } }
private CallState GetNewCallState(IntPtr call, LinphoneCallState callState, ref CallType newCallType, ref string from, ref string to, bool recordEnable) { CallState newCallState; switch (callState) { case LinphoneCallState.LinphoneCallIncomingReceived: case LinphoneCallState.LinphoneCallIncomingEarlyMedia: newCallState = CallState.Loading; newCallType = CallType.Incoming; MarshalingExtensions.TryConvert(CallModule.linphone_call_get_remote_address_as_string(call), out from); to = Identity; break; case LinphoneCallState.LinphoneCallConnected: case LinphoneCallState.LinphoneCallResuming: case LinphoneCallState.LinphoneCallStreamsRunning: case LinphoneCallState.LinphoneCallPausedByRemote: case LinphoneCallState.LinphoneCallUpdatedByRemote: newCallState = CallState.Active; break; case LinphoneCallState.LinphoneCallPaused: case LinphoneCallState.LinphoneCallPausing: newCallState = CallState.Hold; break; case LinphoneCallState.LinphoneCallOutgoingInit: case LinphoneCallState.LinphoneCallOutgoingProgress: case LinphoneCallState.LinphoneCallOutgoingRinging: case LinphoneCallState.LinphoneCallOutgoingEarlyMedia: newCallState = CallState.Loading; newCallType = CallType.Outcoming; from = Identity; MarshalingExtensions.TryConvert(CallModule.linphone_call_get_remote_address_as_string(call), out to); break; case LinphoneCallState.LinphoneCallError: newCallState = CallState.Error; break; case LinphoneCallState.LinphoneCallReleased: case LinphoneCallState.LinphoneCallEnd: newCallState = CallState.Completed; if (recordEnable) { GenericModules.linphone_call_stop_recording(call); } break; default: throw new NotImplementedException("Sorry, that feature not implemented!"); break; } return(newCallState); }
public override CallParamsBuilder BuildAudioParams(bool enableAudio = true) { callParams = CallModule.linphone_core_create_call_params(linphoneCore, IntPtr.Zero); callParams = CallModule.linphone_call_params_ref(callParams); CallModule.linphone_call_params_enable_audio(callParams, enableAudio); return(this); }
public void ReceiveCall(LinphoneCall linphoneCall) { if (linphoneCall.IsExist() && LinphoneCore.IsNonZero()) { CallModule.linphone_call_ref(linphoneCall.LinphoneCallPtr); IntPtr callParams = CreateCallParameters(); CallModule.linphone_core_accept_call_with_params(LinphoneCore, linphoneCall.LinphoneCallPtr, callParams); } }
public void OnMessageReceived(IntPtr lc, IntPtr room, IntPtr message) { var peer_address = ChatModule.linphone_chat_room_get_peer_address(room); if (peer_address.IsNonZero()) { var addressStringPtr = CallModule.linphone_address_as_string(peer_address); var chatMessagePtr = ChatModule.linphone_chat_message_get_text(message); string addressString, chatMessage; if (MarshalingExtensions.TryConvert(addressStringPtr, out addressString) && MarshalingExtensions.TryConvert(chatMessagePtr, out chatMessage)) { MessageReceivedEvent?.Invoke(addressString, chatMessage); } } }
public void ReceiveCallAndRecord(LinphoneCall linphoneCall, string filename, bool startRecordInstantly = true) { if (linphoneCall.IsExist() && LinphoneCore.IsNonZero()) { CallModule.linphone_call_ref(linphoneCall.LinphoneCallPtr); IntPtr callParams = CreateCallParameters(); CallModule.linphone_call_params_set_record_file(callParams, filename); CallModule.linphone_core_accept_call_with_params(LinphoneCore, linphoneCall.LinphoneCallPtr, callParams); if (startRecordInstantly) { GenericModules.linphone_call_start_recording(linphoneCall.LinphoneCallPtr); } } }
public void OnCallStateChanged(IntPtr lc, IntPtr call, LinphoneCallState callState, string message) { if (LinphoneCore.IsNonZero() && IsRunning) { var newCallState = CallState.None; var newCallType = CallType.None; string from, to, recordFile; from = to = recordFile = null; IntPtr callParams = CallModule.linphone_call_get_params(call); bool recordEnable = MarshalingExtensions.TryConvert(CallModule.linphone_call_params_get_record_file(callParams), out recordFile); newCallState = GetNewCallState(call, callState, ref newCallType, ref from, ref to, recordEnable); UpdateCallReferences(call, newCallState, newCallType, callState, from, to, recordFile); } }
private void UpdateCallReferences(IntPtr call, CallState newCallState, CallType newCallType, LinphoneCallState callState, string from, string to, string recordFile) { IntPtr callref = CallModule.linphone_call_ref(call); LinphoneCall existCall = null; if (callref.IsNonZero()) { if (Calls.TryGetValue(callref, out existCall)) { if (existCall.State != newCallState) { existCall.State = newCallState; CallStateChangedEvent?.Invoke(existCall); } } else { existCall = new LinphoneCall() { State = newCallState, Type = newCallType, From = from, To = to, RecordFile = recordFile, LinphoneCallPtr = callref }; Calls.TryAdd(callref, existCall); CallStateChangedEvent?.Invoke(existCall); } } if (callState == LinphoneCallState.LinphoneCallReleased) { CallModule.linphone_call_unref(existCall.LinphoneCallPtr); Calls.TryRemove(callref, out existCall); return; } }
public void DestroyPhone() { if (LinphoneCore != null) { RegistrationStateChangedEvent?.Invoke(LinphoneRegistrationState.LinphoneRegistrationProgress); CallModule.linphone_core_terminate_all_calls(LinphoneCore); var proxySetDownTask = ComponentExtensions.ExecuteWithDelay(() => { if (ProxieModule.linphone_proxy_config_is_registered(ProxyCfg)) { ProxieModule.linphone_proxy_config_edit(ProxyCfg); ProxieModule.linphone_proxy_config_enable_register(ProxyCfg, false); ProxieModule.linphone_proxy_config_done(ProxyCfg); } }, Constants.LC_CORE_PROXY_DISABLE_TIMEOUT); proxySetDownTask.Wait(Constants.LC_CORE_PROXY_DISABLE_TIMEOUT); IsRunning = ProxieModule.linphone_proxy_config_is_registered(ProxyCfg); } }
public override CallParamsBuilder BuildVideoParams(bool enableVideo = false) { CallModule.linphone_call_params_enable_video(callParams, enableVideo); return(this); }
public override CallParamsBuilder BuildMediaParams(bool enablEarlyMediaSending = true) { CallModule.linphone_call_params_enable_early_media_sending(callParams, enablEarlyMediaSending); return(this); }