Example #1
0
bool
Opal::Sip::EndPoint::set_listen_port (unsigned port)
{
  unsigned udp_min, udp_max;

  listen_iface.protocol = "udp";
  listen_iface.voip_protocol = "sip";
  listen_iface.id = "*";

  manager.get_udp_ports (udp_min, udp_max);

  if (port > 0) {

    std::stringstream str;
    RemoveListener (NULL);

    str << "udp$*:" << port;
    if (!StartListeners (PStringArray (str.str ()))) {

      port = udp_min;
      str << "udp$*:" << port;
      while (port <= udp_max) {

        if (StartListeners (PStringArray (str.str ()))) {

          listen_iface.port = port;
	  PTRACE (4, "Opal::Sip::EndPoint\tSet listen port to " << port);
          return true;
        }

        port++;
      }
    }
    else {
      listen_iface.port = port;
      PTRACE (4, "Opal::Sip::EndPoint\tSet listen port to " << port);
      return true;
    }
  }

  return false;
}
Example #2
0
bool
Opal::Sip::EndPoint::StartListener (unsigned port)
{
  unsigned udp_min = GetManager ().GetUDPPortBase ();
  unsigned udp_max = GetManager ().GetUDPPortMax ();
  unsigned tcp_min = GetManager ().GetTCPPortBase ();
  unsigned tcp_max = GetManager ().GetTCPPortMax ();

  const std::string protocols[] = { "udp", "tcp", "" };
  const unsigned ports[][2] = { { udp_min, udp_max }, { tcp_min, tcp_max } };

  if (port > 0) {

    RemoveListener (NULL);
    for (int i = 0 ; !protocols[i].empty () ; i++) {

      std::stringstream str;
      str << protocols[i] << "$*:" << port;
      if (!StartListeners (PStringArray (str.str ()))) {

        port = ports[i][0];
        while (port <= ports[i][1]) {
          str << protocols[i] << "$*:" << port;
          if (StartListeners (PStringArray (str.str ()))) {
            PTRACE (4, "Opal::Sip::EndPoint\tSet listen port to " << port << " (" << protocols[i] << ")");
            break;
          }

          port++;
        }
      }
      else
        PTRACE (4, "Opal::Sip::EndPoint\tSet listen port to " << port << " (" << protocols[i] << ")");
    }
  }

  return false;
}
Example #3
0
BOOL CMyPhoneEndPoint::Initialise(CMyPhoneDlg *dlg, CVideoDlg *vdlg)
{
	m_dialog = dlg;
        m_vdlg = vdlg;
	isIncomingCall = FALSE;

	SetAudioJitterDelay(50, config.GetInteger(JitterConfigKey, GetMaxAudioJitterDelay()));
	SetSoundChannelBufferDepth(config.GetInteger(BufferCountConfigKey, GetSoundChannelBufferDepth()));
	
	// UserInput mode
    // Backward compatibility configuration entry
    unsigned mode = H323Connection::SendUserInputAsString;
	m_fDtmfAsString=true;
    if (config.HasKey(DtmfAsStringConfigKey)) {
		if (!config.GetBoolean(DtmfAsStringConfigKey))
		{
			mode = H323Connection::SendUserInputAsTone;
			m_fDtmfAsString=false;
		}
		config.DeleteKey(DtmfAsStringConfigKey);
	}
	mode = config.GetInteger(UserInputModeConfigKey, mode);
	SetSendUserInputMode((H323Connection::SendUserInputModes)mode);

//        SetSoundChannelPlayDriver("WindowsMutimedia");
//        SetSoundChannelRecordDriver("WindowsMultimedia");
//        SetSoundChannelPlayDriver("DirectSound");
//        SetSoundChannelRecordDriver("DirectSound");
	
        PString soundPlayStr = config.GetString(SoundPlayConfigKey, GetSoundChannelPlayDevice());
        PStringArray soundPlayer = soundPlayStr.Tokenise('\t');
        BOOL fPlayerAvailable;
        if(soundPlayer.GetSize()==1)
        {  
         SetSoundChannelPlayDriver("WindowsMutimedia");
	 fPlayerAvailable = SetSoundChannelPlayDevice(soundPlayer[0]);
         PTRACE(1, "MyPhone\tSetSoundPlayer Driver:WindowsMultimedia, Device:" << soundPlayer[0]);
        }
        else
        {
         SetSoundChannelPlayDriver(soundPlayer[0]);
	 fPlayerAvailable = SetSoundChannelPlayDevice(soundPlayer[1]);
         PTRACE(1, "MyPhone\tSetSoundPlayer Driver:" << soundPlayer[0] << ", Device:" << soundPlayer[1]);
	}

        PString soundRecordStr = config.GetString(SoundRecordConfigKey, GetSoundChannelRecordDevice());
        PStringArray soundRecorder = soundRecordStr.Tokenise('\t');
        BOOL fRecorderAvailable;
        if(soundRecorder.GetSize()==1)
        {  
         SetSoundChannelRecordDriver("WindowsMutimedia");
	 fRecorderAvailable = SetSoundChannelRecordDevice(soundRecorder[0]);
         PTRACE(1, "MyPhone\tSetSoundRecorder Driver:WindowsMultimedia, Device:" << soundRecorder[0]);
        }
        else
        {
         SetSoundChannelRecordDriver(soundRecorder[0]);
	 fRecorderAvailable = SetSoundChannelRecordDevice(soundRecorder[1]);
         PTRACE(1, "MyPhone\tSetSoundRecorder Driver:" << soundRecorder[0] << ", Device:" << soundRecorder[1]);
	}

	m_fAECOn = config.GetBoolean(AECEnableConfigKey, FALSE);
	m_fAGCOn = config.GetInteger(AGCEnableConfigKey, FALSE);
	SetAECAlgo(m_fAECOn);
	agc = m_fAGCOn;
	             
	// set some oter settings from Config
	m_fNoFastStart =  config.GetBoolean(NoFastStartConfigKey, FALSE);
    DisableFastStart(m_fNoFastStart);
	m_fStrictSingleLine =  config.GetBoolean(StrictSingleLineConfigKey, FALSE);
    StrictSingleLine(m_fStrictSingleLine);

	m_fDoH245Tunnelling = !(config.GetBoolean(NoTunnelingConfigKey, FALSE));
    DisableH245Tunneling(!m_fDoH245Tunnelling);
	m_fSilenceOn = config.GetBoolean(SilenceDetectConfigKey, TRUE);
    SetSilenceDetectionMode(m_fSilenceOn
		? H323AudioCodec::AdaptiveSilenceDetection
		: H323AudioCodec::NoSilenceDetection);
    SetLocalUserName(config.GetString(UsernameConfigKey, GetLocalUserName()));
    SetInitialBandwidth((unsigned)(config.GetReal(BandwidthConfigKey, 10000)*20));
    SetRtpIpTypeofService(config.GetInteger(IpTosConfigKey, GetRtpIpTypeofService()));
	
	SetRtpIpPorts(config.GetInteger(RTPPortBaseConfigKey, GetRtpIpPortBase()),
		config.GetInteger(RTPPortMaxConfigKey,  GetRtpIpPortBase()));
	if(config.HasKey(RouterConfigKey))
		m_router = config.GetString(RouterConfigKey, m_router.AsString());
	
	m_fAutoAnswer = config.GetBoolean(AutoAnswerConfigKey, false);
	m_fAutoMute = config.GetBoolean(AutoMuteConfigKey, false);
	
    CString alias, aliases;
	aliases = CString((const char *)config.GetString(AliasConfigKey, _T("")));
	aliases.TrimLeft();
	int iPos=0;
    while ((iPos = aliases.Find(_T("|")))>0)  // loading user aliases
	{
		alias = aliases.Left(iPos);
		aliases.Delete(0,iPos+1);
		AddAliasName((LPCTSTR)alias);
	}
	
	// The order in which capabilities are added to the capability table
	// determines which one is selected by default.
	LoadCapabilities();
	
	PString interfaces = config.GetString(ListenerInterfaceConfigKey, "*");
	if(StartListeners(interfaces.Tokenise(',')))
	{
		m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_MPREADY1STR), S_SYSTEM, (const char *)strProgName);
		return true;
	}
	else
	{
		m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_ERRLSNSTR), S_SYSTEM, (const char *)strProgName, (const char *)interfaces);
		return false;
	}
}