Пример #1
0
/* The class */
Opal::Sip::EndPoint::EndPoint (Opal::CallManager & _manager,
                               Ekiga::ServiceCore& core):
  SIPEndPoint (_manager),
  manager (_manager)
{
  boost::shared_ptr<Ekiga::ChatCore> chat_core = core.get<Ekiga::ChatCore> ("chat-core");
  boost::shared_ptr<Ekiga::PresenceCore> presence_core = core.get<Ekiga::PresenceCore> ("presence-core");

  protocol_name = "sip";
  uri_prefix = "sip:";

  dialect = boost::shared_ptr<SIP::Dialect>(new SIP::Dialect (presence_core, boost::bind (&Opal::Sip::EndPoint::send_message, this, _1, _2)));
  chat_core->add_dialect (dialect);

  /* Timeouts */
  SetAckTimeout (PTimeInterval (0, 32));
  SetPduCleanUpTimeout (PTimeInterval (0, 1));
  SetInviteTimeout (PTimeInterval (0, 60));
  SetNonInviteTimeout (PTimeInterval (0, 6));
  SetRetryTimeouts (500, 4000);
  SetMaxRetries (8);

  /* Update the User Agent */
  SetUserAgent ("Ekiga/" PACKAGE_VERSION);

  /* Ready to take calls */
  manager.AddRouteEntry("sip:.* = pc:*");
  manager.AddRouteEntry("pc:.* = sip:<da>");

  /* NAT Binding */
  SetNATBindingRefreshMethod (SIPEndPoint::Options);

  settings = boost::shared_ptr<Ekiga::Settings> (new Ekiga::Settings (SIP_SCHEMA));
  settings->changed.connect (boost::bind (&EndPoint::setup, this, _1));
}
Пример #2
0
void
Opal::Sip::EndPoint::set_nat_binding_delay (unsigned delay)
{
  PTRACE (3, "Ekiga\tNat binding delay set to " << delay);
  if (delay > 0)
    SetNATBindingTimeout (PTimeInterval (0, delay));
}
Пример #3
0
/* The class */
Opal::Sip::EndPoint::EndPoint (Opal::CallManager & _manager, 
                               Ekiga::ServiceCore & _core, 
                               unsigned _listen_port)
