Changeset 311:a3c7985aa266 in mediastreamer2


Ignore:
Timestamp:
Mar 9, 2009 12:12:59 PM (4 years ago)
Author:
aymeric <aymeric@…>
Branch:
default
Message:

create an ICE filter with no input/no output

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@314 3f6dc0c8-ddfe-455d-9043-3cd528dc4637

Location:
linphone/mediastreamer2
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • linphone/mediastreamer2/build/win32native/alldescs.h

    r102 r311  
    4343extern MSFilterDesc ms_mire_desc; 
    4444extern MSFilterDesc ms_vfw_desc; 
     45extern MSFilterDesc ms_ice_desc; 
    4546MSFilterDesc * ms_filter_descs[]={ 
    4647&ms_alaw_dec_desc, 
     
    8889&ms_mire_desc, 
    8990&ms_vfw_desc, 
     91&ms_ice_desc, 
    9092NULL 
    9193}; 
  • linphone/mediastreamer2/build/win32native/mediastreamer2.def

    r254 r311  
    9090        ms_list_remove 
    9191         
    92         ice_sound_send_stun_request 
    93         ice_process_stun_message 
    94                  
    9592        ms_discover_mtu 
    9693        ms_set_mtu 
  • linphone/mediastreamer2/include/mediastreamer2/allfilters.h

    r102 r311  
    8181        MS_H263_OLD_ENC_ID, 
    8282        MS_MIRE_ID, 
    83         MS_VFW_ID 
     83        MS_VFW_ID, 
     84        MS_ICE_ID 
    8485} MSFilterId; 
    8586 
  • linphone/mediastreamer2/include/mediastreamer2/ice.h

    r298 r311  
    2121#define ice_hh 
    2222 
     23#include "msfilter.h" 
    2324#include "ortp/stun_udp.h" 
    2425#include "ortp/stun.h" 
     
    8889}; 
    8990 
    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*) 
    9393 
    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 
     94extern MSFilterDesc ms_ice_desc; 
    10395 
    10496#endif 
  • linphone/mediastreamer2/include/mediastreamer2/msrtp.h

    r0 r311  
    3232#define MS_RTP_SEND_SEND_DTMF           MS_FILTER_METHOD(MS_RTP_SEND_ID,1,const char) 
    3333 
    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  
    3834#define MS_RTP_SEND_MUTE_MIC            MS_FILTER_METHOD_NO_ARG(MS_RTP_SEND_ID,3) 
    3935 
  • linphone/mediastreamer2/src/ice.c

    r310 r311  
    2626#endif 
    2727 
     28#include "mediastreamer2/msticker.h" 
    2829#include "mediastreamer2/ice.h" 
    2930#include "mediastreamer2/mscommon.h" 
    3031 
    3132#include <math.h> 
    32  
    33 static void  
    34 ice_sendtest( struct IceCheckList *checklist, struct CandidatePair *remote_candidate, Socket myFd, StunAddress4 *dest,  
    35               const StunAtrString *username, const StunAtrString *password,  
    36               UInt96 *tid); 
    3733 
    3834static void  
     
    8379} 
    8480 
    85 int ice_restart(struct IceCheckList *checklist) 
     81static int ice_restart(struct IceCheckList *checklist) 
    8682{ 
    8783        struct CandidatePair *remote_candidates = NULL; 
     
    149145} 
    150146 
    151 int ice_sound_send_stun_request(RtpSession *session, struct IceCheckList *checklist, uint64_t ctime) 
     147static int ice_sound_send_stun_request(RtpSession *session, struct IceCheckList *checklist, uint64_t ctime) 
    152148{ 
    153149        struct CandidatePair *remote_candidates = NULL; 
     
    477473} 
    478474 
    479 int ice_process_stun_message(RtpSession *session, struct IceCheckList *checklist, OrtpEvent *evt) 
     475static int ice_process_stun_message(RtpSession *session, struct IceCheckList *checklist, OrtpEvent *evt) 
    480476{ 
    481477        struct CandidatePair *remote_candidates = NULL; 
     
    12161212} 
    12171213 
     1214 
     1215 
     1216 
     1217struct IceData { 
     1218        RtpSession *session; 
     1219        OrtpEvQueue *ortp_event; 
     1220        struct IceCheckList *check_lists;       /* table of 10 cpair */ 
     1221        int rate; 
     1222}; 
     1223 
     1224typedef struct IceData IceData; 
     1225 
     1226static 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 
     1237static 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 
     1244static 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 
     1252static 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 
     1271static 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 
     1285static 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 
     1291static 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 
     1324static 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 
     1332MSFilterDesc 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 
     1350MSFilterDesc 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 
     1367MS_FILTER_DESC_EXPORT(ms_ice_desc) 
  • linphone/mediastreamer2/src/msfilter.c

    r0 r311  
    8484        if (desc->ninputs>0)    obj->inputs=(MSQueue**)ms_new0(MSQueue*,desc->ninputs); 
    8585        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"); 
    8886        if (obj->desc->init!=NULL) 
    8987                obj->desc->init(obj); 
  • linphone/mediastreamer2/src/msrtp.c

    r298 r311  
    3030struct SenderData { 
    3131        RtpSession *session; 
    32         struct IceCheckList *check_lists; /* table of 10 cpair */ 
    3332        uint32_t tsoff; 
    3433        uint32_t skip_until; 
     
    4948 
    5049        d->session = NULL; 
    51         d->check_lists = NULL; 
    5250        d->tsoff = 0; 
    5351        d->skip_until = 0; 
     
    7674        d->dtmf = dtmf[0]; 
    7775        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); 
    9276        return 0; 
    9377} 
     
    179163        RtpSession *s = d->session; 
    180164 
    181         struct IceCheckList *cp = d->check_lists; 
    182165        mblk_t *im; 
    183166        uint32_t timestamp; 
     
    231214                ms_filter_unlock(f); 
    232215        } 
    233  
    234 #if !defined(_WIN32_WCE) 
    235         ice_sound_send_stun_request(s, cp, f->ticker->time); 
    236 #else 
    237         ice_sound_send_stun_request(s, cp, f->ticker->time)); 
    238 #endif 
    239216} 
    240217 
     
    244221        {MS_RTP_SEND_SET_SESSION, sender_set_session}, 
    245222        {MS_RTP_SEND_SEND_DTMF, sender_send_dtmf}, 
    246         {MS_RTP_SEND_SET_CANDIDATEPAIRS, sender_set_sdpcandidates}, 
    247223        {MS_RTP_SEND_SET_RELAY_SESSION_ID, sender_set_relay_session_id}, 
    248224        {0, NULL} 
     
    286262struct ReceiverData { 
    287263        RtpSession *session; 
    288         OrtpEvQueue *ortp_event; 
    289         struct IceCheckList *check_lists;       /* table of 10 cpair */ 
    290264        int rate; 
    291265}; 
     
    297271        ReceiverData *d = (ReceiverData *)ms_new(ReceiverData, 1); 
    298272 
    299         d->ortp_event = ortp_ev_queue_new(); 
    300273        d->session = NULL; 
    301         d->check_lists = NULL; 
    302274        d->rate = 8000; 
    303275        f->data = d; 
     
    307279{ 
    308280        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); 
    311281} 
    312282 
     
    314284{ 
    315285        ReceiverData *d = (ReceiverData *) f->data; 
    316         if (d->ortp_event!=NULL) 
    317           ortp_ev_queue_destroy(d->ortp_event); 
    318286        ms_free(f->data); 
    319287} 
     
    338306} 
    339307 
    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  
    354308static void receiver_preprocess(MSFilter * f){ 
    355309        ReceiverData *d = (ReceiverData *) f->data; 
     
    363317                } 
    364318        } 
    365         if (d->session!=NULL && d->ortp_event!=NULL) 
    366                 rtp_session_register_event_queue(d->session, d->ortp_event); 
    367319} 
    368320 
     
    384336                ms_queue_put(f->outputs[0], m); 
    385337        } 
    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         } 
    405338} 
    406339 
    407340static MSFilterMethod receiver_methods[] = { 
    408341        {MS_RTP_RECV_SET_SESSION, receiver_set_session}, 
    409         {MS_RTP_RECV_SET_CANDIDATEPAIRS, receiver_set_sdpcandidates}, 
    410342        {0, NULL} 
    411343}; 
Note: See TracChangeset for help on using the changeset viewer.