comparison libpurple/protocols/jabber/jingle/rtp.c @ 24990:607d82dce00e

Have XMPP use the new ready signal.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Sun, 04 Jan 2009 09:56:54 +0000
parents 7caa7e2ce870
children b0e6a64cbf2e
comparison
equal deleted inserted replaced
24989:7caa7e2ce870 24990:607d82dce00e
162 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); 162 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
163 break; 163 break;
164 } 164 }
165 } 165 }
166 166
167 static gboolean
168 jingle_rtp_ready_to_initiate(JingleSession *session, PurpleMedia *media)
169 {
170 if (jingle_session_is_initiator(session)) {
171 GList *iter = jingle_session_get_contents(session);
172 for (; iter; iter = g_list_next(iter)) {
173 JingleContent *content = iter->data;
174 gchar *name = jingle_content_get_name(content);
175 if (!JINGLE_IS_RTP(content)
176 || JINGLE_RTP_GET_PRIVATE(content)->codecs_ready == FALSE
177 || JINGLE_RTP_GET_PRIVATE(content)->candidates_ready == FALSE) {
178 g_free(name);
179 return FALSE;
180 }
181 g_free(name);
182 }
183 return TRUE;
184 }
185 return FALSE;
186 }
187
188 gchar * 167 gchar *
189 jingle_rtp_get_media_type(JingleContent *content) 168 jingle_rtp_get_media_type(JingleContent *content)
190 { 169 {
191 gchar *media_type; 170 gchar *media_type;
192 g_object_get(content, "media-type", &media_type, NULL); 171 g_object_get(content, "media-type", &media_type, NULL);
326 305
327 JINGLE_RTP_GET_PRIVATE(content)->candidates_ready = TRUE; 306 JINGLE_RTP_GET_PRIVATE(content)->candidates_ready = TRUE;
328 307
329 jingle_content_set_pending_transport(content, transport); 308 jingle_content_set_pending_transport(content, transport);
330 jingle_content_accept_transport(content); 309 jingle_content_accept_transport(content);
331 310 }
332 if (jingle_rtp_ready_to_initiate(session, media)) { 311
312 static void
313 jingle_rtp_candidate_pair_established_cb(PurpleMedia *media, FsCandidate *local_candidate, FsCandidate *remote_candidate, JingleSession *session)
314 {
315
316 }
317
318 static void
319 jingle_rtp_ready_cb(PurpleMedia *media, gchar *sid, gchar *name, JingleSession *session)
320 {
321 purple_debug_info("rtp", "ready-new: session: %s name: %s\n", sid, name);
322
323 if (sid == NULL && name == NULL && jingle_session_is_initiator(session) == TRUE) {
324 GList *contents = jingle_session_get_contents(session);
325
333 jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_INITIATE)); 326 jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_INITIATE));
334 if (JINGLE_IS_ICEUDP(transport)) 327
335 jabber_iq_send(jingle_session_to_packet(session, JINGLE_TRANSPORT_INFO)); 328 for (; contents; contents = g_list_next(contents)) {
336 } 329 JingleContent *content = (JingleContent *)contents->data;
337 }
338
339 static void
340 jingle_rtp_candidate_pair_established_cb(PurpleMedia *media, FsCandidate *local_candidate, FsCandidate *remote_candidate, JingleSession *session)
341 {
342
343 }
344
345 static void
346 jingle_rtp_codecs_ready_cb(PurpleMedia *media, gchar *sid, JingleSession *session)
347 {
348 JingleContent *content = jingle_session_find_content(session, sid, "initiator");
349
350 if (content == NULL)
351 content = jingle_session_find_content(session, sid, "responder");
352
353 if (JINGLE_RTP_GET_PRIVATE(content)->codecs_ready == FALSE) {
354 JINGLE_RTP_GET_PRIVATE(content)->codecs_ready =
355 purple_media_codecs_ready(media, sid);
356
357 if (jingle_rtp_ready_to_initiate(session, media)) {
358 JingleTransport *transport = jingle_content_get_transport(content); 330 JingleTransport *transport = jingle_content_get_transport(content);
359 jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_INITIATE));
360 if (JINGLE_IS_ICEUDP(transport)) 331 if (JINGLE_IS_ICEUDP(transport))
361 jabber_iq_send(jingle_session_to_packet(session, JINGLE_TRANSPORT_INFO)); 332 jabber_iq_send(jingle_session_to_packet(session, JINGLE_TRANSPORT_INFO));
362 } 333 }
363 } 334 }
364 }
365
366 static void
367 jingle_rtp_ready_new_cb(PurpleMedia *media, gchar *sid, gchar *name, JingleSession *session) {
368 purple_debug_info("rtp", "ready-new: session: %s name: %s\n", sid, name);
369 } 335 }
370 336
371 static PurpleMedia * 337 static PurpleMedia *
372 jingle_rtp_create_media(JingleContent *content) 338 jingle_rtp_create_media(JingleContent *content)
373 { 339 {
405 G_CALLBACK(jingle_rtp_new_candidate_cb), session); 371 G_CALLBACK(jingle_rtp_new_candidate_cb), session);
406 g_signal_connect(G_OBJECT(media), "candidates-prepared", 372 g_signal_connect(G_OBJECT(media), "candidates-prepared",
407 G_CALLBACK(jingle_rtp_candidates_prepared_cb), session); 373 G_CALLBACK(jingle_rtp_candidates_prepared_cb), session);
408 g_signal_connect(G_OBJECT(media), "candidate-pair", 374 g_signal_connect(G_OBJECT(media), "candidate-pair",
409 G_CALLBACK(jingle_rtp_candidate_pair_established_cb), session); 375 G_CALLBACK(jingle_rtp_candidate_pair_established_cb), session);
410 g_signal_connect(G_OBJECT(media), "codecs-ready",
411 G_CALLBACK(jingle_rtp_codecs_ready_cb), session);
412 g_signal_connect(G_OBJECT(media), "ready-new", 376 g_signal_connect(G_OBJECT(media), "ready-new",
413 G_CALLBACK(jingle_rtp_ready_new_cb), session); 377 G_CALLBACK(jingle_rtp_ready_cb), session);
414 378
415 g_object_unref(session); 379 g_object_unref(session);
416 return media; 380 return media;
417 } 381 }
418 382