public int playTone(ETones toneId) { lock (_lockObj) { if (_isPlaying) { //Task.Factory.StartNew(() => stopTone(), TaskCreationOptions.PreferFairness); _isPlaying = false; CommonDelegates.SafeInvoke(() => dll_releaseWav(_playerId)); } if (_sessionId >= 0) { _playerId = CommonDelegates.SafeInvoke(() => dll_playWav(GetToneFile(toneId), true, _sessionId)); if (_playerId >= 0) { _isPlaying = true; } } return(_playerId); } }
/// <summary> /// Unregister all accounts /// </summary> /// <returns></returns> public override int unregisterAccounts() { CommonDelegates.SafeInvoke(() => dll_removeAccounts()); Instance.BaseAccountStateChanged(-1); return(1); }
/// <summary> /// Shutdown pjsip stack /// </summary> /// <returns></returns> public override int shutdown() { if (!IsInitialized) { return(-1); } return(CommonDelegates.SafeInvoke(() => dll_shutdown())); }
/// <summary> /// Get number of all codecs /// </summary> /// <returns></returns> public override int getNoOfCodecs() { if (!IsInitialized) { return(0); } return(CommonDelegates.SafeInvoke(() => dll_getNumOfCodecs())); }
/// <summary> /// Set codec priority /// </summary> /// <param name="codecname"></param> /// <param name="priority"></param> public override void setCodecPriority(string codecname, int priority) { if (!IsInitialized) { return; } CommonDelegates.SafeInvoke(() => dll_setCodecPriority(codecname, priority)); }
///////////////////////////////////////////////////////////////////////////////// /// <summary> /// Register all configured accounts /// </summary> /// <returns></returns> public override int registerAccounts() { if (!pjsipStackProxy.Instance.IsInitialized) { return(-1); } unregisterAccounts(); // iterate all accounts IAccount acc = Config.Account; // check if accounts available if (null == acc) { return(-1); } // reset account Index field Config.Account.Index = -1; // reset account state Config.Account.RegState = -1; if (acc.Enabled && acc.HostName.Length > 0) { string displayName = acc.DisplayName; // warning:::Publish do not work if display name in uri !!! string uri = "sip:" + acc.UserName; if (acc.UserName.IndexOf("@") < 0) { uri += "@" + acc.HostName; } string reguri = "sip:" + acc.HostName; // check transport - if TCP add transport=TCP reguri = pjsipStackProxy.Instance.SetTransport(reguri); string domain = acc.DomainName; string username = acc.UserName; string password = acc.Password; string proxy = ""; if (acc.ProxyAddress.Length > 0) { proxy = "sip:" + acc.ProxyAddress; } // Indicate connecting state BaseAccountStateChanged(0); // store account Id to Index field Config.Account.Index = CommonDelegates.SafeInvoke(() => dll_registerAccount(uri, reguri, domain, username, password, proxy, true)); } return(1); }
/// <summary> /// Get codec by index /// </summary> /// <param name="index"></param> /// <returns></returns> public override string getCodec(int index) { if (!IsInitialized) { return(""); } StringBuilder codec = new StringBuilder(256); CommonDelegates.SafeInvoke(() => dll_getCodec(index, codec)); return(codec.ToString()); }
internal void HandleDevicesRemoved(IEnumerable <AudioDevicesWatcher.AudioDeviceDescriptor> deviceDescriptors) { var devices = ConvertDeviceDescriptors(deviceDescriptors); // Call sync CommonDelegates.SafeInvoke <int>(() => { ReloadAudioDevices(); return(0); }); if (devices != null && AudioDevicesRemoved != null) { AudioDevicesRemoved(devices); } }
public int stopTone() { lock (_lockObj) { if (!_isPlaying) { return(0); } _isPlaying = false; CommonDelegates.SafeInvoke(() => dll_releaseWav(_playerId)); } return(0); }
/// <summary> /// Set presence status /// </summary> /// <param name="status"></param> /// <returns></returns> public override int setStatus(EUserStatus status) { if (!pjsipStackProxy.Instance.IsInitialized) { return(-1); } if (Config.Account.RegState != 200) { return(-1); } if (!Config.PublishEnabled) { return(-1); } return(CommonDelegates.SafeInvoke(() => dll_setStatus(Config.Account.Index, (int)status))); }
/// <summary> /// /// </summary> /// <returns></returns> private int start() { // prepare configuration struct // read data from Config interface. If null read all values directly from SipConfigMore if (!Config.IsNull) { ConfigMore.listenPort = Config.SIPPort; ConfigMore.rtpPort = Config.RTPPort; } CommonDelegates.SafeInvoke(() => dll_setSipConfig(ConfigMore)); int status = CommonDelegates.SafeInvoke(() => { return(dll_init()); }); if (status != 0) { return(status); } status = CommonDelegates.SafeInvoke(() => dll_main()); return(status); }
/// <summary> /// Add new entry in a buddy list and subscribe presence /// </summary> /// <param name="name">Buddy address (without hostname part</param> /// <param name="presence">subscribe presence flag</param> /// <returns></returns> public override int addBuddy(string name, bool presence) { string sipuri; if (!pjsipStackProxy.Instance.IsInitialized) { return(-1); } // check if name contains URI if (name != null && name.IndexOf("sip:", StringComparison.Ordinal) == 0) { // do nothing... sipuri = name; } else { sipuri = "sip:" + name + "@" + Config.Account.HostName; } // check transport - if TCP add transport=TCP sipuri = pjsipStackProxy.Instance.SetTransport(sipuri); return(CommonDelegates.SafeInvoke(() => dll_addBuddy(sipuri, presence))); }
/// <summary> /// Send an instance message /// </summary> /// <param name="destAddress"></param> /// <param name="message"></param> /// <returns></returns> public override int sendMessage(string destAddress, string message) { if (!pjsipStackProxy.Instance.IsInitialized) { return(-1); } string sipuri = ""; // check if name contains URI if (destAddress != null && destAddress.IndexOf("sip:", StringComparison.Ordinal) == 0) { // do nothing... sipuri = destAddress; } else { sipuri = "sip:" + destAddress + "@" + Config.Account.HostName; } // set transport sipuri = pjsipStackProxy.Instance.SetTransport(sipuri); return(CommonDelegates.SafeInvoke(() => dll_sendMessage(Config.Account.Index, sipuri, message))); }
/// <summary> /// /// </summary> /// <param name="buddyId"></param> /// <returns></returns> public override int delBuddy(int buddyId) { return(CommonDelegates.SafeInvoke(() => dll_removeBuddy(buddyId))); }
public override void renewAccount(int accountIndex) { CommonDelegates.SafeInvoke(() => dll_renewAccount(accountIndex)); Instance.BaseAccountStateChanged(accountIndex); }
private T SafeInvoke <T>(Func <T> func) { return(CommonDelegates.SafeInvoke(func)); }
private void SafeInvoke(Action action) { CommonDelegates.SafeInvoke(action); }
private T SafeInvoke <T>(Delegate del) { return(CommonDelegates.SafeInvoke <T>(del)); }
/// <summary> /// Set sound device for playback and recording /// </summary> /// <param name="deviceId"></param> public void setSoundDevice(string playbackDeviceId, string recordingDeviceId) { CommonDelegates.SafeInvoke(() => dll_setSoundDevice(playbackDeviceId, recordingDeviceId)); }