- Timestamp:
- Jan 23, 2013 6:18:18 AM (12 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 9 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/aconfigure
r4271 r4331 627 627 silk_h_present 628 628 ac_no_silk 629 opencore_amrwb_dec_present 630 opencore_amrwb_dec_h_present 631 opencore_amrwb_enc_present 632 opencore_amrwb_enc_h_present 629 633 opencore_amrnb_present 630 634 opencore_amrnb_h_present 635 ac_no_opencore_amrwb 631 636 ac_no_opencore_amrnb 632 637 libcrypto_present … … 782 787 enable_ssl 783 788 with_opencore_amrnb 784 enable_opencore_amrnb 789 with_opencore_amr 790 with_opencore_amrwbenc 791 enable_opencore_amr 785 792 with_silk 786 793 enable_silk … … 1441 1448 --disable-ssl Exclude SSL support the build (default: autodetect) 1442 1449 1443 --disable-opencore-amrnb 1444 Exclude OpenCORE AMR-NB support from the build 1450 --disable-opencore-amr Exclude OpenCORE AMR support from the build 1445 1451 (default: autodetect) 1446 1452 … … 1475 1481 --with-ssl=DIR Specify alternate libssl prefix 1476 1482 --with-opencore-amrnb=DIR 1477 Specify alternate libopencore-amrnb prefix 1483 This option is obsolete and replaced by 1484 --with-opencore-amr=DIR 1485 --with-opencore-amr=DIR Specify alternate libopencore-amr prefix 1486 --with-opencore-amrwbenc=DIR 1487 Specify alternate libvo-amrwbenc prefix 1478 1488 --with-silk=DIR Specify alternate SILK prefix 1479 1489 … … 7110 7120 # Check whether --with-opencore-amrnb was given. 7111 7121 if test "${with_opencore_amrnb+set}" = set; then : 7112 withval=$with_opencore_amrnb; 7113 else 7114 with_opencore_amrnb=no 7115 7116 fi 7117 7118 7119 if test "x$ac_cross_compile" != "x" -a "x$with_opencore_amrnb" = "xno"; then 7120 enable_opencore_amrnb=no 7121 fi 7122 7123 7124 # Check whether --enable-opencore_amrnb was given. 7125 if test "${enable_opencore_amrnb+set}" = set; then : 7126 enableval=$enable_opencore_amrnb; 7127 if test "$enable_opencore_amrnb" = "no"; then 7122 withval=$with_opencore_amrnb; as_fn_error $? "This option is obsolete and replaced by --with-opencore-amr=DIR" "$LINENO" 5 7123 fi 7124 7125 7126 7127 # Check whether --with-opencore-amr was given. 7128 if test "${with_opencore_amr+set}" = set; then : 7129 withval=$with_opencore_amr; 7130 else 7131 with_opencore_amr=no 7132 7133 fi 7134 7135 7136 if test "x$ac_cross_compile" != "x" -a "x$with_opencore_amr" = "xno"; then 7137 enable_opencore_amr=no 7138 fi 7139 7140 7141 # Check whether --with-opencore-amrwbenc was given. 7142 if test "${with_opencore_amrwbenc+set}" = set; then : 7143 withval=$with_opencore_amrwbenc; 7144 else 7145 with_opencore_amrwbenc=no 7146 7147 fi 7148 7149 7150 if test "x$ac_cross_compile" != "x" -a "x$with_opencore_amrwbenc" = "xno"; then 7151 enable_opencore_amrwbenc=no 7152 fi 7153 7154 7155 7156 7157 # Check whether --enable-opencore_amr was given. 7158 if test "${enable_opencore_amr+set}" = set; then : 7159 enableval=$enable_opencore_amr; 7160 if test "$enable_opencore_amr" = "no"; then 7128 7161 ac_no_opencore_amrnb=1 7162 ac_no_opencore_amrwb=1 7129 7163 $as_echo "#define PJMEDIA_HAS_OPENCORE_AMRNB_CODEC 0" >>confdefs.h 7130 7164 7131 { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if OpenCORE AMR-NB support is disabled... yes" >&5 7132 $as_echo "Checking if OpenCORE AMR-NB support is disabled... yes" >&6; } 7165 $as_echo "#define PJMEDIA_HAS_OPENCORE_AMRWB_CODEC 0" >>confdefs.h 7166 7167 { $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if OpenCORE AMR support is disabled... yes" >&5 7168 $as_echo "Checking if OpenCORE AMR support is disabled... yes" >&6; } 7133 7169 fi 7134 7170 7135 7171 else 7136 7172 7137 { $as_echo "$as_me:${as_lineno-$LINENO}: result: checking for OpenCORE AMR-NB installations.." >&5 7138 $as_echo "checking for OpenCORE AMR-NB installations.." >&6; } 7139 if test "x$with_opencore_amrnb" != "xno" -a "x$with_opencore_amrnb" != "x"; then 7140 CFLAGS="$CFLAGS -I$with_opencore_amrnb/include" 7141 LDFLAGS="$LDFLAGS -L$with_opencore_amrnb/lib" 7142 { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using OpenCORE AMR-NB prefix... $with_opencore_amrnb" >&5 7143 $as_echo "Using OpenCORE AMR-NB prefix... $with_opencore_amrnb" >&6; } 7173 { $as_echo "$as_me:${as_lineno-$LINENO}: result: checking for OpenCORE AMR installations.." >&5 7174 $as_echo "checking for OpenCORE AMR installations.." >&6; } 7175 if test "x$with_opencore_amr" != "xno" -a "x$with_opencore_amr" != "x"; then 7176 CFLAGS="$CFLAGS -I$with_opencore_amr/include" 7177 LDFLAGS="$LDFLAGS -L$with_opencore_amr/lib" 7178 { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using OpenCORE AMR prefix... $with_opencore_amr" >&5 7179 $as_echo "Using OpenCORE AMR prefix... $with_opencore_amr" >&6; } 7180 fi 7181 if test "x$with_opencore_amrwbenc" != "xno" -a "x$with_opencore_amrwbenc" != "x"; then 7182 CFLAGS="$CFLAGS -I$with_opencore_amrwbenc/include" 7183 LDFLAGS="$LDFLAGS -L$with_opencore_amrwbenc/lib" 7184 { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using OpenCORE AMRWB-enc prefix... $with_opencore_amrwbenc" >&5 7185 $as_echo "Using OpenCORE AMRWB-enc prefix... $with_opencore_amrwbenc" >&6; } 7144 7186 fi 7145 7187 … … 7201 7243 7202 7244 fi 7245 7246 7247 7248 7249 ac_fn_c_check_header_mongrel "$LINENO" "vo-amrwbenc/enc_if.h" "ac_cv_header_vo_amrwbenc_enc_if_h" "$ac_includes_default" 7250 if test "x$ac_cv_header_vo_amrwbenc_enc_if_h" = xyes; then : 7251 opencore_amrwb_enc_h_present=1 7252 fi 7253 7254 7255 ac_fn_c_check_header_mongrel "$LINENO" "opencore-amrwb/dec_if.h" "ac_cv_header_opencore_amrwb_dec_if_h" "$ac_includes_default" 7256 if test "x$ac_cv_header_opencore_amrwb_dec_if_h" = xyes; then : 7257 opencore_amrwb_dec_h_present=1 7258 fi 7259 7260 7261 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for D_IF_init in -lopencore-amrwb" >&5 7262 $as_echo_n "checking for D_IF_init in -lopencore-amrwb... " >&6; } 7263 if ${ac_cv_lib_opencore_amrwb_D_IF_init+:} false; then : 7264 $as_echo_n "(cached) " >&6 7265 else 7266 ac_check_lib_save_LIBS=$LIBS 7267 LIBS="-lopencore-amrwb $LIBS" 7268 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7269 /* end confdefs.h. */ 7270 7271 /* Override any GCC internal prototype to avoid an error. 7272 Use char because int might match the return type of a GCC 7273 builtin and then its argument prototype would still apply. */ 7274 #ifdef __cplusplus 7275 extern "C" 7276 #endif 7277 char D_IF_init (); 7278 int 7279 main () 7280 { 7281 return D_IF_init (); 7282 ; 7283 return 0; 7284 } 7285 _ACEOF 7286 if ac_fn_c_try_link "$LINENO"; then : 7287 ac_cv_lib_opencore_amrwb_D_IF_init=yes 7288 else 7289 ac_cv_lib_opencore_amrwb_D_IF_init=no 7290 fi 7291 rm -f core conftest.err conftest.$ac_objext \ 7292 conftest$ac_exeext conftest.$ac_ext 7293 LIBS=$ac_check_lib_save_LIBS 7294 fi 7295 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_opencore_amrwb_D_IF_init" >&5 7296 $as_echo "$ac_cv_lib_opencore_amrwb_D_IF_init" >&6; } 7297 if test "x$ac_cv_lib_opencore_amrwb_D_IF_init" = xyes; then : 7298 opencore_amrwb_dec_present=1 && LIBS="$LIBS -lopencore-amrwb" 7299 fi 7300 7301 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for E_IF_init in -lvo-amrwbenc" >&5 7302 $as_echo_n "checking for E_IF_init in -lvo-amrwbenc... " >&6; } 7303 if ${ac_cv_lib_vo_amrwbenc_E_IF_init+:} false; then : 7304 $as_echo_n "(cached) " >&6 7305 else 7306 ac_check_lib_save_LIBS=$LIBS 7307 LIBS="-lvo-amrwbenc $LIBS" 7308 cat confdefs.h - <<_ACEOF >conftest.$ac_ext 7309 /* end confdefs.h. */ 7310 7311 /* Override any GCC internal prototype to avoid an error. 7312 Use char because int might match the return type of a GCC 7313 builtin and then its argument prototype would still apply. */ 7314 #ifdef __cplusplus 7315 extern "C" 7316 #endif 7317 char E_IF_init (); 7318 int 7319 main () 7320 { 7321 return E_IF_init (); 7322 ; 7323 return 0; 7324 } 7325 _ACEOF 7326 if ac_fn_c_try_link "$LINENO"; then : 7327 ac_cv_lib_vo_amrwbenc_E_IF_init=yes 7328 else 7329 ac_cv_lib_vo_amrwbenc_E_IF_init=no 7330 fi 7331 rm -f core conftest.err conftest.$ac_objext \ 7332 conftest$ac_exeext conftest.$ac_ext 7333 LIBS=$ac_check_lib_save_LIBS 7334 fi 7335 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_vo_amrwbenc_E_IF_init" >&5 7336 $as_echo "$ac_cv_lib_vo_amrwbenc_E_IF_init" >&6; } 7337 if test "x$ac_cv_lib_vo_amrwbenc_E_IF_init" = xyes; then : 7338 opencore_amrwb_enc_present=1 && LIBS="$LIBS -lvo-amrwbenc" 7339 fi 7340 7341 if test "x$opencore_amrwb_enc_h_present" = "x1" -a "x$opencore_amrwb_dec_h_present" = "x1" -a "x$opencore_amrwb_enc_present" = "x1" -a "x$opencore_amrwb_dec_present" = "x1"; then 7342 { $as_echo "$as_me:${as_lineno-$LINENO}: result: OpenCORE AMR-WB library found, AMR-WB support enabled" >&5 7343 $as_echo "OpenCORE AMR-WB library found, AMR-WB support enabled" >&6; } 7344 $as_echo "#define PJMEDIA_HAS_OPENCORE_AMRWB_CODEC 1" >>confdefs.h 7345 7346 else 7347 ac_no_opencore_amrwb=1 7348 $as_echo "#define PJMEDIA_HAS_OPENCORE_AMRWB_CODEC 0" >>confdefs.h 7349 7350 fi 7351 7203 7352 7204 7353 fi -
pjproject/trunk/aconfigure.ac
r4271 r4331 1321 1321 ]) 1322 1322 1323 dnl # opencore-amrnb alt prefix1323 dnl # Obsolete option --with-opencore-amrnb 1324 1324 AC_ARG_WITH(opencore-amrnb, 1325 1325 AC_HELP_STRING([--with-opencore-amrnb=DIR], 1326 [Specify alternate libopencore-amrnb prefix]), 1326 [This option is obsolete and replaced by --with-opencore-amr=DIR]), 1327 [AC_MSG_ERROR(This option is obsolete and replaced by --with-opencore-amr=DIR)], 1328 [] 1329 ) 1330 1331 dnl # opencore-amr alt prefix 1332 AC_ARG_WITH(opencore-amr, 1333 AC_HELP_STRING([--with-opencore-amr=DIR], 1334 [Specify alternate libopencore-amr prefix]), 1327 1335 [], 1328 [with_opencore_amr nb=no]1336 [with_opencore_amr=no] 1329 1337 ) 1330 1338 1331 dnl # Do not use default opencore-amr nbinstallation if we are cross-compiling1332 if test "x$ac_cross_compile" != "x" -a "x$with_opencore_amr nb" = "xno"; then1333 enable_opencore_amr nb=no1339 dnl # Do not use default opencore-amr installation if we are cross-compiling 1340 if test "x$ac_cross_compile" != "x" -a "x$with_opencore_amr" = "xno"; then 1341 enable_opencore_amr=no 1334 1342 fi 1335 1343 1336 dnl # Include opencore-amrnb support 1344 dnl # vo-amrwbenc alt prefix 1345 AC_ARG_WITH(opencore-amrwbenc, 1346 AC_HELP_STRING([--with-opencore-amrwbenc=DIR], 1347 [Specify alternate libvo-amrwbenc prefix]), 1348 [], 1349 [with_opencore_amrwbenc=no] 1350 ) 1351 1352 dnl # Do not use default vo-amrwbenc installation if we are cross-compiling 1353 if test "x$ac_cross_compile" != "x" -a "x$with_opencore_amrwbenc" = "xno"; then 1354 enable_opencore_amrwbenc=no 1355 fi 1356 1357 1358 dnl # Include opencore-amr support 1337 1359 AC_SUBST(ac_no_opencore_amrnb) 1338 AC_ARG_ENABLE(opencore_amrnb, 1339 AC_HELP_STRING([--disable-opencore-amrnb], 1340 [Exclude OpenCORE AMR-NB support from the build (default: autodetect)]) 1360 AC_SUBST(ac_no_opencore_amrwb) 1361 AC_ARG_ENABLE(opencore_amr, 1362 AC_HELP_STRING([--disable-opencore-amr], 1363 [Exclude OpenCORE AMR support from the build (default: autodetect)]) 1341 1364 , 1342 1365 [ 1343 if test "$enable_opencore_amr nb" = "no"; then1366 if test "$enable_opencore_amr" = "no"; then 1344 1367 [ac_no_opencore_amrnb=1] 1368 [ac_no_opencore_amrwb=1] 1345 1369 AC_DEFINE(PJMEDIA_HAS_OPENCORE_AMRNB_CODEC,0) 1346 AC_MSG_RESULT([Checking if OpenCORE AMR-NB support is disabled... yes]) 1370 AC_DEFINE(PJMEDIA_HAS_OPENCORE_AMRWB_CODEC,0) 1371 AC_MSG_RESULT([Checking if OpenCORE AMR support is disabled... yes]) 1347 1372 fi 1348 1373 ], 1349 1374 [ 1350 AC_MSG_RESULT([checking for OpenCORE AMR-NB installations..]) 1351 if test "x$with_opencore_amrnb" != "xno" -a "x$with_opencore_amrnb" != "x"; then 1352 CFLAGS="$CFLAGS -I$with_opencore_amrnb/include" 1353 LDFLAGS="$LDFLAGS -L$with_opencore_amrnb/lib" 1354 AC_MSG_RESULT([Using OpenCORE AMR-NB prefix... $with_opencore_amrnb]) 1355 fi 1375 AC_MSG_RESULT([checking for OpenCORE AMR installations..]) 1376 if test "x$with_opencore_amr" != "xno" -a "x$with_opencore_amr" != "x"; then 1377 CFLAGS="$CFLAGS -I$with_opencore_amr/include" 1378 LDFLAGS="$LDFLAGS -L$with_opencore_amr/lib" 1379 AC_MSG_RESULT([Using OpenCORE AMR prefix... $with_opencore_amr]) 1380 fi 1381 if test "x$with_opencore_amrwbenc" != "xno" -a "x$with_opencore_amrwbenc" != "x"; then 1382 CFLAGS="$CFLAGS -I$with_opencore_amrwbenc/include" 1383 LDFLAGS="$LDFLAGS -L$with_opencore_amrwbenc/lib" 1384 AC_MSG_RESULT([Using OpenCORE AMRWB-enc prefix... $with_opencore_amrwbenc]) 1385 fi 1356 1386 AC_SUBST(opencore_amrnb_h_present) 1357 1387 AC_SUBST(opencore_amrnb_present) … … 1365 1395 AC_DEFINE(PJMEDIA_HAS_OPENCORE_AMRNB_CODEC,0) 1366 1396 fi 1397 AC_SUBST(opencore_amrwb_enc_h_present) 1398 AC_SUBST(opencore_amrwb_enc_present) 1399 AC_SUBST(opencore_amrwb_dec_h_present) 1400 AC_SUBST(opencore_amrwb_dec_present) 1401 AC_CHECK_HEADER(vo-amrwbenc/enc_if.h,[opencore_amrwb_enc_h_present=1]) 1402 AC_CHECK_HEADER(opencore-amrwb/dec_if.h,[opencore_amrwb_dec_h_present=1]) 1403 AC_CHECK_LIB(opencore-amrwb,D_IF_init,[opencore_amrwb_dec_present=1 && LIBS="$LIBS -lopencore-amrwb"]) 1404 AC_CHECK_LIB(vo-amrwbenc,E_IF_init,[opencore_amrwb_enc_present=1 && LIBS="$LIBS -lvo-amrwbenc"]) 1405 if test "x$opencore_amrwb_enc_h_present" = "x1" -a "x$opencore_amrwb_dec_h_present" = "x1" -a "x$opencore_amrwb_enc_present" = "x1" -a "x$opencore_amrwb_dec_present" = "x1"; then 1406 AC_MSG_RESULT([OpenCORE AMR-WB library found, AMR-WB support enabled]) 1407 AC_DEFINE(PJMEDIA_HAS_OPENCORE_AMRWB_CODEC,1) 1408 else 1409 [ac_no_opencore_amrwb=1] 1410 AC_DEFINE(PJMEDIA_HAS_OPENCORE_AMRWB_CODEC,0) 1411 fi 1412 1367 1413 ]) 1368 1414 -
pjproject/trunk/pjmedia/build/Makefile
r4308 r4331 114 114 h263_packetizer.o h264_packetizer.o \ 115 115 $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \ 116 ipp_codecs.o opencore_amr nb.o silk.o $(CODEC_OBJS) \116 ipp_codecs.o opencore_amr.o silk.o $(CODEC_OBJS) \ 117 117 g7221_sdp_match.o amr_sdp_match.o 118 118 export PJMEDIA_CODEC_CFLAGS += $(_CFLAGS) $(GSM_CFLAGS) $(SPEEX_CFLAGS) \ -
pjproject/trunk/pjmedia/build/os-auto.mak.in
r3841 r4331 59 59 AC_NO_G7221_CODEC=@ac_no_g7221_codec@ 60 60 AC_NO_OPENCORE_AMRNB=@ac_no_opencore_amrnb@ 61 AC_NO_OPENCORE_AMRWB=@ac_no_opencore_amrwb@ 61 62 62 63 export CODEC_OBJS= … … 114 115 export CFLAGS += -DPJMEDIA_HAS_OPENCORE_AMRNB_CODEC=0 115 116 else 116 export CODEC_OBJS += opencore_amrnb.o 117 export CODEC_OBJS += opencore_amr.o 118 endif 119 120 ifeq ($(AC_NO_OPENCORE_AMRWB),1) 121 export CFLAGS += -DPJMEDIA_HAS_OPENCORE_AMRWB_CODEC=0 122 else 123 ifeq ($(AC_NO_OPENCORE_AMRNB),1) 124 export CODEC_OBJS += opencore_amr.o 125 endif 117 126 endif 118 127 -
pjproject/trunk/pjmedia/include/pjmedia-codec.h
r4264 r4331 35 35 #include <pjmedia-codec/g7221.h> 36 36 #include <pjmedia-codec/ipp_codecs.h> 37 #include <pjmedia-codec/opencore_amr nb.h>37 #include <pjmedia-codec/opencore_amr.h> 38 38 #include <pjmedia-codec/passthrough.h> 39 39 #include <pjmedia-codec/silk.h> -
pjproject/trunk/pjmedia/include/pjmedia-codec/config.h
r4264 r4331 324 324 325 325 /** 326 * Enable OpenCORE AMR-WB codec. 327 * See https://trac.pjsip.org/repos/ticket/1608 for some info. 328 * 329 * Default: 0 330 */ 331 #ifndef PJMEDIA_HAS_OPENCORE_AMRWB_CODEC 332 # define PJMEDIA_HAS_OPENCORE_AMRWB_CODEC 0 333 #endif 334 335 /** 326 336 * Link with libopencore-amrXX via pragma comment on Visual Studio. 327 * This option only makes sense if PJMEDIA_HAS_OPENCORE_AMRNB _CODEC337 * This option only makes sense if PJMEDIA_HAS_OPENCORE_AMRNB/WB_CODEC 328 338 * is enabled. 329 339 * … … 336 346 /** 337 347 * Link with libopencore-amrXX.a that has been produced with gcc. 338 * This option only makes sense if PJMEDIA_HAS_OPENCORE_AMRNB _CODEC348 * This option only makes sense if PJMEDIA_HAS_OPENCORE_AMRNB/WB_CODEC 339 349 * and PJMEDIA_AUTO_LINK_OPENCORE_AMR_LIBS are enabled. 340 350 * -
pjproject/trunk/pjmedia/include/pjmedia-codec/config_auto.h.in
r4270 r4331 75 75 #endif 76 76 77 /* OpenCORE AMR-WB codec */ 78 #ifndef PJMEDIA_HAS_OPENCORE_AMRWB_CODEC 79 #undef PJMEDIA_HAS_OPENCORE_AMRWB_CODEC 80 #endif 81 77 82 /* SILK codec */ 78 83 #ifndef PJMEDIA_HAS_SILK_CODEC -
pjproject/trunk/pjmedia/include/pjmedia-codec/opencore_amr.h
r4314 r4331 1 1 /* $Id$ */ 2 2 /* 3 * Copyright (C) 2011 Teluu Inc. (http://www.teluu.com)3 * Copyright (C) 2011-2013 Teluu Inc. (http://www.teluu.com) 4 4 * Copyright (C) 2011 Dan Arrhenius <dan@keystream.se> 5 5 * … … 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 #ifndef __PJMEDIA_CODEC_OPENCORE_AMR NB_H__21 #define __PJMEDIA_CODEC_OPENCORE_AMR NB_H__20 #ifndef __PJMEDIA_CODEC_OPENCORE_AMR_H__ 21 #define __PJMEDIA_CODEC_OPENCORE_AMR_H__ 22 22 23 23 #include <pjmedia-codec/types.h> 24 24 25 25 /** 26 * @defgroup PJMED_OC_AMR NB OpenCORE AMR-NBCodec26 * @defgroup PJMED_OC_AMR OpenCORE AMR Codec 27 27 * @ingroup PJMEDIA_CODEC_CODECS 28 * @brief AMRCodec wrapper for OpenCORE AMR -NBcodec28 * @brief AMRCodec wrapper for OpenCORE AMR codec 29 29 * @{ 30 30 */ … … 33 33 34 34 /** 35 * Settings. Use #pjmedia_codec_opencore_amrnb _set_config() to35 * Settings. Use #pjmedia_codec_opencore_amrnb/wb_set_config() to 36 36 * activate. 37 37 */ 38 typedef struct pjmedia_codec_amr nb_config38 typedef struct pjmedia_codec_amr_config 39 39 { 40 40 /** … … 48 48 unsigned bitrate; 49 49 50 } pjmedia_codec_amr nb_config;50 } pjmedia_codec_amr_config; 51 51 52 typedef pjmedia_codec_amr_config pjmedia_codec_amrnb_config; 53 typedef pjmedia_codec_amr_config pjmedia_codec_amrwb_config; 52 54 53 55 /** … … 79 81 const pjmedia_codec_amrnb_config* cfg); 80 82 83 /** 84 * Initialize and register AMR-WB codec factory to pjmedia endpoint. 85 * 86 * @param endpt The pjmedia endpoint. 87 * 88 * @return PJ_SUCCESS on success. 89 */ 90 PJ_DECL(pj_status_t) pjmedia_codec_opencore_amrwb_init(pjmedia_endpt* endpt); 91 92 /** 93 * Unregister AMR-WB codec factory from pjmedia endpoint and deinitialize 94 * the OpenCORE codec library. 95 * 96 * @return PJ_SUCCESS on success. 97 */ 98 PJ_DECL(pj_status_t) pjmedia_codec_opencore_amrwb_deinit(void); 99 100 101 /** 102 * Set AMR-WB parameters. 103 * 104 * @param cfg The settings; 105 * 106 * @return PJ_SUCCESS on success. 107 */ 108 PJ_DECL(pj_status_t) pjmedia_codec_opencore_amrwb_set_config( 109 const pjmedia_codec_amrwb_config* cfg); 110 81 111 PJ_END_DECL 82 112 -
pjproject/trunk/pjmedia/src/pjmedia-codec/audio_codecs.c
r4264 r4331 114 114 return status; 115 115 #endif 116 117 #if PJMEDIA_HAS_OPENCORE_AMRWB_CODEC 118 /* Register OpenCORE AMR-WB */ 119 status = pjmedia_codec_opencore_amrwb_init(endpt); 120 if (status != PJ_SUCCESS) 121 return status; 122 #endif 116 123 117 124 #if PJMEDIA_HAS_SILK_CODEC -
pjproject/trunk/pjmedia/src/pjmedia-codec/opencore_amr.c
r4314 r4331 1 1 /* $Id$ */ 2 2 /* 3 * Copyright (C) 2011 Teluu Inc. (http://www.teluu.com)3 * Copyright (C) 2011-2013 Teluu Inc. (http://www.teluu.com) 4 4 * Copyright (C) 2011 Dan Arrhenius <dan@keystream.se> 5 5 * … … 20 20 21 21 /* 22 * AMR -NB codec implementation with OpenCORE AMRNBlibrary22 * AMR codec implementation with OpenCORE AMR library 23 23 */ 24 24 #include <pjmedia-codec/g722.h> … … 39 39 #if defined(PJMEDIA_HAS_OPENCORE_AMRNB_CODEC) && \ 40 40 (PJMEDIA_HAS_OPENCORE_AMRNB_CODEC != 0) 41 41 #define USE_AMRNB 42 #endif 43 44 #if defined(PJMEDIA_HAS_OPENCORE_AMRWB_CODEC) && \ 45 (PJMEDIA_HAS_OPENCORE_AMRWB_CODEC != 0) 46 #define USE_AMRWB 47 #endif 48 49 #if defined(USE_AMRNB) || defined(USE_AMRWB) 50 51 #ifdef USE_AMRNB 42 52 #include <opencore-amrnb/interf_enc.h> 43 53 #include <opencore-amrnb/interf_dec.h> 54 #endif 55 56 #ifdef USE_AMRWB 57 #include <vo-amrwbenc/enc_if.h> 58 #include <opencore-amrwb/dec_if.h> 59 #endif 60 44 61 #include <pjmedia-codec/amr_helper.h> 45 #include <pjmedia-codec/opencore_amr nb.h>46 47 #define THIS_FILE "opencore_amr nb.c"62 #include <pjmedia-codec/opencore_amr.h> 63 64 #define THIS_FILE "opencore_amr.c" 48 65 49 66 /* Tracing */ … … 59 76 #define USE_PJMEDIA_PLC 1 60 77 61 62 63 /* Prototypes for AMR-NB factory */ 78 #define FRAME_LENGTH_MS 20 79 80 81 /* Prototypes for AMR factory */ 64 82 static pj_status_t amr_test_alloc(pjmedia_codec_factory *factory, 65 83 const pjmedia_codec_info *id ); … … 76 94 pjmedia_codec *codec ); 77 95 78 /* Prototypes for AMR -NBimplementation. */96 /* Prototypes for AMR implementation. */ 79 97 static pj_status_t amr_codec_init(pjmedia_codec *codec, 80 98 pj_pool_t *pool ); … … 104 122 105 123 106 /* Definition for AMR -NBcodec operations. */124 /* Definition for AMR codec operations. */ 107 125 static pjmedia_codec_op amr_op = 108 126 { … … 117 135 }; 118 136 119 /* Definition for AMR -NBcodec factory operations. */137 /* Definition for AMR codec factory operations. */ 120 138 static pjmedia_codec_factory_op amr_factory_op = 121 139 { … … 129 147 130 148 131 /* AMR -NBfactory */149 /* AMR factory */ 132 150 static struct amr_codec_factory 133 151 { … … 135 153 pjmedia_endpt *endpt; 136 154 pj_pool_t *pool; 155 pj_bool_t init[2]; 137 156 } amr_codec_factory; 138 157 139 158 140 /* AMR -NBcodec private data. */159 /* AMR codec private data. */ 141 160 struct amr_data 142 161 { 143 162 pj_pool_t *pool; 163 unsigned clock_rate; 144 164 void *encoder; 145 165 void *decoder; … … 155 175 }; 156 176 157 static pjmedia_codec_amrnb_config def_config = 158 { 177 /* Index for AMR tables. */ 178 enum 179 { 180 IDX_AMR_NB, /* Index for narrowband. */ 181 IDX_AMR_WB /* Index for wideband. */ 182 }; 183 184 static pjmedia_codec_amr_config def_config[2] = 185 {{ /* AMR-NB */ 159 186 PJ_FALSE, /* octet align */ 160 187 5900 /* bitrate */ 161 }; 162 163 164 165 /* 166 * Initialize and register AMR-NB codec factory to pjmedia endpoint. 167 */ 168 PJ_DEF(pj_status_t) pjmedia_codec_opencore_amrnb_init( pjmedia_endpt *endpt ) 188 }, 189 { /* AMR-WB */ 190 PJ_FALSE, /* octet align */ 191 12650 /* bitrate */ 192 }}; 193 194 static const pj_uint16_t* amr_bitrates[2] = 195 {pjmedia_codec_amrnb_bitrates, pjmedia_codec_amrwb_bitrates}; 196 197 198 /* 199 * Initialize and register AMR codec factory to pjmedia endpoint. 200 */ 201 static pj_status_t amr_init( pjmedia_endpt *endpt ) 169 202 { 170 203 pjmedia_codec_mgr *codec_mgr; … … 175 208 return PJ_SUCCESS; 176 209 177 /* Create AMR -NBcodec factory. */210 /* Create AMR codec factory. */ 178 211 amr_codec_factory.base.op = &amr_factory_op; 179 212 amr_codec_factory.base.factory_data = NULL; 180 213 amr_codec_factory.endpt = endpt; 181 214 182 amr_codec_factory.pool = pjmedia_endpt_create_pool(endpt, "amr nb", 1000,215 amr_codec_factory.pool = pjmedia_endpt_create_pool(endpt, "amr", 1000, 183 216 1000); 184 217 if (!amr_codec_factory.pool) … … 215 248 } 216 249 217 218 /* 219 * Unregister AMR-NB codec factory from pjmedia endpoint and deinitialize 220 * the AMR-NB codec library. 221 */ 222 PJ_DEF(pj_status_t) pjmedia_codec_opencore_amrnb_deinit(void) 250 PJ_DEF(pj_status_t) pjmedia_codec_opencore_amrnb_init( pjmedia_endpt *endpt ) 251 { 252 amr_codec_factory.init[IDX_AMR_NB] = PJ_TRUE; 253 254 return amr_init(endpt); 255 } 256 257 PJ_DEF(pj_status_t) pjmedia_codec_opencore_amrwb_init( pjmedia_endpt *endpt ) 258 { 259 amr_codec_factory.init[IDX_AMR_WB] = PJ_TRUE; 260 261 return amr_init(endpt); 262 } 263 264 265 /* 266 * Unregister AMR codec factory from pjmedia endpoint and deinitialize 267 * the AMR codec library. 268 */ 269 static pj_status_t amr_deinit(void) 223 270 { 224 271 pjmedia_codec_mgr *codec_mgr; 225 272 pj_status_t status; 226 273 274 if (amr_codec_factory.init[IDX_AMR_NB] || 275 amr_codec_factory.init[IDX_AMR_WB]) 276 { 277 return PJ_SUCCESS; 278 } 279 227 280 if (amr_codec_factory.pool == NULL) 228 281 return PJ_SUCCESS; … … 236 289 } 237 290 238 /* Unregister AMR -NBcodec factory. */291 /* Unregister AMR codec factory. */ 239 292 status = pjmedia_codec_mgr_unregister_factory(codec_mgr, 240 293 &amr_codec_factory.base); … … 247 300 } 248 301 249 250 PJ_DEF(pj_status_t) pjmedia_codec_opencore_amrnb_set_config( 251 const pjmedia_codec_amrnb_config *config) 302 PJ_DEF(pj_status_t) pjmedia_codec_opencore_amrnb_deinit(void) 303 { 304 amr_codec_factory.init[IDX_AMR_NB] = PJ_FALSE; 305 306 return amr_deinit(); 307 } 308 309 PJ_DEF(pj_status_t) pjmedia_codec_opencore_amrwb_deinit(void) 310 { 311 amr_codec_factory.init[IDX_AMR_WB] = PJ_FALSE; 312 313 return amr_deinit(); 314 } 315 316 static pj_status_t 317 amr_set_config(unsigned idx, const pjmedia_codec_amr_config *config) 252 318 { 253 319 unsigned nbitrates; 254 320 255 256 def_config = *config; 321 def_config[idx] = *config; 257 322 258 323 /* Normalize bitrate. */ 259 nbitrates = PJ_ARRAY_SIZE( pjmedia_codec_amrnb_bitrates);260 if (def_config .bitrate < pjmedia_codec_amrnb_bitrates[0])261 def_config .bitrate = pjmedia_codec_amrnb_bitrates[0];262 else if (def_config.bitrate > pjmedia_codec_amrnb_bitrates[nbitrates-1])263 def_config .bitrate = pjmedia_codec_amrnb_bitrates[nbitrates-1];264 else324 nbitrates = PJ_ARRAY_SIZE(amr_bitrates[idx]); 325 if (def_config[idx].bitrate < amr_bitrates[idx][0]) { 326 def_config[idx].bitrate = amr_bitrates[idx][0]; 327 } else if (def_config[idx].bitrate > amr_bitrates[idx][nbitrates-1]) { 328 def_config[idx].bitrate = amr_bitrates[idx][nbitrates-1]; 329 } else 265 330 { 266 331 unsigned i; 267 332 268 333 for (i = 0; i < nbitrates; ++i) { 269 if (def_config .bitrate <= pjmedia_codec_amrnb_bitrates[i])334 if (def_config[idx].bitrate <= amr_bitrates[idx][i]) 270 335 break; 271 336 } 272 def_config.bitrate = pjmedia_codec_amrnb_bitrates[i]; 273 } 274 275 return PJ_SUCCESS; 276 } 277 278 /* 279 * Check if factory can allocate the specified codec. 337 def_config[idx].bitrate = amr_bitrates[idx][i]; 338 } 339 340 return PJ_SUCCESS; 341 } 342 343 PJ_DEF(pj_status_t) pjmedia_codec_opencore_amrnb_set_config( 344 const pjmedia_codec_amrnb_config *config) 345 { 346 return amr_set_config(IDX_AMR_NB, (const pjmedia_codec_amr_config *)config); 347 } 348 349 PJ_DEF(pj_status_t) pjmedia_codec_opencore_amrwb_set_config( 350 const pjmedia_codec_amrwb_config *config) 351 { 352 return amr_set_config(IDX_AMR_WB, (const pjmedia_codec_amr_config *)config); 353 } 354 355 /* 356 * Check if factory can allocate the specified codec. 280 357 */ 281 358 static pj_status_t amr_test_alloc( pjmedia_codec_factory *factory, 282 359 const pjmedia_codec_info *info ) 283 360 { 361 const pj_str_t amr_tag = { "AMR", 3}; 362 const pj_str_t amrwb_tag = { "AMR-WB", 6}; 284 363 PJ_UNUSED_ARG(factory); 285 364 365 /* Type MUST be audio. */ 366 if (info->type != PJMEDIA_TYPE_AUDIO) 367 return PJMEDIA_CODEC_EUNSUP; 368 286 369 /* Check payload type. */ 287 if (info->pt != PJMEDIA_RTP_PT_AMR )370 if (info->pt != PJMEDIA_RTP_PT_AMR && info->pt != PJMEDIA_RTP_PT_AMRWB) 288 371 return PJMEDIA_CODEC_EUNSUP; 289 290 /* Ignore the rest, since it's static payload type. */ 291 292 return PJ_SUCCESS; 372 373 /* Check encoding name. */ 374 if (pj_stricmp(&info->encoding_name, &amr_tag) != 0 && 375 pj_stricmp(&info->encoding_name, &amrwb_tag) != 0) 376 { 377 return PJMEDIA_CODEC_EUNSUP; 378 } 379 380 /* Check clock-rate */ 381 if ((info->clock_rate == 8000 && amr_codec_factory.init[IDX_AMR_NB]) || 382 (info->clock_rate == 16000 && amr_codec_factory.init[IDX_AMR_WB])) 383 { 384 return PJ_SUCCESS; 385 } 386 387 /* Unsupported or disabled. */ 388 return PJMEDIA_CODEC_EUNSUP; 293 389 } 294 390 … … 300 396 pjmedia_codec_param *attr ) 301 397 { 398 unsigned idx; 399 302 400 PJ_UNUSED_ARG(factory); 303 PJ_UNUSED_ARG(id); 304 401 402 idx = (id->clock_rate <= 8000? IDX_AMR_NB: IDX_AMR_WB); 305 403 pj_bzero(attr, sizeof(pjmedia_codec_param)); 306 attr->info.clock_rate = 8000;404 attr->info.clock_rate = (id->clock_rate <= 8000? 8000: 16000); 307 405 attr->info.channel_cnt = 1; 308 attr->info.avg_bps = def_config .bitrate;309 attr->info.max_bps = pjmedia_codec_amrnb_bitrates[7];406 attr->info.avg_bps = def_config[idx].bitrate; 407 attr->info.max_bps = amr_bitrates[idx][PJ_ARRAY_SIZE(amr_bitrates[idx])-1]; 310 408 attr->info.pcm_bits_per_sample = 16; 311 409 attr->info.frm_ptime = 20; 312 attr->info.pt = PJMEDIA_RTP_PT_AMR;410 attr->info.pt = (pj_uint8_t)id->pt; 313 411 314 412 attr->setting.frm_per_pkt = 2; … … 316 414 attr->setting.plc = 1; 317 415 318 if (def_config .octet_align) {416 if (def_config[idx].octet_align) { 319 417 attr->setting.dec_fmtp.cnt = 1; 320 418 attr->setting.dec_fmtp.param[0].name = pj_str("octet-align"); … … 329 427 330 428 /* 331 * Enum codecs supported by this factory (i.e. only AMR-NB!).429 * Enum codecs supported by this factory (i.e. AMR-NB and AMR-WB). 332 430 */ 333 431 static pj_status_t amr_enum_codecs( pjmedia_codec_factory *factory, … … 338 436 PJ_ASSERT_RETURN(codecs && *count > 0, PJ_EINVAL); 339 437 340 pj_bzero(&codecs[0], sizeof(pjmedia_codec_info)); 341 codecs[0].encoding_name = pj_str("AMR"); 342 codecs[0].pt = PJMEDIA_RTP_PT_AMR; 343 codecs[0].type = PJMEDIA_TYPE_AUDIO; 344 codecs[0].clock_rate = 8000; 345 codecs[0].channel_cnt = 1; 346 347 *count = 1; 348 349 return PJ_SUCCESS; 350 } 351 352 353 /* 354 * Allocate a new AMR-NB codec instance. 438 *count = 0; 439 440 if (amr_codec_factory.init[IDX_AMR_NB]) { 441 pj_bzero(&codecs[*count], sizeof(pjmedia_codec_info)); 442 codecs[*count].encoding_name = pj_str("AMR"); 443 codecs[*count].pt = PJMEDIA_RTP_PT_AMR; 444 codecs[*count].type = PJMEDIA_TYPE_AUDIO; 445 codecs[*count].clock_rate = 8000; 446 codecs[*count].channel_cnt = 1; 447 (*count)++; 448 } 449 450 if (amr_codec_factory.init[IDX_AMR_NB]) { 451 pj_bzero(&codecs[*count], sizeof(pjmedia_codec_info)); 452 codecs[*count].encoding_name = pj_str("AMR-WB"); 453 codecs[*count].pt = PJMEDIA_RTP_PT_AMRWB; 454 codecs[*count].type = PJMEDIA_TYPE_AUDIO; 455 codecs[*count].clock_rate = 16000; 456 codecs[*count].channel_cnt = 1; 457 (*count)++; 458 } 459 460 return PJ_SUCCESS; 461 } 462 463 464 /* 465 * Allocate a new AMR codec instance. 355 466 */ 356 467 static pj_status_t amr_alloc_codec( pjmedia_codec_factory *factory, … … 366 477 PJ_ASSERT_RETURN(factory == &amr_codec_factory.base, PJ_EINVAL); 367 478 368 pool = pjmedia_endpt_create_pool(amr_codec_factory.endpt, "amr nb-inst",479 pool = pjmedia_endpt_create_pool(amr_codec_factory.endpt, "amr-inst", 369 480 512, 512); 370 481 … … 380 491 #if USE_PJMEDIA_PLC 381 492 /* Create PLC */ 382 status = pjmedia_plc_create(pool, 8000, 160, 0, &amr_data->plc); 493 status = pjmedia_plc_create(pool, id->clock_rate, 494 id->clock_rate * FRAME_LENGTH_MS / 1000, 0, 495 &amr_data->plc); 383 496 if (status != PJ_SUCCESS) { 384 497 return status; … … 438 551 pj_int8_t enc_mode; 439 552 const pj_str_t STR_FMTP_OCTET_ALIGN = {"octet-align", 11}; 553 unsigned idx; 440 554 441 555 PJ_ASSERT_RETURN(codec && attr, PJ_EINVAL); 442 556 PJ_ASSERT_RETURN(amr_data != NULL, PJ_EINVALIDOP); 443 557 558 idx = (attr->info.clock_rate <= 8000? IDX_AMR_NB: IDX_AMR_WB); 444 559 enc_mode = pjmedia_codec_amr_get_mode(attr->info.avg_bps); 445 pj_assert(enc_mode >= 0 && enc_mode <= 7); 560 pj_assert(enc_mode >= 0 && 561 enc_mode < PJ_ARRAY_SIZE(amr_bitrates[idx])); 446 562 447 563 /* Check octet-align */ … … 477 593 l = pj_strlen(&attr->setting.enc_fmtp.param[i].val); 478 594 while (l--) { 479 if (*p>='0' && *p<='7') { 595 if (*p>='0' && 596 *p<=('0'+PJ_ARRAY_SIZE(amr_bitrates[idx])-1)) 597 { 480 598 pj_int8_t tmp = *p - '0' - enc_mode; 481 599 … … 497 615 } 498 616 617 amr_data->clock_rate = attr->info.clock_rate; 499 618 amr_data->vad_enabled = (attr->setting.vad != 0); 500 619 amr_data->plc_enabled = (attr->setting.plc != 0); 501 620 amr_data->enc_mode = enc_mode; 502 621 503 amr_data->encoder = Encoder_Interface_init(amr_data->vad_enabled); 622 if (idx == IDX_AMR_NB) { 623 #ifdef USE_AMRNB 624 amr_data->encoder = Encoder_Interface_init(amr_data->vad_enabled); 625 #endif 626 } else { 627 #ifdef USE_AMRWB 628 amr_data->encoder = E_IF_init(); 629 #endif 630 } 504 631 if (amr_data->encoder == NULL) { 505 TRACE_((THIS_FILE, "Encoder _Interface_init()failed"));632 TRACE_((THIS_FILE, "Encoder initialization failed")); 506 633 amr_codec_close(codec); 507 634 return PJMEDIA_CODEC_EFAILED; … … 509 636 setting = &amr_data->enc_setting; 510 637 pj_bzero(setting, sizeof(pjmedia_codec_amr_pack_setting)); 511 setting->amr_nb = 1;638 setting->amr_nb = (idx == IDX_AMR_NB? 1: 0); 512 639 setting->reorder = 0; 513 640 setting->octet_aligned = octet_align; 514 641 setting->cmr = 15; 515 642 516 amr_data->decoder = Decoder_Interface_init(); 643 if (idx == IDX_AMR_NB) { 644 #ifdef USE_AMRNB 645 amr_data->decoder = Decoder_Interface_init(); 646 #endif 647 } else { 648 #ifdef USE_AMRWB 649 amr_data->decoder = D_IF_init(); 650 #endif 651 } 517 652 if (amr_data->decoder == NULL) { 518 TRACE_((THIS_FILE, "Decoder _Interface_init()failed"));653 TRACE_((THIS_FILE, "Decoder initialization failed")); 519 654 amr_codec_close(codec); 520 655 return PJMEDIA_CODEC_EFAILED; … … 522 657 setting = &amr_data->dec_setting; 523 658 pj_bzero(setting, sizeof(pjmedia_codec_amr_pack_setting)); 524 setting->amr_nb = 1;659 setting->amr_nb = (idx == IDX_AMR_NB? 1: 0); 525 660 setting->reorder = 0; 526 661 setting->octet_aligned = octet_align; 527 662 528 TRACE_((THIS_FILE, "AMR-NB codec allocated: vad=%d, plc=%d, bitrate=%d", 663 TRACE_((THIS_FILE, "AMR codec allocated: clockrate=%d vad=%d, plc=%d," 664 " bitrate=%d", amr_data->clock_rate, 529 665 amr_data->vad_enabled, amr_data->plc_enabled, 530 pjmedia_codec_amrnb_bitrates[amr_data->enc_mode]));666 amr_bitrates[idx][amr_data->enc_mode])); 531 667 return PJ_SUCCESS; 532 668 } … … 546 682 547 683 if (amr_data->encoder) { 548 Encoder_Interface_exit(amr_data->encoder); 684 if (amr_data->enc_setting.amr_nb) { 685 #ifdef USE_AMRNB 686 Encoder_Interface_exit(amr_data->encoder); 687 #endif 688 } else { 689 #ifdef USE_AMRWB 690 E_IF_exit(amr_data->encoder); 691 #endif 692 } 549 693 amr_data->encoder = NULL; 550 694 } 551 695 552 696 if (amr_data->decoder) { 553 Decoder_Interface_exit(amr_data->decoder); 697 if (amr_data->dec_setting.amr_nb) { 698 #ifdef USE_AMRNB 699 Decoder_Interface_exit(amr_data->decoder); 700 #endif 701 } else { 702 #ifdef USE_AMRWB 703 D_IF_exit(amr_data->decoder); 704 #endif 705 } 554 706 amr_data->decoder = NULL; 555 707 } 556 708 557 TRACE_((THIS_FILE, "AMR -NBcodec closed"));709 TRACE_((THIS_FILE, "AMR codec closed")); 558 710 return PJ_SUCCESS; 559 711 } … … 576 728 amr_data->plc_enabled = (attr->setting.plc != 0); 577 729 578 if (prev_vad_state != amr_data->vad_enabled) { 730 if (amr_data->enc_setting.amr_nb && 731 prev_vad_state != amr_data->vad_enabled) 732 { 579 733 /* Reinit AMR encoder to update VAD setting */ 580 734 TRACE_((THIS_FILE, "Reiniting AMR encoder to update VAD setting.")); 735 #ifdef USE_AMRNB 581 736 Encoder_Interface_exit(amr_data->encoder); 582 737 amr_data->encoder = Encoder_Interface_init(amr_data->vad_enabled); 738 #endif 583 739 if (amr_data->encoder == NULL) { 584 740 TRACE_((THIS_FILE, "Encoder_Interface_init() failed")); … … 588 744 } 589 745 590 TRACE_((THIS_FILE, "AMR -NBcodec modified: vad=%d, plc=%d",746 TRACE_((THIS_FILE, "AMR codec modified: vad=%d, plc=%d", 591 747 amr_data->vad_enabled, amr_data->plc_enabled)); 592 748 return PJ_SUCCESS; … … 607 763 pj_uint8_t cmr; 608 764 pj_status_t status; 765 unsigned idx = (amr_data->enc_setting.amr_nb? 0: 1); 609 766 610 767 status = pjmedia_codec_amr_parse(pkt, pkt_size, ts, &amr_data->dec_setting, … … 614 771 615 772 /* Check for Change Mode Request. */ 616 if (cmr < = 7&& amr_data->enc_mode != cmr) {773 if (cmr < PJ_ARRAY_SIZE(amr_bitrates[idx]) && amr_data->enc_mode != cmr) { 617 774 amr_data->enc_mode = cmr; 618 TRACE_((THIS_FILE, "AMR -NBencoder switched mode to %d (%dbps)",619 620 pjmedia_codec_amrnb_bitrates[amr_data->enc_mode]));775 TRACE_((THIS_FILE, "AMR encoder switched mode to %d (%dbps)", 776 amr_data->enc_mode, 777 amr_bitrates[idx][amr_data->enc_mode])); 621 778 } 622 779 … … 650 807 651 808 nsamples = input->size >> 1; 652 samples_per_frame = 160;809 samples_per_frame = amr_data->clock_rate * FRAME_LENGTH_MS / 1000; 653 810 PJ_ASSERT_RETURN(nsamples % samples_per_frame == 0, 654 811 PJMEDIA_CODEC_EPCMFRMINLEN); … … 662 819 bitstream = (unsigned char*)output->buf; 663 820 while (nsamples >= samples_per_frame) { 664 size = Encoder_Interface_Encode (amr_data->encoder, amr_data->enc_mode, 665 speech, bitstream, 0); 821 if (amr_data->enc_setting.amr_nb) { 822 #ifdef USE_AMRNB 823 size = Encoder_Interface_Encode (amr_data->encoder, 824 amr_data->enc_mode, 825 speech, bitstream, 0); 826 #endif 827 } else { 828 #ifdef USE_AMRWB 829 size = E_IF_encode (amr_data->encoder, amr_data->enc_mode, 830 speech, bitstream, 0); 831 #endif 832 } 666 833 if (size == 0) { 667 834 output->size = 0; 668 835 output->buf = NULL; 669 836 output->type = PJMEDIA_FRAME_TYPE_NONE; 670 TRACE_((THIS_FILE, "AMR -NBencode() failed"));837 TRACE_((THIS_FILE, "AMR encode() failed")); 671 838 return PJMEDIA_CODEC_EFAILED; 672 839 } 673 nsamples -= 160;840 nsamples -= samples_per_frame; 674 841 speech += samples_per_frame; 675 842 bitstream += size; 676 843 out_size += size; 677 TRACE_((THIS_FILE, "AMR -NBencode(): mode=%d, size=%d",844 TRACE_((THIS_FILE, "AMR encode(): mode=%d, size=%d", 678 845 amr_data->enc_mode, out_size)); 679 846 } … … 691 858 info->start_bit = 0; 692 859 frames[i].buf = p + 1; 693 frames[i].size = (info->frame_type <= 8)? 694 pjmedia_codec_amrnb_framelen[info->frame_type] : 0; 860 if (amr_data->enc_setting.amr_nb) { 861 frames[i].size = (info->frame_type <= 8)? 862 pjmedia_codec_amrnb_framelen[info->frame_type] : 0; 863 } else { 864 frames[i].size = (info->frame_type <= 9)? 865 pjmedia_codec_amrwb_framelen[info->frame_type] : 0; 866 } 695 867 p += frames[i].size + 1; 696 868 … … 714 886 &input->timestamp); 715 887 if (PJMEDIA_CODEC_MAX_SILENCE_PERIOD == -1 || 716 dtx_duration < PJMEDIA_CODEC_MAX_SILENCE_PERIOD*8000/1000) 888 dtx_duration < PJMEDIA_CODEC_MAX_SILENCE_PERIOD* 889 amr_data->clock_rate/1000) 717 890 { 718 891 output->size = 0; … … 756 929 pjmedia_frame input_; 757 930 pjmedia_codec_amr_bit_info *info; 758 /* VA AMR-NB decoding buffer: AMR-NB max frame size + 1 byte header. */ 759 unsigned char bitstream[32]; 931 unsigned out_size; 932 /* AMR decoding buffer: AMR max frame size + 1 byte header. */ 933 unsigned char bitstream[61]; 760 934 761 935 pj_assert(amr_data != NULL); 762 936 PJ_ASSERT_RETURN(input && output, PJ_EINVAL); 763 937 764 if (output_buf_len < 320) 938 out_size = amr_data->clock_rate * FRAME_LENGTH_MS / 1000 * 2; 939 if (output_buf_len < out_size) 765 940 return PJMEDIA_CODEC_EPCMTOOSHORT; 766 941 767 942 input_.buf = &bitstream[1]; 768 input_.size = 31; /* AMR-NB max frame size */ 943 /* AMR max frame size */ 944 input_.size = (amr_data->dec_setting.amr_nb? 31: 60); 769 945 pjmedia_codec_amr_predecode(input, &amr_data->dec_setting, &input_); 770 946 info = (pjmedia_codec_amr_bit_info*)&input_.bit_info; 771 947 772 /* VA AMR NBdecoder requires frame info in the first byte. */948 /* VA AMR decoder requires frame info in the first byte. */ 773 949 bitstream[0] = (info->frame_type << 3) | (info->good_quality << 2); 774 950 775 TRACE_((THIS_FILE, "AMR -NBdecode(): mode=%d, ft=%d, size=%d",951 TRACE_((THIS_FILE, "AMR decode(): mode=%d, ft=%d, size=%d", 776 952 info->mode, info->frame_type, input_.size)); 777 953 778 954 /* Decode */ 779 Decoder_Interface_Decode(amr_data->decoder, bitstream, 780 (pj_int16_t*)output->buf, 0); 781 782 output->size = 320; 955 if (amr_data->dec_setting.amr_nb) { 956 #ifdef USE_AMRNB 957 Decoder_Interface_Decode(amr_data->decoder, bitstream, 958 (pj_int16_t*)output->buf, 0); 959 #endif 960 } else { 961 #ifdef USE_AMRWB 962 D_IF_decode(amr_data->decoder, bitstream, 963 (pj_int16_t*)output->buf, 0); 964 #endif 965 } 966 967 output->size = out_size; 783 968 output->type = PJMEDIA_FRAME_TYPE_AUDIO; 784 969 output->timestamp = input->timestamp; … … 805 990 { 806 991 struct amr_data *amr_data = codec->codec_data; 992 unsigned out_size = amr_data->clock_rate * FRAME_LENGTH_MS / 1000 * 2; 807 993 808 994 TRACE_((THIS_FILE, "amr_codec_recover")); … … 810 996 PJ_ASSERT_RETURN(amr_data->plc_enabled, PJ_EINVALIDOP); 811 997 812 PJ_ASSERT_RETURN(output_buf_len >= 320, PJMEDIA_CODEC_EPCMTOOSHORT);998 PJ_ASSERT_RETURN(output_buf_len >= out_size, PJMEDIA_CODEC_EPCMTOOSHORT); 813 999 814 1000 pjmedia_plc_generate(amr_data->plc, (pj_int16_t*)output->buf); 815 1001 816 output->size = 320;1002 output->size = out_size; 817 1003 output->type = PJMEDIA_FRAME_TYPE_AUDIO; 818 1004 … … 822 1008 823 1009 #if defined(_MSC_VER) && PJMEDIA_AUTO_LINK_OPENCORE_AMR_LIBS 824 # if PJMEDIA_OPENCORE_AMR_BUILT_WITH_GCC 825 # pragma comment( lib, "libopencore-amrnb.a") 826 # else 827 # error Unsupported OpenCORE AMR library, fix here 828 # endif 829 #endif 830 831 #endif 1010 # if PJMEDIA_OPENCORE_AMR_BUILT_WITH_GCC 1011 # ifdef USE_AMRNB 1012 # pragma comment( lib, "libopencore-amrnb.a") 1013 # endif 1014 # ifdef USE_AMRWB 1015 # pragma comment( lib, "libopencore-amrwb.a") 1016 # pragma comment( lib, "libvo-amrwbenc.a") 1017 # endif 1018 # else 1019 # error Unsupported OpenCORE AMR library, fix here 1020 # endif 1021 #endif 1022 1023 #endif -
pjproject/trunk/pjmedia/src/test/mips_test.c
r3982 r4331 944 944 #endif /* PJMEDIA_HAS_OPENCORE_AMRNB_CODEC */ 945 945 946 #if PJMEDIA_HAS_OPENCORE_AMRWB_CODEC 947 /* AMR-WB benchmark benchmark */ 948 static pjmedia_port* amrwb_encode_decode(pj_pool_t *pool, 949 unsigned clock_rate, 950 unsigned channel_count, 951 unsigned samples_per_frame, 952 unsigned flags, 953 struct test_entry *te) 954 { 955 return codec_encode_decode(pool, "AMR/16000", 956 &pjmedia_codec_opencore_amrwb_init, 957 &pjmedia_codec_opencore_amrwb_deinit, 958 clock_rate, channel_count, 959 samples_per_frame, flags, te); 960 } 961 #endif /* PJMEDIA_HAS_OPENCORE_AMRWB_CODEC */ 962 946 963 #if defined(PJMEDIA_HAS_L16_CODEC) && PJMEDIA_HAS_L16_CODEC!=0 947 964 static pj_status_t init_l16_default(pjmedia_endpt *endpt) … … 2025 2042 samples_per_frame, flags, te); 2026 2043 } 2027 #endif /* PJMEDIA_HAS_OPENCORE_AMRNB_CODEC */ 2044 #endif /* PJMEDIA_HAS_OPENCORE_AMRNB_CODEC */ 2045 2046 /* AMR-WB stream */ 2047 #if PJMEDIA_HAS_OPENCORE_AMRWB_CODEC 2048 static pjmedia_port* create_stream_amrwb( pj_pool_t *pool, 2049 unsigned clock_rate, 2050 unsigned channel_count, 2051 unsigned samples_per_frame, 2052 unsigned flags, 2053 struct test_entry *te) 2054 { 2055 return create_stream(pool, "AMR/16000", &pjmedia_codec_opencore_amrwb_init, 2056 &pjmedia_codec_opencore_amrwb_deinit, 2057 PJ_FALSE, PJ_FALSE, PJ_FALSE, 2058 clock_rate, channel_count, 2059 samples_per_frame, flags, te); 2060 } 2061 #endif /* PJMEDIA_HAS_OPENCORE_AMRWB_CODEC */ 2028 2062 2029 2063 /***************************************************************************/ … … 2420 2454 { "codec encode/decode - AMR-NB", OP_PUT, K8, &amr_encode_decode}, 2421 2455 #endif 2456 #if PJMEDIA_HAS_OPENCORE_AMRWB_CODEC 2457 { "codec encode/decode - AMR-WB", OP_PUT, K16, &amrwb_encode_decode}, 2458 #endif 2422 2459 #if PJMEDIA_HAS_L16_CODEC 2423 2460 { "codec encode/decode - L16/8000/1", OP_PUT, K8, &l16_8_encode_decode}, … … 2448 2485 { "stream TX/RX - AMR-NB", OP_PUT_GET, K8, &create_stream_amr}, 2449 2486 #endif 2487 #if PJMEDIA_HAS_OPENCORE_AMRWB_CODEC 2488 { "stream TX/RX - AMR-WB", OP_PUT_GET, K16, &create_stream_amrwb}, 2489 #endif 2450 2490 }; 2451 2491
Note: See TracChangeset
for help on using the changeset viewer.