Changeset 311:a3c7985aa266 in mediastreamer2 for linphone/mediastreamer2/src/ice.c
- Timestamp:
- Mar 9, 2009 12:12:59 PM (4 years ago)
- Branch:
- default
- File:
-
- 1 edited
-
linphone/mediastreamer2/src/ice.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
linphone/mediastreamer2/src/ice.c
r310 r311 26 26 #endif 27 27 28 #include "mediastreamer2/msticker.h" 28 29 #include "mediastreamer2/ice.h" 29 30 #include "mediastreamer2/mscommon.h" 30 31 31 32 #include <math.h> 32 33 static void34 ice_sendtest( struct IceCheckList *checklist, struct CandidatePair *remote_candidate, Socket myFd, StunAddress4 *dest,35 const StunAtrString *username, const StunAtrString *password,36 UInt96 *tid);37 33 38 34 static void … … 83 79 } 84 80 85 int ice_restart(struct IceCheckList *checklist)81 static int ice_restart(struct IceCheckList *checklist) 86 82 { 87 83 struct CandidatePair *remote_candidates = NULL; … … 149 145 } 150 146 151 int ice_sound_send_stun_request(RtpSession *session, struct IceCheckList *checklist, uint64_t ctime)147 static int ice_sound_send_stun_request(RtpSession *session, struct IceCheckList *checklist, uint64_t ctime) 152 148 { 153 149 struct CandidatePair *remote_candidates = NULL; … … 477 473 } 478 474 479 int ice_process_stun_message(RtpSession *session, struct IceCheckList *checklist, OrtpEvent *evt)475 static int ice_process_stun_message(RtpSession *session, struct IceCheckList *checklist, OrtpEvent *evt) 480 476 { 481 477 struct CandidatePair *remote_candidates = NULL; … … 1216 1212 } 1217 1213 1214 1215 1216 1217 struct IceData { 1218 RtpSession *session; 1219 OrtpEvQueue *ortp_event; 1220 struct IceCheckList *check_lists; /* table of 10 cpair */ 1221 int rate; 1222 }; 1223 1224 typedef struct IceData IceData; 1225 1226 static void ice_init(MSFilter * f) 1227 { 1228 IceData *d = (IceData *)ms_new(IceData, 1); 1229 1230 d->ortp_event = ortp_ev_queue_new(); 1231 d->session = NULL; 1232 d->check_lists = NULL; 1233 d->rate = 8000; 1234 f->data = d; 1235 } 1236 1237 static void ice_postprocess(MSFilter * f) 1238 { 1239 IceData *d = (IceData *) f->data; 1240 if (d->session!=NULL && d->ortp_event!=NULL) 1241 rtp_session_unregister_event_queue(d->session, d->ortp_event); 1242 } 1243 1244 static void ice_uninit(MSFilter * f) 1245 { 1246 IceData *d = (IceData *) f->data; 1247 if (d->ortp_event!=NULL) 1248 ortp_ev_queue_destroy(d->ortp_event); 1249 ms_free(f->data); 1250 } 1251 1252 static int ice_set_session(MSFilter * f, void *arg) 1253 { 1254 IceData *d = (IceData *) f->data; 1255 RtpSession *s = (RtpSession *) arg; 1256 PayloadType *pt = rtp_profile_get_payload(rtp_session_get_profile(s), 1257 rtp_session_get_recv_payload_type 1258 (s)); 1259 if (pt != NULL) { 1260 if (strcasecmp("g722", pt->mime_type)==0 ) 1261 d->rate=8000; 1262 else d->rate = pt->clock_rate; 1263 } else { 1264 ms_warning("Receiving undefined payload type ?"); 1265 } 1266 d->session = s; 1267 1268 return 0; 1269 } 1270 1271 static int ice_set_sdpcandidates(MSFilter * f, void *arg) 1272 { 1273 IceData *d = (IceData *) f->data; 1274 struct IceCheckList *scs = NULL; 1275 1276 if (d == NULL) 1277 return -1; 1278 1279 scs = (struct IceCheckList *) arg; 1280 d->check_lists = scs; 1281 ice_restart(d->check_lists); 1282 return 0; 1283 } 1284 1285 static void ice_preprocess(MSFilter * f){ 1286 IceData *d = (IceData *) f->data; 1287 if (d->session!=NULL && d->ortp_event!=NULL) 1288 rtp_session_register_event_queue(d->session, d->ortp_event); 1289 } 1290 1291 static void ice_process(MSFilter * f) 1292 { 1293 IceData *d = (IceData *) f->data; 1294 1295 if (d->session == NULL) 1296 return; 1297 1298 /* check received STUN request */ 1299 if (d->ortp_event!=NULL) 1300 { 1301 OrtpEvent *evt = ortp_ev_queue_get(d->ortp_event); 1302 1303 while (evt != NULL) { 1304 if (ortp_event_get_type(evt) == 1305 ORTP_EVENT_STUN_PACKET_RECEIVED) { 1306 ice_process_stun_message(d->session, d->check_lists, evt); 1307 } 1308 if (ortp_event_get_type(evt) == 1309 ORTP_EVENT_TELEPHONE_EVENT) { 1310 } 1311 1312 ortp_event_destroy(evt); 1313 evt = ortp_ev_queue_get(d->ortp_event); 1314 } 1315 } 1316 1317 #if !defined(_WIN32_WCE) 1318 ice_sound_send_stun_request(d->session, d->check_lists, f->ticker->time); 1319 #else 1320 ice_sound_send_stun_request(d->session, d->check_lists, f->ticker->time)); 1321 #endif 1322 } 1323 1324 static MSFilterMethod ice_methods[] = { 1325 {MS_ICE_SET_SESSION, ice_set_session}, 1326 {MS_ICE_SET_CANDIDATEPAIRS, ice_set_sdpcandidates}, 1327 {0, NULL} 1328 }; 1329 1330 #ifdef _MSC_VER 1331 1332 MSFilterDesc ms_ice_desc = { 1333 MS_ICE_ID, 1334 "MSIce", 1335 N_("ICE filter"), 1336 MS_FILTER_OTHER, 1337 NULL, 1338 0, 1339 0, 1340 ice_init, 1341 ice_preprocess, 1342 ice_process, 1343 ice_postprocess, 1344 ice_uninit, 1345 ice_methods 1346 }; 1347 1348 #else 1349 1350 MSFilterDesc ms_ice_desc = { 1351 .id = MS_ICE_ID, 1352 .name = "MSIce", 1353 .text = N_("ICE filter"), 1354 .category = MS_FILTER_OTHER, 1355 .ninputs = 0, 1356 .noutputs = 0, 1357 .init = ice_init, 1358 .preprocess = ice_preprocess, 1359 .process = ice_process, 1360 .postprocess=ice_postprocess, 1361 .uninit = ice_uninit, 1362 .methods = ice_methods 1363 }; 1364 1365 #endif 1366 1367 MS_FILTER_DESC_EXPORT(ms_ice_desc)
Note: See TracChangeset
for help on using the changeset viewer.
