Changeset 6103 for pjproject/trunk/pjmedia/src/pjmedia/endpoint.c
- Timestamp:
- Nov 8, 2019 10:17:16 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/endpoint.c
r5311 r6103 417 417 unsigned max_bitrate = 0; 418 418 pj_status_t status; 419 #if defined(PJMEDIA_RTP_PT_TELEPHONE_EVENTS) && \ 420 PJMEDIA_RTP_PT_TELEPHONE_EVENTS != 0 421 unsigned televent_num = 0; 422 unsigned televent_clockrates[8]; 423 unsigned used_pt_num = 0; 424 unsigned used_pt[PJMEDIA_MAX_SDP_FMT]; 425 #endif 419 426 420 427 PJ_UNUSED_ARG(options); … … 541 548 if (max_bitrate < codec_param.info.max_bps) 542 549 max_bitrate = codec_param.info.max_bps; 543 } 544 550 551 /* List clock rate & channel count of audio codecs for generating 552 * telephone-event later. 553 */ 545 554 #if defined(PJMEDIA_RTP_PT_TELEPHONE_EVENTS) && \ 546 PJMEDIA_RTP_PT_TELEPHONE_EVENTS != 0 555 PJMEDIA_RTP_PT_TELEPHONE_EVENTS != 0 556 { 557 unsigned j; 558 559 /* Take a note of used dynamic PT */ 560 if (codec_info->pt >= 96) 561 used_pt[used_pt_num++] = codec_info->pt; 562 563 for (j=0; j<televent_num; ++j) { 564 if (televent_clockrates[j] == rtpmap.clock_rate) 565 break; 566 } 567 if (j==televent_num && 568 televent_num<PJ_ARRAY_SIZE(televent_clockrates)) 569 { 570 /* List this clockrate for tel-event generation */ 571 televent_clockrates[televent_num++] = rtpmap.clock_rate; 572 } 573 } 574 #endif 575 } 576 577 #if defined(PJMEDIA_RTP_PT_TELEPHONE_EVENTS) && \ 578 PJMEDIA_RTP_PT_TELEPHONE_EVENTS != 0 547 579 /* 548 580 * Add support telephony event 549 581 */ 550 582 if (endpt->has_telephone_event) { 551 m->desc.fmt[m->desc.fmt_count++] = 552 pj_str(PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR); 553 554 /* Add rtpmap. */ 555 attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr); 556 attr->name = pj_str("rtpmap"); 557 attr->value = pj_str(PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR 558 " telephone-event/8000"); 559 m->attr[m->attr_count++] = attr; 560 561 /* Add fmtp */ 562 attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr); 563 attr->name = pj_str("fmtp"); 583 for (i=0; i<televent_num; i++) { 584 char buf[160]; 585 unsigned j = 0; 586 unsigned pt = PJMEDIA_RTP_PT_TELEPHONE_EVENTS; 587 588 /* Find PT for this tel-event */ 589 while (j < used_pt_num && pt <= 127) { 590 if (pt == used_pt[j]) { 591 pt++; 592 j = 0; 593 } else { 594 j++; 595 } 596 } 597 if (pt > 127) { 598 /* No more available PT */ 599 break; 600 } 601 used_pt[used_pt_num++] = pt; 602 603 /* Print tel-event PT */ 604 pj_ansi_snprintf(buf, sizeof(buf), "%d", pt); 605 m->desc.fmt[m->desc.fmt_count++] = pj_strdup3(pool, buf); 606 607 /* Add rtpmap. */ 608 attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr); 609 attr->name = pj_str("rtpmap"); 610 pj_ansi_snprintf(buf, sizeof(buf), "%d telephone-event/%d", 611 pt, televent_clockrates[i]); 612 attr->value = pj_strdup3(pool, buf); 613 m->attr[m->attr_count++] = attr; 614 615 /* Add fmtp */ 616 attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr); 617 attr->name = pj_str("fmtp"); 564 618 #if defined(PJMEDIA_HAS_DTMF_FLASH) && PJMEDIA_HAS_DTMF_FLASH!= 0 565 attr->value = pj_str(PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR " 0-16");619 pj_ansi_snprintf(buf, sizeof(buf), "%d 0-16", pt); 566 620 #else 567 attr->value = pj_str(PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR " 0-15");621 pj_ansi_snprintf(buf, sizeof(buf), "%d 0-15", pt); 568 622 #endif 569 m->attr[m->attr_count++] = attr; 623 attr->value = pj_strdup3(pool, buf); 624 m->attr[m->attr_count++] = attr; 625 } 570 626 } 571 627 #endif
Note: See TracChangeset
for help on using the changeset viewer.