Changeset 3547
- Timestamp:
- Apr 28, 2011 4:01:40 AM (13 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/sdp.h
r3327 r3547 48 48 #ifndef PJMEDIA_MAX_SDP_FMT 49 49 # define PJMEDIA_MAX_SDP_FMT 32 50 #endif 51 52 /** 53 * The PJMEDIA_MAX_SDP_BANDW macro defines maximum bandwidth information 54 * lines in a media line. 55 */ 56 #ifndef PJMEDIA_MAX_SDP_BANDW 57 # define PJMEDIA_MAX_SDP_BANDW 4 50 58 #endif 51 59 … … 365 373 PJ_DECL(pjmedia_sdp_conn*) pjmedia_sdp_conn_clone(pj_pool_t *pool, 366 374 const pjmedia_sdp_conn *rhs); 375 376 377 378 /* ************************************************************************** 379 * SDP BANDWIDTH INFO 380 **************************************************************************** 381 */ 382 383 /** 384 * This structure describes SDP bandwidth info ("b=" line). 385 */ 386 typedef struct pjmedia_sdp_bandw 387 { 388 pj_str_t modifier; /**< Bandwidth modifier. */ 389 pj_uint32_t value; /**< Bandwidth value. */ 390 } pjmedia_sdp_bandw; 391 392 393 /** 394 * Clone bandwidth info. 395 * 396 * @param pool Pool to allocate memory for the new bandwidth info. 397 * @param rhs The bandwidth into to clone. 398 * 399 * @return The new bandwidth info. 400 */ 401 PJ_DECL(pjmedia_sdp_bandw*) 402 pjmedia_sdp_bandw_clone(pj_pool_t *pool, const pjmedia_sdp_bandw *rhs); 367 403 368 404 … … 388 424 pj_str_t transport; /**< Transport ("RTP/AVP") */ 389 425 unsigned fmt_count; /**< Number of formats. */ 390 pj_str_t fmt[PJMEDIA_MAX_SDP_FMT]; 426 pj_str_t fmt[PJMEDIA_MAX_SDP_FMT]; /**< Media formats. */ 391 427 } desc; 392 428 393 pjmedia_sdp_conn *conn; /**< Optional connection info. */ 394 unsigned attr_count; /**< Number of attributes. */ 395 pjmedia_sdp_attr*attr[PJMEDIA_MAX_SDP_ATTR]; /**< Attributes. */ 429 pjmedia_sdp_conn *conn; /**< Optional connection info. */ 430 unsigned bandw_count; /**< Number of bandwidth info. */ 431 pjmedia_sdp_bandw *bandw[PJMEDIA_MAX_SDP_BANDW]; /**< Bandwidth info. */ 432 unsigned attr_count; /**< Number of attributes. */ 433 pjmedia_sdp_attr *attr[PJMEDIA_MAX_SDP_ATTR]; /**< Attributes. */ 396 434 397 435 }; -
pjproject/trunk/pjmedia/src/pjmedia/sdp.c
r3541 r3547 545 545 } 546 546 547 PJ_DEF(pjmedia_sdp_bandw*) 548 pjmedia_sdp_bandw_clone (pj_pool_t *pool, 549 const pjmedia_sdp_bandw *rhs) 550 { 551 pjmedia_sdp_bandw *b = PJ_POOL_ALLOC_T(pool, pjmedia_sdp_bandw); 552 if (!b) return NULL; 553 554 if (!pj_strdup (pool, &b->modifier, &rhs->modifier)) return NULL; 555 b->value = rhs->value; 556 557 return b; 558 } 559 560 static pj_ssize_t print_bandw(const pjmedia_sdp_bandw *bandw, 561 char *buf, pj_size_t len) 562 { 563 char *p = buf; 564 565 if ((int)len < bandw->modifier.slen + 10 + 5) 566 return -1; 567 568 *p++ = 'b'; 569 *p++ = '='; 570 pj_memcpy(p, bandw->modifier.ptr, bandw->modifier.slen); 571 p += bandw->modifier.slen; 572 *p++ = ':'; 573 p += pj_utoa(bandw->value, p); 574 575 *p++ = '\r'; 576 *p++ = '\n'; 577 return p-buf; 578 } 579 547 580 static pj_ssize_t print_attr(const pjmedia_sdp_attr *attr, 548 581 char *buf, pj_size_t len) … … 612 645 p += printed; 613 646 } 647 648 /* print optional bandwidth info. */ 649 for (i=0; i<m->bandw_count; ++i) { 650 printed = print_bandw(m->bandw[i], p, end-p); 651 if (printed < 0) { 652 return -1; 653 } 654 p += printed; 655 } 614 656 615 657 /* print attributes. */ … … 646 688 } else { 647 689 m->conn = NULL; 690 } 691 692 m->bandw_count = rhs->bandw_count; 693 for (i=0; i < rhs->bandw_count; ++i) { 694 m->bandw[i] = pjmedia_sdp_bandw_clone (pool, rhs->bandw[i]); 695 PJ_ASSERT_RETURN(m->bandw[i] != NULL, NULL); 648 696 } 649 697 … … 1468 1516 } 1469 1517 1518 m->bandw_count = rhs->bandw_count; 1519 for (i=0; i < rhs->bandw_count; ++i) { 1520 m->bandw[i] = pjmedia_sdp_bandw_clone (pool, rhs->bandw[i]); 1521 PJ_ASSERT_RETURN(m->bandw[i] != NULL, NULL); 1522 } 1523 1470 1524 /* And deactivate it */ 1471 1525 pjmedia_sdp_media_deactivate(pool, m); -
pjproject/trunk/pjmedia/src/pjmedia/transport_ice.c
r2957 r3547 175 175 static const pj_str_t STR_IP6 = { "IP6", 3 }; 176 176 static const pj_str_t STR_RTCP = { "rtcp", 4 }; 177 static const pj_str_t STR_BANDW_RR = { "RR", 2 }; 178 static const pj_str_t STR_BANDW_RS = { "RS", 2 }; 177 179 178 180 enum { … … 602 604 if (attr) 603 605 pjmedia_sdp_attr_remove(&m->attr_count, m->attr, attr); 606 /* If RTCP is not in use, we MUST send b=RS:0 and b=RR:0. */ 607 pj_assert(m->bandw_count + 2 <= PJ_ARRAY_SIZE(m->bandw)); 608 if (m->bandw_count + 2 <= PJ_ARRAY_SIZE(m->bandw)) { 609 m->bandw[m->bandw_count] = PJ_POOL_ZALLOC_T(sdp_pool, 610 pjmedia_sdp_bandw); 611 pj_memcpy(&m->bandw[m->bandw_count]->modifier, &STR_BANDW_RS, 612 sizeof(pj_str_t)); 613 m->bandw_count++; 614 m->bandw[m->bandw_count] = PJ_POOL_ZALLOC_T(sdp_pool, 615 pjmedia_sdp_bandw); 616 pj_memcpy(&m->bandw[m->bandw_count]->modifier, &STR_BANDW_RR, 617 sizeof(pj_str_t)); 618 m->bandw_count++; 619 } 604 620 } 605 621
Note: See TracChangeset
for help on using the changeset viewer.