comparison libpurple/media/media.c @ 29556:74e75fc3481e

Move Farsight 2's new-active-candidate-pair into the Fs2 media backend.
author maiku@pidgin.im
date Mon, 26 Oct 2009 17:39:38 +0000
parents cc978a1a4bd1
children 1fdc75c94c22
comparison
equal deleted inserted replaced
29555:cc978a1a4bd1 29556:74e75fc3481e
141 static void purple_media_new_local_candidate_cb(PurpleMediaBackend *backend, 141 static void purple_media_new_local_candidate_cb(PurpleMediaBackend *backend,
142 const gchar *sess_id, const gchar *participant, 142 const gchar *sess_id, const gchar *participant,
143 PurpleMediaCandidate *candidate, PurpleMedia *media); 143 PurpleMediaCandidate *candidate, PurpleMedia *media);
144 static void purple_media_candidates_prepared_cb(FsStream *stream, 144 static void purple_media_candidates_prepared_cb(FsStream *stream,
145 PurpleMediaSession *session); 145 PurpleMediaSession *session);
146 static void purple_media_candidate_pair_established_cb(FsStream *stream, 146 static void purple_media_candidate_pair_established_cb(
147 FsCandidate *native_candidate, FsCandidate *remote_candidate, 147 PurpleMediaBackend *backend,
148 PurpleMediaSession *session); 148 const gchar *sess_id, const gchar *name,
149 PurpleMediaCandidate *local_candidate,
150 PurpleMediaCandidate *remote_candidate,
151 PurpleMedia *media);
149 static void purple_media_codecs_changed_cb(PurpleMediaBackend *backend, 152 static void purple_media_codecs_changed_cb(PurpleMediaBackend *backend,
150 const gchar *sess_id, PurpleMedia *media); 153 const gchar *sess_id, PurpleMedia *media);
151 static gboolean media_bus_call(GstBus *bus, 154 static gboolean media_bus_call(GstBus *bus,
152 GstMessage *msg, PurpleMedia *media); 155 GstMessage *msg, PurpleMedia *media);
153 156
440 "conference-type", 443 "conference-type",
441 media->priv->conference_type, 444 media->priv->conference_type,
442 "media", media, 445 "media", media,
443 NULL); 446 NULL);
444 g_signal_connect(media->priv->backend, 447 g_signal_connect(media->priv->backend,
448 "active-candidate-pair",
449 G_CALLBACK(
450 purple_media_candidate_pair_established_cb),
451 media);
452 g_signal_connect(media->priv->backend,
445 "codecs-changed", 453 "codecs-changed",
446 G_CALLBACK( 454 G_CALLBACK(
447 purple_media_codecs_changed_cb), 455 purple_media_codecs_changed_cb),
448 media); 456 media);
449 g_signal_connect(media->priv->backend, 457 g_signal_connect(media->priv->backend,
1070 if (gst_structure_has_name(msg->structure, 1078 if (gst_structure_has_name(msg->structure,
1071 "farsight-local-candidates-prepared")) { 1079 "farsight-local-candidates-prepared")) {
1072 FsStream *stream = g_value_get_object(gst_structure_get_value(msg->structure, "stream")); 1080 FsStream *stream = g_value_get_object(gst_structure_get_value(msg->structure, "stream"));
1073 PurpleMediaSession *session = purple_media_session_from_fs_stream(media, stream); 1081 PurpleMediaSession *session = purple_media_session_from_fs_stream(media, stream);
1074 purple_media_candidates_prepared_cb(stream, session); 1082 purple_media_candidates_prepared_cb(stream, session);
1075 } else if (gst_structure_has_name(msg->structure,
1076 "farsight-new-active-candidate-pair")) {
1077 FsStream *stream = g_value_get_object(gst_structure_get_value(msg->structure, "stream"));
1078 FsCandidate *local_candidate = g_value_get_boxed(gst_structure_get_value(msg->structure, "local-candidate"));
1079 FsCandidate *remote_candidate = g_value_get_boxed(gst_structure_get_value(msg->structure, "remote-candidate"));
1080 PurpleMediaSession *session = purple_media_session_from_fs_stream(media, stream);
1081 purple_media_candidate_pair_established_cb(stream, local_candidate, remote_candidate, session);
1082 } 1083 }
1083 break; 1084 break;
1084 } 1085 }
1085 default: 1086 default:
1086 break; 1087 break;
1295 } 1296 }
1296 1297
1297 /* callback called when a pair of transport candidates (local and remote) 1298 /* callback called when a pair of transport candidates (local and remote)
1298 * has been established */ 1299 * has been established */
1299 static void 1300 static void
1300 purple_media_candidate_pair_established_cb(FsStream *fsstream, 1301 purple_media_candidate_pair_established_cb(PurpleMediaBackend *backend,
1301 FsCandidate *native_candidate, 1302 const gchar *sess_id, const gchar *name,
1302 FsCandidate *remote_candidate, 1303 PurpleMediaCandidate *local_candidate,
1303 PurpleMediaSession *session) 1304 PurpleMediaCandidate *remote_candidate,
1304 { 1305 PurpleMedia *media)
1305 gchar *name; 1306 {
1306 FsParticipant *participant;
1307 PurpleMediaStream *stream; 1307 PurpleMediaStream *stream;
1308 GList *iter; 1308 GList *iter;
1309 1309 guint id;
1310 g_return_if_fail(FS_IS_STREAM(fsstream)); 1310
1311 g_return_if_fail(session != NULL); 1311 g_return_if_fail(PURPLE_IS_MEDIA(media));
1312 1312
1313 g_object_get(fsstream, "participant", &participant, NULL); 1313 stream = purple_media_get_stream(media, sess_id, name);
1314 g_object_get(participant, "cname", &name, NULL); 1314 id = purple_media_candidate_get_component_id(local_candidate);
1315 g_object_unref(participant);
1316
1317 stream = purple_media_get_stream(session->media, session->id, name);
1318 1315
1319 iter = stream->active_local_candidates; 1316 iter = stream->active_local_candidates;
1320 for(; iter; iter = g_list_next(iter)) { 1317 for(; iter; iter = g_list_next(iter)) {
1321 FsCandidate *c = iter->data; 1318 FsCandidate *c = iter->data;
1322 if (native_candidate->component_id == c->component_id) { 1319 if (id == c->component_id) {
1323 fs_candidate_destroy(c); 1320 fs_candidate_destroy(c);
1324 stream->active_local_candidates = 1321 stream->active_local_candidates =
1325 g_list_delete_link(iter, iter); 1322 g_list_delete_link(iter, iter);
1326 stream->active_local_candidates = g_list_prepend( 1323 stream->active_local_candidates = g_list_prepend(
1327 stream->active_local_candidates, 1324 stream->active_local_candidates,
1328 fs_candidate_copy(native_candidate)); 1325 purple_media_candidate_to_fs(
1326 local_candidate));
1329 break; 1327 break;
1330 } 1328 }
1331 } 1329 }
1332 if (iter == NULL) 1330 if (iter == NULL)
1333 stream->active_local_candidates = g_list_prepend( 1331 stream->active_local_candidates = g_list_prepend(
1334 stream->active_local_candidates, 1332 stream->active_local_candidates,
1335 fs_candidate_copy(native_candidate)); 1333 purple_media_candidate_to_fs(
1334 local_candidate));
1335
1336 id = purple_media_candidate_get_component_id(local_candidate);
1336 1337
1337 iter = stream->active_remote_candidates; 1338 iter = stream->active_remote_candidates;
1338 for(; iter; iter = g_list_next(iter)) { 1339 for(; iter; iter = g_list_next(iter)) {
1339 FsCandidate *c = iter->data; 1340 FsCandidate *c = iter->data;
1340 if (native_candidate->component_id == c->component_id) { 1341 if (id == c->component_id) {
1341 fs_candidate_destroy(c); 1342 fs_candidate_destroy(c);
1342 stream->active_remote_candidates = 1343 stream->active_remote_candidates =
1343 g_list_delete_link(iter, iter); 1344 g_list_delete_link(iter, iter);
1344 stream->active_remote_candidates = g_list_prepend( 1345 stream->active_remote_candidates = g_list_prepend(
1345 stream->active_remote_candidates, 1346 stream->active_remote_candidates,
1346 fs_candidate_copy(remote_candidate)); 1347 purple_media_candidate_to_fs(
1348 remote_candidate));
1347 break; 1349 break;
1348 } 1350 }
1349 } 1351 }
1350 if (iter == NULL) 1352 if (iter == NULL)
1351 stream->active_remote_candidates = g_list_prepend( 1353 stream->active_remote_candidates = g_list_prepend(
1352 stream->active_remote_candidates, 1354 stream->active_remote_candidates,
1353 fs_candidate_copy(remote_candidate)); 1355 purple_media_candidate_to_fs(
1356 remote_candidate));
1354 1357
1355 purple_debug_info("media", "candidate pair established\n"); 1358 purple_debug_info("media", "candidate pair established\n");
1356 } 1359 }
1357 1360
1358 static void 1361 static void