Пример #1
0
 public void RedirectCall(LinphoneCall linphoneCall, string redirect_uri)
 {
     if (linphoneCall.IsExist() && LinphoneCore.IsNonZero())
     {
         CallModule.linphone_call_redirect(LinphoneCore, linphoneCall.LinphoneCallPtr, redirect_uri);
     }
 }
Пример #2
0
 public void HoldCall(LinphoneCall linphoneCall)
 {
     if (linphoneCall.IsExist() && LinphoneCore.IsNonZero())
     {
         CallModule.linphone_core_pause_call(LinphoneCore, linphoneCall.LinphoneCallPtr);
     }
 }
Пример #3
0
 public void ResumeCall(LinphoneCall linphoneCall)
 {
     if (linphoneCall.IsExist() && LinphoneCore.IsNonZero())
     {
         CallModule.linphone_core_resume_call(LinphoneCore, linphoneCall.LinphoneCallPtr);
     }
 }
Пример #4
0
 public void TerminateCall(LinphoneCall linphoneCall)
 {
     if (linphoneCall.IsExist() && LinphoneCore.IsNonZero())
     {
         CallModule.linphone_core_terminate_call(LinphoneCore, linphoneCall.LinphoneCallPtr);
     }
 }
Пример #5
0
 public void SendDTMFs(LinphoneCall linphoneCall, string dtmfs)
 {
     if (linphoneCall.IsExist() && LinphoneCore.IsNonZero() && !string.IsNullOrWhiteSpace(dtmfs))
     {
         CallModule.linphone_call_send_dtmfs(linphoneCall.LinphoneCallPtr, dtmfs);
     }
 }
Пример #6
0
        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);
                }
            }
        }
Пример #7
0
        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);
        }
Пример #8
0
        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);
        }
Пример #9
0
        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);
            }
        }
Пример #10
0
        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);
                }
            }
        }
Пример #11
0
        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);
                }
            }
        }
Пример #12
0
        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);
            }
        }
Пример #13
0
        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;
            }
        }
Пример #14
0
        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);
            }
        }
Пример #15
0
        public override CallParamsBuilder BuildVideoParams(bool enableVideo = false)
        {
            CallModule.linphone_call_params_enable_video(callParams, enableVideo);

            return(this);
        }
Пример #16
0
        public override CallParamsBuilder BuildMediaParams(bool enablEarlyMediaSending = true)
        {
            CallModule.linphone_call_params_enable_early_media_sending(callParams, enablEarlyMediaSending);

            return(this);
        }