Changeset 3086


Ignore:
Timestamp:
Feb 3, 2010 2:43:25 PM (14 years ago)
Author:
nanang
Message:

Ticket #998:

  • Updated pjmedia_sdp_parse() to apply direction attribute in session to each media that has no direction attribute (no overriding).
  • Added python tests.
Location:
pjproject/trunk
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/sdp.c

    r2995 r3086  
    10611061    return attr; 
    10621062} 
     1063 
     1064 
     1065/* 
     1066 * Apply direction attribute in session to all media. 
     1067 */ 
     1068static void apply_media_direction(pjmedia_sdp_session *sdp) 
     1069{ 
     1070    pjmedia_sdp_attr *dir_attr = NULL; 
     1071    unsigned i; 
     1072 
     1073    const pj_str_t inactive = { "inactive", 8 }; 
     1074    const pj_str_t sendonly = { "sendonly", 8 }; 
     1075    const pj_str_t recvonly = { "recvonly", 8 }; 
     1076    const pj_str_t sendrecv = { "sendrecv", 8 }; 
     1077 
     1078    /* Find direction attribute in session, don't need to find default  
     1079     * direction "sendrecv". 
     1080     */ 
     1081    for (i = 0; i < sdp->attr_count && !dir_attr; ++i) { 
     1082        if (!pj_strcmp(&sdp->attr[i]->name, &sendonly) || 
     1083            !pj_strcmp(&sdp->attr[i]->name, &recvonly) || 
     1084            !pj_strcmp(&sdp->attr[i]->name, &inactive))  
     1085        { 
     1086            dir_attr = sdp->attr[i]; 
     1087        } 
     1088    } 
     1089 
     1090    /* Found the direction attribute */ 
     1091    if (dir_attr) { 
     1092        /* Remove the direction attribute in session */ 
     1093        pjmedia_sdp_attr_remove(&sdp->attr_count, sdp->attr, dir_attr); 
     1094 
     1095        /* Apply the direction attribute to all media, but not overriding it 
     1096         * if media already has direction attribute. 
     1097         */ 
     1098        for (i = 0; i < sdp->media_count; ++i) { 
     1099            pjmedia_sdp_media *m; 
     1100            unsigned j; 
     1101 
     1102            /* Find direction attribute in this media */ 
     1103            m = sdp->media[i]; 
     1104            for (j = 0; j < m->attr_count; ++j) { 
     1105                if (!pj_strcmp(&m->attr[j]->name, &sendrecv) || 
     1106                    !pj_strcmp(&m->attr[j]->name, &sendonly) || 
     1107                    !pj_strcmp(&m->attr[j]->name, &recvonly) || 
     1108                    !pj_strcmp(&m->attr[j]->name, &inactive))  
     1109                { 
     1110                    break; 
     1111                } 
     1112            } 
     1113 
     1114            /* Not found, apply direction attribute from session */ 
     1115            if (j == m->attr_count) 
     1116                pjmedia_sdp_media_add_attr(m, dir_attr); 
     1117        } 
     1118    } 
     1119} 
     1120 
    10631121 
    10641122/* 
     
    11781236    pj_scan_fini(&scanner); 
    11791237 
     1238    apply_media_direction(session); 
     1239 
    11801240    *p_sdp = session; 
    11811241    return ctx.last_error; 
Note: See TracChangeset for help on using the changeset viewer.