Mercurial > pidgin
comparison libpurple/protocols/jabber/jingle.c @ 23823:9983353706b8
merge of '3969ff3f40069748728f9ee2376a4bab3f089d04'
and 'f284e82ae268ed7050aba789e9bbb15885d4fb6a'
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Fri, 06 Jun 2008 08:26:57 +0000 |
parents | 12a16471f94e a7be3074923b |
children | bfaad8393463 |
comparison
equal
deleted
inserted
replaced
23821:12a16471f94e | 23823:9983353706b8 |
---|---|
748 JingleSessionContent *jsc = contents->data; | 748 JingleSessionContent *jsc = contents->data; |
749 GList *candidates = purple_media_get_local_candidates( | 749 GList *candidates = purple_media_get_local_candidates( |
750 media, | 750 media, |
751 jabber_jingle_session_content_get_name(jsc), | 751 jabber_jingle_session_content_get_name(jsc), |
752 jabber_jingle_session_get_remote_jid(session)); | 752 jabber_jingle_session_get_remote_jid(session)); |
753 purple_debug_info("jabber", | 753 purple_debug_info("jingle", |
754 "jabber_session_candidates_prepared: %d candidates\n", | 754 "jabber_session_candidates_prepared: %d candidates\n", |
755 g_list_length(candidates)); | 755 g_list_length(candidates)); |
756 for (; candidates; candidates = candidates->next) { | 756 for (; candidates; candidates = candidates->next) { |
757 FsCandidate *candidate = candidates->data; | 757 FsCandidate *candidate = candidates->data; |
758 JabberIq *result = jabber_jingle_session_create_transport_info(jsc, | 758 JabberIq *result = jabber_jingle_session_create_transport_info(jsc, |
771 jabber_jingle_session_content_get_name(jsc), | 771 jabber_jingle_session_content_get_name(jsc), |
772 jabber_jingle_session_get_remote_jid(session)))); | 772 jabber_jingle_session_get_remote_jid(session)))); |
773 } | 773 } |
774 | 774 |
775 | 775 |
776 purple_debug_info("jabber", "Sent session accept, starting stream\n"); | 776 purple_debug_info("jingle", "Sent session accept, starting stream\n"); |
777 gst_element_set_state(purple_media_get_pipeline(session->media), GST_STATE_PLAYING); | 777 gst_element_set_state(purple_media_get_pipeline(session->media), GST_STATE_PLAYING); |
778 | 778 |
779 session->session_started = TRUE; | 779 session->session_started = TRUE; |
780 } | 780 } |
781 | 781 |
854 GList *contents = jabber_jingle_session_get_contents(session); | 854 GList *contents = jabber_jingle_session_get_contents(session); |
855 for (; contents; contents = contents->next) { | 855 for (; contents; contents = contents->next) { |
856 JingleSessionContent *jsc = contents->data; | 856 JingleSessionContent *jsc = contents->data; |
857 GList *candidates = purple_media_get_local_audio_candidates( | 857 GList *candidates = purple_media_get_local_audio_candidates( |
858 jabber_jingle_session_get_media(session)); | 858 jabber_jingle_session_get_media(session)); |
859 purple_debug_info("jabber", | 859 purple_debug_info("jingle", |
860 "jabber_session_candidates_prepared: %d candidates\n", | 860 "jabber_session_candidates_prepared: %d candidates\n", |
861 g_list_length(candidates)); | 861 g_list_length(candidates)); |
862 for (; candidates; candidates = candidates->next) { | 862 for (; candidates; candidates = candidates->next) { |
863 FsCandidate *candidate = candidates->data; | 863 FsCandidate *candidate = candidates->data; |
864 JabberIq *result = jabber_jingle_session_create_transport_info(jsc, | 864 JabberIq *result = jabber_jingle_session_create_transport_info(jsc, |
878 FsCandidate *native_candidate, | 878 FsCandidate *native_candidate, |
879 FsCandidate *remote_candidate, | 879 FsCandidate *remote_candidate, |
880 JingleSession *session) | 880 JingleSession *session) |
881 { | 881 { |
882 #if 0 | 882 #if 0 |
883 purple_debug_info("jabber", "jabber_candidate_pair_established called\n"); | 883 purple_debug_info("jingle", "jabber_candidate_pair_established called\n"); |
884 /* if we are the responder, we should send a sesson-accept message */ | 884 /* if we are the responder, we should send a sesson-accept message */ |
885 if (!jabber_jingle_session_is_initiator(session) && | 885 if (!jabber_jingle_session_is_initiator(session) && |
886 !session->session_started) { | 886 !session->session_started) { |
887 jabber_iq_send(jabber_jingle_session_create_session_accept(session, | 887 jabber_iq_send(jabber_jingle_session_create_session_accept(session, |
888 native_candidate, remote_candidate)); | 888 native_candidate, remote_candidate)); |
900 | 900 |
901 media = purple_media_manager_create_media(purple_media_manager_get(), | 901 media = purple_media_manager_create_media(purple_media_manager_get(), |
902 session->js->gc, "fsrtpconference", remote_jid); | 902 session->js->gc, "fsrtpconference", remote_jid); |
903 | 903 |
904 if (!media) { | 904 if (!media) { |
905 purple_debug_error("jabber", "Couldn't create fsrtpconference\n"); | 905 purple_debug_error("jingle", "Couldn't create fsrtpconference\n"); |
906 return FALSE; | 906 return FALSE; |
907 } | 907 } |
908 | 908 |
909 for (; contents; contents = contents->next) { | 909 for (; contents; contents = contents->next) { |
910 JingleSessionContent *jsc = contents->data; | 910 JingleSessionContent *jsc = contents->data; |
921 PURPLE_MEDIA_VIDEO, "rawudp"); | 921 PURPLE_MEDIA_VIDEO, "rawudp"); |
922 purple_debug_info("jingle", "Created Jingle video session\n"); | 922 purple_debug_info("jingle", "Created Jingle video session\n"); |
923 } | 923 } |
924 | 924 |
925 if (!result) { | 925 if (!result) { |
926 purple_debug_error("jabber", "Couldn't create stream\n"); | 926 purple_debug_error("jingle", "Couldn't create stream\n"); |
927 purple_media_reject(media); | 927 purple_media_reject(media); |
928 return FALSE; | 928 return FALSE; |
929 } | 929 } |
930 } | 930 } |
931 g_list_free(contents); | 931 g_list_free(contents); |
976 JingleSessionContent *jsc = contents->data; | 976 JingleSessionContent *jsc = contents->data; |
977 GList *candidates = purple_media_get_local_candidates( | 977 GList *candidates = purple_media_get_local_candidates( |
978 jabber_jingle_session_get_media(session), | 978 jabber_jingle_session_get_media(session), |
979 jabber_jingle_session_content_get_name(jsc), | 979 jabber_jingle_session_content_get_name(jsc), |
980 jabber_jingle_session_get_remote_jid(session)); | 980 jabber_jingle_session_get_remote_jid(session)); |
981 purple_debug_info("jabber", | 981 purple_debug_info("jingle", |
982 "jabber_session_candidates_prepared: %d candidates\n", | 982 "jabber_session_candidates_prepared: %d candidates\n", |
983 g_list_length(candidates)); | 983 g_list_length(candidates)); |
984 for (; candidates; candidates = candidates->next) { | 984 for (; candidates; candidates = candidates->next) { |
985 FsCandidate *candidate = candidates->data; | 985 FsCandidate *candidate = candidates->data; |
986 JabberIq *result = jabber_jingle_session_create_transport_info(jsc, | 986 JabberIq *result = jabber_jingle_session_create_transport_info(jsc, |
1004 char *jid = NULL, *me = NULL; | 1004 char *jid = NULL, *me = NULL; |
1005 | 1005 |
1006 /* construct JID to send to */ | 1006 /* construct JID to send to */ |
1007 jb = jabber_buddy_find(js, who, FALSE); | 1007 jb = jabber_buddy_find(js, who, FALSE); |
1008 if (!jb) { | 1008 if (!jb) { |
1009 purple_debug_error("jabber", "Could not find Jabber buddy\n"); | 1009 purple_debug_error("jingle", "Could not find Jabber buddy\n"); |
1010 return NULL; | 1010 return NULL; |
1011 } | 1011 } |
1012 jbr = jabber_buddy_find_resource(jb, NULL); | 1012 jbr = jabber_buddy_find_resource(jb, NULL); |
1013 if (!jbr) { | 1013 if (!jbr) { |
1014 purple_debug_error("jabber", "Could not find buddy's resource\n"); | 1014 purple_debug_error("jingle", "Could not find buddy's resource\n"); |
1015 } | 1015 } |
1016 | 1016 |
1017 if ((strchr(who, '/') == NULL) && jbr && (jbr->name != NULL)) { | 1017 if ((strchr(who, '/') == NULL) && jbr && (jbr->name != NULL)) { |
1018 jid = g_strdup_printf("%s/%s", who, jbr->name); | 1018 jid = g_strdup_printf("%s/%s", who, jbr->name); |
1019 } else { | 1019 } else { |
1125 content = xmlnode_get_next_twin(content)) { | 1125 content = xmlnode_get_next_twin(content)) { |
1126 description = xmlnode_get_child(content, "description"); | 1126 description = xmlnode_get_child(content, "description"); |
1127 transport = xmlnode_get_child(content, "transport"); | 1127 transport = xmlnode_get_child(content, "transport"); |
1128 | 1128 |
1129 /* fetch codecs from remote party */ | 1129 /* fetch codecs from remote party */ |
1130 purple_debug_info("jabber", "get codecs from session-accept\n"); | 1130 purple_debug_info("jingle", "get codecs from session-accept\n"); |
1131 remote_codecs = jabber_jingle_get_codecs(description); | 1131 remote_codecs = jabber_jingle_get_codecs(description); |
1132 purple_debug_info("jabber", "get transport candidates from session accept\n"); | 1132 purple_debug_info("jingle", "get transport candidates from session accept\n"); |
1133 remote_transports = jabber_jingle_get_candidates(transport); | 1133 remote_transports = jabber_jingle_get_candidates(transport); |
1134 | 1134 |
1135 purple_debug_info("jabber", "Got %d codecs from responder\n", | 1135 purple_debug_info("jingle", "Got %d codecs from responder\n", |
1136 g_list_length(remote_codecs)); | 1136 g_list_length(remote_codecs)); |
1137 purple_debug_info("jabber", "Got %d transport candidates from responder\n", | 1137 purple_debug_info("jingle", "Got %d transport candidates from responder\n", |
1138 g_list_length(remote_transports)); | 1138 g_list_length(remote_transports)); |
1139 | 1139 |
1140 purple_debug_info("jabber", "Setting remote codecs on stream\n"); | 1140 purple_debug_info("jingle", "Setting remote codecs on stream\n"); |
1141 | 1141 |
1142 purple_media_set_remote_codecs(session->media, | 1142 purple_media_set_remote_codecs(session->media, |
1143 xmlnode_get_attrib(content, "name"), | 1143 xmlnode_get_attrib(content, "name"), |
1144 jabber_jingle_session_get_remote_jid(session), | 1144 jabber_jingle_session_get_remote_jid(session), |
1145 remote_codecs); | 1145 remote_codecs); |
1146 | 1146 |
1147 codec_intersection = purple_media_get_negotiated_codecs(session->media, | 1147 codec_intersection = purple_media_get_negotiated_codecs(session->media, |
1148 xmlnode_get_attrib(content, "name")); | 1148 xmlnode_get_attrib(content, "name")); |
1149 purple_debug_info("jabber", "codec_intersection contains %d elems\n", | 1149 purple_debug_info("jingle", "codec_intersection contains %d elems\n", |
1150 g_list_length(codec_intersection)); | 1150 g_list_length(codec_intersection)); |
1151 /* get the top codec */ | 1151 /* get the top codec */ |
1152 if (g_list_length(codec_intersection) > 0) { | 1152 if (g_list_length(codec_intersection) > 0) { |
1153 top = (FsCodec *) codec_intersection->data; | 1153 top = (FsCodec *) codec_intersection->data; |
1154 purple_debug_info("jabber", "Found a suitable codec on stream = %d\n", | 1154 purple_debug_info("jingle", "Found a suitable codec on stream = %d\n", |
1155 top->id); | 1155 top->id); |
1156 | 1156 |
1157 /* we have found a suitable codec, but we will not start the stream | 1157 /* we have found a suitable codec, but we will not start the stream |
1158 just yet, wait for transport negotiation to complete... */ | 1158 just yet, wait for transport negotiation to complete... */ |
1159 } | 1159 } |
1178 | 1178 |
1179 } | 1179 } |
1180 | 1180 |
1181 if (!strcmp(action, "session-accept")) { | 1181 if (!strcmp(action, "session-accept")) { |
1182 purple_media_got_accept(jabber_jingle_session_get_media(session)); | 1182 purple_media_got_accept(jabber_jingle_session_get_media(session)); |
1183 purple_debug_info("jabber", "Got session-accept, starting stream\n"); | 1183 purple_debug_info("jingle", "Got session-accept, starting stream\n"); |
1184 gst_element_set_state(purple_media_get_pipeline(session->media), | 1184 gst_element_set_state(purple_media_get_pipeline(session->media), |
1185 GST_STATE_PLAYING); | 1185 GST_STATE_PLAYING); |
1186 } | 1186 } |
1187 | 1187 |
1188 jabber_iq_send(result); | 1188 jabber_iq_send(result); |
1208 const char *sid = NULL; | 1208 const char *sid = NULL; |
1209 const char *initiator = NULL; | 1209 const char *initiator = NULL; |
1210 GList *codecs = NULL; | 1210 GList *codecs = NULL; |
1211 | 1211 |
1212 if (!jingle) { | 1212 if (!jingle) { |
1213 purple_debug_error("jabber", "Malformed request"); | 1213 purple_debug_error("jingle", "Malformed request"); |
1214 return; | 1214 return; |
1215 } | 1215 } |
1216 | 1216 |
1217 sid = xmlnode_get_attrib(jingle, "sid"); | 1217 sid = xmlnode_get_attrib(jingle, "sid"); |
1218 initiator = xmlnode_get_attrib(jingle, "initiator"); | 1218 initiator = xmlnode_get_attrib(jingle, "initiator"); |
1219 | 1219 |
1220 if (jabber_jingle_session_find_by_id(js, sid)) { | 1220 if (jabber_jingle_session_find_by_id(js, sid)) { |
1221 /* This should only happen if you start a session with yourself */ | 1221 /* This should only happen if you start a session with yourself */ |
1222 purple_debug_error("jabber", "Jingle session with id={%s} already exists\n", sid); | 1222 purple_debug_error("jingle", "Jingle session with id={%s} already exists\n", sid); |
1223 return; | 1223 return; |
1224 } | 1224 } |
1225 | 1225 |
1226 session = jabber_jingle_session_create_by_id(js, sid); | 1226 session = jabber_jingle_session_create_by_id(js, sid); |
1227 | 1227 |
1228 for (content = xmlnode_get_child(jingle, "content"); content; | 1228 for (content = xmlnode_get_child(jingle, "content"); content; |
1229 content = xmlnode_get_next_twin(content)) { | 1229 content = xmlnode_get_next_twin(content)) { |
1230 /* init media */ | 1230 /* init media */ |
1231 if (!content) { | 1231 if (!content) { |
1232 purple_debug_error("jabber", "jingle tag must contain content tag\n"); | 1232 purple_debug_error("jingle", "jingle tag must contain content tag\n"); |
1233 /* should send error here */ | 1233 /* should send error here */ |
1234 return; | 1234 return; |
1235 } | 1235 } |
1236 | 1236 |
1237 description = xmlnode_get_child(content, "description"); | 1237 description = xmlnode_get_child(content, "description"); |
1238 | 1238 |
1239 if (!description) { | 1239 if (!description) { |
1240 purple_debug_error("jabber", "content tag must contain description tag\n"); | 1240 purple_debug_error("jingle", "content tag must contain description tag\n"); |
1241 /* we should create an error iq here */ | 1241 /* we should create an error iq here */ |
1242 return; | 1242 return; |
1243 } | 1243 } |
1244 | 1244 |
1245 transport = xmlnode_get_child(content, "transport"); | 1245 transport = xmlnode_get_child(content, "transport"); |
1252 | 1252 |
1253 jabber_jingle_session_content_create_parse(session, content); | 1253 jabber_jingle_session_content_create_parse(session, content); |
1254 } | 1254 } |
1255 | 1255 |
1256 if (!jabber_jingle_session_initiate_media_internal(session, initiator, initiator)) { | 1256 if (!jabber_jingle_session_initiate_media_internal(session, initiator, initiator)) { |
1257 purple_debug_error("jabber", "Couldn't start media session with %s\n", initiator); | 1257 purple_debug_error("jingle", "Couldn't start media session with %s\n", initiator); |
1258 jabber_jingle_session_destroy(session); | 1258 jabber_jingle_session_destroy(session); |
1259 /* we should create an error iq here */ | 1259 /* we should create an error iq here */ |
1260 return; | 1260 return; |
1261 } | 1261 } |
1262 | 1262 |
1263 for (content = xmlnode_get_child(jingle, "content"); content; | 1263 for (content = xmlnode_get_child(jingle, "content"); content; |
1264 content = xmlnode_get_next_twin(content)) { | 1264 content = xmlnode_get_next_twin(content)) { |
1265 /* init media */ | 1265 /* init media */ |
1266 if (!content) { | 1266 if (!content) { |
1267 purple_debug_error("jabber", "jingle tag must contain content tag\n"); | 1267 purple_debug_error("jingle", "jingle tag must contain content tag\n"); |
1268 /* should send error here */ | 1268 /* should send error here */ |
1269 return; | 1269 return; |
1270 } | 1270 } |
1271 | 1271 |
1272 description = xmlnode_get_child(content, "description"); | 1272 description = xmlnode_get_child(content, "description"); |
1273 | 1273 |
1274 if (!description) { | 1274 if (!description) { |
1275 purple_debug_error("jabber", "content tag must contain description tag\n"); | 1275 purple_debug_error("jingle", "content tag must contain description tag\n"); |
1276 /* we should create an error iq here */ | 1276 /* we should create an error iq here */ |
1277 return; | 1277 return; |
1278 } | 1278 } |
1279 codecs = jabber_jingle_get_codecs(description); | 1279 codecs = jabber_jingle_get_codecs(description); |
1280 | 1280 |
1295 xmlnode *jingle = xmlnode_get_child(packet, "jingle"); | 1295 xmlnode *jingle = xmlnode_get_child(packet, "jingle"); |
1296 const char *sid = xmlnode_get_attrib(jingle, "sid"); | 1296 const char *sid = xmlnode_get_attrib(jingle, "sid"); |
1297 JingleSession *session = jabber_jingle_session_find_by_id(js, sid); | 1297 JingleSession *session = jabber_jingle_session_find_by_id(js, sid); |
1298 | 1298 |
1299 if (!session) { | 1299 if (!session) { |
1300 purple_debug_error("jabber", "jabber_handle_session_terminate couldn't find session\n"); | 1300 purple_debug_error("jingle", "jabber_handle_session_terminate couldn't find session\n"); |
1301 return; | 1301 return; |
1302 } | 1302 } |
1303 | 1303 |
1304 /* maybe we should look at the reasoncode to determine if it was | 1304 /* maybe we should look at the reasoncode to determine if it was |
1305 a hangup or a reject, and call different callbacks to purple_media */ | 1305 a hangup or a reject, and call different callbacks to purple_media */ |
1320 GList *remote_candidates = jabber_jingle_get_candidates(transport); | 1320 GList *remote_candidates = jabber_jingle_get_candidates(transport); |
1321 const char *sid = xmlnode_get_attrib(jingle, "sid"); | 1321 const char *sid = xmlnode_get_attrib(jingle, "sid"); |
1322 JingleSession *session = jabber_jingle_session_find_by_id(js, sid); | 1322 JingleSession *session = jabber_jingle_session_find_by_id(js, sid); |
1323 | 1323 |
1324 if (!session) | 1324 if (!session) |
1325 purple_debug_error("jabber", "jabber_handle_session_candidates couldn't find session\n"); | 1325 purple_debug_error("jingle", "jabber_handle_session_candidates couldn't find session\n"); |
1326 | 1326 |
1327 /* send acknowledement */ | 1327 /* send acknowledement */ |
1328 xmlnode_set_attrib(result->node, "id", xmlnode_get_attrib(packet, "id")); | 1328 xmlnode_set_attrib(result->node, "id", xmlnode_get_attrib(packet, "id")); |
1329 xmlnode_set_attrib(result->node, "to", xmlnode_get_attrib(packet, "from")); | 1329 xmlnode_set_attrib(result->node, "to", xmlnode_get_attrib(packet, "from")); |
1330 jabber_iq_send(result); | 1330 jabber_iq_send(result); |