const ktJssip = require('./ktJssip');
const microSip = require('./microsip');
let sipTool = 'jssip'; //MicroSIP
function register(options, log) {
  if (process.platform === 'win32') {
    sipTool = options.sipTool || 'jssip';
  }
  if (sipTool === 'jssip') {
    return ktJssip.register(options, log);
  }
  return microSip.register({ ...options, KtLog: log });
}
function setRejectMessage(options) {
  if (sipTool === 'jssip') {
    return ktJssip.setRejectMessage(options);
  }
}
function sipCall(sipcustom, callState) {
  if (sipTool === 'jssip') {
    return ktJssip.sipCall(sipcustom, callState);
  }
  return microSip.sipCall(sipcustom);
}
function disconnectSip() {
  if (sipTool === 'jssip') {
    return ktJssip.disconnectSip();
  }
  return microSip.disconnectSip();
}
function sipAnswerCall() {
  if (sipTool === 'jssip') {
    return ktJssip.sipAnswerCall();
  }
}
function createAudioStream(mediaElement, volume = 1, tts) {
  if (sipTool === 'jssip') {
    return ktJssip.createAudioStream(mediaElement, volume, tts);
  }
}
function sipIsCallingState() {
  if (sipTool === 'jssip') {
    return ktJssip.sipIsCallingState();
  }
  return microSip.sipIsCallingState();
}
function setSipLogConfig(configParam) {
  if (sipTool === 'jssip') {
    return ktJssip.setSipLogConfig(configParam);
  }
}
module.exports = {
  setRejectMessage,
  register,
  sipCall,
  disconnectSip,
  sipAnswerCall,
  createAudioStream,
  sipIsCallingState,
  setSipLogConfig,
};
