Ticket #679: ticket679.patch
File ticket679.patch, 4.1 KB (added by nanang, 15 years ago) |
---|
-
pjmedia/include/pjmedia/sdp.h
64 64 # define PJMEDIA_MAX_SDP_MEDIA 16 65 65 #endif 66 66 67 /** 68 * The PJMEDIA_MAX_SDP_GEN_LINE macro defines maximum SDP generic lines in a 69 * SDP session descriptor. 70 */ 71 #ifndef PJMEDIA_MAX_SDP_GEN_LINE 72 # define PJMEDIA_MAX_SDP_GEN_LINE 8 73 #endif 67 74 75 68 76 /* ************************************************************************** 69 77 * SDP ATTRIBUTES 70 78 *************************************************************************** … … 535 543 **************************************************************************** 536 544 */ 537 545 546 /** 547 * This structure describes generic SDP line description. 548 */ 549 typedef struct pjmedia_sdp_gen_line 550 { 551 char type; /**< SDP line type. */ 552 pj_str_t value; /**< SDP line value. */ 553 } pjmedia_sdp_gen_line; 538 554 555 539 556 /** 540 557 * This structure describes SDP session description. A SDP session descriptor 541 558 * contains complete information about a session, and normally is exchanged … … 570 587 unsigned media_count; /**< Number of media. */ 571 588 pjmedia_sdp_media *media[PJMEDIA_MAX_SDP_MEDIA]; /**< Media array. */ 572 589 590 unsigned generic_count; /**< Number of generic lines*/ 591 pjmedia_sdp_gen_line *generic[PJMEDIA_MAX_SDP_GEN_LINE]; 592 /**< Generic lines array. */ 573 593 }; 574 594 575 595 /** … … 578 598 typedef struct pjmedia_sdp_session pjmedia_sdp_session; 579 599 580 600 581 582 601 /** 583 602 * Parse SDP message. 584 603 * -
pjmedia/src/pjmedia/sdp.c
785 785 p += printed; 786 786 } 787 787 788 /* Print generic lines. */ 789 for (i=0; i<ses->generic_count; ++i) { 790 if ((end-p) < 4 + ses->generic[i]->value.slen) { 791 return -1; 792 } 793 *p++ = (char)ses->generic[i]->type; 794 *p++ = '='; 795 pj_memcpy(p, ses->generic[i]->value.ptr, ses->generic[i]->value.slen); 796 p += ses->generic[i]->value.slen; 797 *p++ = '\r'; 798 *p++ = '\n'; 799 } 800 788 801 return p-buf; 789 802 } 790 803 … … 1122 1135 } 1123 1136 break; 1124 1137 default: 1125 if (cur_name >= 'a' && cur_name <= 'z') 1138 if (cur_name >= 'a' && cur_name <= 'z') { 1126 1139 parse_generic_line(&scanner, &dummy, &ctx); 1127 else { 1140 if (session->generic_count < PJMEDIA_MAX_SDP_GEN_LINE) 1141 { 1142 pjmedia_sdp_gen_line *gen; 1143 1144 gen = PJ_POOL_ALLOC_T(pool, pjmedia_sdp_gen_line); 1145 gen->type = (char)cur_name; 1146 gen->value = dummy; 1147 session->generic[session->generic_count++] = gen; 1148 } 1149 } else { 1128 1150 ctx.last_error = PJMEDIA_SDP_EINSDP; 1129 1151 on_scanner_error(&scanner); 1130 1152 } … … 1213 1235 sess->media[i] = pjmedia_sdp_media_clone(pool, rhs->media[i]); 1214 1236 } 1215 1237 1238 /* Duplicate generic lines. */ 1239 sess->generic_count = rhs->generic_count; 1240 for (i=0; i<rhs->generic_count; ++i) { 1241 pjmedia_sdp_gen_line *gen; 1242 1243 gen = PJ_POOL_ALLOC_T(pool, pjmedia_sdp_gen_line); 1244 gen->type = rhs->generic[i]->type; 1245 pj_strdup(pool, &gen->value, &rhs->generic[i]->value); 1246 sess->generic[i] = gen; 1247 } 1248 1216 1249 return sess; 1217 1250 } 1218 1251 -
pjmedia/src/pjmedia/sdp_cmp.c
285 285 return status; 286 286 } 287 287 288 /* Compare generic lines. */ 289 if (sd1->generic_count != sd2->generic_count) 290 return PJMEDIA_SDP_ESESSNOTEQUAL; 291 292 for (i=0; i<sd1->generic_count; ++i) { 293 unsigned j; 294 pj_bool_t match = PJ_FALSE; 295 296 for (j=0; j<sd2->generic_count && !match; ++j) { 297 if (sd1->generic[i]->type == sd2->generic[j]->type) { 298 if (pj_strcmp(&sd1->generic[i]->value, 299 &sd2->generic[j]->value) == 0) 300 match = PJ_TRUE; 301 else 302 return PJMEDIA_SDP_ESESSNOTEQUAL; 303 } 304 } 305 306 if (!match) 307 return PJMEDIA_SDP_ESESSNOTEQUAL; 308 } 309 288 310 /* Looks equal. */ 289 311 return PJ_SUCCESS; 290 312 }