Changeset 311:a3c7985aa266 in mediastreamer2
- Timestamp:
- Mar 9, 2009 12:12:59 PM (4 years ago)
- Branch:
- default
- Location:
- linphone/mediastreamer2
- Files:
-
- 8 edited
-
build/win32native/alldescs.h (modified) (2 diffs)
-
build/win32native/mediastreamer2.def (modified) (1 diff)
-
include/mediastreamer2/allfilters.h (modified) (1 diff)
-
include/mediastreamer2/ice.h (modified) (2 diffs)
-
include/mediastreamer2/msrtp.h (modified) (1 diff)
-
src/ice.c (modified) (5 diffs)
-
src/msfilter.c (modified) (1 diff)
-
src/msrtp.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
linphone/mediastreamer2/build/win32native/alldescs.h
r102 r311 43 43 extern MSFilterDesc ms_mire_desc; 44 44 extern MSFilterDesc ms_vfw_desc; 45 extern MSFilterDesc ms_ice_desc; 45 46 MSFilterDesc * ms_filter_descs[]={ 46 47 &ms_alaw_dec_desc, … … 88 89 &ms_mire_desc, 89 90 &ms_vfw_desc, 91 &ms_ice_desc, 90 92 NULL 91 93 }; -
linphone/mediastreamer2/build/win32native/mediastreamer2.def
r254 r311 90 90 ms_list_remove 91 91 92 ice_sound_send_stun_request93 ice_process_stun_message94 95 92 ms_discover_mtu 96 93 ms_set_mtu -
linphone/mediastreamer2/include/mediastreamer2/allfilters.h
r102 r311 81 81 MS_H263_OLD_ENC_ID, 82 82 MS_MIRE_ID, 83 MS_VFW_ID 83 MS_VFW_ID, 84 MS_ICE_ID 84 85 } MSFilterId; 85 86 -
linphone/mediastreamer2/include/mediastreamer2/ice.h
r298 r311 21 21 #define ice_hh 22 22 23 #include "msfilter.h" 23 24 #include "ortp/stun_udp.h" 24 25 #include "ortp/stun.h" … … 88 89 }; 89 90 90 #ifdef __cplusplus 91 extern "C"{ 92 #endif 91 #define MS_ICE_SET_SESSION MS_FILTER_METHOD(MS_ICE_ID,0,RtpSession*) 92 #define MS_ICE_SET_CANDIDATEPAIRS MS_FILTER_METHOD(MS_ICE_ID,1,struct CandidatePair*) 93 93 94 int ice_sound_send_stun_request(RtpSession *session, struct IceCheckList *checklist, uint64_t ctime); 95 96 int ice_process_stun_message(RtpSession *session, struct IceCheckList *checklist, OrtpEvent *evt); 97 98 int ice_restart(struct IceCheckList *checklist); 99 100 #ifdef __cplusplus 101 } 102 #endif 94 extern MSFilterDesc ms_ice_desc; 103 95 104 96 #endif -
linphone/mediastreamer2/include/mediastreamer2/msrtp.h
r0 r311 32 32 #define MS_RTP_SEND_SEND_DTMF MS_FILTER_METHOD(MS_RTP_SEND_ID,1,const char) 33 33 34 #define MS_RTP_RECV_SET_CANDIDATEPAIRS MS_FILTER_METHOD(MS_RTP_RECV_ID,1,struct CandidatePair*)35 36 #define MS_RTP_SEND_SET_CANDIDATEPAIRS MS_FILTER_METHOD(MS_RTP_SEND_ID,2,struct CandidatePair*)37 38 34 #define MS_RTP_SEND_MUTE_MIC MS_FILTER_METHOD_NO_ARG(MS_RTP_SEND_ID,3) 39 35 -
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) -
linphone/mediastreamer2/src/msfilter.c
r0 r311 84 84 if (desc->ninputs>0) obj->inputs=(MSQueue**)ms_new0(MSQueue*,desc->ninputs); 85 85 if (desc->noutputs>0) obj->outputs=(MSQueue**)ms_new0(MSQueue*,desc->noutputs); 86 if (desc->ninputs==0 && desc->noutputs==0)87 ms_fatal("A filter cannot have no inputs and outputs");88 86 if (obj->desc->init!=NULL) 89 87 obj->desc->init(obj); -
linphone/mediastreamer2/src/msrtp.c
r298 r311 30 30 struct SenderData { 31 31 RtpSession *session; 32 struct IceCheckList *check_lists; /* table of 10 cpair */33 32 uint32_t tsoff; 34 33 uint32_t skip_until; … … 49 48 50 49 d->session = NULL; 51 d->check_lists = NULL;52 50 d->tsoff = 0; 53 51 d->skip_until = 0; … … 76 74 d->dtmf = dtmf[0]; 77 75 ms_filter_unlock(f); 78 return 0;79 }80 81 static int sender_set_sdpcandidates(MSFilter * f, void *arg)82 {83 SenderData *d = (SenderData *) f->data;84 struct IceCheckList *scs = NULL;85 86 if (d == NULL)87 return -1;88 89 scs = (struct IceCheckList *) arg;90 d->check_lists = scs;91 ice_restart(d->check_lists);92 76 return 0; 93 77 } … … 179 163 RtpSession *s = d->session; 180 164 181 struct IceCheckList *cp = d->check_lists;182 165 mblk_t *im; 183 166 uint32_t timestamp; … … 231 214 ms_filter_unlock(f); 232 215 } 233 234 #if !defined(_WIN32_WCE)235 ice_sound_send_stun_request(s, cp, f->ticker->time);236 #else237 ice_sound_send_stun_request(s, cp, f->ticker->time));238 #endif239 216 } 240 217 … … 244 221 {MS_RTP_SEND_SET_SESSION, sender_set_session}, 245 222 {MS_RTP_SEND_SEND_DTMF, sender_send_dtmf}, 246 {MS_RTP_SEND_SET_CANDIDATEPAIRS, sender_set_sdpcandidates},247 223 {MS_RTP_SEND_SET_RELAY_SESSION_ID, sender_set_relay_session_id}, 248 224 {0, NULL} … … 286 262 struct ReceiverData { 287 263 RtpSession *session; 288 OrtpEvQueue *ortp_event;289 struct IceCheckList *check_lists; /* table of 10 cpair */290 264 int rate; 291 265 }; … … 297 271 ReceiverData *d = (ReceiverData *)ms_new(ReceiverData, 1); 298 272 299 d->ortp_event = ortp_ev_queue_new();300 273 d->session = NULL; 301 d->check_lists = NULL;302 274 d->rate = 8000; 303 275 f->data = d; … … 307 279 { 308 280 ReceiverData *d = (ReceiverData *) f->data; 309 if (d->session!=NULL && d->ortp_event!=NULL)310 rtp_session_unregister_event_queue(d->session, d->ortp_event);311 281 } 312 282 … … 314 284 { 315 285 ReceiverData *d = (ReceiverData *) f->data; 316 if (d->ortp_event!=NULL)317 ortp_ev_queue_destroy(d->ortp_event);318 286 ms_free(f->data); 319 287 } … … 338 306 } 339 307 340 static int receiver_set_sdpcandidates(MSFilter * f, void *arg)341 {342 ReceiverData *d = (ReceiverData *) f->data;343 struct IceCheckList *scs = NULL;344 345 if (d == NULL)346 return -1;347 348 scs = (struct IceCheckList *) arg;349 d->check_lists = scs;350 ice_restart(d->check_lists);351 return 0;352 }353 354 308 static void receiver_preprocess(MSFilter * f){ 355 309 ReceiverData *d = (ReceiverData *) f->data; … … 363 317 } 364 318 } 365 if (d->session!=NULL && d->ortp_event!=NULL)366 rtp_session_register_event_queue(d->session, d->ortp_event);367 319 } 368 320 … … 384 336 ms_queue_put(f->outputs[0], m); 385 337 } 386 387 /* check received STUN request */388 if (d->ortp_event!=NULL)389 {390 OrtpEvent *evt = ortp_ev_queue_get(d->ortp_event);391 392 while (evt != NULL) {393 if (ortp_event_get_type(evt) ==394 ORTP_EVENT_STUN_PACKET_RECEIVED) {395 ice_process_stun_message(d->session, d->check_lists, evt);396 }397 if (ortp_event_get_type(evt) ==398 ORTP_EVENT_TELEPHONE_EVENT) {399 }400 401 ortp_event_destroy(evt);402 evt = ortp_ev_queue_get(d->ortp_event);403 }404 }405 338 } 406 339 407 340 static MSFilterMethod receiver_methods[] = { 408 341 {MS_RTP_RECV_SET_SESSION, receiver_set_session}, 409 {MS_RTP_RECV_SET_CANDIDATEPAIRS, receiver_set_sdpcandidates},410 342 {0, NULL} 411 343 };
Note: See TracChangeset
for help on using the changeset viewer.
