Changeset 3074 for pjproject/trunk/pjmedia/src/pjmedia-codec/passthrough.c
- Timestamp:
- Jan 26, 2010 3:29:23 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-codec/passthrough.c
r2997 r3074 25 25 #include <pj/assert.h> 26 26 #include <pj/log.h> 27 #include <pj/math.h> 27 28 #include <pj/pool.h> 28 29 #include <pj/string.h> … … 681 682 amr_settings_t *s; 682 683 pj_uint8_t octet_align = 0; 683 const pj_str_t STR_FMTP_OCTET_ALIGN = {"octet-align", 11}; 684 pj_int8_t enc_mode; 685 686 enc_mode = pjmedia_codec_amr_get_mode(attr->info.avg_bps); 687 pj_assert(enc_mode >= 0 && enc_mode <= 8); 684 688 685 689 /* Fetch octet-align setting. It should be fine to fetch only … … 688 692 */ 689 693 for (i = 0; i < attr->setting.dec_fmtp.cnt; ++i) { 694 const pj_str_t STR_FMTP_OCTET_ALIGN = {"octet-align", 11}; 695 690 696 if (pj_stricmp(&attr->setting.dec_fmtp.param[i].name, 691 697 &STR_FMTP_OCTET_ALIGN) == 0) … … 697 703 } 698 704 705 for (i = 0; i < attr->setting.enc_fmtp.cnt; ++i) { 706 /* mode-set, encoding mode is chosen based on local default mode 707 * setting: 708 * - if local default mode is included in the mode-set, use it 709 * - otherwise, find the closest mode to local default mode; 710 * if there are two closest modes, prefer to use the higher 711 * one, e.g: local default mode is 4, the mode-set param 712 * contains '2,3,5,6', then 5 will be chosen. 713 */ 714 const pj_str_t STR_FMTP_MODE_SET = {"mode-set", 8}; 715 716 if (pj_stricmp(&attr->setting.enc_fmtp.param[i].name, 717 &STR_FMTP_MODE_SET) == 0) 718 { 719 const char *p; 720 pj_size_t l; 721 pj_int8_t diff = 99; 722 723 p = pj_strbuf(&attr->setting.enc_fmtp.param[i].val); 724 l = pj_strlen(&attr->setting.enc_fmtp.param[i].val); 725 726 while (l--) { 727 if ((desc->pt==PJMEDIA_RTP_PT_AMR && *p>='0' && *p<='7') || 728 (desc->pt==PJMEDIA_RTP_PT_AMRWB && *p>='0' && *p<='8')) 729 { 730 pj_int8_t tmp = (pj_int8_t)(*p - '0' - enc_mode); 731 732 if (PJ_ABS(diff) > PJ_ABS(tmp) || 733 (PJ_ABS(diff) == PJ_ABS(tmp) && tmp > diff)) 734 { 735 diff = tmp; 736 if (diff == 0) break; 737 } 738 } 739 ++p; 740 } 741 742 if (diff == 99) 743 return PJMEDIA_CODEC_EFAILED; 744 745 enc_mode = (pj_int8_t)(enc_mode + diff); 746 747 break; 748 } 749 } 750 699 751 s = PJ_POOL_ZALLOC_T(pool, amr_settings_t); 700 752 codec_data->codec_setting = s; 701 753 702 s->enc_mode = pjmedia_codec_amr_get_mode(desc->def_bitrate);754 s->enc_mode = enc_mode; 703 755 if (s->enc_mode < 0) 704 756 return PJMEDIA_CODEC_EINMODE; … … 716 768 doesn't do sensitivity bits 717 769 reordering */ 770 771 /* Return back bitrate info to application */ 772 attr->info.avg_bps = s->enc_setting.amr_nb? 773 pjmedia_codec_amrnb_bitrates[s->enc_mode]: 774 pjmedia_codec_amrwb_bitrates[s->enc_mode]; 718 775 } 719 776 #endif
Note: See TracChangeset
for help on using the changeset viewer.