Changeset 3075 for pjproject/trunk/pjmedia/src/pjmedia-codec/passthrough.c
- Timestamp:
- Jan 26, 2010 6:54:28 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-codec/passthrough.c
r3074 r3075 25 25 #include <pj/assert.h> 26 26 #include <pj/log.h> 27 #include <pj/math.h>28 27 #include <pj/pool.h> 29 28 #include <pj/string.h> … … 682 681 amr_settings_t *s; 683 682 pj_uint8_t octet_align = 0; 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); 683 const pj_str_t STR_FMTP_OCTET_ALIGN = {"octet-align", 11}; 688 684 689 685 /* Fetch octet-align setting. It should be fine to fetch only … … 692 688 */ 693 689 for (i = 0; i < attr->setting.dec_fmtp.cnt; ++i) { 694 const pj_str_t STR_FMTP_OCTET_ALIGN = {"octet-align", 11};695 696 690 if (pj_stricmp(&attr->setting.dec_fmtp.param[i].name, 697 691 &STR_FMTP_OCTET_ALIGN) == 0) … … 703 697 } 704 698 705 for (i = 0; i < attr->setting.enc_fmtp.cnt; ++i) {706 /* mode-set, encoding mode is chosen based on local default mode707 * setting:708 * - if local default mode is included in the mode-set, use it709 * - otherwise, find the closest mode to local default mode;710 * if there are two closest modes, prefer to use the higher711 * one, e.g: local default mode is 4, the mode-set param712 * 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 751 699 s = PJ_POOL_ZALLOC_T(pool, amr_settings_t); 752 700 codec_data->codec_setting = s; 753 701 754 s->enc_mode = enc_mode;702 s->enc_mode = pjmedia_codec_amr_get_mode(desc->def_bitrate); 755 703 if (s->enc_mode < 0) 756 704 return PJMEDIA_CODEC_EINMODE; … … 768 716 doesn't do sensitivity bits 769 717 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];775 718 } 776 719 #endif
Note: See TracChangeset
for help on using the changeset viewer.