Mercurial > pidgin
comparison libpurple/protocols/jabber/jingle/rtp.c @ 26317:85c571d11417
Stop sending multiple session-initiate packets.
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Fri, 20 Mar 2009 06:18:03 +0000 |
parents | 96ffb196d18d |
children | 2c9fb8ac325b |
comparison
equal
deleted
inserted
replaced
26316:bd9fa96c47dc | 26317:85c571d11417 |
---|---|
333 } else { | 333 } else { |
334 return NULL; | 334 return NULL; |
335 } | 335 } |
336 } | 336 } |
337 | 337 |
338 static void jingle_rtp_send_initiate(JingleSession *session); | 338 static void jingle_rtp_ready(JingleSession *session); |
339 static void jingle_rtp_send_accept(JingleSession *session); | |
340 | 339 |
341 static void | 340 static void |
342 jingle_rtp_accepted_cb(PurpleMedia *media, gchar *sid, gchar *name, | 341 jingle_rtp_accepted_cb(PurpleMedia *media, gchar *sid, gchar *name, |
343 JingleSession *session) | 342 JingleSession *session) |
344 { | 343 { |
345 purple_debug_info("jingle-rtp", "jingle_rtp_accepted_cb\n"); | 344 purple_debug_info("jingle-rtp", "jingle_rtp_accepted_cb\n"); |
346 jingle_rtp_send_accept(session); | 345 jingle_rtp_ready(session); |
347 } | 346 } |
348 | 347 |
349 static void | 348 static void |
350 jingle_rtp_candidates_prepared_cb(PurpleMedia *media, | 349 jingle_rtp_candidates_prepared_cb(PurpleMedia *media, |
351 gchar *sid, gchar *name, JingleSession *session) | 350 gchar *sid, gchar *name, JingleSession *session) |
375 g_object_unref(oldtransport); | 374 g_object_unref(oldtransport); |
376 | 375 |
377 jingle_content_set_pending_transport(content, transport); | 376 jingle_content_set_pending_transport(content, transport); |
378 jingle_content_accept_transport(content); | 377 jingle_content_accept_transport(content); |
379 | 378 |
380 jingle_rtp_send_initiate(session); | 379 jingle_rtp_ready(session); |
381 jingle_rtp_send_accept(session); | |
382 } | 380 } |
383 | 381 |
384 static void | 382 static void |
385 jingle_rtp_codecs_changed_cb(PurpleMedia *media, gchar *sid, | 383 jingle_rtp_codecs_changed_cb(PurpleMedia *media, gchar *sid, |
386 JingleSession *session) | 384 JingleSession *session) |
387 { | 385 { |
388 purple_debug_info("jingle-rtp", "jingle_rtp_codecs_changed_cb: " | 386 purple_debug_info("jingle-rtp", "jingle_rtp_codecs_changed_cb: " |
389 "session_id: %s jingle_session: %p\n", sid, session); | 387 "session_id: %s jingle_session: %p\n", sid, session); |
390 jingle_rtp_send_initiate(session); | 388 jingle_rtp_ready(session); |
391 jingle_rtp_send_accept(session); | |
392 } | 389 } |
393 | 390 |
394 static void | 391 static void |
395 jingle_rtp_new_candidate_cb(PurpleMedia *media, gchar *sid, gchar *name, PurpleMediaCandidate *candidate, JingleSession *session) | 392 jingle_rtp_new_candidate_cb(PurpleMedia *media, gchar *sid, gchar *name, PurpleMediaCandidate *candidate, JingleSession *session) |
396 { | 393 { |
451 g_object_unref(session); | 448 g_object_unref(session); |
452 } | 449 } |
453 } | 450 } |
454 | 451 |
455 static void | 452 static void |
456 jingle_rtp_send_initiate(JingleSession *session) | 453 jingle_rtp_ready(JingleSession *session) |
457 { | 454 { |
458 PurpleMedia *media = jingle_rtp_get_media(session); | 455 PurpleMedia *media = jingle_rtp_get_media(session); |
459 | 456 |
460 if (jingle_session_is_initiator(session) == TRUE && | 457 if (purple_media_candidates_prepared(media, NULL, NULL) && |
461 purple_media_codecs_ready(media, NULL) && | 458 purple_media_codecs_ready(media, NULL) && |
462 purple_media_candidates_prepared(media, NULL, NULL)) { | 459 (jingle_session_is_initiator(session) == TRUE || |
463 JabberIq *iq = jingle_session_to_packet( | 460 purple_media_accepted(media, NULL, NULL))) { |
464 session, JINGLE_SESSION_INITIATE); | 461 if (jingle_session_is_initiator(session)) { |
465 jabber_iq_set_callback(iq, | 462 JabberIq *iq = jingle_session_to_packet( |
466 jingle_rtp_initiate_ack_cb, session); | 463 session, JINGLE_SESSION_INITIATE); |
467 jabber_iq_send(iq); | 464 jabber_iq_set_callback(iq, |
468 g_signal_connect(G_OBJECT(media), "new-candidate", | 465 jingle_rtp_initiate_ack_cb, session); |
469 G_CALLBACK(jingle_rtp_new_candidate_cb), | 466 jabber_iq_send(iq); |
467 } else { | |
468 jabber_iq_send(jingle_session_to_packet(session, | |
469 JINGLE_SESSION_ACCEPT)); | |
470 } | |
471 | |
472 g_signal_handlers_disconnect_by_func(G_OBJECT(media), | |
473 G_CALLBACK(jingle_rtp_accepted_cb), session); | |
474 g_signal_handlers_disconnect_by_func(G_OBJECT(media), | |
475 G_CALLBACK(jingle_rtp_candidates_prepared_cb), | |
470 session); | 476 session); |
471 } | 477 g_signal_handlers_disconnect_by_func(G_OBJECT(media), |
472 } | 478 G_CALLBACK(jingle_rtp_codecs_changed_cb), |
473 | 479 session); |
474 static void | |
475 jingle_rtp_send_accept(JingleSession *session) | |
476 { | |
477 PurpleMedia *media = jingle_rtp_get_media(session); | |
478 | |
479 if (jingle_session_is_initiator(session) == FALSE && | |
480 purple_media_codecs_ready(media, NULL) && | |
481 purple_media_accepted(media, NULL, NULL) && | |
482 purple_media_candidates_prepared(media, NULL, NULL)) { | |
483 jabber_iq_send(jingle_session_to_packet(session, | |
484 JINGLE_SESSION_ACCEPT)); | |
485 g_signal_connect(G_OBJECT(media), "new-candidate", | 480 g_signal_connect(G_OBJECT(media), "new-candidate", |
486 G_CALLBACK(jingle_rtp_new_candidate_cb), | 481 G_CALLBACK(jingle_rtp_new_candidate_cb), |
487 session); | 482 session); |
488 } | 483 } |
489 } | 484 } |
506 } | 501 } |
507 | 502 |
508 purple_media_set_prpl_data(media, session); | 503 purple_media_set_prpl_data(media, session); |
509 | 504 |
510 /* connect callbacks */ | 505 /* connect callbacks */ |
511 g_signal_connect(G_OBJECT(media), "accepted", | 506 if (jingle_session_is_initiator(session) == FALSE) |
512 G_CALLBACK(jingle_rtp_accepted_cb), session); | 507 g_signal_connect(G_OBJECT(media), "accepted", |
508 G_CALLBACK(jingle_rtp_accepted_cb), session); | |
513 g_signal_connect(G_OBJECT(media), "candidates-prepared", | 509 g_signal_connect(G_OBJECT(media), "candidates-prepared", |
514 G_CALLBACK(jingle_rtp_candidates_prepared_cb), session); | 510 G_CALLBACK(jingle_rtp_candidates_prepared_cb), session); |
515 g_signal_connect(G_OBJECT(media), "codecs-changed", | 511 g_signal_connect(G_OBJECT(media), "codecs-changed", |
516 G_CALLBACK(jingle_rtp_codecs_changed_cb), session); | 512 G_CALLBACK(jingle_rtp_codecs_changed_cb), session); |
517 g_signal_connect(G_OBJECT(media), "state-changed", | 513 g_signal_connect(G_OBJECT(media), "state-changed", |