Changeset 6105
- Timestamp:
- Nov 13, 2019 8:09:34 AM (5 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia-codec/types.h
r5791 r6105 42 42 * this library. Also see the header file <pjmedia/codec.h> for list 43 43 * of static payload types. 44 * 45 * These enumeration is for older audio codecs only, newer audio codec using 46 * dynamic payload type can simply assign PJMEDIA_RTP_PT_DYNAMIC in its 47 * payload type (i.e: pjmedia_codec_info.pt). Endpoint will automatically 48 * rearrange dynamic payload types in SDP generation. 44 49 */ 45 50 enum pjmedia_audio_pt 46 51 { 47 52 /* According to IANA specifications, dynamic payload types are to be in 48 * the range 96-127 (inclusive). This enum is structured to place the 49 * values of the payload types specified below into that range. 53 * the range 96-127 (inclusive), but this enum allows the value to be 54 * outside that range, later endpoint will rearrange dynamic payload types 55 * in SDP generation to be inside the 96-127 range and not equal to 56 * PJMEDIA_RTP_PT_TELEPHONE_EVENTS. 50 57 * 51 58 * PJMEDIA_RTP_PT_DYNAMIC is defined in <pjmedia/codec.h>. It is defined 52 59 * to be 96. 53 *54 * PJMEDIA_RTP_PT_TELEPHONE_EVENTS is defined in <pjmedia/config.h>.55 * The default value is 96.56 60 */ 57 #if PJMEDIA_RTP_PT_TELEPHONE_EVENTS58 PJMEDIA_RTP_PT_START = PJMEDIA_RTP_PT_TELEPHONE_EVENTS,59 #else60 61 PJMEDIA_RTP_PT_START = (PJMEDIA_RTP_PT_DYNAMIC-1), 61 #endif62 62 63 63 PJMEDIA_RTP_PT_SPEEX_NB, /**< Speex narrowband/8KHz */ … … 109 109 PJMEDIA_RTP_PT_L16_48KHZ_STEREO, /**< L16 @ 48KHz, stereo */ 110 110 #endif 111 112 /* Caution!113 * Ensure the value of the last pt above is <= 127.114 */115 111 }; 116 112 -
pjproject/trunk/pjmedia/include/pjmedia/config.h
r6005 r6105 845 845 846 846 /** 847 * This macro declares the payload type for telephone-event847 * This macro declares the start payload type for telephone-event 848 848 * that is advertised by PJMEDIA for outgoing SDP. If this macro 849 849 * is set to zero, telephone events would not be advertised nor 850 850 * supported. 851 *852 * If this value is changed to other number, please update the853 * PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR too.854 851 */ 855 852 #ifndef PJMEDIA_RTP_PT_TELEPHONE_EVENTS 856 # define PJMEDIA_RTP_PT_TELEPHONE_EVENTS 96 857 #endif 858 859 860 /** 861 * Macro to get the string representation of the telephone-event 862 * payload type. 863 */ 864 #ifndef PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR 865 # define PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR "96" 853 # define PJMEDIA_RTP_PT_TELEPHONE_EVENTS 120 866 854 #endif 867 855 -
pjproject/trunk/pjmedia/src/pjmedia/endpoint.c
r6103 r6105 421 421 unsigned televent_num = 0; 422 422 unsigned televent_clockrates[8]; 423 #endif 423 424 unsigned used_pt_num = 0; 424 425 unsigned used_pt[PJMEDIA_MAX_SDP_FMT]; 425 #endif426 426 427 427 PJ_UNUSED_ARG(options); … … 430 430 PJ_ASSERT_RETURN(endpt->codec_mgr.codec_cnt <= PJMEDIA_MAX_SDP_FMT, 431 431 PJ_ETOOMANY); 432 433 /* Insert PJMEDIA_RTP_PT_TELEPHONE_EVENTS as used PT */ 434 #if defined(PJMEDIA_RTP_PT_TELEPHONE_EVENTS) && \ 435 PJMEDIA_RTP_PT_TELEPHONE_EVENTS != 0 436 if (endpt->has_telephone_event) { 437 used_pt[used_pt_num++] = PJMEDIA_RTP_PT_TELEPHONE_EVENTS; 438 } 439 #endif 432 440 433 441 /* Create and init basic SDP media */ … … 445 453 pjmedia_codec_param codec_param; 446 454 pj_str_t *fmt; 455 unsigned pt; 447 456 448 457 if (endpt->codec_mgr.codec_desc[i].prio == PJMEDIA_CODEC_PRIO_DISABLED) … … 453 462 &codec_param); 454 463 fmt = &m->desc.fmt[m->desc.fmt_count++]; 464 pt = codec_info->pt; 465 466 /* Rearrange dynamic payload type to make sure it is inside 96-127 467 * range and not being used by other codec/tel-event. 468 */ 469 if (pt >= 96) { 470 unsigned pt_check = 96; 471 unsigned j = 0; 472 while (j < used_pt_num && pt_check <= 127) { 473 if (pt_check==used_pt[j]) { 474 pt_check++; 475 j = 0; 476 } else { 477 j++; 478 } 479 } 480 if (pt_check > 127) { 481 /* No more available PT */ 482 PJ_LOG(4,(THIS_FILE, "Warning: no available dynamic " 483 "payload type for audio codec")); 484 break; 485 } 486 pt = pt_check; 487 } 488 489 /* Take a note of used dynamic PT */ 490 if (pt >= 96) 491 used_pt[used_pt_num++] = pt; 455 492 456 493 fmt->ptr = (char*) pj_pool_alloc(pool, 8); 457 fmt->slen = pj_utoa( codec_info->pt, fmt->ptr);494 fmt->slen = pj_utoa(pt, fmt->ptr); 458 495 459 496 rtpmap.pt = *fmt; … … 461 498 462 499 #if defined(PJMEDIA_HANDLE_G722_MPEG_BUG) && (PJMEDIA_HANDLE_G722_MPEG_BUG != 0) 463 if ( codec_info->pt == PJMEDIA_RTP_PT_G722)500 if (pt == PJMEDIA_RTP_PT_G722) 464 501 rtpmap.clock_rate = 8000; 465 502 else … … 488 525 } 489 526 490 if ( codec_info->pt >= 96 || pjmedia_add_rtpmap_for_static_pt) {527 if (pt >= 96 || pjmedia_add_rtpmap_for_static_pt) { 491 528 pjmedia_sdp_rtpmap_to_attr(pool, &rtpmap, &attr); 492 529 m->attr[m->attr_count++] = attr; … … 504 541 MAX_FMTP_STR_LEN - buf_len, 505 542 "%d", 506 codec_info->pt);543 pt); 507 544 508 545 for (ii = 0; ii < dec_fmtp->cnt; ++ii) { … … 549 586 max_bitrate = codec_param.info.max_bps; 550 587 551 /* List clock rate & channel count of audio codecs for generating 552 * telephone-event later. 553 */ 588 /* List clock rate of audio codecs for generating telephone-event */ 554 589 #if defined(PJMEDIA_RTP_PT_TELEPHONE_EVENTS) && \ 555 590 PJMEDIA_RTP_PT_TELEPHONE_EVENTS != 0 556 {591 if (endpt->has_telephone_event) { 557 592 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 593 563 594 for (j=0; j<televent_num; ++j) { … … 584 615 char buf[160]; 585 616 unsigned j = 0; 586 unsigned pt = PJMEDIA_RTP_PT_TELEPHONE_EVENTS;617 unsigned pt; 587 618 588 619 /* Find PT for this tel-event */ 589 while (j < used_pt_num && pt <= 127) { 590 if (pt == used_pt[j]) { 591 pt++; 620 if (i == 0) { 621 /* First telephony-event always uses preconfigured PT 622 * PJMEDIA_RTP_PT_TELEPHONE_EVENTS. 623 */ 624 pt = PJMEDIA_RTP_PT_TELEPHONE_EVENTS; 625 } else { 626 /* Otherwise, find any free PT slot, starting from 627 * (PJMEDIA_RTP_PT_TELEPHONE_EVENTS + 1). 628 */ 629 pt = PJMEDIA_RTP_PT_TELEPHONE_EVENTS + 1; 630 while (j < used_pt_num && pt <= 127) { 631 if (pt == used_pt[j]) { 632 pt++; 633 j = 0; 634 } else { 635 j++; 636 } 637 } 638 if (pt > 127) { 639 /* Not found? Find more, but now starting from 96 */ 640 pt = 96; 592 641 j = 0; 593 } else { 594 j++; 642 while (j < used_pt_num && 643 pt < PJMEDIA_RTP_PT_TELEPHONE_EVENTS) 644 { 645 if (pt == used_pt[j]) { 646 pt++; 647 j = 0; 648 } else { 649 j++; 650 } 651 } 652 if (pt >= PJMEDIA_RTP_PT_TELEPHONE_EVENTS) { 653 /* No more available PT */ 654 PJ_LOG(4,(THIS_FILE, "Warning: no available dynamic " 655 "payload type for telephone-event")); 656 break; 657 } 595 658 } 596 }597 if (pt > 127) {598 /* No more available PT */599 break;600 659 } 601 660 used_pt[used_pt_num++] = pt;
Note: See TracChangeset
for help on using the changeset viewer.