Beispiel #1
0
static void
codecs_box_set_codecs (CodecsBox *self,
                       const Ekiga::CodecList & list)
{
  GtkTreeSelection *selection = NULL;
  GtkTreeModel *model = NULL;
  GtkTreeIter iter;

  gchar *selected_codec = NULL;
  unsigned select_rate = 0;
  bool selected = false;

  model = gtk_tree_view_get_model (GTK_TREE_VIEW (self->priv->codecs_list));
  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->codecs_list));

  if (gtk_tree_selection_get_selected (selection, &model, &iter))
    gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
                        COLUMN_CODEC_NAME, &selected_codec,
                        COLUMN_CODEC_INFO, &select_rate, -1);
  gtk_list_store_clear (GTK_LIST_STORE (model));

  for (Ekiga::CodecList::const_iterator itr = list.begin ();
       itr != list.end ();
       itr++) {

    if ((self->priv->type == Ekiga::Call::Audio && (*itr).audio)
        || (self->priv->type == Ekiga::Call::Video && !(*itr).audio)) {

      gtk_list_store_append (GTK_LIST_STORE (model), &iter);
      gtk_list_store_set (GTK_LIST_STORE (model), &iter,
                          COLUMN_CODEC_ACTIVE, (*itr).active,
                          COLUMN_CODEC_NAME, (*itr).name.c_str (),
                          COLUMN_CODEC_DISPLAY_NAME, (*itr).display_name.c_str (),
                          COLUMN_CODEC_INFO, (*itr).display_info.c_str (),
                          COLUMN_CODEC_SELECTABLE, "true",
                          -1);

      if (selected_codec && (*itr).name == selected_codec) {

        selected = true;
        gtk_tree_selection_select_iter (selection, &iter);
      }
    }
  }

  if (!selected && gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter))
    gtk_tree_selection_select_iter (selection, &iter);

  g_free (selected_codec);
}
Beispiel #2
0
void CallManager::set_codecs (Ekiga::CodecList & _codecs)
{
  PStringArray initial_order;
  PStringArray initial_mask;

  OpalMediaFormatList all_media_formats;
  OpalMediaFormatList media_formats;

  PStringArray order;
  PStringArray mask;

  // What do we support
  GetAllowedFormats (all_media_formats);
  Ekiga::CodecList all_codecs = Opal::CodecList (all_media_formats);

  //
  // Clean the CodecList given as paramenter : remove unsupported codecs and
  // add missing codecs at the end of the list
  //

  // Build the Ekiga::CodecList taken into account by the CallManager
  // It contains codecs given as argument to set_codecs, and other codecs
  // supported by the manager
  for (Ekiga::CodecList::iterator it = all_codecs.begin ();
       it != all_codecs.end ();
       it++) {

    Ekiga::CodecList::iterator i  =
      search_n (_codecs.begin (), _codecs.end (), 1, *it, same_codec_desc);
    if (i == _codecs.end ()) {
      _codecs.append (*it);
    }
  }

  // Remove unsupported codecs
  for (Ekiga::CodecList::iterator it = _codecs.begin ();
       it != _codecs.end ();
       it++) {

    Ekiga::CodecList::iterator i  =
      search_n (all_codecs.begin (), all_codecs.end (), 1, *it, same_codec_desc);
    if (i == all_codecs.end ()) {
      _codecs.remove (it);
      it = _codecs.begin ();
    }
  }
  codecs = _codecs;


  //
  // Update OPAL
  //
  Ekiga::CodecList::iterator codecs_it;
  for (codecs_it = codecs.begin () ;
       codecs_it != codecs.end () ;
       codecs_it++) {

    bool active = (*codecs_it).active;
    std::string name = (*codecs_it).name;
    unsigned rate = (*codecs_it).rate;
    int j = 0;

    // Find the OpalMediaFormat corresponding to the Ekiga::CodecDescription
    if (active) {
      for (j = 0 ;
           j < all_media_formats.GetSize () ;
           j++) {

        if (name == (const char *) all_media_formats [j].GetEncodingName ()
            && (rate == all_media_formats [j].GetClockRate () || name == "G722")) {

          // Found something
          order += all_media_formats [j];
        }
      }
    }
  }
  

  // Add the PCSS codecs
  all_media_formats = pcssEP->GetMediaFormats ();
  for (int j = 0 ;
       j < all_media_formats.GetSize () ;
       j++)
    order += all_media_formats [j];


  // Build the mask
  all_media_formats = OpalTranscoder::GetPossibleFormats (pcssEP->GetMediaFormats ());
  all_media_formats.Remove (order);

  for (int i = 0 ;
       i < all_media_formats.GetSize () ;
       i++)
    mask += all_media_formats [i];

  // Blacklist IM protocols for now
  mask += "T.140";
  mask += "MSRP";
  mask += "SIP-IM";

  // Blacklist NSE, since it is unused in ekiga and might create
  // problems with some registrars (such as Eutelia)
  mask += "NamedSignalEvent";

  // Update the OpalManager
  SetMediaFormatMask (mask);
  SetMediaFormatOrder (order);
}
void ConfBridge::on_property_changed (std::string key, GmConfEntry *entry)
{
  CallManager & manager = (CallManager &) service;

  //
  // Video options
  //
  if (key == VIDEO_CODECS_KEY "maximum_video_tx_bitrate") {

    CallManager::VideoOptions options;
    manager.get_video_options (options);
    options.maximum_transmitted_bitrate = gm_conf_entry_get_int (entry);
    PTRACE(4, "OpalConfBridge\tmaximum_video_tx_bitrate set to " << options.maximum_transmitted_bitrate << "kb/s");
    manager.set_video_options (options);
  }
  else if (key == VIDEO_CODECS_KEY "temporal_spatial_tradeoff") {

    CallManager::VideoOptions options;
    manager.get_video_options (options);
    options.temporal_spatial_tradeoff = gm_conf_entry_get_int (entry);
    manager.set_video_options (options);
  }
  else if (key == VIDEO_DEVICES_KEY "size") {

    CallManager::VideoOptions options;
    manager.get_video_options (options);
    options.size = gm_conf_entry_get_int (entry);
    manager.set_video_options (options);
  }
  else if (key == VIDEO_DEVICES_KEY "max_frame_rate") {

    CallManager::VideoOptions options;
    manager.get_video_options (options);
    options.maximum_frame_rate = gm_conf_entry_get_int (entry);
    if ( (options.maximum_frame_rate < 1) || (options.maximum_frame_rate > 30) ) {
      PTRACE(1, "OpalConfBridge\t" << VIDEO_DEVICES_KEY "max_frame_rate" << " out of range, ajusting to 30");
      options.maximum_frame_rate = 30;
    }
    manager.set_video_options (options);
  }
  else if (key == VIDEO_CODECS_KEY "maximum_video_rx_bitrate") {

    CallManager::VideoOptions options;
    manager.get_video_options (options);
    options.maximum_received_bitrate = gm_conf_entry_get_int (entry);
    manager.set_video_options (options);
  }

  //
  // NAT Key
  //
  else if (key == NAT_KEY "stun_server") {

    gchar* stun_server = gm_conf_entry_get_string (entry);
    manager.set_stun_server (stun_server ? stun_server : "stun.ekiga.net");
    g_free (stun_server);
  }
  else if (key == NAT_KEY "enable_stun") {

    manager.set_stun_enabled (gm_conf_entry_get_bool (entry));
  }


  //
  // Jitter buffer configuration
  //
  else if (key == AUDIO_CODECS_KEY "maximum_jitter_buffer") {

    manager.set_maximum_jitter (gm_conf_entry_get_int (entry));
  }


  //
  // Silence detection
  //
  else if (key == AUDIO_CODECS_KEY "enable_silence_detection") {

    manager.set_silence_detection (gm_conf_entry_get_bool (entry));
  }


  //
  // Echo cancellation
  //
  else if (key == AUDIO_CODECS_KEY "enable_echo_cancellation") {

    manager.set_echo_cancellation (gm_conf_entry_get_bool (entry));
  }
  
  
  // 
  // Audio & video codecs
  //
  else if (key == AUDIO_CODECS_KEY "media_list"
           || key == VIDEO_CODECS_KEY "media_list") {

    // This is a bit longer, we are not sure the list stored in the 
    // configuration is complete, and it could also contain unsupported codecs
    GSList *audio_codecs = NULL;
    GSList *video_codecs = NULL;

    if (key == AUDIO_CODECS_KEY "media_list") {

      audio_codecs = gm_conf_entry_get_list (entry);
      video_codecs = gm_conf_get_string_list (VIDEO_CODECS_KEY "media_list");
    }
    else {

      video_codecs = gm_conf_entry_get_list (entry);
      audio_codecs = gm_conf_get_string_list (AUDIO_CODECS_KEY "media_list");
    }

    Ekiga::CodecList codecs;
    Ekiga::CodecList a_codecs (audio_codecs);
    Ekiga::CodecList v_codecs (video_codecs);

    // Update the manager codecs
    codecs = a_codecs;
    codecs.append (v_codecs);
    manager.set_codecs (codecs);

    g_slist_foreach (audio_codecs, (GFunc) g_free, NULL);
    g_slist_free (audio_codecs);
    g_slist_foreach (video_codecs, (GFunc) g_free, NULL);
    g_slist_free (video_codecs);

    // Update the GmConf keys, in case we would have missed some codecs or
    // used codecs we do not really support
    if (a_codecs != codecs.get_audio_list ()) {

      audio_codecs = codecs.get_audio_list ().gslist ();
      gm_conf_set_string_list (AUDIO_CODECS_KEY "media_list", audio_codecs);
      g_slist_foreach (audio_codecs, (GFunc) g_free, NULL);
      g_slist_free (audio_codecs);
    }

    if (v_codecs != codecs.get_video_list ()) {

      video_codecs = codecs.get_video_list ().gslist ();
      gm_conf_set_string_list (VIDEO_CODECS_KEY "media_list", video_codecs);
      g_slist_foreach (video_codecs, (GFunc) g_free, NULL);
      g_slist_free (video_codecs);
    }
  }

  //
  // SIP related keys
  // 
  else if (key.find (SIP_KEY) != string::npos) {

    boost::shared_ptr<Opal::Sip::EndPoint> sip_manager = boost::dynamic_pointer_cast<Opal::Sip::EndPoint> (manager.get_protocol_manager ("sip"));
    if (sip_manager) {

      if (key == SIP_KEY "outbound_proxy_host") {

        gchar* str = gm_conf_entry_get_string (entry);
        if (str != NULL)
          sip_manager->set_outbound_proxy (str);
        g_free (str);
      }
      else if (key == SIP_KEY "dtmf_mode") {

        sip_manager->set_dtmf_mode (gm_conf_entry_get_int (entry));
      }
      else if (key == SIP_KEY "forward_host") {

        gchar* str = gm_conf_entry_get_string (entry);
        if (str != NULL)
          sip_manager->set_forward_uri (str);
        g_free (str);
      }
      else if (key == SIP_KEY "binding_timeout") {

        sip_manager->set_nat_binding_delay (gm_conf_entry_get_int (entry));
      }
    }
  }

  //
  // H.323 keys
  //
#ifdef HAVE_H323
  else if (key.find (SIP_KEY) != string::npos) {

    boost::shared_ptr<Opal::H323::EndPoint> h323_manager = boost::dynamic_pointer_cast<Opal::H323::EndPoint> (manager.get_protocol_manager ("h323"));
    if (h323_manager) {

      if (key == H323_KEY "enable_h245_tunneling") {

        h323_manager->DisableH245Tunneling (!gm_conf_entry_get_bool (entry));
      }
      else if (key == H323_KEY "enable_early_h245") {

        h323_manager->DisableH245inSetup (!gm_conf_entry_get_bool (entry));
      }
      else if (key == H323_KEY "enable_fast_start") {

        h323_manager->DisableFastStart (!gm_conf_entry_get_bool (entry));
      }
      else if (key == H323_KEY "dtmf_mode") {

        h323_manager->set_dtmf_mode (gm_conf_entry_get_int (entry));
      }
      else if (key == H323_KEY "forward_host") {

        gchar* str = gm_conf_entry_get_string (entry);
        if (str != NULL)
          h323_manager->set_forward_uri (str);
        g_free (str);
      }
    }
  }
#endif


  //
  // Personal Data Key
  //
  else if (key == PERSONAL_DATA_KEY "full_name") {

    gchar* str = gm_conf_entry_get_string (entry);
    if (str != NULL)
      manager.set_display_name (str);
    g_free (str);
  }


  //
  // Misc keys
  //
  else if (key == CALL_FORWARDING_KEY "forward_on_no_answer") {

    manager.set_forward_on_no_answer (gm_conf_entry_get_bool (entry));
  }
  else if (key == CALL_FORWARDING_KEY "forward_on_busy") {

    manager.set_forward_on_busy (gm_conf_entry_get_bool (entry));
  }
  else if (key == CALL_FORWARDING_KEY "always_forward") {

    manager.set_unconditional_forward (gm_conf_entry_get_bool (entry));
  }
  else if (key == CALL_OPTIONS_KEY "no_answer_timeout") {

    manager.set_reject_delay (gm_conf_entry_get_int (entry));
  }
  else if (key == CALL_OPTIONS_KEY "auto_answer") {

    manager.set_auto_answer (gm_conf_entry_get_bool (entry));
  }
  else if (key == PROTOCOLS_KEY "rtp_tos_field") {

    manager.set_rtp_tos (gm_conf_entry_get_int (entry));
  }


  //
  // Ports keys
  //
  else if (key == PORTS_KEY "udp_port_range"
           || key == PORTS_KEY "tcp_port_range") {

    gchar* ports = NULL;
    gchar **couple = NULL;
    unsigned min_port = 0;
    unsigned max_port = 0;

    ports = gm_conf_entry_get_string (entry);
    if (ports)
      couple = g_strsplit (ports, ":", 2);
    g_free (ports);

    if (couple && couple [0])
      min_port = atoi (couple [0]);

    if (couple && couple [1])
      max_port = atoi (couple [1]);

    if (key == PORTS_KEY "udp_port_range")
      manager.set_udp_ports (min_port, max_port);
    else
      manager.set_tcp_ports (min_port, max_port);

    g_strfreev (couple);
  }

}
Beispiel #4
0
void CallManager::set_codecs (Ekiga::CodecList & _codecs)
{
  PStringArray initial_order;
  PStringArray initial_mask;

  OpalMediaFormatList all_media_formats;
  OpalMediaFormatList media_formats;

  PStringArray order;
  PStringArray mask;

  // What do we support
  GetAllowedFormats (all_media_formats);
  Ekiga::CodecList all_codecs = Opal::CodecList (all_media_formats);

  // 
  // Clean the CodecList given as paramenter : remove unsupported codecs and 
  // add missing codecs at the end of the list
  //

  // Build the Ekiga::CodecList taken into account by the CallManager
  // It contains codecs given as argument to set_codecs, and other codecs
  // supported by the manager
  for (Ekiga::CodecList::iterator it = all_codecs.begin ();
       it != all_codecs.end ();
       it++) {

    Ekiga::CodecList::iterator i  = 
      search_n (_codecs.begin (), _codecs.end (), 1, *it, same_codec_desc);
    if (i == _codecs.end ()) {
      _codecs.push_back (*it);
    }
  }

  // Remove unsupported codecs
  for (Ekiga::CodecList::iterator it = _codecs.begin ();
       it != _codecs.end ();
       it++) {

    Ekiga::CodecList::iterator i  = 
      search_n (all_codecs.begin (), all_codecs.end (), 1, *it, same_codec_desc);
    if (i == all_codecs.end ()) {
      _codecs.erase (it);
      it = _codecs.begin ();
    }
  }
  codecs = _codecs;


  // 
  // Update OPAL
  //
  Ekiga::CodecList::iterator codecs_it;
  for (codecs_it = codecs.begin () ;
       codecs_it != codecs.end () ;
       codecs_it++) {

    bool active = (*codecs_it).active;
    std::string name = (*codecs_it).name;
    unsigned rate = (*codecs_it).rate;
    int j = 0;

    // Find the OpalMediaFormat corresponding to the Ekiga::CodecDescription
    if (active) {
      for (j = 0 ; 
           j < all_media_formats.GetSize () ;
           j++) {

        if (name == (const char *) all_media_formats [j].GetEncodingName ()
            && rate == all_media_formats [j].GetClockRate ()) {

          // Found something
          order += all_media_formats [j];
        }
      }
    }
  }

  // Build the mask
  all_media_formats = OpalTranscoder::GetPossibleFormats (pcssEP->GetMediaFormats ());
  all_media_formats.Remove (order);

  for (int i = 0 ; 
       i < all_media_formats.GetSize () ; 
       i++)
    mask += all_media_formats [i];

  // Update the OpalManager
  SetMediaFormatMask (mask);
  SetMediaFormatOrder (order);
}