Ejemplo n.º 1
0
 public void PauseRecording(LinphoneCall linphoneCall)
 {
     if (linphoneCall.IsExist() && LinphoneCore.IsNonZero() && !string.IsNullOrWhiteSpace(linphoneCall.RecordFile))
     {
         GenericModules.linphone_call_stop_recording(linphoneCall.LinphoneCallPtr);
     }
 }
Ejemplo n.º 2
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);
                }
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
                }
            }
        }
Ejemplo n.º 5
0
        public void CreatePhone(LinphoneConnectionParams connectionParams)
        {
            IsRunning = true;

            registration_state_changed = new LinphoneDelegates.LinphoneCoreRegistrationStateChangedCb(OnRegistrationChanged);
            call_state_changed         = new LinphoneDelegates.LinphoneCoreCallStateChangedCb(OnCallStateChanged);
            message_received           = new LinphoneDelegates.LinphoneCoreCbsMessageReceivedCb(OnMessageReceived);

            VTable    = CreateDefaultLinphoneCoreVTable();
            VTablePtr = VTable.ToIntPtr();

            LinphoneCore = CoreModule.linphone_core_new(VTablePtr, null, null, IntPtr.Zero);

            coreLoop = new Thread(LinphoneMainLoopHandler);
            coreLoop.IsBackground = false;
            coreLoop.Start();

            TransportConfig    = CreateTransportConfig();
            TransportConfigPtr = TransportConfig.ToIntPtr();
            NetworkModule.linphone_core_set_sip_transports(LinphoneCore, TransportConfigPtr);

            GenericModules.linphone_core_set_user_agent(LinphoneCore, connectionParams.Agent, connectionParams.Version);

            Identity = string.IsNullOrEmpty(connectionParams.AccountAlias)
                ? $"sip:{connectionParams.Username}@{connectionParams.Host}"
                : $"\"{connectionParams.AccountAlias}\" sip:{connectionParams.Username}@{connectionParams.Host}";

            ServerHost = $"sip:{connectionParams.Host}:{connectionParams.Port}";

            AuthInfo = GenericModules.linphone_auth_info_new(connectionParams.Username, null, connectionParams.Password, null, null, null);
            GenericModules.linphone_core_add_auth_info(LinphoneCore, AuthInfo);

            NatPolicy = CreateNatPolicy(connectionParams.NatPolicy);

            ProxyCfg = CreateProxyCfg();

            CallParamsBuilder = new CallParamsBuilder(LinphoneCore);
        }