:   SIPEndPoint (_manager),
    manager (_manager), 
    core (_core),
    presence_core (*(dynamic_cast<Ekiga::PresenceCore *> (core.get ("presence-core")))),
    runtime (*(dynamic_cast<Ekiga::Runtime *> (core.get ("runtime")))),
    account_core (*(dynamic_cast<Ekiga::AccountCore *> (core.get ("account-core"))))
{
  Ekiga::ChatCore* chat_core;

  protocol_name = "sip";
  uri_prefix = "sip:";
  listen_port = _listen_port;

  chat_core = dynamic_cast<Ekiga::ChatCore *> (core.get ("chat-core"));
  dialect = new SIP::Dialect (core, sigc::mem_fun (this, &Opal::Sip::EndPoint::send_message));
  chat_core->add_dialect (*dialect);

  /* Timeouts */
  SetAckTimeout (PTimeInterval (0, 32));
  SetPduCleanUpTimeout (PTimeInterval (0, 1));
  SetInviteTimeout (PTimeInterval (0, 6));
  SetNonInviteTimeout (PTimeInterval (0, 6));
  SetRetryTimeouts (500, 4000);
  SetMaxRetries (8);

  /* Start listener */
  set_listen_port (listen_port);

  /* Update the User Agent */
  SetUserAgent ("Ekiga/" PACKAGE_VERSION);

  /* Ready to take calls */
  manager.AddRouteEntry("sip:.* = pc:<db>");
  manager.AddRouteEntry("pc:.* = sip:<da>");

  /* NAT Binding */
  SetNATBindingRefreshMethod (SIPEndPoint::EmptyRequest);

  Ekiga::PersonalDetails *details = dynamic_cast<Ekiga::PersonalDetails *> (_core.get ("personal-details"));
  if (details)
    publish (*details);
}
Пример #4
0
/* The class */
Opal::Sip::EndPoint::EndPoint (Opal::CallManager & _manager,
                               Ekiga::ServiceCore& core):
  SIPEndPoint (_manager),
  manager (_manager)
{
  boost::shared_ptr<Ekiga::ChatCore> chat_core = core.get<Ekiga::ChatCore> ("chat-core");

  protocol_name = "sip";
  uri_prefix = "sip:";
  listen_port = gm_conf_get_int (SIP_KEY "listen_port");
  listen_port = (listen_port > 0 ? listen_port : 5060);

  dialect = boost::shared_ptr<SIP::Dialect>(new SIP::Dialect (core, boost::bind (&Opal::Sip::EndPoint::send_message, this, _1, _2)));
  chat_core->add_dialect (dialect);

  /* Timeouts */
  SetAckTimeout (PTimeInterval (0, 32));
  SetPduCleanUpTimeout (PTimeInterval (0, 1));
  SetInviteTimeout (PTimeInterval (0, 60));
  SetNonInviteTimeout (PTimeInterval (0, 6));
  SetRetryTimeouts (500, 4000);
  SetMaxRetries (8);

  /* Start listener */
  set_listen_port (listen_port);

  /* Update the User Agent */
  SetUserAgent ("Ekiga/" PACKAGE_VERSION);

  /* Ready to take calls */
  manager.AddRouteEntry("sip:.* = pc:*");
  manager.AddRouteEntry("pc:.* = sip:<da>");

  /* NAT Binding */
  SetNATBindingRefreshMethod (SIPEndPoint::Options);
}
Пример #5
0
  jboolean Java_org_opalvoip_opal_andsample_AndOPAL_TestAudio(JNIEnv* env, jclass clazz)
  {
    PTRACE(1, "AndOPAL", "Testing audio output");
    std::auto_ptr<PSoundChannel> player(PSoundChannel::CreateOpenedChannel("*", "voice", PSoundChannel::Player));
    if (player.get() == NULL)
      return false;

    player->SetBuffers(400, 8);
    {
      PTones tones("C:0.2/D:0.2/E:0.2/F:0.2/G:0.2/A:0.2/B:0.2/C5:1.0");
      PTRACE(1, "AndOPAL", "Tones using " << tones.GetSize() << " samples, "
              << PTimeInterval(1000*tones.GetSize()/tones.GetSampleRate()) << " seconds");
      PTime then;
      if (!tones.Write(*player))
        return false;

      PTRACE(1, "AndOPAL", "Audio queued");
      player->WaitForPlayCompletion();
      PTRACE(1, "AndOPAL", "Finished tone output: " << PTime() - then << " seconds");
    }

    std::auto_ptr<PSoundChannel> recorder(PSoundChannel::CreateOpenedChannel("*", "*", PSoundChannel::Recorder));
    if (player.get() == NULL)
      return false;

    PShortArray recording(5*recorder->GetSampleRate()); // Five seconds

    {
      PTRACE(1, "AndOPAL", "Started recording");
      PTime then;
      if (!recorder->ReadBlock(recording.GetPointer(), recording.GetSize()*sizeof(short)))
        return false;
      PTRACE(1, "AndOPAL", "Finished recording " << PTime() - then << " seconds");
    }

    {
      PTRACE(1, "AndOPAL", "Started play back");
      PTime then;
      if (!player->Write(recording.GetPointer(), recording.GetSize()*sizeof(short)))
        return false;
      PTRACE(1, "AndOPAL", "Finished play back " << PTime() - then << " seconds");
    }
  }
Пример #6
0
void Opal::Sip::CallManager::setup (const std::string & setting)
{
    if (!endpoint.IsReady ()) {
        endpoint.ready.connect (boost::bind (&Opal::Sip::CallManager::setup, this, ""));
        return;
    }

    if (setting.empty () || setting == "instance-id") {
        std::string instance_id = sip_settings->get_string ("instance-id");
        if (!instance_id.empty ())
            sip_endpoint.SetInstanceID (instance_id);
    }

    if (setting.empty () || setting == "listen-port")
        set_listen_port (sip_settings->get_int ("listen-port"));

    if (setting.empty () || setting == "keepalive-interval")  {
        int delay = sip_settings->get_int ("keepalive-interval");
        PTRACE (4, "Opal::Sip::CallManager\tKeepalive interval set to " << delay);
        sip_endpoint.SetKeepAlive (PTimeInterval (0, delay), SIPEndPoint::KeepAliveByOPTION);
    }

    if (setting.empty () || setting == "dtmf-mode")
        set_dtmf_mode (sip_settings->get_enum ("dtmf-mode"));

    /* Setup the various forwarding targets.
     * The no answer delay is defined in the opal-call-manager (our parent).
     */
    if (setting.empty () || setting == "forward-on-no-anwer" || setting == "forward-host")
        sip_endpoint.SetNoAnswerForwardTarget (call_forwarding_settings->get_bool ("forward-on-no-answer") ? sip_settings->get_string ("forward-host") : "");

    if (setting.empty () || setting == "forward-on-busy" || setting == "forward-host")
        sip_endpoint.SetBusyForwardTarget (call_forwarding_settings->get_bool ("forward-on-busy") ? sip_settings->get_string ("forward-host") : "");

    if (setting.empty () || setting == "always-forward" || setting == "forward-host")
        sip_endpoint.SetUnconditionalForwardTarget (call_forwarding_settings->get_bool ("always-forward") ? sip_settings->get_string ("forward-host") : "");

    Opal::CallManager::setup (setting);
}
Пример #7
0
void Opal::Sip::EndPoint::set_nat_binding_delay (unsigned delay)
{
  SetNATBindingTimeout (PTimeInterval (0, delay));
}