Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/jingle/jingle.c @ 30932:f858b53dfbf0
Can now generate a relayed candidate for the initiator
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Thu, 24 Sep 2009 20:22:24 +0000 |
parents | c585572e80dd |
children | a7e16735b218 |
comparison
equal
deleted
inserted
replaced
30931:794001c22306 | 30932:f858b53dfbf0 |
---|---|
33 #include "session.h" | 33 #include "session.h" |
34 #include "iceudp.h" | 34 #include "iceudp.h" |
35 #include "rawudp.h" | 35 #include "rawudp.h" |
36 #include "rtp.h" | 36 #include "rtp.h" |
37 | 37 |
38 #ifdef USE_VV | |
39 #include <gst/farsight/fs-conference-iface.h> | |
40 #include <gst/farsight/fs-element-added-notifier.h> | |
41 #endif | |
42 | |
38 GType | 43 GType |
39 jingle_get_type(const gchar *type) | 44 jingle_get_type(const gchar *type) |
40 { | 45 { |
41 if (!strcmp(type, JINGLE_TRANSPORT_RAWUDP)) | 46 if (!strcmp(type, JINGLE_TRANSPORT_RAWUDP)) |
42 return JINGLE_TYPE_RAWUDP; | 47 return JINGLE_TYPE_RAWUDP; |
428 if (js->sessions) | 433 if (js->sessions) |
429 g_hash_table_foreach(js->sessions, | 434 g_hash_table_foreach(js->sessions, |
430 jingle_terminate_sessions_gh, NULL); | 435 jingle_terminate_sessions_gh, NULL); |
431 } | 436 } |
432 | 437 |
438 #ifdef USE_VV | |
433 GParameter * | 439 GParameter * |
434 jingle_get_params(JabberStream *js, guint *num) | 440 jingle_get_params(JabberStream *js, const gchar *relay_ip, guint relay_udp, |
441 guint relay_tcp, guint relay_ssltcp, const gchar *relay_username, | |
442 const gchar *relay_password, guint *num) | |
435 { | 443 { |
436 /* don't set a STUN server if one is set globally in prefs, in that case | 444 /* don't set a STUN server if one is set globally in prefs, in that case |
437 this will be handled in media.c */ | 445 this will be handled in media.c */ |
438 gboolean has_account_stun = js->stun_ip && !purple_network_get_stun_ip(); | 446 gboolean has_account_stun = js->stun_ip && !purple_network_get_stun_ip(); |
439 guint num_params = has_account_stun ? 2 : 0; | 447 guint num_params = has_account_stun ? |
448 (relay_ip ? 3 : 2) : (relay_ip ? 1 : 0); | |
440 GParameter *params = NULL; | 449 GParameter *params = NULL; |
441 | 450 int next_index = 0; |
451 | |
442 if (num_params > 0) { | 452 if (num_params > 0) { |
443 params = g_new0(GParameter, num_params); | 453 params = g_new0(GParameter, num_params); |
444 | 454 |
445 purple_debug_info("jabber", | 455 if (has_account_stun) { |
446 "setting param stun-ip for stream using Google auto-config: %s\n", | 456 purple_debug_info("jabber", |
447 js->stun_ip); | 457 "setting param stun-ip for stream using Google auto-config: %s\n", |
448 params[0].name = "stun-ip"; | 458 js->stun_ip); |
449 g_value_init(¶ms[0].value, G_TYPE_STRING); | 459 params[next_index].name = "stun-ip"; |
450 g_value_set_string(¶ms[0].value, js->stun_ip); | 460 g_value_init(¶ms[next_index].value, G_TYPE_STRING); |
451 purple_debug_info("jabber", | 461 g_value_set_string(¶ms[next_index].value, js->stun_ip); |
452 "setting param stun-port for stream using Google auto-config: %d\n", | 462 purple_debug_info("jabber", |
453 js->stun_port); | 463 "setting param stun-port for stream using Google auto-config: %d\n", |
454 params[1].name = "stun-port"; | 464 js->stun_port); |
455 g_value_init(¶ms[1].value, G_TYPE_UINT); | 465 next_index++; |
456 g_value_set_uint(¶ms[1].value, js->stun_port); | 466 params[next_index].name = "stun-port"; |
467 g_value_init(¶ms[next_index].value, G_TYPE_UINT); | |
468 g_value_set_uint(¶ms[next_index].value, js->stun_port); | |
469 next_index++; | |
470 } | |
471 | |
472 if (relay_ip) { | |
473 GValueArray *relay_info = g_value_array_new(0); | |
474 GValue udp_value; | |
475 GValue tcp_value; | |
476 GValue ssltcp_value; | |
477 | |
478 if (relay_udp) { | |
479 GstStructure *turn_setup = gst_structure_new("relay-info", | |
480 "ip", G_TYPE_STRING, relay_ip, | |
481 "port", G_TYPE_UINT, relay_udp, | |
482 "username", G_TYPE_STRING, relay_username, | |
483 "password", G_TYPE_STRING, relay_password, | |
484 "relay-type", G_TYPE_STRING, "udp", | |
485 NULL); | |
486 if (turn_setup) { | |
487 memset(&udp_value, 0, sizeof(GValue)); | |
488 g_value_init(&udp_value, GST_TYPE_STRUCTURE); | |
489 gst_value_set_structure(&udp_value, turn_setup); | |
490 relay_info = g_value_array_append(relay_info, &udp_value); | |
491 gst_structure_free(turn_setup); | |
492 } | |
493 } | |
494 if (relay_tcp) { | |
495 GstStructure *turn_setup = gst_structure_new("relay-info", | |
496 "ip", G_TYPE_STRING, relay_ip, | |
497 "port", G_TYPE_UINT, relay_tcp, | |
498 "username", G_TYPE_STRING, relay_username, | |
499 "password", G_TYPE_STRING, relay_password, | |
500 "relay-type", G_TYPE_STRING, "tcp", | |
501 NULL); | |
502 if (turn_setup) { | |
503 memset(&tcp_value, 0, sizeof(GValue)); | |
504 g_value_init(&tcp_value, GST_TYPE_STRUCTURE); | |
505 gst_value_set_structure(&tcp_value, turn_setup); | |
506 relay_info = g_value_array_append(relay_info, &tcp_value); | |
507 gst_structure_free(turn_setup); | |
508 } | |
509 } | |
510 if (relay_ssltcp) { | |
511 GstStructure *turn_setup = gst_structure_new("relay-info", | |
512 "ip", G_TYPE_STRING, relay_ip, | |
513 "port", G_TYPE_UINT, relay_ssltcp, | |
514 "username", G_TYPE_STRING, relay_username, | |
515 "password", G_TYPE_STRING, relay_password, | |
516 "relay-type", G_TYPE_STRING, "tls", | |
517 NULL); | |
518 if (turn_setup) { | |
519 memset(&ssltcp_value, 0, sizeof(GValue)); | |
520 g_value_init(&ssltcp_value, GST_TYPE_STRUCTURE); | |
521 gst_value_set_structure(&ssltcp_value, turn_setup); | |
522 relay_info = g_value_array_append(relay_info, &ssltcp_value); | |
523 gst_structure_free(turn_setup); | |
524 } | |
525 } | |
526 params[next_index].name = "relay-info"; | |
527 g_value_init(¶ms[next_index].value, G_TYPE_VALUE_ARRAY); | |
528 g_value_set_boxed(¶ms[next_index].value, relay_info); | |
529 g_value_array_free(relay_info); | |
530 } | |
457 } | 531 } |
458 | 532 |
459 *num = num_params; | 533 *num = num_params; |
460 return params; | 534 return params; |
461 } | 535 } |
536 #endif | |
537 |