From 564387c6b1d1ff9651241238dcdeedc0d658ecd5 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Thu, 9 Apr 2015 08:15:48 +0000 Subject: Re #1794: - Updated G7221, the bitrate can also be set via param.info.avg_bps, this is applicable only when param.setting.dec_fmtp doesn't contain bitrate info. - Fixed failing codec vector test in pjmedia-test due to wrong G7221 bitrate setting. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5058 74dad513-b988-da41-8d7b-12977e46ad98 --- pjmedia/include/pjmedia-codec/g7221.h | 3 +++ pjmedia/src/pjmedia-codec/g7221.c | 5 ++++- pjmedia/src/test/codec_vectors.c | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/pjmedia/include/pjmedia-codec/g7221.h b/pjmedia/include/pjmedia-codec/g7221.h index 16a5e038..c3f6ed36 100644 --- a/pjmedia/include/pjmedia-codec/g7221.h +++ b/pjmedia/include/pjmedia-codec/g7221.h @@ -76,6 +76,9 @@ * - for 14kHz audio bandwidth (32kHz sampling rate): 24000 to 48000 bps, * multiplication of 400 * + * The bitrate is set via param.setting.dec_fmtp, if it does not + * contain bitrate info, the codec will check param.info.avg_bps. + * * \note * Currently only up to two non-standard modes can be enabled. * diff --git a/pjmedia/src/pjmedia-codec/g7221.c b/pjmedia/src/pjmedia-codec/g7221.c index 8fa9efbd..2b9f1db7 100644 --- a/pjmedia/src/pjmedia-codec/g7221.c +++ b/pjmedia/src/pjmedia-codec/g7221.c @@ -678,7 +678,10 @@ static pj_status_t codec_open( pjmedia_codec *codec, fmtp_bitrate = (pj_uint16_t)pj_strtoul(&fmtp->param[tmp].val); } - /* Validation mode first! */ + if (fmtp_bitrate == 0) + fmtp_bitrate = attr->info.avg_bps; + + /* Validate bitrate */ if (!fmtp_bitrate || !validate_mode(attr->info.clock_rate, fmtp_bitrate)) return PJMEDIA_CODEC_EINMODE; diff --git a/pjmedia/src/test/codec_vectors.c b/pjmedia/src/test/codec_vectors.c index 4aa21301..bce41545 100644 --- a/pjmedia/src/test/codec_vectors.c +++ b/pjmedia/src/test/codec_vectors.c @@ -74,6 +74,14 @@ static int codec_test_encode(pjmedia_codec_mgr *mgr, codec_param.info.avg_bps = bitrate; codec_param.setting.vad = 0; + /* For G7221, the bitrate is set via param.setting.dec_fmtp, if it has + * no info about bitrate, the codec will check info.avg_bps. So, let's + * just clear the SDP fmtp. + */ + if (pj_ansi_strstr(codec_name, "G7221/")) { + codec_param.setting.dec_fmtp.cnt = 0; + } + status = pjmedia_codec_init(codec, pool); if (status != PJ_SUCCESS) { rc = -60; @@ -325,6 +333,14 @@ static int codec_test_decode(pjmedia_codec_mgr *mgr, codec_param.info.avg_bps = bitrate; codec_param.setting.vad = 0; + /* For G7221, the bitrate is set via param.setting.dec_fmtp, if it has + * no info about bitrate, the codec will check info.avg_bps. So, let's + * just clear the SDP fmtp. + */ + if (pj_ansi_strstr(codec_name, "G7221/")) { + codec_param.setting.dec_fmtp.cnt = 0; + } + status = pjmedia_codec_init(codec, pool); if (status != PJ_SUCCESS) { rc = -60; -- cgit v1.2.3