Mercurial > pidgin
comparison libpurple/protocols/jabber/jingle/rtp.c @ 24954:365eb0b68d5f
Update Jingle raw-udp to latest spec version.
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Fri, 07 Nov 2008 03:00:09 +0000 |
parents | 1a2d446cb8a0 |
children | b83c83143a69 |
comparison
equal
deleted
inserted
replaced
24953:b9d4ab2c84c6 | 24954:365eb0b68d5f |
---|---|
204 | 204 |
205 return media; | 205 return media; |
206 } | 206 } |
207 | 207 |
208 static JingleTransport * | 208 static JingleTransport * |
209 jingle_rtp_candidate_to_transport(GType type, guint generation, FsCandidate *candidate) | 209 jingle_rtp_candidates_to_transport(JingleSession *session, GType type, guint generation, GList *candidates) |
210 { | 210 { |
211 if (type == JINGLE_TYPE_RAWUDP) { | 211 if (type == JINGLE_TYPE_RAWUDP) { |
212 return JINGLE_TRANSPORT(jingle_rawudp_create(generation, | 212 gchar *id = jabber_get_next_id(jingle_session_get_js(session)); |
213 candidate->foundation, candidate->ip, candidate->port)); | 213 JingleTransport *transport = jingle_transport_create(JINGLE_TRANSPORT_RAWUDP); |
214 JingleRawUdpCandidate *rawudp_candidate; | |
215 for (; candidates; candidates = g_list_next(candidates)) { | |
216 FsCandidate *candidate = candidates->data; | |
217 id = jabber_get_next_id(jingle_session_get_js(session)); | |
218 rawudp_candidate = jingle_rawudp_candidate_new(id, | |
219 generation, candidate->component_id, | |
220 candidate->ip, candidate->port); | |
221 jingle_rawudp_add_local_candidate(JINGLE_RAWUDP(transport), rawudp_candidate); | |
222 } | |
223 g_free(id); | |
224 return transport; | |
214 #if 0 | 225 #if 0 |
215 } else if (type == JINGLE_TYPE_ICEUDP) { | 226 } else if (type == JINGLE_TYPE_ICEUDP) { |
216 return NULL; | 227 return NULL; |
217 #endif | 228 #endif |
218 } else { | 229 } else { |
219 return NULL; | 230 return NULL; |
220 } | 231 } |
221 } | 232 } |
222 | 233 |
223 static FsCandidate * | 234 static GList * |
224 jingle_rtp_transport_to_candidate(xmlnode *transport) | 235 jingle_rtp_transport_to_candidates(JingleTransport *transport) |
225 { | 236 { |
226 xmlnode *candidate = xmlnode_get_child(transport, "candidate"); | 237 const gchar *type = jingle_transport_get_transport_type(transport); |
227 const gchar *type = xmlnode_get_namespace(transport); | 238 GList *ret = NULL; |
228 if (!strcmp(type, JINGLE_TRANSPORT_RAWUDP)) { | 239 if (!strcmp(type, JINGLE_TRANSPORT_RAWUDP)) { |
229 return fs_candidate_new("", FS_COMPONENT_RTP, | 240 GList *candidates = jingle_rawudp_get_remote_candidates(JINGLE_RAWUDP(transport)); |
230 FS_CANDIDATE_TYPE_SRFLX, FS_NETWORK_PROTOCOL_UDP, | 241 |
231 xmlnode_get_attrib(candidate, "ip"), | 242 for (; candidates; candidates = g_list_delete_link(candidates, candidates)) { |
232 atoi(xmlnode_get_attrib(candidate, "port"))); | 243 JingleRawUdpCandidate *candidate = candidates->data; |
244 ret = g_list_append(ret, fs_candidate_new("", candidate->component, | |
245 FS_CANDIDATE_TYPE_SRFLX, FS_NETWORK_PROTOCOL_UDP, | |
246 candidate->ip, candidate->port)); | |
247 } | |
248 | |
249 return ret; | |
233 #if 0 | 250 #if 0 |
234 } else if (type == JINGLE_TRANSPORT_ICEUDP) { | 251 } else if (type == JINGLE_TRANSPORT_ICEUDP) { |
235 return NULL; | 252 return NULL; |
236 #endif | 253 #endif |
237 } else { | 254 } else { |
262 | 279 |
263 static void | 280 static void |
264 jingle_rtp_new_candidate_cb(PurpleMedia *media, gchar *sid, gchar *name, FsCandidate *candidate, JingleSession *session) | 281 jingle_rtp_new_candidate_cb(PurpleMedia *media, gchar *sid, gchar *name, FsCandidate *candidate, JingleSession *session) |
265 { | 282 { |
266 purple_debug_info("jingle-rtp", "jingle_rtp_new_candidate_cb\n"); | 283 purple_debug_info("jingle-rtp", "jingle_rtp_new_candidate_cb\n"); |
267 | |
268 if (candidate->component_id == 1) { | |
269 JingleContent *content = jingle_session_find_content(session, sid, "initiator"); | |
270 JingleTransport *transport = | |
271 JINGLE_TRANSPORT(jingle_rtp_candidate_to_transport( | |
272 JINGLE_TYPE_RAWUDP, 0, candidate)); | |
273 jingle_content_set_pending_transport(content, transport); | |
274 jingle_content_accept_transport(content); | |
275 } | |
276 } | 284 } |
277 | 285 |
278 static void | 286 static void |
279 jingle_rtp_candidates_prepared_cb(PurpleMedia *media, gchar *sid, gchar *name, JingleSession *session) | 287 jingle_rtp_candidates_prepared_cb(PurpleMedia *media, gchar *sid, gchar *name, JingleSession *session) |
280 { | 288 { |
281 JingleContent *content = jingle_session_find_content(session, sid, "initiator"); | 289 JingleContent *content = jingle_session_find_content(session, sid, "initiator"); |
290 GList *candidates = purple_media_get_local_candidates(media, sid, name); | |
291 JingleTransport *transport = | |
292 JINGLE_TRANSPORT(jingle_rtp_candidates_to_transport( | |
293 session, JINGLE_TYPE_RAWUDP, 0, candidates)); | |
294 g_list_free(candidates); | |
295 | |
282 JINGLE_RTP_GET_PRIVATE(content)->candidates_ready = TRUE; | 296 JINGLE_RTP_GET_PRIVATE(content)->candidates_ready = TRUE; |
297 | |
298 jingle_content_set_pending_transport(content, transport); | |
299 jingle_content_accept_transport(content); | |
283 | 300 |
284 if (jingle_rtp_ready_to_initiate(session, media)) | 301 if (jingle_rtp_ready_to_initiate(session, media)) |
285 jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_INITIATE)); | 302 jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_INITIATE)); |
286 } | 303 } |
287 | 304 |
540 g_object_unref(session); | 557 g_object_unref(session); |
541 break; | 558 break; |
542 } | 559 } |
543 case JINGLE_SESSION_INITIATE: { | 560 case JINGLE_SESSION_INITIATE: { |
544 JingleSession *session = jingle_content_get_session(content); | 561 JingleSession *session = jingle_content_get_session(content); |
562 JingleTransport *transport = jingle_transport_parse( | |
563 xmlnode_get_child(xmlcontent, "transport")); | |
545 xmlnode *description = xmlnode_get_child(xmlcontent, "description"); | 564 xmlnode *description = xmlnode_get_child(xmlcontent, "description"); |
546 xmlnode *transport = xmlnode_get_child(xmlcontent, "transport"); | 565 GList *candidates = jingle_rtp_transport_to_candidates(transport); |
547 FsCandidate *candidate = jingle_rtp_transport_to_candidate(transport); | |
548 GList *candidates = g_list_append(NULL, candidate); | |
549 GList *codecs = jingle_rtp_parse_codecs(description); | 566 GList *codecs = jingle_rtp_parse_codecs(description); |
550 | 567 |
551 jingle_rtp_init_media(content); | 568 jingle_rtp_init_media(content); |
552 | 569 |
553 purple_media_set_remote_codecs(jingle_rtp_get_media(session), | 570 purple_media_set_remote_codecs(jingle_rtp_get_media(session), |
554 jingle_content_get_name(content), | 571 jingle_content_get_name(content), |
555 jingle_session_get_remote_jid(session), codecs); | 572 jingle_session_get_remote_jid(session), codecs); |
556 | |
557 /* manufacture rtcp candidate */ | |
558 candidate = fs_candidate_copy(candidate); | |
559 candidate->component_id = 2; | |
560 candidate->port = candidate->port + 1; | |
561 candidates = g_list_append(candidates, candidate); | |
562 | 573 |
563 purple_media_add_remote_candidates(jingle_rtp_get_media(session), | 574 purple_media_add_remote_candidates(jingle_rtp_get_media(session), |
564 jingle_content_get_name(content), | 575 jingle_content_get_name(content), |
565 jingle_session_get_remote_jid(session), | 576 jingle_session_get_remote_jid(session), |
566 candidates); | 577 candidates); |
578 g_object_unref(session); | 589 g_object_unref(session); |
579 break; | 590 break; |
580 } | 591 } |
581 case JINGLE_TRANSPORT_INFO: { | 592 case JINGLE_TRANSPORT_INFO: { |
582 JingleSession *session = jingle_content_get_session(content); | 593 JingleSession *session = jingle_content_get_session(content); |
583 xmlnode *transport = xmlnode_get_child(xmlcontent, "transport"); | 594 JingleTransport *transport = jingle_transport_parse( |
584 FsCandidate *candidate = jingle_rtp_transport_to_candidate(transport); | 595 xmlnode_get_child(xmlcontent, "transport")); |
585 GList *candidates = g_list_append(NULL, candidate); | 596 GList *candidates = jingle_rtp_transport_to_candidates(transport); |
586 | |
587 /* manufacture rtcp candidate */ | |
588 candidate = fs_candidate_copy(candidate); | |
589 candidate->component_id = 2; | |
590 candidate->port = candidate->port + 1; | |
591 candidates = g_list_append(candidates, candidate); | |
592 | 597 |
593 purple_media_add_remote_candidates(jingle_rtp_get_media(session), | 598 purple_media_add_remote_candidates(jingle_rtp_get_media(session), |
594 jingle_content_get_name(content), | 599 jingle_content_get_name(content), |
595 jingle_session_get_remote_jid(session), | 600 jingle_session_get_remote_jid(session), |
596 candidates); | 601 candidates); |