Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/jingle/rtp.c @ 26369:26cf297796a5
Update Jingle Ice-Udp according to the XEP.
This mainly includes sending and receiving candidates in
session-initiate and session-accept packets. It also includes a few
memory leak fixes.
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Tue, 17 Mar 2009 11:57:22 +0000 |
parents | b1c4fcc5b814 |
children | 44684f0d2e42 |
comparison
equal
deleted
inserted
replaced
26368:d8a7c7d9ac8a | 26369:26cf297796a5 |
---|---|
341 xmlnode_get_child(packet, "error")) { | 341 xmlnode_get_child(packet, "error")) { |
342 purple_media_end(jingle_rtp_get_media(session), NULL, NULL); | 342 purple_media_end(jingle_rtp_get_media(session), NULL, NULL); |
343 g_object_unref(session); | 343 g_object_unref(session); |
344 return; | 344 return; |
345 } | 345 } |
346 | |
347 jabber_iq_send(jingle_session_to_packet(session, | |
348 JINGLE_TRANSPORT_INFO)); | |
349 } | 346 } |
350 | 347 |
351 static void | 348 static void |
352 jingle_rtp_ready_cb(PurpleMedia *media, gchar *sid, gchar *name, JingleSession *session) | 349 jingle_rtp_ready_cb(PurpleMedia *media, gchar *sid, gchar *name, JingleSession *session) |
353 { | 350 { |
354 purple_debug_info("rtp", "ready-new: session: %s name: %s\n", sid, name); | 351 purple_debug_info("rtp", "ready-new: session: %s name: %s\n", sid, name); |
355 | 352 |
356 if (sid == NULL && name == NULL) { | 353 if (sid == NULL && name == NULL) { |
357 if (jingle_session_is_initiator(session) == TRUE) { | 354 if (jingle_session_is_initiator(session) == TRUE) { |
358 GList *contents = jingle_session_get_contents(session); | |
359 JabberIq *iq = jingle_session_to_packet( | 355 JabberIq *iq = jingle_session_to_packet( |
360 session, JINGLE_SESSION_INITIATE); | 356 session, JINGLE_SESSION_INITIATE); |
361 | 357 jabber_iq_set_callback(iq, |
362 if (contents->data) { | 358 jingle_rtp_initiate_ack_cb, session); |
363 JingleTransport *transport = | |
364 jingle_content_get_transport(contents->data); | |
365 if (JINGLE_IS_ICEUDP(transport)) | |
366 jabber_iq_set_callback(iq, | |
367 jingle_rtp_initiate_ack_cb, session); | |
368 } | |
369 | |
370 jabber_iq_send(iq); | 359 jabber_iq_send(iq); |
371 } else { | 360 } else { |
372 jabber_iq_send(jingle_session_to_packet(session, JINGLE_TRANSPORT_INFO)); | |
373 jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_ACCEPT)); | 361 jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_ACCEPT)); |
374 } | 362 } |
375 } else if (sid != NULL && name != NULL) { | 363 } else if (sid != NULL && name != NULL) { |
376 JingleContent *content = jingle_session_find_content(session, sid, "initiator"); | 364 JingleContent *content = jingle_session_find_content(session, sid, "initiator"); |
377 JingleTransport *oldtransport = jingle_content_get_transport(content); | 365 JingleTransport *oldtransport = jingle_content_get_transport(content); |
619 | 607 |
620 static void | 608 static void |
621 jingle_rtp_handle_action_internal(JingleContent *content, xmlnode *xmlcontent, JingleActionType action) | 609 jingle_rtp_handle_action_internal(JingleContent *content, xmlnode *xmlcontent, JingleActionType action) |
622 { | 610 { |
623 switch (action) { | 611 switch (action) { |
624 case JINGLE_SESSION_ACCEPT: { | 612 case JINGLE_SESSION_ACCEPT: |
625 JingleSession *session = jingle_content_get_session(content); | |
626 xmlnode *description = xmlnode_get_child(xmlcontent, "description"); | |
627 GList *codecs = jingle_rtp_parse_codecs(description); | |
628 | |
629 purple_media_set_remote_codecs(jingle_rtp_get_media(session), | |
630 jingle_content_get_name(content), | |
631 jingle_session_get_remote_jid(session), codecs); | |
632 | |
633 /* This needs to be for the entire session, not a single content */ | |
634 /* very hacky */ | |
635 if (xmlnode_get_next_twin(xmlcontent) == NULL) | |
636 purple_media_accept(jingle_rtp_get_media(session)); | |
637 | |
638 g_object_unref(session); | |
639 break; | |
640 } | |
641 case JINGLE_SESSION_INITIATE: { | 613 case JINGLE_SESSION_INITIATE: { |
642 JingleSession *session = jingle_content_get_session(content); | 614 JingleSession *session = jingle_content_get_session(content); |
643 JingleTransport *transport = jingle_transport_parse( | 615 JingleTransport *transport = jingle_transport_parse( |
644 xmlnode_get_child(xmlcontent, "transport")); | 616 xmlnode_get_child(xmlcontent, "transport")); |
645 xmlnode *description = xmlnode_get_child(xmlcontent, "description"); | 617 xmlnode *description = xmlnode_get_child(xmlcontent, "description"); |
646 GList *candidates = jingle_rtp_transport_to_candidates(transport); | 618 GList *candidates = jingle_rtp_transport_to_candidates(transport); |
647 GList *codecs = jingle_rtp_parse_codecs(description); | 619 GList *codecs = jingle_rtp_parse_codecs(description); |
648 | 620 gchar *name = jingle_content_get_name(content); |
649 if (jingle_rtp_init_media(content) == FALSE) { | 621 gchar *remote_jid = |
622 jingle_session_get_remote_jid(session); | |
623 PurpleMedia *media; | |
624 | |
625 if (action == JINGLE_SESSION_INITIATE && | |
626 jingle_rtp_init_media(content) == FALSE) { | |
650 /* XXX: send error */ | 627 /* XXX: send error */ |
651 jabber_iq_send(jingle_session_terminate_packet( | 628 jabber_iq_send(jingle_session_terminate_packet( |
652 session, "general-error")); | 629 session, "general-error")); |
653 g_object_unref(session); | 630 g_object_unref(session); |
654 break; | 631 break; |
655 } | 632 } |
656 | 633 |
657 purple_media_set_remote_codecs(jingle_rtp_get_media(session), | 634 media = jingle_rtp_get_media(session); |
658 jingle_content_get_name(content), | 635 purple_media_set_remote_codecs(media, |
659 jingle_session_get_remote_jid(session), codecs); | 636 name, remote_jid, codecs); |
660 | 637 purple_media_add_remote_candidates(media, |
661 if (JINGLE_IS_RAWUDP(transport)) { | 638 name, remote_jid, candidates); |
662 purple_media_add_remote_candidates(jingle_rtp_get_media(session), | 639 |
663 jingle_content_get_name(content), | 640 /* This needs to be for the entire session, not a single content */ |
664 jingle_session_get_remote_jid(session), | 641 /* very hacky */ |
665 candidates); | 642 if (action == JINGLE_SESSION_ACCEPT && |
666 } | 643 xmlnode_get_next_twin(xmlcontent) == NULL) |
667 | 644 purple_media_accept(media); |
645 | |
646 g_free(remote_jid); | |
647 g_free(name); | |
668 g_object_unref(session); | 648 g_object_unref(session); |
669 break; | 649 break; |
670 } | 650 } |
671 case JINGLE_SESSION_TERMINATE: { | 651 case JINGLE_SESSION_TERMINATE: { |
672 JingleSession *session = jingle_content_get_session(content); | 652 JingleSession *session = jingle_content_get_session(content); |
682 case JINGLE_TRANSPORT_INFO: { | 662 case JINGLE_TRANSPORT_INFO: { |
683 JingleSession *session = jingle_content_get_session(content); | 663 JingleSession *session = jingle_content_get_session(content); |
684 JingleTransport *transport = jingle_transport_parse( | 664 JingleTransport *transport = jingle_transport_parse( |
685 xmlnode_get_child(xmlcontent, "transport")); | 665 xmlnode_get_child(xmlcontent, "transport")); |
686 GList *candidates = jingle_rtp_transport_to_candidates(transport); | 666 GList *candidates = jingle_rtp_transport_to_candidates(transport); |
687 | 667 gchar *name = jingle_content_get_name(content); |
688 purple_media_add_remote_candidates(jingle_rtp_get_media(session), | 668 gchar *remote_jid = |
689 jingle_content_get_name(content), | 669 jingle_session_get_remote_jid(session); |
690 jingle_session_get_remote_jid(session), | 670 |
691 candidates); | 671 purple_media_add_remote_candidates( |
672 jingle_rtp_get_media(session), | |
673 name, remote_jid, candidates); | |
674 | |
675 g_free(remote_jid); | |
676 g_free(name); | |
692 g_object_unref(session); | 677 g_object_unref(session); |
693 break; | 678 break; |
694 } | 679 } |
695 default: | 680 default: |
696 break; | 681 break; |