diff options
author | David M. Lee <dlee@digium.com> | 2013-01-07 14:24:28 -0600 |
---|---|---|
committer | David M. Lee <dlee@digium.com> | 2013-01-07 14:24:28 -0600 |
commit | f3ab456a17af1c89a6e3be4d20c5944853df1cb0 (patch) | |
tree | d00e1a332cd038a6d906a1ea0ac91e1a4458e617 /pjmedia/include/pjmedia-codec |
Import pjproject-2.0.1
Diffstat (limited to 'pjmedia/include/pjmedia-codec')
19 files changed, 3836 insertions, 0 deletions
diff --git a/pjmedia/include/pjmedia-codec/amr_helper.h b/pjmedia/include/pjmedia-codec/amr_helper.h new file mode 100644 index 0000000..dc1f6e7 --- /dev/null +++ b/pjmedia/include/pjmedia-codec/amr_helper.h @@ -0,0 +1,1228 @@ +/* $Id: amr_helper.h 3841 2011-10-24 09:28:13Z ming $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __PJMEDIA_CODECS_AMR_HELPER_H__ +#define __PJMEDIA_CODECS_AMR_HELPER_H__ + +/** + * @file pjmedia-codec/amr_helper.h + * @brief Common tables and helper functions for AMR codec (NB & WB). + */ + + +#ifdef _MSC_VER +# pragma warning(disable:4214) // bit field types other than int +#endif + +/** + * @defgroup PJMED_AMR_CODEC_HELPER AMR Codec Helper + * @ingroup PJMEDIA_CODEC_CODECS + * @brief AMR common tables and helper functions. + * @{ + * + * This sections describes common AMR constants tables (e.g: bits sensitivity + * order map, frame lengths, bitrates) and helper functions (e.g: pack AMR + * payload in octet-aligned mode or bandwidth-efficient mode, payload parser, + * reorder AMR bitstream). + */ + +PJ_BEGIN_DECL + + +/* AMR bits sensitivity order maps */ + +const pj_int16_t pjmedia_codec_amrnb_ordermap122[244] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 23, 15, 16, 17, 18, + 19, 20, 21, 22, 24, 25, 26, 27, 28, 38, + 141, 39, 142, 40, 143, 41, 144, 42, 145, 43, + 146, 44, 147, 45, 148, 46, 149, 47, 97, 150, + 200, 48, 98, 151, 201, 49, 99, 152, 202, 86, + 136, 189, 239, 87, 137, 190, 240, 88, 138, 191, + 241, 91, 194, 92, 195, 93, 196, 94, 197, 95, + 198, 29, 30, 31, 32, 33, 34, 35, 50, 100, + 153, 203, 89, 139, 192, 242, 51, 101, 154, 204, + 55, 105, 158, 208, 90, 140, 193, 243, 59, 109, + 162, 212, 63, 113, 166, 216, 67, 117, 170, 220, + 36, 37, 54, 53, 52, 58, 57, 56, 62, 61, + 60, 66, 65, 64, 70, 69, 68, 104, 103, 102, + 108, 107, 106, 112, 111, 110, 116, 115, 114, 120, + 119, 118, 157, 156, 155, 161, 160, 159, 165, 164, + 163, 169, 168, 167, 173, 172, 171, 207, 206, 205, + 211, 210, 209, 215, 214, 213, 219, 218, 217, 223, + 222, 221, 73, 72, 71, 76, 75, 74, 79, 78, + 77, 82, 81, 80, 85, 84, 83, 123, 122, 121, + 126, 125, 124, 129, 128, 127, 132, 131, 130, 135, + 134, 133, 176, 175, 174, 179, 178, 177, 182, 181, + 180, 185, 184, 183, 188, 187, 186, 226, 225, 224, + 229, 228, 227, 232, 231, 230, 235, 234, 233, 238, + 237, 236, 96, 199 +}; + +const pj_int16_t pjmedia_codec_amrnb_ordermap102[204] = +{ + 7, 6, 5, 4, 3, 2, 1, 0, 16, 15, + 14, 13, 12, 11, 10, 9, 8, 26, 27, 28, + 29, 30, 31, 115, 116, 117, 118, 119, 120, 72, + 73, 161, 162, 65, 68, 69, 108, 111, 112, 154, + 157, 158, 197, 200, 201, 32, 33, 121, 122, 74, + 75, 163, 164, 66, 109, 155, 198, 19, 23, 21, + 22, 18, 17, 20, 24, 25, 37, 36, 35, 34, + 80, 79, 78, 77, 126, 125, 124, 123, 169, 168, + 167, 166, 70, 67, 71, 113, 110, 114, 159, 156, + 160, 202, 199, 203, 76, 165, 81, 82, 92, 91, + 93, 83, 95, 85, 84, 94, 101, 102, 96, 104, + 86, 103, 87, 97, 127, 128, 138, 137, 139, 129, + 141, 131, 130, 140, 147, 148, 142, 150, 132, 149, + 133, 143, 170, 171, 181, 180, 182, 172, 184, 174, + 173, 183, 190, 191, 185, 193, 175, 192, 176, 186, + 38, 39, 49, 48, 50, 40, 52, 42, 41, 51, + 58, 59, 53, 61, 43, 60, 44, 54, 194, 179, + 189, 196, 177, 195, 178, 187, 188, 151, 136, 146, + 153, 134, 152, 135, 144, 145, 105, 90, 100, 107, + 88, 106, 89, 98, 99, 62, 47, 57, 64, 45, + 63, 46, 55, 56 +}; + +const pj_int16_t pjmedia_codec_amrnb_ordermap795[159] = +{ + 8, 7, 6, 5, 4, 3, 2, 14, 16, 9, + 10, 12, 13, 15, 11, 17, 20, 22, 24, 23, + 19, 18, 21, 56, 88, 122, 154, 57, 89, 123, + 155, 58, 90, 124, 156, 52, 84, 118, 150, 53, + 85, 119, 151, 27, 93, 28, 94, 29, 95, 30, + 96, 31, 97, 61, 127, 62, 128, 63, 129, 59, + 91, 125, 157, 32, 98, 64, 130, 1, 0, 25, + 26, 33, 99, 34, 100, 65, 131, 66, 132, 54, + 86, 120, 152, 60, 92, 126, 158, 55, 87, 121, + 153, 117, 116, 115, 46, 78, 112, 144, 43, 75, + 109, 141, 40, 72, 106, 138, 36, 68, 102, 134, + 114, 149, 148, 147, 146, 83, 82, 81, 80, 51, + 50, 49, 48, 47, 45, 44, 42, 39, 35, 79, + 77, 76, 74, 71, 67, 113, 111, 110, 108, 105, + 101, 145, 143, 142, 140, 137, 133, 41, 73, 107, + 139, 37, 69, 103, 135, 38, 70, 104, 136 +}; + +const pj_int16_t pjmedia_codec_amrnb_ordermap74[148] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 26, 87, 27, + 88, 28, 89, 29, 90, 30, 91, 51, 80, 112, + 141, 52, 81, 113, 142, 54, 83, 115, 144, 55, + 84, 116, 145, 58, 119, 59, 120, 21, 22, 23, + 17, 18, 19, 31, 60, 92, 121, 56, 85, 117, + 146, 20, 24, 25, 50, 79, 111, 140, 57, 86, + 118, 147, 49, 78, 110, 139, 48, 77, 53, 82, + 114, 143, 109, 138, 47, 76, 108, 137, 32, 33, + 61, 62, 93, 94, 122, 123, 41, 42, 43, 44, + 45, 46, 70, 71, 72, 73, 74, 75, 102, 103, + 104, 105, 106, 107, 131, 132, 133, 134, 135, 136, + 34, 63, 95, 124, 35, 64, 96, 125, 36, 65, + 97, 126, 37, 66, 98, 127, 38, 67, 99, 128, + 39, 68, 100, 129, 40, 69, 101, 130 +}; + +const pj_int16_t pjmedia_codec_amrnb_ordermap67[134] = +{ + 0, 1, 4, 3, 5, 6, 13, 7, 2, 8, + 9, 11, 15, 12, 14, 10, 28, 82, 29, 83, + 27, 81, 26, 80, 30, 84, 16, 55, 109, 56, + 110, 31, 85, 57, 111, 48, 73, 102, 127, 32, + 86, 51, 76, 105, 130, 52, 77, 106, 131, 58, + 112, 33, 87, 19, 23, 53, 78, 107, 132, 21, + 22, 18, 17, 20, 24, 25, 50, 75, 104, 129, + 47, 72, 101, 126, 54, 79, 108, 133, 46, 71, + 100, 125, 128, 103, 74, 49, 45, 70, 99, 124, + 42, 67, 96, 121, 39, 64, 93, 118, 38, 63, + 92, 117, 35, 60, 89, 114, 34, 59, 88, 113, + 44, 69, 98, 123, 43, 68, 97, 122, 41, 66, + 95, 120, 40, 65, 94, 119, 37, 62, 91, 116, + 36, 61, 90, 115 +}; + +const pj_int16_t pjmedia_codec_amrnb_ordermap59[118] = +{ + 0, 1, 4, 5, 3, 6, 7, 2, 13, 15, + 8, 9, 11, 12, 14, 10, 16, 28, 74, 29, + 75, 27, 73, 26, 72, 30, 76, 51, 97, 50, + 71, 96, 117, 31, 77, 52, 98, 49, 70, 95, + 116, 53, 99, 32, 78, 33, 79, 48, 69, 94, + 115, 47, 68, 93, 114, 46, 67, 92, 113, 19, + 21, 23, 22, 18, 17, 20, 24, 111, 43, 89, + 110, 64, 65, 44, 90, 25, 45, 66, 91, 112, + 54, 100, 40, 61, 86, 107, 39, 60, 85, 106, + 36, 57, 82, 103, 35, 56, 81, 102, 34, 55, + 80, 101, 42, 63, 88, 109, 41, 62, 87, 108, + 38, 59, 84, 105, 37, 58, 83, 104 +}; + +const pj_int16_t pjmedia_codec_amrnb_ordermap515[103] = +{ + 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, + 13, 12, 11, 10, 9, 8, 23, 24, 25, 26, + 27, 46, 65, 84, 45, 44, 43, 64, 63, 62, + 83, 82, 81, 102, 101, 100, 42, 61, 80, 99, + 28, 47, 66, 85, 18, 41, 60, 79, 98, 29, + 48, 67, 17, 20, 22, 40, 59, 78, 97, 21, + 30, 49, 68, 86, 19, 16, 87, 39, 38, 58, + 57, 77, 35, 54, 73, 92, 76, 96, 95, 36, + 55, 74, 93, 32, 51, 33, 52, 70, 71, 89, + 90, 31, 50, 69, 88, 37, 56, 75, 94, 34, + 53, 72, 91 +}; + +const pj_int16_t pjmedia_codec_amrnb_ordermap475[95] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 23, 24, 25, 26, + 27, 28, 48, 49, 61, 62, 82, 83, 47, 46, + 45, 44, 81, 80, 79, 78, 17, 18, 20, 22, + 77, 76, 75, 74, 29, 30, 43, 42, 41, 40, + 38, 39, 16, 19, 21, 50, 51, 59, 60, 63, + 64, 72, 73, 84, 85, 93, 94, 32, 33, 35, + 36, 53, 54, 56, 57, 66, 67, 69, 70, 87, + 88, 90, 91, 34, 55, 68, 89, 37, 58, 71, + 92, 31, 52, 65, 86 +}; + + +const pj_int16_t pjmedia_codec_amrwb_ordermap_660[] = +{ + 0, 5, 6, 7, 61, 84, 107, 130, 62, 85, + 8, 4, 37, 38, 39, 40, 58, 81, 104, 127, + 60, 83, 106, 129, 108, 131, 128, 41, 42, 80, + 126, 1, 3, 57, 103, 82, 105, 59, 2, 63, + 109, 110, 86, 19, 22, 23, 64, 87, 18, 20, + 21, 17, 13, 88, 43, 89, 65, 111, 14, 24, + 25, 26, 27, 28, 15, 16, 44, 90, 66, 112, + 9, 11, 10, 12, 67, 113, 29, 30, 31, 32, + 34, 33, 35, 36, 45, 51, 68, 74, 91, 97, + 114, 120, 46, 69, 92, 115, 52, 75, 98, 121, + 47, 70, 93, 116, 53, 76, 99, 122, 48, 71, + 94, 117, 54, 77, 100, 123, 49, 72, 95, 118, + 55, 78, 101, 124, 50, 73, 96, 119, 56, 79, + 102, 125 +}; + +const pj_int16_t pjmedia_codec_amrwb_ordermap_885[] = +{ + 0, 4, 6, 7, 5, 3, 47, 48, 49, 112, + 113, 114, 75, 106, 140, 171, 80, 111, 145, 176, + 77, 108, 142, 173, 78, 109, 143, 174, 79, 110, + 144, 175, 76, 107, 141, 172, 50, 115, 51, 2, + 1, 81, 116, 146, 19, 21, 12, 17, 18, 20, + 16, 25, 13, 10, 14, 24, 23, 22, 26, 8, + 15, 52, 117, 31, 82, 147, 9, 33, 11, 83, + 148, 53, 118, 28, 27, 84, 149, 34, 35, 29, + 46, 32, 30, 54, 119, 37, 36, 39, 38, 40, + 85, 150, 41, 42, 43, 44, 45, 55, 60, 65, + 70, 86, 91, 96, 101, 120, 125, 130, 135, 151, + 156, 161, 166, 56, 87, 121, 152, 61, 92, 126, + 157, 66, 97, 131, 162, 71, 102, 136, 167, 57, + 88, 122, 153, 62, 93, 127, 158, 67, 98, 132, + 163, 72, 103, 137, 168, 58, 89, 123, 154, 63, + 94, 128, 159, 68, 99, 133, 164, 73, 104, 138, + 169, 59, 90, 124, 155, 64, 95, 129, 160, 69, + 100, 134, 165, 74, 105, 139, 170 +}; + +const pj_int16_t pjmedia_codec_amrwb_ordermap_1265[] = +{ + 0, 4, 6, 93, 143, 196, 246, 7, 5, 3, + 47, 48, 49, 50, 51, 150, 151, 152, 153, 154, + 94, 144, 197, 247, 99, 149, 202, 252, 96, 146, + 199, 249, 97, 147, 200, 250, 100, 203, 98, 148, + 201, 251, 95, 145, 198, 248, 52, 2, 1, 101, + 204, 155, 19, 21, 12, 17, 18, 20, 16, 25, + 13, 10, 14, 24, 23, 22, 26, 8, 15, 53, + 156, 31, 102, 205, 9, 33, 11, 103, 206, 54, + 157, 28, 27, 104, 207, 34, 35, 29, 46, 32, + 30, 55, 158, 37, 36, 39, 38, 40, 105, 208, + 41, 42, 43, 44, 45, 56, 106, 159, 209, 57, + 66, 75, 84, 107, 116, 125, 134, 160, 169, 178, + 187, 210, 219, 228, 237, 58, 108, 161, 211, 62, + 112, 165, 215, 67, 117, 170, 220, 71, 121, 174, + 224, 76, 126, 179, 229, 80, 130, 183, 233, 85, + 135, 188, 238, 89, 139, 192, 242, 59, 109, 162, + 212, 63, 113, 166, 216, 68, 118, 171, 221, 72, + 122, 175, 225, 77, 127, 180, 230, 81, 131, 184, + 234, 86, 136, 189, 239, 90, 140, 193, 243, 60, + 110, 163, 213, 64, 114, 167, 217, 69, 119, 172, + 222, 73, 123, 176, 226, 78, 128, 181, 231, 82, + 132, 185, 235, 87, 137, 190, 240, 91, 141, 194, + 244, 61, 111, 164, 214, 65, 115, 168, 218, 70, + 120, 173, 223, 74, 124, 177, 227, 79, 129, 182, + 232, 83, 133, 186, 236, 88, 138, 191, 241, 92, + 142, 195, 245 +}; + +const pj_int16_t pjmedia_codec_amrwb_ordermap_1425[] = +{ + 0, 4, 6, 101, 159, 220, 278, 7, 5, 3, + 47, 48, 49, 50, 51, 166, 167, 168, 169, 170, + 102, 160, 221, 279, 107, 165, 226, 284, 104, 162, + 223, 281, 105, 163, 224, 282, 108, 227, 106, 164, + 225, 283, 103, 161, 222, 280, 52, 2, 1, 109, + 228, 171, 19, 21, 12, 17, 18, 20, 16, 25, + 13, 10, 14, 24, 23, 22, 26, 8, 15, 53, + 172, 31, 110, 229, 9, 33, 11, 111, 230, 54, + 173, 28, 27, 112, 231, 34, 35, 29, 46, 32, + 30, 55, 174, 37, 36, 39, 38, 40, 113, 232, + 41, 42, 43, 44, 45, 56, 114, 175, 233, 62, + 120, 181, 239, 75, 133, 194, 252, 57, 115, 176, + 234, 63, 121, 182, 240, 70, 128, 189, 247, 76, + 134, 195, 253, 83, 141, 202, 260, 92, 150, 211, + 269, 84, 142, 203, 261, 93, 151, 212, 270, 85, + 143, 204, 262, 94, 152, 213, 271, 86, 144, 205, + 263, 95, 153, 214, 272, 64, 122, 183, 241, 77, + 135, 196, 254, 65, 123, 184, 242, 78, 136, 197, + 255, 87, 145, 206, 264, 96, 154, 215, 273, 58, + 116, 177, 235, 66, 124, 185, 243, 71, 129, 190, + 248, 79, 137, 198, 256, 88, 146, 207, 265, 97, + 155, 216, 274, 59, 117, 178, 236, 67, 125, 186, + 244, 72, 130, 191, 249, 80, 138, 199, 257, 89, + 147, 208, 266, 98, 156, 217, 275, 60, 118, 179, + 237, 68, 126, 187, 245, 73, 131, 192, 250, 81, + 139, 200, 258, 90, 148, 209, 267, 99, 157, 218, + 276, 61, 119, 180, 238, 69, 127, 188, 246, 74, + 132, 193, 251, 82, 140, 201, 259, 91, 149, 210, + 268, 100, 158, 219, 277 +}; + +const pj_int16_t pjmedia_codec_amrwb_ordermap_1585[] = +{ + 0, 4, 6, 109, 175, 244, 310, 7, 5, 3, + 47, 48, 49, 50, 51, 182, 183, 184, 185, 186, + 110, 176, 245, 311, 115, 181, 250, 316, 112, 178, + 247, 313, 113, 179, 248, 314, 116, 251, 114, 180, + 249, 315, 111, 177, 246, 312, 52, 2, 1, 117, + 252, 187, 19, 21, 12, 17, 18, 20, 16, 25, + 13, 10, 14, 24, 23, 22, 26, 8, 15, 53, + 188, 31, 118, 253, 9, 33, 11, 119, 254, 54, + 189, 28, 27, 120, 255, 34, 35, 29, 46, 32, + 30, 55, 190, 37, 36, 39, 38, 40, 121, 256, + 41, 42, 43, 44, 45, 56, 122, 191, 257, 63, + 129, 198, 264, 76, 142, 211, 277, 89, 155, 224, + 290, 102, 168, 237, 303, 57, 123, 192, 258, 70, + 136, 205, 271, 83, 149, 218, 284, 96, 162, 231, + 297, 62, 128, 197, 263, 75, 141, 210, 276, 88, + 154, 223, 289, 101, 167, 236, 302, 58, 124, 193, + 259, 71, 137, 206, 272, 84, 150, 219, 285, 97, + 163, 232, 298, 59, 125, 194, 260, 64, 130, 199, + 265, 67, 133, 202, 268, 72, 138, 207, 273, 77, + 143, 212, 278, 80, 146, 215, 281, 85, 151, 220, + 286, 90, 156, 225, 291, 93, 159, 228, 294, 98, + 164, 233, 299, 103, 169, 238, 304, 106, 172, 241, + 307, 60, 126, 195, 261, 65, 131, 200, 266, 68, + 134, 203, 269, 73, 139, 208, 274, 78, 144, 213, + 279, 81, 147, 216, 282, 86, 152, 221, 287, 91, + 157, 226, 292, 94, 160, 229, 295, 99, 165, 234, + 300, 104, 170, 239, 305, 107, 173, 242, 308, 61, + 127, 196, 262, 66, 132, 201, 267, 69, 135, 204, + 270, 74, 140, 209, 275, 79, 145, 214, 280, 82, + 148, 217, 283, 87, 153, 222, 288, 92, 158, 227, + 293, 95, 161, 230, 296, 100, 166, 235, 301, 105, + 171, 240, 306, 108, 174, 243, 309 +}; + +const pj_int16_t pjmedia_codec_amrwb_ordermap_1825[] = +{ + 0, 4, 6, 121, 199, 280, 358, 7, 5, 3, + 47, 48, 49, 50, 51, 206, 207, 208, 209, 210, + 122, 200, 281, 359, 127, 205, 286, 364, 124, 202, + 283, 361, 125, 203, 284, 362, 128, 287, 126, 204, + 285, 363, 123, 201, 282, 360, 52, 2, 1, 129, + 288, 211, 19, 21, 12, 17, 18, 20, 16, 25, + 13, 10, 14, 24, 23, 22, 26, 8, 15, 53, + 212, 31, 130, 289, 9, 33, 11, 131, 290, 54, + 213, 28, 27, 132, 291, 34, 35, 29, 46, 32, + 30, 55, 214, 37, 36, 39, 38, 40, 133, 292, + 41, 42, 43, 44, 45, 56, 134, 215, 293, 198, + 299, 136, 120, 138, 60, 279, 58, 62, 357, 139, + 140, 295, 156, 57, 219, 297, 63, 217, 137, 170, + 300, 222, 64, 106, 61, 78, 294, 92, 142, 141, + 135, 221, 296, 301, 343, 59, 298, 184, 329, 315, + 220, 216, 265, 251, 218, 237, 352, 223, 157, 86, + 171, 87, 164, 351, 111, 302, 65, 178, 115, 323, + 72, 192, 101, 179, 93, 73, 193, 151, 337, 309, + 143, 274, 69, 324, 165, 150, 97, 338, 110, 310, + 330, 273, 68, 107, 175, 245, 114, 79, 113, 189, + 246, 259, 174, 71, 185, 96, 344, 100, 322, 83, + 334, 316, 333, 252, 161, 348, 147, 82, 269, 232, + 260, 308, 353, 347, 163, 231, 306, 320, 188, 270, + 146, 177, 266, 350, 256, 85, 149, 116, 191, 160, + 238, 258, 336, 305, 255, 88, 224, 99, 339, 230, + 228, 227, 272, 242, 241, 319, 233, 311, 102, 74, + 180, 275, 66, 194, 152, 325, 172, 247, 244, 261, + 117, 158, 166, 354, 75, 144, 108, 312, 94, 186, + 303, 80, 234, 89, 195, 112, 340, 181, 345, 317, + 326, 276, 239, 167, 118, 313, 70, 355, 327, 253, + 190, 176, 271, 104, 98, 153, 103, 90, 76, 267, + 277, 248, 225, 262, 182, 84, 154, 235, 335, 168, + 331, 196, 341, 249, 162, 307, 148, 349, 263, 321, + 257, 243, 229, 356, 159, 119, 67, 187, 173, 145, + 240, 77, 304, 332, 314, 342, 109, 254, 81, 278, + 105, 91, 346, 318, 183, 250, 197, 328, 95, 155, + 169, 268, 226, 236, 264 +}; + +const pj_int16_t pjmedia_codec_amrwb_ordermap_1985[] = +{ + 0, 4, 6, 129, 215, 304, 390, 7, 5, 3, + 47, 48, 49, 50, 51, 222, 223, 224, 225, 226, + 130, 216, 305, 391, 135, 221, 310, 396, 132, 218, + 307, 393, 133, 219, 308, 394, 136, 311, 134, 220, + 309, 395, 131, 217, 306, 392, 52, 2, 1, 137, + 312, 227, 19, 21, 12, 17, 18, 20, 16, 25, + 13, 10, 14, 24, 23, 22, 26, 8, 15, 53, + 228, 31, 138, 313, 9, 33, 11, 139, 314, 54, + 229, 28, 27, 140, 315, 34, 35, 29, 46, 32, + 30, 55, 230, 37, 36, 39, 38, 40, 141, 316, + 41, 42, 43, 44, 45, 56, 142, 231, 317, 63, + 73, 92, 340, 82, 324, 149, 353, 159, 334, 165, + 338, 178, 163, 254, 77, 168, 257, 153, 343, 57, + 248, 238, 79, 252, 166, 67, 80, 201, 101, 267, + 143, 164, 341, 255, 339, 187, 376, 318, 78, 328, + 362, 115, 232, 242, 253, 290, 276, 62, 58, 158, + 68, 93, 179, 319, 148, 169, 154, 72, 385, 329, + 333, 344, 102, 83, 144, 233, 323, 124, 243, 192, + 354, 237, 64, 247, 202, 209, 150, 116, 335, 268, + 239, 299, 188, 196, 298, 94, 195, 258, 123, 363, + 384, 109, 325, 371, 170, 370, 84, 110, 295, 180, + 74, 210, 191, 106, 291, 205, 367, 381, 377, 206, + 355, 122, 119, 120, 383, 160, 105, 108, 277, 380, + 294, 284, 285, 345, 208, 269, 249, 366, 386, 300, + 297, 259, 125, 369, 197, 97, 194, 286, 211, 281, + 280, 183, 372, 87, 155, 283, 59, 348, 327, 184, + 76, 111, 330, 203, 349, 69, 98, 152, 145, 189, + 66, 320, 337, 173, 358, 251, 198, 174, 263, 262, + 126, 241, 193, 88, 388, 117, 95, 387, 112, 359, + 287, 244, 103, 272, 301, 171, 162, 234, 273, 127, + 373, 181, 292, 85, 378, 302, 121, 107, 364, 346, + 356, 212, 278, 213, 65, 382, 288, 207, 113, 175, + 99, 296, 374, 368, 199, 260, 185, 336, 331, 161, + 270, 264, 250, 240, 75, 350, 151, 60, 89, 321, + 156, 274, 360, 326, 70, 282, 167, 146, 352, 81, + 91, 389, 266, 245, 177, 235, 190, 256, 204, 342, + 128, 118, 303, 104, 379, 182, 114, 375, 200, 96, + 293, 172, 214, 365, 279, 86, 289, 351, 347, 357, + 261, 186, 176, 271, 90, 100, 147, 322, 275, 361, + 71, 332, 61, 265, 157, 246, 236 +}; + +const pj_int16_t pjmedia_codec_amrwb_ordermap_2305[] = +{ + 0, 4, 6, 145, 247, 352, 454, 7, 5, 3, + 47, 48, 49, 50, 51, 254, 255, 256, 257, 258, + 146, 248, 353, 455, 151, 253, 358, 460, 148, 250, + 355, 457, 149, 251, 356, 458, 152, 359, 150, 252, + 357, 459, 147, 249, 354, 456, 52, 2, 1, 153, + 360, 259, 19, 21, 12, 17, 18, 20, 16, 25, + 13, 10, 14, 24, 23, 22, 26, 8, 15, 53, + 260, 31, 154, 361, 9, 33, 11, 155, 362, 54, + 261, 28, 27, 156, 363, 34, 35, 29, 46, 32, + 30, 55, 262, 37, 36, 39, 38, 40, 157, 364, + 41, 42, 43, 44, 45, 56, 158, 263, 365, 181, + 192, 170, 79, 57, 399, 90, 159, 297, 377, 366, + 275, 68, 183, 388, 286, 194, 299, 92, 70, 182, + 401, 172, 59, 91, 58, 400, 368, 161, 81, 160, + 264, 171, 80, 389, 390, 378, 379, 193, 298, 69, + 266, 265, 367, 277, 288, 276, 287, 184, 60, 195, + 82, 93, 71, 369, 402, 173, 162, 444, 300, 391, + 98, 76, 278, 61, 267, 374, 135, 411, 167, 102, + 380, 200, 87, 178, 65, 94, 204, 124, 72, 342, + 189, 305, 381, 396, 433, 301, 226, 407, 289, 237, + 113, 215, 185, 128, 309, 403, 116, 320, 196, 331, + 370, 422, 174, 64, 392, 83, 425, 219, 134, 188, + 432, 112, 427, 139, 279, 163, 436, 208, 447, 218, + 236, 229, 97, 294, 385, 230, 166, 268, 177, 443, + 225, 426, 101, 272, 138, 127, 290, 117, 347, 199, + 414, 95, 140, 240, 410, 395, 209, 129, 283, 346, + 105, 241, 437, 86, 308, 448, 203, 345, 186, 107, + 220, 415, 334, 319, 106, 313, 118, 123, 73, 207, + 421, 214, 384, 373, 438, 62, 371, 341, 75, 449, + 168, 323, 164, 242, 416, 324, 304, 197, 335, 404, + 271, 63, 191, 325, 96, 169, 231, 280, 312, 187, + 406, 84, 201, 100, 67, 382, 175, 336, 202, 330, + 269, 393, 376, 383, 293, 307, 409, 179, 285, 314, + 302, 372, 398, 190, 180, 89, 99, 103, 232, 78, + 88, 77, 136, 387, 165, 198, 394, 125, 176, 428, + 74, 375, 238, 227, 66, 273, 282, 141, 306, 412, + 114, 85, 130, 348, 119, 291, 296, 386, 233, 397, + 303, 405, 284, 445, 423, 221, 210, 205, 450, 108, + 274, 434, 216, 343, 337, 142, 243, 321, 408, 451, + 310, 292, 120, 109, 281, 439, 270, 429, 332, 295, + 418, 211, 315, 222, 326, 131, 430, 244, 327, 349, + 417, 316, 143, 338, 440, 234, 110, 212, 452, 245, + 121, 419, 350, 223, 132, 441, 328, 413, 317, 339, + 126, 104, 137, 446, 344, 239, 435, 115, 333, 206, + 322, 217, 228, 424, 453, 311, 351, 111, 442, 224, + 213, 122, 431, 340, 235, 246, 133, 144, 420, 329, + 318 +}; + +const pj_int16_t pjmedia_codec_amrwb_ordermap_2385[] = +{ + 0, 4, 6, 145, 251, 360, 466, 7, 5, 3, + 47, 48, 49, 50, 51, 262, 263, 264, 265, 266, + 146, 252, 361, 467, 151, 257, 366, 472, 148, 254, + 363, 469, 149, 255, 364, 470, 156, 371, 150, 256, + 365, 471, 147, 253, 362, 468, 52, 2, 1, 157, + 372, 267, 19, 21, 12, 17, 18, 20, 16, 25, + 13, 10, 14, 24, 23, 22, 26, 8, 15, 53, + 268, 31, 152, 153, 154, 155, 258, 259, 260, 261, + 367, 368, 369, 370, 473, 474, 475, 476, 158, 373, + 9, 33, 11, 159, 374, 54, 269, 28, 27, 160, + 375, 34, 35, 29, 46, 32, 30, 55, 270, 37, + 36, 39, 38, 40, 161, 376, 41, 42, 43, 44, + 45, 56, 162, 271, 377, 185, 196, 174, 79, 57, + 411, 90, 163, 305, 389, 378, 283, 68, 187, 400, + 294, 198, 307, 92, 70, 186, 413, 176, 59, 91, + 58, 412, 380, 165, 81, 164, 272, 175, 80, 401, + 402, 390, 391, 197, 306, 69, 274, 273, 379, 285, + 296, 284, 295, 188, 60, 199, 82, 93, 71, 381, + 414, 177, 166, 456, 308, 403, 98, 76, 286, 61, + 275, 386, 135, 423, 171, 102, 392, 204, 87, 182, + 65, 94, 208, 124, 72, 350, 193, 313, 393, 408, + 445, 309, 230, 419, 297, 241, 113, 219, 189, 128, + 317, 415, 116, 328, 200, 339, 382, 434, 178, 64, + 404, 83, 437, 223, 134, 192, 444, 112, 439, 139, + 287, 167, 448, 212, 459, 222, 240, 233, 97, 302, + 397, 234, 170, 276, 181, 455, 229, 438, 101, 280, + 138, 127, 298, 117, 355, 203, 426, 95, 140, 244, + 422, 407, 213, 129, 291, 354, 105, 245, 449, 86, + 316, 460, 207, 353, 190, 107, 224, 427, 342, 327, + 106, 321, 118, 123, 73, 211, 433, 218, 396, 385, + 450, 62, 383, 349, 75, 461, 172, 331, 168, 246, + 428, 332, 312, 201, 343, 416, 279, 63, 195, 333, + 96, 173, 235, 288, 320, 191, 418, 84, 205, 100, + 67, 394, 179, 344, 206, 338, 277, 405, 388, 395, + 301, 315, 421, 183, 293, 322, 310, 384, 410, 194, + 184, 89, 99, 103, 236, 78, 88, 77, 136, 399, + 169, 202, 406, 125, 180, 440, 74, 387, 242, 231, + 66, 281, 290, 141, 314, 424, 114, 85, 130, 356, + 119, 299, 304, 398, 237, 409, 311, 417, 292, 457, + 435, 225, 214, 209, 462, 108, 282, 446, 220, 351, + 345, 142, 247, 329, 420, 463, 318, 300, 120, 109, + 289, 451, 278, 441, 340, 303, 430, 215, 323, 226, + 334, 131, 442, 248, 335, 357, 429, 324, 143, 346, + 452, 238, 110, 216, 464, 249, 121, 431, 358, 227, + 132, 453, 336, 425, 325, 347, 126, 104, 137, 458, + 352, 243, 447, 115, 341, 210, 330, 221, 232, 436, + 465, 319, 359, 111, 454, 228, 217, 122, 443, 348, + 239, 250, 133, 144, 432, 337, 326 +}; + +/** + * AMR-NB bitstream sensitivity order maps. + */ +const pj_int16_t* const pjmedia_codec_amrnb_ordermaps[8] = +{ + pjmedia_codec_amrnb_ordermap475, + pjmedia_codec_amrnb_ordermap515, + pjmedia_codec_amrnb_ordermap59, + pjmedia_codec_amrnb_ordermap67, + pjmedia_codec_amrnb_ordermap74, + pjmedia_codec_amrnb_ordermap795, + pjmedia_codec_amrnb_ordermap102, + pjmedia_codec_amrnb_ordermap122 +}; + +/** + * AMR-WB bitstream sensitivity order maps. + */ +const pj_int16_t* const pjmedia_codec_amrwb_ordermaps[9] = +{ + pjmedia_codec_amrwb_ordermap_660, + pjmedia_codec_amrwb_ordermap_885, + pjmedia_codec_amrwb_ordermap_1265, + pjmedia_codec_amrwb_ordermap_1425, + pjmedia_codec_amrwb_ordermap_1585, + pjmedia_codec_amrwb_ordermap_1825, + pjmedia_codec_amrwb_ordermap_1985, + pjmedia_codec_amrwb_ordermap_2305, + pjmedia_codec_amrwb_ordermap_2385 +}; + +/** + * Constant of AMR-NB frame lengths in bytes. + */ +const pj_uint8_t pjmedia_codec_amrnb_framelen[16] = + {12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0}; +/** + * Constant of AMR-NB frame lengths in bits. + */ +const pj_uint16_t pjmedia_codec_amrnb_framelenbits[9] = + {95, 103, 118, 134, 148, 159, 204, 244, 39}; +/** + * Constant of AMR-NB bitrates. + */ +const pj_uint16_t pjmedia_codec_amrnb_bitrates[8] = + {4750, 5150, 5900, 6700, 7400, 7950, 10200, 12200}; + +/** + * Constant of AMR-WB frame lengths in bytes. + */ +const pj_uint8_t pjmedia_codec_amrwb_framelen[16] = + {17, 23, 32, 37, 40, 46, 50, 58, 60, 5, 0, 0, 0, 0, 0, 0}; +/** + * Constant of AMR-WB frame lengths in bits. + */ +const pj_uint16_t pjmedia_codec_amrwb_framelenbits[10] = + {132, 177, 253, 285, 317, 365, 397, 461, 477, 40}; +/** + * Constant of AMR-WB bitrates. + */ +const pj_uint16_t pjmedia_codec_amrwb_bitrates[9] = + {6600, 8850, 12650, 14250, 15850, 18250, 19850, 23050, 23850}; + + +/** + * This structure describes AMR frame info, to be fitted into #pjmedia_frame + * bit info. + */ +#pragma pack(1) +typedef struct pjmedia_codec_amr_bit_info { + pj_uint8_t frame_type; /**< AMR frame type. */ + pj_int8_t mode; /**< AMR mode. */ + pj_uint8_t start_bit; /**< Frame start bit. */ + pj_uint8_t good_quality:1; /**< Flag if frame is good/degraded. */ + pj_uint8_t STI:1; /**< STI mode (first/update). */ +} pjmedia_codec_amr_bit_info; +#pragma pack() + + +/** + * This structure describes AMR settings. + */ +typedef struct pjmedia_codec_amr_pack_setting { + pj_uint8_t amr_nb:1; /**< Set 1 for AMR-NB, 0 for AMR-WB. */ + pj_uint8_t reorder:1; /**< Reorder bitstream into descending + sensitivity order or vice versa. */ + pj_uint8_t octet_aligned:1; /**< TRUE if payload is in octet-aligned mode, + FALSE if payload is in bandwidth + efficient mode. */ + pj_uint8_t cmr:4; /**< Change Mode Request for remote + encoder. */ +} pjmedia_codec_amr_pack_setting; + + +/** + * Get AMR mode based on bitrate. + * + * @param bitrate AMR bitrate. + * + * @return AMR mode. + */ +PJ_INLINE(pj_int8_t) pjmedia_codec_amr_get_mode(unsigned bitrate) +{ + pj_int8_t mode = -1; + + if(bitrate==4750){ + mode = 0; + } else if(bitrate==5150){ + mode = 1; + } else if(bitrate==5900){ + mode = 2; + } else if(bitrate==6700){ + mode = 3; + } else if(bitrate==7400){ + mode = 4; + } else if(bitrate==7950){ + mode = 5; + } else if(bitrate==10200){ + mode = 6; + } else if(bitrate==12200){ + mode = 7; + + /* AMRWB */ + } else if(bitrate==6600){ + mode = 0; + } else if(bitrate==8850){ + mode = 1; + } else if(bitrate==12650){ + mode = 2; + } else if(bitrate==14250){ + mode = 3; + } else if(bitrate==15850){ + mode = 4; + } else if(bitrate==18250){ + mode = 5; + } else if(bitrate==19850){ + mode = 6; + } else if(bitrate==23050){ + mode = 7; + } else if(bitrate==23850){ + mode = 8; + } + return mode; +} + +/** + * Get AMR mode based on frame length. + * + * @param amrnb Set to PJ_TRUE for AMR-NB domain or PJ_FALSE for AMR-WB. + * @param frame_len The frame length. + * + * @return AMR mode. + */ + +PJ_INLINE(pj_int8_t) pjmedia_codec_amr_get_mode2(pj_bool_t amrnb, + unsigned frame_len) +{ + int i; + + if (amrnb) { + for (i = 0; i < 9; ++i) + if (frame_len == pjmedia_codec_amrnb_framelen[i]) + return (pj_int8_t)i; + } else { + for (i = 0; i < 10; ++i) { + if (frame_len == pjmedia_codec_amrwb_framelen[i]) + return (pj_int8_t)i; + } + } + + pj_assert(!"Invalid AMR frame length"); + return -1; +} + +/** + * Prepare a frame before pass it to decoder. This function will do: + * - reorder AMR bitstream from descending sensitivity order into + * encoder bits order. This can be enabled/disabled via param + * 'setting' by setting/resetting field 'reorder'. + * - align left the start bit (make the start_bit to be 0). + * + * @param in Input frame. + * @param setting Settings, see #pjmedia_codec_amr_pack_setting. + * @param out Output frame. + * + * @return PJ_SUCCESS on success. + */ +PJ_INLINE(pj_status_t) pjmedia_codec_amr_predecode( + const pjmedia_frame *in, + const pjmedia_codec_amr_pack_setting *setting, + pjmedia_frame *out) +{ + pj_int8_t amr_bits[477 + 7] = {0}; + pj_int8_t *p_amr_bits = &amr_bits[0]; + + pj_uint8_t *r = (pj_uint8_t*) in->buf; /* read cursor */ + pj_uint8_t *w = (pj_uint8_t*) out->buf; /* write cursor */ + + /* env vars for AMR or AMRWB */ + pj_uint8_t SID_FT; + const pj_uint8_t *framelen_tbl; + const pj_uint16_t *framelenbit_tbl; + const pj_uint16_t *bitrate_tbl; + const pj_int16_t* const *order_maps; + + pjmedia_codec_amr_bit_info *in_info = + (pjmedia_codec_amr_bit_info*) &in->bit_info; + pjmedia_codec_amr_bit_info *out_info = + (pjmedia_codec_amr_bit_info*) &out->bit_info; + + unsigned i; + + *out_info = *in_info; + + if (setting->amr_nb) { + SID_FT = 8; + framelen_tbl = pjmedia_codec_amrnb_framelen; + framelenbit_tbl = pjmedia_codec_amrnb_framelenbits; + bitrate_tbl = pjmedia_codec_amrnb_bitrates; + order_maps = pjmedia_codec_amrnb_ordermaps; + } else { + SID_FT = 9; + framelen_tbl = pjmedia_codec_amrwb_framelen; + framelenbit_tbl = pjmedia_codec_amrwb_framelenbits; + bitrate_tbl = pjmedia_codec_amrwb_bitrates; + order_maps = pjmedia_codec_amrwb_ordermaps; + } + + /* unpack AMR bitstream if there is any data */ + if (in_info->frame_type <= SID_FT) { + i = 0; + if (in_info->start_bit) { + for (; i < (unsigned)(8-in_info->start_bit); ++i) + *p_amr_bits++ = (pj_uint8_t) + ((*r >> (7-in_info->start_bit-i)) & 1); + ++r; + } + for(; i < framelenbit_tbl[in_info->frame_type]; i += 8, ++r) { + *p_amr_bits++ = (pj_uint8_t)((*r >> 7) & 1); + *p_amr_bits++ = (pj_uint8_t)((*r >> 6) & 1); + *p_amr_bits++ = (pj_uint8_t)((*r >> 5) & 1); + *p_amr_bits++ = (pj_uint8_t)((*r >> 4) & 1); + *p_amr_bits++ = (pj_uint8_t)((*r >> 3) & 1); + *p_amr_bits++ = (pj_uint8_t)((*r >> 2) & 1); + *p_amr_bits++ = (pj_uint8_t)((*r >> 1) & 1); + *p_amr_bits++ = (pj_uint8_t)((*r ) & 1); + } + } + + if (in_info->frame_type < SID_FT) { + + /* Speech */ + out_info->mode = in_info->frame_type; + out->size = framelen_tbl[out_info->mode]; + + pj_bzero(out->buf, out->size); + + if (setting->reorder) { + const pj_int16_t *order_map; + + order_map = order_maps[out_info->mode]; + for(i = 0; i < framelenbit_tbl[out_info->mode]; ++i) { + if (amr_bits[i]) { + pj_uint16_t bitpos; + bitpos = order_map[i]; + w[bitpos>>3] |= 1 << (7 - (bitpos % 8)); + } + } + } else { + for(i = 0; i < framelenbit_tbl[out_info->mode]; ++i) { + if (amr_bits[i]) + w[i >> 3] |= 1 << (7 - (i % 8)); + } + } + + } else if (in_info->frame_type == SID_FT) { + + /* SID */ + pj_uint8_t w_bitptr = 0; + pj_uint8_t FT_; + + if (setting->amr_nb) + FT_ = (pj_uint8_t)((amr_bits[36] << 2) | (amr_bits[37] << 1) | + amr_bits[38]); + else + FT_ = (pj_uint8_t)((amr_bits[36] << 3) | (amr_bits[37] << 2) | + (amr_bits[38] << 1) | amr_bits[39]); + + out_info->mode = FT_; + out->size = 5; + + pj_bzero(out->buf, out->size); + for(i = 0; i < framelenbit_tbl[SID_FT]; ++i) { + if (amr_bits[i]) + *w |= (1 << (7-w_bitptr)); + + if (++w_bitptr == 8) { + ++w; + w_bitptr = 0; + } + } + + } else { + + /* NO DATA */ + out->size = 0; + out_info->mode = -1; + } + + out_info->start_bit = 0; + + return PJ_SUCCESS; +} + + +/** + * Pack encoded AMR frame(s) into an RTP payload. + * + * @param frames AMR frames to be packed. + * @param nframes Number of frames to be packed. + * @param setting Settings, see #pjmedia_codec_amr_pack_setting. + * @param pkt Payload. + * @param pkt_size Payload size, as input this specifies payload maximum size, + * as output this specifies payload packed size. + * + * @return PJ_SUCCESS on success. + */ +PJ_INLINE (pj_status_t) pjmedia_codec_amr_pack( + const pjmedia_frame frames[], + unsigned nframes, + const pjmedia_codec_amr_pack_setting *setting, + void *pkt, + pj_size_t *pkt_size) +{ + /* Write cursor */ + pj_uint8_t *w = (pj_uint8_t*)pkt; + pj_uint8_t w_bitptr = 0; + + /* Read cursor */ + pj_uint8_t *r; + + /* env vars for AMR or AMRWB */ + pj_uint8_t SID_FT; + const pj_uint8_t *framelen_tbl; + const pj_uint16_t *framelenbit_tbl; + const pj_uint16_t *bitrate_tbl; + const pj_int16_t* const *order_maps; + + /* frame info */ + pjmedia_codec_amr_bit_info *info; + + unsigned i, max_pkt_size; + + max_pkt_size = *pkt_size; + + if (setting->amr_nb) { + SID_FT = 8; + framelen_tbl = pjmedia_codec_amrnb_framelen; + framelenbit_tbl = pjmedia_codec_amrnb_framelenbits; + bitrate_tbl = pjmedia_codec_amrnb_bitrates; + order_maps = pjmedia_codec_amrnb_ordermaps; + } else { + SID_FT = 9; + framelen_tbl = pjmedia_codec_amrwb_framelen; + framelenbit_tbl = pjmedia_codec_amrwb_framelenbits; + bitrate_tbl = pjmedia_codec_amrwb_bitrates; + order_maps = pjmedia_codec_amrwb_ordermaps; + } + + /* Code Mode Request, 4 bits */ + *w = (pj_uint8_t)(setting->cmr << 4); + w_bitptr = 4; + if (setting->octet_aligned) { + ++w; + w_bitptr = 0; + } + + /* Table Of Contents, 6 bits each */ + for (i = 0; i < nframes; ++i) { + pj_uint8_t TOC, FT, Q; + pj_bool_t F; + + info = (pjmedia_codec_amr_bit_info*)&frames[i].bit_info; + + F = (i != nframes-1); + FT = info->frame_type; + Q = (pj_uint8_t)(info->good_quality == 1); + pj_assert(FT <= SID_FT || FT == 14 || FT == 15); + + /* Check buffer availability */ + *pkt_size = w - (pj_uint8_t*)pkt + 1; + PJ_ASSERT_RETURN(*pkt_size <= max_pkt_size, PJ_ETOOSMALL); + + TOC = (pj_uint8_t)((F<<5) | (FT<<1) | Q); + if (w_bitptr == 0) { + *w = (pj_uint8_t)(TOC<<2); + w_bitptr = 6; + } else if (w_bitptr == 2) { + *w++ |= TOC; + w_bitptr = 0; + } else if (w_bitptr == 4) { + *w++ |= TOC>>2; + *w = (pj_uint8_t)(TOC<<6); + w_bitptr = 2; + } else if (w_bitptr == 6) { + *w++ |= TOC>>4; + *w = (pj_uint8_t)(TOC<<4); + w_bitptr = 4; + } + if (setting->octet_aligned) { + ++w; + w_bitptr = 0; + } + } + + /* Encoded data */ + for (i = 0; i < nframes; ++i) { + pj_int8_t amr_bits[477 + 7] = {0}; + pj_int8_t *p_amr_bits = &amr_bits[0]; + unsigned j; + + info = (pjmedia_codec_amr_bit_info*)&frames[i].bit_info; + + /* Check buffer availability */ + *pkt_size = w - (pj_uint8_t*)pkt; + if (info->frame_type <= SID_FT) + *pkt_size += framelen_tbl[info->frame_type] + 1; + PJ_ASSERT_RETURN(*pkt_size <= max_pkt_size, PJ_ETOOSMALL); + + /* Skip if there is no data */ + if (info->frame_type > SID_FT) + continue; + + /* Unpack bits */ + r = (pj_uint8_t*) frames[i].buf; + j = 0; + if (info->start_bit) { + for (; j < (unsigned)(8-info->start_bit); ++j) + *p_amr_bits++ = (pj_uint8_t) + ((*r >> (7-info->start_bit-j)) & 1); + ++r; + } + for(; j < framelenbit_tbl[info->frame_type]; j+=8, ++r) { + *p_amr_bits++ = (pj_uint8_t)((*r >> 7) & 1); + *p_amr_bits++ = (pj_uint8_t)((*r >> 6) & 1); + *p_amr_bits++ = (pj_uint8_t)((*r >> 5) & 1); + *p_amr_bits++ = (pj_uint8_t)((*r >> 4) & 1); + *p_amr_bits++ = (pj_uint8_t)((*r >> 3) & 1); + *p_amr_bits++ = (pj_uint8_t)((*r >> 2) & 1); + *p_amr_bits++ = (pj_uint8_t)((*r >> 1) & 1); + *p_amr_bits++ = (pj_uint8_t)((*r ) & 1); + } + + if (info->frame_type < SID_FT) { + + /* Speech */ + if (w_bitptr == 0) *w = 0; + + if (setting->reorder) { + const pj_int16_t *order_map; + + /* Put bits in the packet, sensitivity descending ordered */ + order_map = order_maps[info->frame_type]; + for(j = 0; j < framelenbit_tbl[info->frame_type]; ++j) { + if (amr_bits[order_map[j]]) + *w |= (1 << (7-w_bitptr)); + + if (++w_bitptr == 8) { + w_bitptr = 0; + ++w; + *w = 0; + } + } + } else { + for(j = 0; j < framelenbit_tbl[info->frame_type]; ++j) { + if (amr_bits[j]) + *w |= (1 << (7-w_bitptr)); + + if (++w_bitptr == 8) { + w_bitptr = 0; + ++w; + *w = 0; + } + } + } + + } else if (info->frame_type == SID_FT) { + + /* SID */ + amr_bits[35] |= info->STI; + + if (setting->amr_nb) { + amr_bits[36] = (pj_uint8_t)((info->mode >> 2) & 1); + amr_bits[37] = (pj_uint8_t)((info->mode >> 1) & 1); + amr_bits[38] = (pj_uint8_t)((info->mode) & 1); + } else { + amr_bits[36] = (pj_uint8_t)((info->mode >> 3) & 1); + amr_bits[37] = (pj_uint8_t)((info->mode >> 2) & 1); + amr_bits[38] = (pj_uint8_t)((info->mode >> 1) & 1); + amr_bits[39] = (pj_uint8_t)((info->mode) & 1); + } + + if (w_bitptr == 0) *w = 0; + for(j = 0; j < framelenbit_tbl[info->frame_type]; ++j) { + if (amr_bits[j]) + *w |= (1 << (7-w_bitptr)); + + if (++w_bitptr == 8) { + w_bitptr = 0; + ++w; + *w = 0; + } + } + } + + if (setting->octet_aligned) { + ++w; + w_bitptr = 0; + } + } + + *pkt_size = w - (pj_uint8_t*)pkt; + if (w_bitptr) + *pkt_size += 1; + + return PJ_SUCCESS; +} + + +/** + * Parse AMR payload into frames. + * + * @param pkt Payload. + * @param pkt_size Payload size. + * @param ts Base timestamp. + * @param setting Settings, see #pjmedia_codec_amr_pack_setting. + * @param frames Frames parsed. + * @param nframes Number of frames parsed. + * @param cmr Change Mode Request message for local encoder. + * + * @return PJ_SUCCESS on success. + */ +PJ_INLINE(pj_status_t) pjmedia_codec_amr_parse( + void *pkt, + pj_size_t pkt_size, + const pj_timestamp *ts, + const pjmedia_codec_amr_pack_setting* setting, + pjmedia_frame frames[], + unsigned *nframes, + pj_uint8_t *cmr) +{ + unsigned cnt = 0; + pj_timestamp ts_ = *ts; + + /* Read cursor */ + pj_uint8_t r_bitptr = 0; + pj_uint8_t *r = (pj_uint8_t*)pkt; + + /* env vars for AMR or AMRWB */ + pj_uint8_t SID_FT; + const pj_uint8_t *framelen_tbl; + const pj_uint16_t *framelenbit_tbl; + const pj_int16_t* const *order_maps; + + /* frame info */ + pjmedia_codec_amr_bit_info *info; + + if (setting->amr_nb) { + SID_FT = 8; + framelen_tbl = pjmedia_codec_amrnb_framelen; + framelenbit_tbl = pjmedia_codec_amrnb_framelenbits; + order_maps = pjmedia_codec_amrnb_ordermaps; + } else { + SID_FT = 9; + framelen_tbl = pjmedia_codec_amrwb_framelen; + framelenbit_tbl = pjmedia_codec_amrwb_framelenbits; + order_maps = pjmedia_codec_amrwb_ordermaps; + } + + PJ_UNUSED_ARG(pkt_size); + + /* Code Mode Request, 4 bits */ + *cmr = (pj_uint8_t)((*r >> 4) & 0x0F); + r_bitptr = 4; + if (setting->octet_aligned) { + ++r; + r_bitptr = 0; + } + + /* Table Of Contents, 6 bits each */ + for (;;) { + pj_uint8_t TOC = 0; + pj_uint8_t F, FT, Q; + + if (r_bitptr == 0) { + TOC = (pj_uint8_t)(*r >> 2); + r_bitptr = 6; + } else if (r_bitptr == 2) { + TOC = (pj_uint8_t)(*r++ & 0x3F); + r_bitptr = 0; + } else if (r_bitptr == 4) { + TOC = (pj_uint8_t)((*r++ & 0x0f) << 2); + TOC |= *r >> 6; + r_bitptr = 2; + } else if (r_bitptr == 6) { + TOC = (pj_uint8_t)((*r++ & 0x03) << 4); + TOC |= *r >> 4; + r_bitptr = 4; + } + + F = (pj_uint8_t)(TOC >> 5); + FT = (pj_uint8_t)((TOC >> 1) & 0x0F); + Q = (pj_uint8_t)(TOC & 1); + + if (FT > SID_FT && FT < 14) { + pj_assert(!"Invalid AMR frametype, stream may be corrupted!"); + break; + } + + if (setting->octet_aligned) { + ++r; + r_bitptr = 0; + } + + /* Set frame attributes */ + info = (pjmedia_codec_amr_bit_info*) &frames[cnt].bit_info; + info->frame_type = FT; + info->mode = (pj_int8_t)((FT < SID_FT)? FT : -1); + info->good_quality = (pj_uint8_t)(Q == 1); + info->start_bit = 0; + info->STI = 0; + frames[cnt].timestamp = ts_; + frames[cnt].type = PJMEDIA_FRAME_TYPE_AUDIO; + + /* AMR frame length is 20ms */ + ts_.u64 += setting->amr_nb? 160 : 320; + + if (++cnt == *nframes || !F) + break; + } + *nframes = cnt; + + cnt = 0; + + /* Speech frames */ + while (cnt < *nframes) { + pj_uint8_t FT; + + info = (pjmedia_codec_amr_bit_info*) &frames[cnt].bit_info; + FT = info->frame_type; + + frames[cnt].buf = r; + info->start_bit = r_bitptr; + + if (FT == SID_FT) { + unsigned sti_bitptr; + sti_bitptr = r_bitptr + 35; + info->STI = (pj_uint8_t) + (r[sti_bitptr >> 3] >> (7 - (sti_bitptr % 8))) & 1; + } + + if (setting->octet_aligned) { + r += framelen_tbl[FT]; + frames[cnt].size = framelen_tbl[FT]; + } else { + if (FT == 14 || FT == 15) { + /* NO DATA */ + frames[cnt].size = 0; + } else { + unsigned adv_bit; + + adv_bit = framelenbit_tbl[FT] + r_bitptr; + r += adv_bit >> 3; + r_bitptr = (pj_uint8_t)(adv_bit % 8); + + frames[cnt].size = adv_bit >> 3; + if (r_bitptr) + ++frames[cnt].size; + } + } + ++cnt; + } + + return PJ_SUCCESS; +} + + +PJ_END_DECL + +/** + * @} + */ + +#endif /* __PJMEDIA_CODECS_AMR_HELPER_H__ */ diff --git a/pjmedia/include/pjmedia-codec/amr_sdp_match.h b/pjmedia/include/pjmedia-codec/amr_sdp_match.h new file mode 100644 index 0000000..7f379ab --- /dev/null +++ b/pjmedia/include/pjmedia-codec/amr_sdp_match.h @@ -0,0 +1,61 @@ +/* $Id: amr_sdp_match.h 3911 2011-12-15 06:45:23Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJMEDIA_CODEC_AMR_SDP_MATCH_H__ +#define __PJMEDIA_CODEC_AMR_SDP_MATCH_H__ + + +/** + * @file g7221_sdp_match.h + * @brief Special SDP format match for AMR-NB and AMR-WB. + */ + +#include <pjmedia/sdp_neg.h> + +PJ_BEGIN_DECL + + +/* Match AMR-NB and AMR-WB format in the SDP media offer and answer. This + * function will match some AMR settings in the SDP format parameters, i.e: + * octet-align, crc, robust-sorting, interleaving. Note that, for answerer, + * if octet-align mode needs to be adaptable to offerer setting, application + * should set #PJMEDIA_SDP_NEG_FMT_MATCH_ALLOW_MODIFY_ANSWER in the option. + * + * @param pool The memory pool. + * @param offer The SDP media offer. + * @param o_fmt_idx Index of the AMR format in the SDP media offer. + * @param answer The SDP media answer. + * @param a_fmt_idx Index of the AMR format in the SDP media answer. + * @param option The format matching option, see + * #pjmedia_sdp_neg_fmt_match_flag. + * + * @return PJ_SUCCESS when the formats in offer and answer match. + */ +PJ_DECL(pj_status_t) pjmedia_codec_amr_match_sdp( pj_pool_t *pool, + pjmedia_sdp_media *offer, + unsigned o_fmt_idx, + pjmedia_sdp_media *answer, + unsigned a_fmt_idx, + unsigned option); + + +PJ_END_DECL + + +#endif /* __PJMEDIA_CODEC_AMR_SDP_MATCH_H__ */ diff --git a/pjmedia/include/pjmedia-codec/audio_codecs.h b/pjmedia/include/pjmedia-codec/audio_codecs.h new file mode 100644 index 0000000..5605c5c --- /dev/null +++ b/pjmedia/include/pjmedia-codec/audio_codecs.h @@ -0,0 +1,98 @@ +/* $Id: audio_codecs.h 3666 2011-07-19 08:40:20Z nanang $ */ +/* + * Copyright (C) 2011-2011 Teluu Inc. (http://www.teluu.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJMEDIA_CODEC_ALL_CODECS_H__ +#define __PJMEDIA_CODEC_ALL_CODECS_H__ + +/** + * @file pjmedia-codec/all_codecs.h + * @brief Helper function to register all codecs + */ +#include <pjmedia/endpoint.h> +#include <pjmedia-codec/passthrough.h> + + +PJ_BEGIN_DECL + +/** + * @defgroup PJMEDIA_CODEC_REGISTER_ALL Codec registration helper + * @ingroup PJMEDIA_CODEC_CODECS + * @brief Helper function to register all codecs + * @{ + * + * Helper function to register all codecs that are implemented in + * PJMEDIA-CODEC library. + */ + +/** + * Codec configuration. Call #pjmedia_audio_codec_config_default() to initialize + * this structure with the default values. + */ +typedef struct pjmedia_audio_codec_config +{ + /** Speex codec settings. See #pjmedia_codec_speex_init() for more info */ + struct { + unsigned option; /**< Bitmask of options. */ + int quality; /**< Codec quality. */ + int complexity; /**< Codec complexity. */ + } speex; + + /** iLBC settings */ + struct { + unsigned mode; /**< iLBC mode. */ + } ilbc; + + /** Passthrough */ + struct { + pjmedia_codec_passthrough_setting setting; /**< Passthrough */ + } passthrough; + +} pjmedia_audio_codec_config; + + +/** + * Initialize pjmedia_audio_codec_config structure with default values. + * + * @param cfg The codec config to be initialized. + */ +PJ_DECL(void) +pjmedia_audio_codec_config_default(pjmedia_audio_codec_config *cfg); + +/** + * Register all known audio codecs implemented in PJMEDA-CODEC library to the + * specified media endpoint. + * + * @param endpt The media endpoint. + * @param c Optional codec configuration, or NULL to use default + * values. + * + * @return PJ_SUCCESS on success or the appropriate error code. + */ +PJ_DECL(pj_status_t) +pjmedia_codec_register_audio_codecs(pjmedia_endpt *endpt, + const pjmedia_audio_codec_config *c); + + +/** + * @} PJMEDIA_CODEC_REGISTER_ALL + */ + + +PJ_END_DECL + +#endif /* __PJMEDIA_CODEC_ALL_CODECS_H__ */ diff --git a/pjmedia/include/pjmedia-codec/config.h b/pjmedia/include/pjmedia-codec/config.h new file mode 100644 index 0000000..2c71cc9 --- /dev/null +++ b/pjmedia/include/pjmedia-codec/config.h @@ -0,0 +1,423 @@ +/* $Id: config.h 4070 2012-04-23 13:48:10Z bennylp $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJMEDIA_CODEC_CONFIG_H__ +#define __PJMEDIA_CODEC_CONFIG_H__ + +/** + * @file config.h + * @brief PJMEDIA-CODEC compile time settings + */ + +/** + * @defgroup pjmedia_codec_config PJMEDIA-CODEC Compile Time Settings + * @ingroup PJMEDIA_CODEC + * @brief Various compile time settings such as to enable/disable codecs + * @{ + */ + +#include <pjmedia/types.h> + +/* + * Include config_auto.h if autoconf is used (PJ_AUTOCONF is set) + */ +#if defined(PJ_AUTOCONF) +# include <pjmedia-codec/config_auto.h> +#endif + + +/** + * Unless specified otherwise, L16 codec is included by default. + */ +#ifndef PJMEDIA_HAS_L16_CODEC +# define PJMEDIA_HAS_L16_CODEC 1 +#endif + + +/** + * Unless specified otherwise, GSM codec is included by default. + */ +#ifndef PJMEDIA_HAS_GSM_CODEC +# define PJMEDIA_HAS_GSM_CODEC 1 +#endif + + +/** + * Unless specified otherwise, Speex codec is included by default. + */ +#ifndef PJMEDIA_HAS_SPEEX_CODEC +# define PJMEDIA_HAS_SPEEX_CODEC 1 +#endif + +/** + * Speex codec default complexity setting. + */ +#ifndef PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY +# define PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY 2 +#endif + +/** + * Speex codec default quality setting. Please note that pjsua-lib may override + * this setting via its codec quality setting (i.e PJSUA_DEFAULT_CODEC_QUALITY). + */ +#ifndef PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY +# define PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY 8 +#endif + + +/** + * Unless specified otherwise, iLBC codec is included by default. + */ +#ifndef PJMEDIA_HAS_ILBC_CODEC +# define PJMEDIA_HAS_ILBC_CODEC 1 +#endif + + +/** + * Unless specified otherwise, G.722 codec is included by default. + */ +#ifndef PJMEDIA_HAS_G722_CODEC +# define PJMEDIA_HAS_G722_CODEC 1 +#endif + + +/** + * Default G.722 codec encoder and decoder level adjustment. The G.722 + * specifies that it uses 14 bit PCM for input and output, while PJMEDIA + * normally uses 16 bit PCM, so the conversion is done by applying + * level adjustment. If the value is non-zero, then PCM input samples to + * the encoder will be shifted right by this value, and similarly PCM + * output samples from the decoder will be shifted left by this value. + * + * This can be changed at run-time after initialization by calling + * #pjmedia_codec_g722_set_pcm_shift(). + * + * Default: 2. + */ +#ifndef PJMEDIA_G722_DEFAULT_PCM_SHIFT +# define PJMEDIA_G722_DEFAULT_PCM_SHIFT 2 +#endif + + +/** + * Specifies whether G.722 PCM shifting should be stopped when clipping + * detected in the decoder. Enabling this feature can be useful when + * talking to G.722 implementation that uses 16 bit PCM for G.722 input/ + * output (for any reason it seems to work) and the PCM shifting causes + * audio clipping. + * + * See also #PJMEDIA_G722_DEFAULT_PCM_SHIFT. + * + * Default: enabled. + */ +#ifndef PJMEDIA_G722_STOP_PCM_SHIFT_ON_CLIPPING +# define PJMEDIA_G722_STOP_PCM_SHIFT_ON_CLIPPING 1 +#endif + + +/** + * Enable the features provided by Intel IPP libraries, for example + * codecs such as G.729, G.723.1, G.726, G.728, G.722.1, and AMR. + * + * By default this is disabled. Please follow the instructions in + * http://trac.pjsip.org/repos/wiki/Intel_IPP_Codecs on how to setup + * Intel IPP with PJMEDIA. + */ +#ifndef PJMEDIA_HAS_INTEL_IPP +# define PJMEDIA_HAS_INTEL_IPP 0 +#endif + + +/** + * Visual Studio only: when this option is set, the Intel IPP libraries + * will be automatically linked to application using pragma(comment) + * constructs. This is convenient, however it will only link with + * the stub libraries and the Intel IPP DLL's will be required when + * distributing the application. + * + * If application wants to link with the different types of the Intel IPP + * libraries (for example, the static libraries), it must set this option + * to zero and specify the Intel IPP libraries in the application's input + * library specification manually. + * + * Default 1. + */ +#ifndef PJMEDIA_AUTO_LINK_IPP_LIBS +# define PJMEDIA_AUTO_LINK_IPP_LIBS 1 +#endif + + +/** + * Enable Intel IPP AMR codec. This also needs to be enabled when AMR WB + * codec is enabled. This option is only used when PJMEDIA_HAS_INTEL_IPP + * is enabled. + * + * Default: 1 + */ +#ifndef PJMEDIA_HAS_INTEL_IPP_CODEC_AMR +# define PJMEDIA_HAS_INTEL_IPP_CODEC_AMR 1 +#endif + + +/** + * Enable Intel IPP AMR wideband codec. The PJMEDIA_HAS_INTEL_IPP_CODEC_AMR + * option must also be enabled to use this codec. This option is only used + * when PJMEDIA_HAS_INTEL_IPP is enabled. + * + * Default: 1 + */ +#ifndef PJMEDIA_HAS_INTEL_IPP_CODEC_AMRWB +# define PJMEDIA_HAS_INTEL_IPP_CODEC_AMRWB 1 +#endif + + +/** + * Enable Intel IPP G.729 codec. This option is only used when + * PJMEDIA_HAS_INTEL_IPP is enabled. + * + * Default: 1 + */ +#ifndef PJMEDIA_HAS_INTEL_IPP_CODEC_G729 +# define PJMEDIA_HAS_INTEL_IPP_CODEC_G729 1 +#endif + + +/** + * Enable Intel IPP G.723.1 codec. This option is only used when + * PJMEDIA_HAS_INTEL_IPP is enabled. + * + * Default: 1 + */ +#ifndef PJMEDIA_HAS_INTEL_IPP_CODEC_G723_1 +# define PJMEDIA_HAS_INTEL_IPP_CODEC_G723_1 1 +#endif + + +/** + * Enable Intel IPP G.726 codec. This option is only used when + * PJMEDIA_HAS_INTEL_IPP is enabled. + * + * Default: 1 + */ +#ifndef PJMEDIA_HAS_INTEL_IPP_CODEC_G726 +# define PJMEDIA_HAS_INTEL_IPP_CODEC_G726 1 +#endif + + +/** + * Enable Intel IPP G.728 codec. This option is only used when + * PJMEDIA_HAS_INTEL_IPP is enabled. + * + * Default: 1 + */ +#ifndef PJMEDIA_HAS_INTEL_IPP_CODEC_G728 +# define PJMEDIA_HAS_INTEL_IPP_CODEC_G728 1 +#endif + + +/** + * Enable Intel IPP G.722.1 codec. This option is only used when + * PJMEDIA_HAS_INTEL_IPP is enabled. + * + * Default: 1 + */ +#ifndef PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1 +# define PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1 1 +#endif + +/** + * Enable Passthrough codecs. + * + * Default: 0 + */ +#ifndef PJMEDIA_HAS_PASSTHROUGH_CODECS +# define PJMEDIA_HAS_PASSTHROUGH_CODECS 0 +#endif + +/** + * Enable AMR passthrough codec. + * + * Default: 1 + */ +#ifndef PJMEDIA_HAS_PASSTHROUGH_CODEC_AMR +# define PJMEDIA_HAS_PASSTHROUGH_CODEC_AMR 1 +#endif + +/** + * Enable G.729 passthrough codec. + * + * Default: 1 + */ +#ifndef PJMEDIA_HAS_PASSTHROUGH_CODEC_G729 +# define PJMEDIA_HAS_PASSTHROUGH_CODEC_G729 1 +#endif + +/** + * Enable iLBC passthrough codec. + * + * Default: 1 + */ +#ifndef PJMEDIA_HAS_PASSTHROUGH_CODEC_ILBC +# define PJMEDIA_HAS_PASSTHROUGH_CODEC_ILBC 1 +#endif + +/** + * Enable PCMU passthrough codec. + * + * Default: 1 + */ +#ifndef PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMU +# define PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMU 1 +#endif + +/** + * Enable PCMA passthrough codec. + * + * Default: 1 + */ +#ifndef PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMA +# define PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMA 1 +#endif + +/* If passthrough and PCMU/PCMA are enabled, disable the software + * G.711 codec + */ +#if PJMEDIA_HAS_PASSTHROUGH_CODECS && \ + (PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMU || PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMA) +# undef PJMEDIA_HAS_G711_CODEC +# define PJMEDIA_HAS_G711_CODEC 0 +#endif + + +/** + * G.722.1 codec is disabled by default. + */ +#ifndef PJMEDIA_HAS_G7221_CODEC +# define PJMEDIA_HAS_G7221_CODEC 0 +#endif + +/** + * Enable OpenCORE AMR-NB codec. + * See https://trac.pjsip.org/repos/ticket/1388 for some info. + * + * Default: 0 + */ +#ifndef PJMEDIA_HAS_OPENCORE_AMRNB_CODEC +# define PJMEDIA_HAS_OPENCORE_AMRNB_CODEC 0 +#endif + +/** + * Link with libopencore-amrXX via pragma comment on Visual Studio. + * This option only makes sense if PJMEDIA_HAS_OPENCORE_AMRNB_CODEC + * is enabled. + * + * Default: 1 + */ +#ifndef PJMEDIA_AUTO_LINK_OPENCORE_AMR_LIBS +# define PJMEDIA_AUTO_LINK_OPENCORE_AMR_LIBS 1 +#endif + +/** + * Link with libopencore-amrXX.a that has been produced with gcc. + * This option only makes sense if PJMEDIA_HAS_OPENCORE_AMRNB_CODEC + * and PJMEDIA_AUTO_LINK_OPENCORE_AMR_LIBS are enabled. + * + * Default: 1 + */ +#ifndef PJMEDIA_OPENCORE_AMR_BUILT_WITH_GCC +# define PJMEDIA_OPENCORE_AMR_BUILT_WITH_GCC 1 +#endif + + +/** + * Default G.722.1 codec encoder and decoder level adjustment. + * If the value is non-zero, then PCM input samples to the encoder will + * be shifted right by this value, and similarly PCM output samples from + * the decoder will be shifted left by this value. + * + * This can be changed at run-time after initialization by calling + * #pjmedia_codec_g7221_set_pcm_shift(). + */ +#ifndef PJMEDIA_G7221_DEFAULT_PCM_SHIFT +# define PJMEDIA_G7221_DEFAULT_PCM_SHIFT 1 +#endif + + +/** + * Enabling both G.722.1 codec implementations, internal PJMEDIA and IPP, + * may cause problem in SDP, i.e: payload types duplications. So, let's + * just trap such case here at compile time. + * + * Application can control which implementation to be used by manipulating + * PJMEDIA_HAS_G7221_CODEC and PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1 in + * config_site.h. + */ +#if (PJMEDIA_HAS_G7221_CODEC != 0) && (PJMEDIA_HAS_INTEL_IPP != 0) && \ + (PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1 != 0) +# error Only one G.722.1 implementation can be enabled at the same time. \ + Please use PJMEDIA_HAS_G7221_CODEC and \ + PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1 in your config_site.h \ + to control which implementation to be used. +#endif + + +/** + * Specify if FFMPEG codecs are available. + * + * Default: PJMEDIA_HAS_LIBAVCODEC + */ +#ifndef PJMEDIA_HAS_FFMPEG_CODEC +# define PJMEDIA_HAS_FFMPEG_CODEC PJMEDIA_HAS_LIBAVCODEC +#endif + + +/** + * Specify if FFMPEG video codecs are available. + * + * Default: PJMEDIA_HAS_FFMPEG_CODEC + */ +#ifndef PJMEDIA_HAS_FFMPEG_VID_CODEC +# define PJMEDIA_HAS_FFMPEG_VID_CODEC PJMEDIA_HAS_FFMPEG_CODEC +#endif + +/** + * Enable FFMPEG H263+/H263-1998 codec. + * + * Default: 1 + */ +#ifndef PJMEDIA_HAS_FFMPEG_CODEC_H263P +# define PJMEDIA_HAS_FFMPEG_CODEC_H263P PJMEDIA_HAS_FFMPEG_VID_CODEC +#endif + +/** + * Enable FFMPEG H264 codec (requires libx264). + * + * Default: 0 + */ +#ifndef PJMEDIA_HAS_FFMPEG_CODEC_H264 +# define PJMEDIA_HAS_FFMPEG_CODEC_H264 PJMEDIA_HAS_FFMPEG_VID_CODEC +#endif + +/** + * @} + */ + + + +#endif /* __PJMEDIA_CODEC_CONFIG_H__ */ diff --git a/pjmedia/include/pjmedia-codec/config_auto.h.in b/pjmedia/include/pjmedia-codec/config_auto.h.in new file mode 100644 index 0000000..887d083 --- /dev/null +++ b/pjmedia/include/pjmedia-codec/config_auto.h.in @@ -0,0 +1,80 @@ +/* $Id: config_auto.h.in 3841 2011-10-24 09:28:13Z ming $ */ +/* + * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) + * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJMEDIA_CODEC_CONFIG_AUTO_H_ +#define __PJMEDIA_CODEC_CONFIG_AUTO_H_ + +/** + * @file config_auto.h + * @brief PJMEDIA-CODEC configuration as set by autoconf script + */ + +/* + * Note: + * The configuration in config_site.h overrides any other settings, + * including the setting as detected by autoconf. + */ + +/* L16 codec */ +#ifndef PJMEDIA_HAS_L16_CODEC +#undef PJMEDIA_HAS_L16_CODEC +#endif + + +/* GSM codec */ +#ifndef PJMEDIA_HAS_GSM_CODEC +#undef PJMEDIA_HAS_GSM_CODEC +#endif + +#undef PJMEDIA_EXTERNAL_GSM_CODEC +#undef PJMEDIA_EXTERNAL_GSM_GSM_H +#undef PJMEDIA_EXTERNAL_GSM_H + +/* Speex codec */ +#ifndef PJMEDIA_HAS_SPEEX_CODEC +#undef PJMEDIA_HAS_SPEEX_CODEC +#endif + +#undef PJMEDIA_EXTERNAL_SPEEX_CODEC + +/* iLBC codec */ +#ifndef PJMEDIA_HAS_ILBC_CODEC +#undef PJMEDIA_HAS_ILBC_CODEC +#endif + + +/* G722 codec */ +#ifndef PJMEDIA_HAS_G722_CODEC +#undef PJMEDIA_HAS_G722_CODEC +#endif + +/* G7221 codec */ +#ifndef PJMEDIA_HAS_G7221_CODEC +#undef PJMEDIA_HAS_G7221_CODEC +#endif + +/* OpenCORE AMR-NB codec */ +#ifndef PJMEDIA_HAS_OPENCORE_AMRNB_CODEC +#undef PJMEDIA_HAS_OPENCORE_AMRNB_CODEC +#endif + + +#endif /* __PJMEDIA_CODEC_CONFIG_AUTO_H_ */ + + diff --git a/pjmedia/include/pjmedia-codec/ffmpeg_vid_codecs.h b/pjmedia/include/pjmedia-codec/ffmpeg_vid_codecs.h new file mode 100644 index 0000000..e238af2 --- /dev/null +++ b/pjmedia/include/pjmedia-codec/ffmpeg_vid_codecs.h @@ -0,0 +1,67 @@ +/* $Id: ffmpeg_vid_codecs.h 4049 2012-04-13 06:24:23Z ming $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJMEDIA_CODECS_FFMPEG_VID_H__ +#define __PJMEDIA_CODECS_FFMPEG_VID_H__ + + +#include <pjmedia-codec/types.h> +#include <pjmedia/vid_codec.h> + +PJ_BEGIN_DECL + +/** + * @defgroup PJMEDIA_CODEC_VID_FFMPEG FFmpeg Codecs + * @ingroup PJMEDIA_CODEC_VID_CODECS + * @{ + */ + +/** + * Initialize and register FFMPEG video codecs factory to pjmedia endpoint. + * + * @param mgr The video codec manager instance where this codec will + * be registered to. Specify NULL to use default instance + * (in that case, an instance of video codec manager must + * have been created beforehand). + * @param pf Pool factory. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_ffmpeg_vid_init(pjmedia_vid_codec_mgr *mgr, + pj_pool_factory *pf); + + +/** + * Unregister FFMPEG video codecs factory from the video codec manager and + * deinitialize the codecs library. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_ffmpeg_vid_deinit(void); + + +PJ_END_DECL + + +/** + * @} + */ + +#endif /* __PJMEDIA_CODECS_FFMPEG_VID_H__ */ + diff --git a/pjmedia/include/pjmedia-codec/g722.h b/pjmedia/include/pjmedia-codec/g722.h new file mode 100644 index 0000000..8f5b72f --- /dev/null +++ b/pjmedia/include/pjmedia-codec/g722.h @@ -0,0 +1,104 @@ +/* $Id: g722.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJMEDIA_CODEC_G722_H__ +#define __PJMEDIA_CODEC_G722_H__ + +/** + * @file pjmedia-codec/g722.h + * @brief G.722 codec. + */ + +#include <pjmedia-codec/types.h> + +/** + * @defgroup PJMED_G722 G.722 Codec + * @ingroup PJMEDIA_CODEC_CODECS + * @brief Implementation of G.722 Codec + * @{ + * + * This section describes functions to initialize and register G.722 codec + * factory to the codec manager. After the codec factory has been registered, + * application can use @ref PJMEDIA_CODEC API to manipulate the codec. + * + * The G.722 implementation uses 16-bit PCM with sampling rate 16000Hz and + * 20ms frame length resulting in 64kbps bitrate. + * + * The G.722 codec implementation is provided as part of pjmedia-codec + * library, and does not depend on external G.722 codec implementation. + * + * \section codec_setting Codec Settings + * + * \subsection general_setting General Settings + * + * General codec settings for this codec such as VAD and PLC can be + * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param. + * Please see the documentation of #pjmedia_codec_param for more info. + * + * \subsection specific_setting Codec Specific Settings + * + * Currently none. + */ + +PJ_BEGIN_DECL + + +/** + * Initialize and register G.722 codec factory to pjmedia endpoint. + * + * @param endpt The pjmedia endpoint. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_g722_init(pjmedia_endpt *endpt); + + +/** + * Unregister G.722 codec factory from pjmedia endpoint and cleanup + * resources allocated by the factory. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_g722_deinit(void); + + +/** + * Set the G.722 codec encoder and decoder level adjustment. + * If the value is non-zero, then PCM input samples to the encoder will + * be shifted right by this value, and similarly PCM output samples from + * the decoder will be shifted left by this value. + * + * Default value is PJMEDIA_G722_DEFAULT_PCM_SHIFT. + * + * @param val The value + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_g722_set_pcm_shift(unsigned val); + + +PJ_END_DECL + + +/** + * @} + */ + +#endif /* __PJMEDIA_CODEC_G722_H__ */ + diff --git a/pjmedia/include/pjmedia-codec/g7221.h b/pjmedia/include/pjmedia-codec/g7221.h new file mode 100644 index 0000000..596eee2 --- /dev/null +++ b/pjmedia/include/pjmedia-codec/g7221.h @@ -0,0 +1,162 @@ +/* $Id: g7221.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJMEDIA_CODECS_G7221_H__ +#define __PJMEDIA_CODECS_G7221_H__ + +/** + * @file pjmedia-codec/g7221.h + * @brief G722.1 codec. + */ + +#include <pjmedia-codec/types.h> + +/** + * @defgroup PJMED_G7221_CODEC G.722.1 Codec (Siren7/Siren14) + * @ingroup PJMEDIA_CODEC_CODECS + * @brief Implementation of G.722.1 codec + * @{ + * + * <b>G.722.1 licensed from Polycom®</b><br /> + * <b>G.722.1 Annex C licensed from Polycom®</b> + * + * This section describes functions to initialize and register G.722.1 codec + * factory to the codec manager. After the codec factory has been registered, + * application can use @ref PJMEDIA_CODEC API to manipulate the codec. + * + * PJMEDIA G722.1 codec implementation is based on ITU-T Recommendation + * G.722.1 (05/2005) C fixed point implementation including its Annex C. + * + * G.722.1 is a low complexity codec that supports 7kHz and 14kHz audio + * bandwidth working at bitrates ranging from 16kbps to 48kbps. It may be + * used with speech or music inputs. + * + * + * \section codec_setting Codec Settings + * + * \subsection general_setting General Settings + * + * General codec settings for this codec such as VAD and PLC can be + * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param. + * Please see the documentation of #pjmedia_codec_param for more info. + * + * \subsection specific_setting Codec Specific Settings + * + * The following settings are applicable for this codec. + * + * \subsubsection bitrate Bitrate + * + * The codec implementation supports standard and non-standard bitrates. + * Use #pjmedia_codec_g7221_set_mode() to enable or disable the bitrates. + * + * By default, only standard bitrates are enabled upon initialization: + * - for 7kHz audio bandwidth (16kHz sampling rate): 24kbps and 32kbps, + * - for 14kHz audio bandwidth (32kHz sampling rate): 24kbps, 32kbps, and + * 48kbps. + * + * The usage of non-standard bitrates must follow these requirements: + * - for 7kHz audio bandwidth (16kHz sampling rate): 16000 to 32000 bps, + * multiplication of 400 + * - for 14kHz audio bandwidth (32kHz sampling rate): 24000 to 48000 bps, + * multiplication of 400 + * + * \note + * Currently only up to two non-standard modes can be enabled. + * + * \remark + * There is a flaw in the codec manager as currently it could not + * differentiate G.722.1 codecs by bitrates, hence invoking + * #pjmedia_codec_mgr_set_default_param() may only affect a G.722.1 codec + * with the highest priority (or first index found in codec enumeration + * when they have same priority) and invoking + * #pjmedia_codec_mgr_set_codec_priority() will set priority of all G.722.1 + * codecs with sampling rate as specified. + */ + +PJ_BEGIN_DECL + +/** + * Initialize and register G.722.1 codec factory to pjmedia endpoint. + * + * @param endpt The pjmedia endpoint. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_g7221_init( pjmedia_endpt *endpt ); + + +/** + * Enable and disable G.722.1 mode. By default, the standard modes are + * enabled upon initialization, i.e.: + * - sampling rate 16kHz, bitrate 24kbps and 32kbps. + * - sampling rate 32kHz, bitrate 24kbps, 32kbps, and 48kbps. + * This function can also be used for enabling non-standard modes. + * Note that currently only up to two non-standard modes can be enabled + * at one time. + * + * @param sample_rate PCM sampling rate, in Hz, valid values are only + * 16000 and 32000. + * @param bitrate G722.1 bitrate, in bps, the valid values are + * standard and non-standard bitrates as described + * above. + * @param enabled PJ_TRUE for enabling specified mode. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_g7221_set_mode(unsigned sample_rate, + unsigned bitrate, + pj_bool_t enabled); + +/** + * Set the G.722.1 codec encoder and decoder level adjustment. + * If the value is non-zero, then PCM input samples to the encoder will + * be shifted right by this value, and similarly PCM output samples from + * the decoder will be shifted left by this value. + * + * \note + * This function is also applicable for G722.1 implementation with IPP + * back-end. + * + * Default value is PJMEDIA_G7221_DEFAULT_PCM_SHIFT. + * + * @param val The value + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_g7221_set_pcm_shift(int val); + + + +/** + * Unregister G.722.1 codecs factory from pjmedia endpoint. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_g7221_deinit(void); + + +PJ_END_DECL + + +/** + * @} + */ + +#endif /* __PJMEDIA_CODECS_G7221_H__ */ + diff --git a/pjmedia/include/pjmedia-codec/g7221_sdp_match.h b/pjmedia/include/pjmedia-codec/g7221_sdp_match.h new file mode 100644 index 0000000..c3aa647 --- /dev/null +++ b/pjmedia/include/pjmedia-codec/g7221_sdp_match.h @@ -0,0 +1,59 @@ +/* $Id: g7221_sdp_match.h 3911 2011-12-15 06:45:23Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJMEDIA_CODEC_G7221_SDP_MATCH_H__ +#define __PJMEDIA_CODEC_G7221_SDP_MATCH_H__ + + +/** + * @file g7221_sdp_match.h + * @brief Special SDP format match for G722.1. + */ + +#include <pjmedia/sdp_neg.h> + +PJ_BEGIN_DECL + +/** + * Match G.722.1 format in the SDP media offer and answer. This function + * will match G.722.1 bitrate setting in the SDP format parameter of + * offer and answer. + * + * @param pool The memory pool. + * @param offer The SDP media offer. + * @param o_fmt_idx Index of the G.722.1 format in the SDP media offer. + * @param answer The SDP media answer. + * @param a_fmt_idx Index of the G.722.1 format in the SDP media answer. + * @param option The format matching option, see + * #pjmedia_sdp_neg_fmt_match_flag. + * + * @return PJ_SUCCESS when the formats in offer and answer match. + */ +PJ_DECL(pj_status_t) pjmedia_codec_g7221_match_sdp( pj_pool_t *pool, + pjmedia_sdp_media *offer, + unsigned o_fmt_idx, + pjmedia_sdp_media *answer, + unsigned a_fmt_idx, + unsigned option); + + +PJ_END_DECL + + +#endif /* __PJMEDIA_CODEC_G7221_SDP_MATCH_H__ */ diff --git a/pjmedia/include/pjmedia-codec/gsm.h b/pjmedia/include/pjmedia-codec/gsm.h new file mode 100644 index 0000000..aa939d4 --- /dev/null +++ b/pjmedia/include/pjmedia-codec/gsm.h @@ -0,0 +1,87 @@ +/* $Id: gsm.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJMEDIA_CODEC_GSM_H__ +#define __PJMEDIA_CODEC_GSM_H__ + +/** + * @file pjmedia-codec/gsm.h + * @brief GSM 06.10 codec. + */ + +#include <pjmedia-codec/types.h> + +/** + * @defgroup PJMED_GSM GSM 06.10 Codec + * @ingroup PJMEDIA_CODEC_CODECS + * @brief Implementation of GSM FR based on GSM 06.10 library + * @{ + * + * This section describes functions to initialize and register GSM codec + * factory to the codec manager. After the codec factory has been registered, + * application can use @ref PJMEDIA_CODEC API to manipulate the codec. + * + * The GSM codec supports 16-bit PCM with sampling rate of 8000Hz resulting + * in 13.2kbps bitrate. + * + * \section codec_setting Codec Settings + * + * \subsection general_setting General Settings + * + * General codec settings for this codec such as VAD and PLC can be + * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param. + * Please see the documentation of #pjmedia_codec_param for more info. + * + * \subsection specific_setting Codec Specific Settings + * + * Currently none. + */ + +PJ_BEGIN_DECL + + +/** + * Initialize and register GSM codec factory to pjmedia endpoint. + * + * @param endpt The pjmedia endpoint. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_gsm_init( pjmedia_endpt *endpt ); + + + +/** + * Unregister GSM codec factory from pjmedia endpoint and deinitialize + * the GSM codec library. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_gsm_deinit(void); + + +PJ_END_DECL + + +/** + * @} + */ + +#endif /* __PJMEDIA_CODEC_GSM_H__ */ + diff --git a/pjmedia/include/pjmedia-codec/h263_packetizer.h b/pjmedia/include/pjmedia-codec/h263_packetizer.h new file mode 100644 index 0000000..62644a0 --- /dev/null +++ b/pjmedia/include/pjmedia-codec/h263_packetizer.h @@ -0,0 +1,146 @@ +/* $Id: h263_packetizer.h 3715 2011-08-19 09:35:25Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJMEDIA_H263_PACKETIZER_H__ +#define __PJMEDIA_H263_PACKETIZER_H__ + + +/** + * @file h263_packetizer.h + * @brief Packetizes/unpacketizes H.263 bitstream into RTP payload. + */ + +#include <pj/pool.h> +#include <pj/types.h> + +PJ_BEGIN_DECL + + +/** + * Opaque declaration for H.263 packetizer. + */ +typedef struct pjmedia_h263_packetizer pjmedia_h263_packetizer; + + +/** + * Enumeration of H.263 packetization modes. + */ +typedef enum +{ + /** + * H.263 RTP packetization using RFC 4629. + */ + PJMEDIA_H263_PACKETIZER_MODE_RFC4629, + + /** + * H.263 RTP packetization using legacy RFC 2190. + * This is currently not supported. + */ + PJMEDIA_H263_PACKETIZER_MODE_RFC2190, + +} pjmedia_h263_packetizer_mode; + + +/** + * H.263 packetizer configuration. + */ +typedef struct pjmedia_h263_packetizer_cfg +{ + /** + * Maximum payload length. + * Default: PJMEDIA_MAX_MTU + */ + int mtu; + + /** + * Packetization mode. + * Default: PJMEDIA_H263_PACKETIZER_MODE_RFC4629 + */ + pjmedia_h263_packetizer_mode mode; + +} pjmedia_h263_packetizer_cfg; + + +/** + * Create H.263 packetizer. + * + * @param pool The memory pool. + * @param cfg Packetizer settings, if NULL, default setting + * will be used. + * @param p_pktz Pointer to receive the packetizer. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_h263_packetizer_create( + pj_pool_t *pool, + const pjmedia_h263_packetizer_cfg *cfg, + pjmedia_h263_packetizer **p_pktz); + + +/** + * Generate an RTP payload from a H.263 picture bitstream. Note that this + * function will apply in-place processing, so the bitstream may be modified + * during the packetization. + * + * @param pktz The packetizer. + * @param bits The picture bitstream to be packetized. + * @param bits_len The length of the bitstream. + * @param bits_pos The bitstream offset to be packetized. + * @param payload The output payload. + * @param payload_len The output payload length. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_h263_packetize(pjmedia_h263_packetizer *pktz, + pj_uint8_t *bits, + pj_size_t bits_len, + unsigned *bits_pos, + const pj_uint8_t **payload, + pj_size_t *payload_len); + + +/** + * Append an RTP payload to an H.263 picture bitstream. Note that in case of + * noticing packet lost, application should keep calling this function with + * payload pointer set to NULL, as the packetizer need to update its internal + * state. + * + * @param pktz The packetizer. + * @param payload The payload to be unpacketized. + * @param payload_len The payload length. + * @param bits The bitstream buffer. + * @param bits_size The bitstream buffer size. + * @param bits_pos The bitstream offset to put the unpacketized payload + * in the bitstream, upon return, this will be updated + * to the latest offset as a result of the unpacketized + * payload. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_h263_unpacketize(pjmedia_h263_packetizer *pktz, + const pj_uint8_t *payload, + pj_size_t payload_len, + pj_uint8_t *bits, + pj_size_t bits_size, + unsigned *bits_pos); + + +PJ_END_DECL + + +#endif /* __PJMEDIA_H263_PACKETIZER_H__ */ diff --git a/pjmedia/include/pjmedia-codec/h264_packetizer.h b/pjmedia/include/pjmedia-codec/h264_packetizer.h new file mode 100644 index 0000000..4e26180 --- /dev/null +++ b/pjmedia/include/pjmedia-codec/h264_packetizer.h @@ -0,0 +1,157 @@ +/* $Id: h264_packetizer.h 3664 2011-07-19 03:42:28Z nanang $ */ +/* + * Copyright (C) 2011 Teluu Inc. (http://www.teluu.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJMEDIA_H264_PACKETIZER_H__ +#define __PJMEDIA_H264_PACKETIZER_H__ + +/** + * @file h264_packetizer.h + * @brief Packetizes H.264 bitstream into RTP payload and vice versa. + */ + +#include <pj/types.h> + +PJ_BEGIN_DECL + +/** + * Opaque declaration for H.264 packetizer. + */ +typedef struct pjmedia_h264_packetizer pjmedia_h264_packetizer; + + +/** + * Enumeration of H.264 packetization modes. + */ +typedef enum +{ + /** + * Single NAL unit packetization mode will only generate payloads + * containing a complete single NAL unit packet. As H.264 NAL unit + * size can be very large, this mode is usually not applicable for + * network environments with MTU size limitation. + */ + PJMEDIA_H264_PACKETIZER_MODE_SINGLE_NAL, + + /** + * Non-interleaved packetization mode will generate payloads with the + * following possible formats: + * - single NAL unit packets, + * - NAL units aggregation STAP-A packets, + * - fragmented NAL unit FU-A packets. + */ + PJMEDIA_H264_PACKETIZER_MODE_NON_INTERLEAVED, + + /** + * Interleaved packetization mode will generate payloads with the + * following possible formats: + * - single NAL unit packets, + * - NAL units aggregation STAP-A & STAP-B packets, + * - fragmented NAL unit FU-A & FU-B packets. + * This packetization mode is currently unsupported. + */ + PJMEDIA_H264_PACKETIZER_MODE_INTERLEAVED, +} pjmedia_h264_packetizer_mode; + + +/** + * H.264 packetizer setting. + */ +typedef struct pjmedia_h264_packetizer_cfg +{ + /** + * Maximum payload length. + * Default: PJMEDIA_MAX_MTU + */ + int mtu; + + /** + * Packetization mode. + * Default: PJMEDIA_H264_PACKETIZER_MODE_NON_INTERLEAVED + */ + pjmedia_h264_packetizer_mode mode; +} +pjmedia_h264_packetizer_cfg; + + +/** + * Create H.264 packetizer. + * + * @param pool The memory pool. + * @param cfg Packetizer settings, if NULL, default setting + * will be used. + * @param p_pktz Pointer to receive the packetizer. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_h264_packetizer_create( + pj_pool_t *pool, + const pjmedia_h264_packetizer_cfg *cfg, + pjmedia_h264_packetizer **p_pktz); + + +/** + * Generate an RTP payload from a H.264 picture bitstream. Note that this + * function will apply in-place processing, so the bitstream may be modified + * during the packetization. + * + * @param pktz The packetizer. + * @param bits The picture bitstream to be packetized. + * @param bits_len The length of the bitstream. + * @param bits_pos The bitstream offset to be packetized. + * @param payload The output payload. + * @param payload_len The output payload length. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_h264_packetize(pjmedia_h264_packetizer *pktz, + pj_uint8_t *bits, + pj_size_t bits_len, + unsigned *bits_pos, + const pj_uint8_t **payload, + pj_size_t *payload_len); + + +/** + * Append an RTP payload to an H.264 picture bitstream. Note that in case of + * noticing packet lost, application should keep calling this function with + * payload pointer set to NULL, as the packetizer need to update its internal + * state. + * + * @param pktz The packetizer. + * @param payload The payload to be unpacketized. + * @param payload_len The payload length. + * @param bits The bitstream buffer. + * @param bits_size The bitstream buffer size. + * @param bits_pos The bitstream offset to put the unpacketized payload + * in the bitstream, upon return, this will be updated + * to the latest offset as a result of the unpacketized + * payload. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_h264_unpacketize(pjmedia_h264_packetizer *pktz, + const pj_uint8_t *payload, + pj_size_t payload_len, + pj_uint8_t *bits, + pj_size_t bits_len, + unsigned *bits_pos); + + +PJ_END_DECL + +#endif /* __PJMEDIA_H264_PACKETIZER_H__ */ diff --git a/pjmedia/include/pjmedia-codec/ilbc.h b/pjmedia/include/pjmedia-codec/ilbc.h new file mode 100644 index 0000000..c92f637 --- /dev/null +++ b/pjmedia/include/pjmedia-codec/ilbc.h @@ -0,0 +1,119 @@ +/* $Id: ilbc.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJMEDIA_CODEC_ILBC_H__ +#define __PJMEDIA_CODEC_ILBC_H__ + +/** + * @file pjmedia-codec/ilbc.h + * @brief iLBC codec. + */ + +#include <pjmedia-codec/types.h> + +/** + * @defgroup PJMED_ILBC iLBC Codec + * @ingroup PJMEDIA_CODEC_CODECS + * @brief Implementation of iLBC Codec + * @{ + * + * This section describes functions to initialize and register iLBC codec + * factory to the codec manager. After the codec factory has been registered, + * application can use @ref PJMEDIA_CODEC API to manipulate the codec. + * + * The iLBC codec is developed by Global IP Solutions (GIPS), formerly + * Global IP Sound. The iLBC offers low bitrate and graceful audio quality + * degradation on frame losses. + * + * The iLBC codec supports 16-bit PCM audio signal with sampling rate of + * 8000Hz operating at two modes: 20ms and 30ms frame length modes, resulting + * in bitrates of 15.2kbps for 20ms mode and 13.33kbps for 30ms mode. + * + * + * \section codec_setting Codec Settings + * + * \subsection general_setting General Settings + * + * General codec settings for this codec such as VAD and PLC can be + * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param. + * Please see the documentation of #pjmedia_codec_param for more info. + * + * \subsection specific_setting Codec Specific Settings + * + * The following settings are applicable for this codec. + * + * \subsubsection mode Mode + * + * The default mode should be set upon initialization, see + * #pjmedia_codec_ilbc_init(). After the codec is initialized, the default + * mode can be modified using #pjmedia_codec_mgr_set_default_param(). + * + * In #pjmedia_codec_param, iLBC mode can be set by specifying SDP + * format parameter "mode" in the SDP "a=fmtp" attribute for decoding + * direction. Valid values are "20" and "30" (for 20ms and 30ms mode + * respectively). + * + * Here is an example to set up #pjmedia_codec_param to use mode 20ms: + * \code + pjmedia_codec_param param; + ... + // setting iLBC mode in SDP + param.setting.dec_fmtp.cnt = 1; + param.setting.dec_fmtp.param[0].name = pj_str("mode"); + param.setting.dec_fmtp.param[0].val = pj_str("20"); + ... + \endcode + */ + +PJ_BEGIN_DECL + + +/** + * Initialize and register iLBC codec factory to pjmedia endpoint. + * + * @param endpt The pjmedia endpoint. + * @param mode Default decoder mode to be used. Valid values are + * 20 and 30 ms. Note that encoder mode follows the + * setting advertised in the remote's SDP. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_ilbc_init( pjmedia_endpt *endpt, + int mode ); + + + +/** + * Unregister iLBC codec factory from pjmedia endpoint and deinitialize + * the iLBC codec library. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_ilbc_deinit(void); + + +PJ_END_DECL + + +/** + * @} + */ + +#endif /* __PJMEDIA_CODEC_ILBC_H__ */ + diff --git a/pjmedia/include/pjmedia-codec/ipp_codecs.h b/pjmedia/include/pjmedia-codec/ipp_codecs.h new file mode 100644 index 0000000..3544367 --- /dev/null +++ b/pjmedia/include/pjmedia-codec/ipp_codecs.h @@ -0,0 +1,322 @@ +/* $Id: ipp_codecs.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJMEDIA_CODECS_IPP_H__ +#define __PJMEDIA_CODECS_IPP_H__ + +/** + * @file pjmedia-codec/ipp_codecs.h + * @brief IPP codecs wrapper. + */ + +#include <pjmedia-codec/types.h> + +/** + * @defgroup PJMED_IPP_CODEC IPP Codecs + * @ingroup PJMEDIA_CODEC_CODECS + * @brief Implementation of IPP codecs + * @{ + * + * This section describes functions to initialize and register IPP codec + * factory to the codec manager. After the codec factory has been registered, + * application can use @ref PJMEDIA_CODEC API to manipulate the codec. + * + * This codec factory contains various codecs, i.e: G.729, G.723.1, G.726, + * G.728, G.722.1, AMR, and AMR-WB. + * + * + * \section pjmedia_codec_ipp_g729 IPP G.729 + * + * IPP G.729 is compliant with ITU-T G.729 and Annexes A, B, C, C+, D, + * E, I specifications. However, currently the pjmedia implementation is + * using Annexes A and B only. + * + * IPP G.729 supports 16-bit PCM audio signal with sampling rate 8000Hz, + * frame length 10ms, and resulting in bitrate 8000bps (annexes D and E + * introduce bitrates 6400bps and 11800bps). + * + * \subsection codec_setting Codec Settings + * + * General codec settings for this codec such as VAD and PLC can be + * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param. + * Please see the documentation of #pjmedia_codec_param for more info. + * + * Note that G.729 VAD status should be signalled in SDP, see more + * description below. + * + * \subsubsection annexb Annex B + * + * The capability of VAD/DTX is specified in Annex B. + * + * By default, Annex B is enabled. This default setting of Annex B can + * be modified using #pjmedia_codec_mgr_set_default_param(). + * + * In #pjmedia_codec_param, Annex B is configured via VAD setting and + * format parameter "annexb" in the SDP "a=fmtp" attribute in + * decoding fmtp field. Valid values are "yes" and "no", + * the implementation default is "yes". When this parameter is omitted + * in the SDP, the value will be "yes" (RFC 4856 Section 2.1.9). + * + * Here is an example of modifying default setting of Annex B to + * be disabled using #pjmedia_codec_mgr_set_default_param(): + \code + pjmedia_codec_param param; + + pjmedia_codec_mgr_get_default_param(.., ¶m); + ... + // Set VAD + param.setting.vad = 0; + // Set SDP format parameter + param.setting.dec_fmtp.cnt = 1; + param.setting.dec_fmtp.param[0].name = pj_str("annexb"); + param.setting.dec_fmtp.param[0].val = pj_str("no"); + ... + pjmedia_codec_mgr_set_default_param(.., ¶m); + \endcode + * + * \note + * The difference of Annex B status in SDP offer/answer may be considered as + * incompatible codec in SDP negotiation. + * + * + * \section pjmedia_codec_ipp_g7231 IPP G.723.1 + * + * IPP G.723.1 speech codec is compliant with ITU-T G.723.1 and Annex A + * specifications. + * + * IPP G.723.1 supports 16-bit PCM audio signal with sampling rate 8000Hz, + * frame length 30ms, and resulting in bitrates 5300bps and 6300bps. + * + * By default, pjmedia implementation uses encoding bitrate of 6300bps. + * The bitrate is signalled in-band in G.723.1 frames and interoperable. + * + * \subsection codec_setting Codec Settings + * + * General codec settings for this codec such as VAD and PLC can be + * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param. + * Please see the documentation of #pjmedia_codec_param for more info. + * + * + * \section pjmedia_codec_ipp_g726 IPP G.726 + * + * IPP G.726 is compliant with ITU-T G.726 and G.726 Annex A specifications. + * + * IPP G.726 supports 16-bit PCM audio signal with sampling rate 8000Hz, + * 10ms frame length and producing 16kbps, 24kbps, 32kbps, 48kbps bitrates. + * The bitrate is specified explicitly in its encoding name, i.e: G726-16, + * G726-24, G726-32, G726-48. + * + * \subsection codec_setting Codec Settings + * + * General codec settings for this codec such as VAD and PLC can be + * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param. + * Please see the documentation of #pjmedia_codec_param for more info. + * + * + * \section pjmedia_codec_ipp_g728 IPP G.728 + * + * IPP G.728 is compliant with ITU-T G.728 with I, G, H Appendixes + * specifications for Low-Delay CELP coder. + * + * IPP G.728 supports 16-bit PCM audio signal with sampling rate 8000Hz, + * 20ms frame length and producing 9.6kbps, 12.8kbps, and 16kbps bitrates. + * + * The pjmedia implementation currently uses 16kbps bitrate only. + * + * \subsection codec_setting Codec Settings + * + * General codec settings for this codec such as VAD and PLC can be + * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param. + * Please see the documentation of #pjmedia_codec_param for more info. + * + * + * \section pjmedia_codec_ipp_g7221 IPP G.722.1 + * + * The pjmedia implementation of IPP G.722.1 supports 16-bit PCM audio + * signal with sampling rate 16000Hz, 20ms frame length and producing + * 16kbps, 24kbps, and 32kbps bitrates. + * + * \subsection codec_setting Codec Settings + * + * General codec settings for this codec such as VAD and PLC can be + * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param. + * Please see the documentation of #pjmedia_codec_param for more info. + * + * \subsubsection bitrate Bitrate + * + * The codec implementation supports only standard bitrates, i.e: + * 24kbps and 32kbps. Both are enabled by default. + * + * \remark + * There is a flaw in the codec manager as currently it could not + * differentiate G.722.1 codecs by bitrates, hence invoking + * #pjmedia_codec_mgr_set_default_param() may only affect a G.722.1 codec + * with the highest priority (or first index found in codec enumeration + * when they have same priority) and invoking + * #pjmedia_codec_mgr_set_codec_priority() will set priority of all G.722.1 + * codecs with sampling rate as specified. + * + * + * \section pjmedia_codec_ipp_amr IPP AMR + * + * The IPP AMR is compliant with GSM06.90-94 specifications for GSM Adaptive + * Multi-Rate codec. + * + * IPP AMR supports 16-bit PCM audio signal with sampling rate 8000Hz, + * 20ms frame length and producing various bitrates that ranges from 4.75kbps + * to 12.2kbps. + * + * \subsection codec_setting Codec Settings + * + * General codec settings for this codec such as VAD and PLC can be + * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param. + * Please see the documentation of #pjmedia_codec_param for more info. + * + * \subsubsection bitrate Bitrate + * + * By default, encoding bitrate is 7400bps. This default setting can be + * modified using #pjmedia_codec_mgr_set_default_param() by specifying + * prefered AMR bitrate in field <tt>info::avg_bps</tt> of + * #pjmedia_codec_param. Valid bitrates could be seen in + * #pjmedia_codec_amrnb_bitrates. + * + * \subsubsection payload_format Payload Format + * + * There are two AMR payload format types, bandwidth-efficient and + * octet-aligned. Default setting is using octet-aligned. This default payload + * format can be modified using #pjmedia_codec_mgr_set_default_param(). + * + * In #pjmedia_codec_param, payload format can be set by specifying SDP + * format parameters "octet-align" in the SDP "a=fmtp" attribute for + * decoding direction. Valid values are "0" (for bandwidth efficient mode) + * and "1" (for octet-aligned mode). + * + * \subsubsection mode_set Mode-Set + * + * Mode-set is used for restricting AMR modes in decoding direction. + * + * By default, no mode-set restriction applied. This default setting can be + * be modified using #pjmedia_codec_mgr_set_default_param(). + * + * In #pjmedia_codec_param, mode-set could be specified via format parameters + * "mode-set" in the SDP "a=fmtp" attribute for decoding direction. Valid + * value is a comma separated list of modes from the set 0 - 7, e.g: + * "4,5,6,7". When this parameter is omitted, no mode-set restrictions applied. + * + * Here is an example of modifying AMR default codec param: + \code + pjmedia_codec_param param; + + pjmedia_codec_mgr_get_default_param(.., ¶m); + ... + // set default encoding bitrate to the highest 12.2kbps + param.info.avg_bps = 12200; + + // restrict decoding bitrate to 10.2kbps and 12.2kbps only + param.setting.dec_fmtp.param[0].name = pj_str("mode-set"); + param.setting.dec_fmtp.param[0].val = pj_str("6,7"); + + // also set to use bandwidth-efficient payload format + param.setting.dec_fmtp.param[1].name = pj_str("octet-align"); + param.setting.dec_fmtp.param[1].val = pj_str("0"); + + param.setting.dec_fmtp.cnt = 2; + ... + pjmedia_codec_mgr_set_default_param(.., ¶m); + \endcode + * + * + * \section pjmedia_codec_ipp_amrwb IPP AMR-WB + * + * The IPP AMR-WB is compliant with 3GPP TS 26.190-192, 194, 201 + * specifications for Adaptive Multi-Rate WideBand codec. + * + * IPP AMR-WB supports 16-bit PCM audio signal with sampling rate 16000Hz, + * 20ms frame length and producing various bitrates. Valid bitrates could be + * seen in #pjmedia_codec_amrwb_bitrates. The pjmedia implementation default + * bitrate is 15850bps. + * + * \subsection codec_setting Codec Settings + * + * General codec settings for this codec such as VAD and PLC can be + * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param. + * Please see the documentation of #pjmedia_codec_param for more info. + * + * \subsubsection bitrate Bitrate + * + * By default, encoding bitrate is 15850bps. This default setting can be + * modified using #pjmedia_codec_mgr_set_default_param() by specifying + * prefered AMR bitrate in field <tt>info::avg_bps</tt> of + * #pjmedia_codec_param. + * + * \subsubsection payload_format Payload Format + * + * There are two AMR payload format types, bandwidth-efficient and + * octet-aligned. Default setting is using octet-aligned. This default payload + * format can be modified using #pjmedia_codec_mgr_set_default_param(). + * + * In #pjmedia_codec_param, payload format can be set by specifying SDP + * format parameters "octet-align" in the SDP "a=fmtp" attribute for + * decoding direction. Valid values are "0" (for bandwidth efficient mode) + * and "1" (for octet-aligned mode). + * + * \subsubsection mode_set Mode-Set + * + * Mode-set is used for restricting AMR modes in decoding direction. + * + * By default, no mode-set restriction applied. This default setting can be + * be modified using #pjmedia_codec_mgr_set_default_param(). + * + * In #pjmedia_codec_param, mode-set could be specified via format parameters + * "mode-set" in the SDP "a=fmtp" attribute for decoding direction. Valid + * value is a comma separated list of modes from the set 0 - 7, e.g: + * "4,5,6,7". When this parameter is omitted, no mode-set restrictions applied. + */ + +PJ_BEGIN_DECL + + +/** + * Initialize and register IPP codecs factory to pjmedia endpoint. + * + * @param endpt The pjmedia endpoint. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_ipp_init( pjmedia_endpt *endpt ); + + +/** + * Unregister IPP codecs factory from pjmedia endpoint and deinitialize + * the IPP codecs library. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_ipp_deinit(void); + + +PJ_END_DECL + + +/** + * @} + */ + +#endif /* __PJMEDIA_CODECS_IPP_H__ */ + diff --git a/pjmedia/include/pjmedia-codec/l16.h b/pjmedia/include/pjmedia-codec/l16.h new file mode 100644 index 0000000..04b50d0 --- /dev/null +++ b/pjmedia/include/pjmedia-codec/l16.h @@ -0,0 +1,81 @@ +/* $Id: l16.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJMEDIA_CODEC_L16_H__ +#define __PJMEDIA_CODEC_L16_H__ + +#include <pjmedia-codec/types.h> + + +/** + * @defgroup PJMED_L16 L16 Codec Family + * @ingroup PJMEDIA_CODEC_CODECS + * @brief Implementation of PCM/16bit/linear codecs + * @{ + * + * This section describes functions to initialize and register L16 codec + * factory to the codec manager. After the codec factory has been registered, + * application can use @ref PJMEDIA_CODEC API to manipulate the codec. + * + * Note that the L16 codec factory registers several (about fourteen!) + * L16 codec types to codec manager (different combinations of clock + * rate and number of channels). + * + * \section codec_setting Codec Settings + * + * \subsection general_setting General Settings + * + * General codec settings for this codec such as VAD and PLC can be + * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param. + * Please see the documentation of #pjmedia_codec_param for more info. + * + * \subsection specific_setting Codec Specific Settings + * + * Currently none. + */ + +PJ_BEGIN_DECL + + +/** + * Initialize and register L16 codec factory to pjmedia endpoint. + * + * @param endpt The pjmedia endpoint. + * @param options Must be zero for now. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_l16_init( pjmedia_endpt *endpt, + unsigned options); + + + +/** + * Unregister L16 codec factory from pjmedia endpoint. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_l16_deinit(void); + + +PJ_END_DECL + + +#endif /* __PJMEDIA_CODEC_L16_H__ */ + diff --git a/pjmedia/include/pjmedia-codec/opencore_amrnb.h b/pjmedia/include/pjmedia-codec/opencore_amrnb.h new file mode 100644 index 0000000..aedb460 --- /dev/null +++ b/pjmedia/include/pjmedia-codec/opencore_amrnb.h @@ -0,0 +1,89 @@ +/* $Id: opencore_amrnb.h 3841 2011-10-24 09:28:13Z ming $ */ +/* + * Copyright (C) 2011 Teluu Inc. (http://www.teluu.com) + * Copyright (C) 2011 Dan Arrhenius <dan@keystream.se> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJMEDIA_CODEC_OPENCORE_AMRNB_H__ +#define __PJMEDIA_CODEC_OPENCORE_AMRNB_H__ + +#include <pjmedia-codec/types.h> + +/** + * @defgroup PJMED_OC_AMRNB OpenCORE AMR-NB Codec + * @ingroup PJMEDIA_CODEC_CODECS + * @brief AMRCodec wrapper for OpenCORE AMR-NB codec + * @{ + */ + +PJ_BEGIN_DECL + +/** + * Settings. Use #pjmedia_codec_opencore_amrnb_set_config() to + * activate. + */ +typedef struct pjmedia_codec_amrnb_config +{ + /** + * Control whether to use octent align. + */ + pj_bool_t octet_align; + + /** + * Set the bitrate. + */ + unsigned bitrate; + +} pjmedia_codec_amrnb_config; + + +/** + * Initialize and register AMR-NB codec factory to pjmedia endpoint. + * + * @param endpt The pjmedia endpoint. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_opencore_amrnb_init(pjmedia_endpt* endpt); + +/** + * Unregister AMR-NB codec factory from pjmedia endpoint and deinitialize + * the OpenCORE codec library. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_opencore_amrnb_deinit(void); + + +/** + * Set AMR-NB parameters. + * + * @param cfg The settings; + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_opencore_amrnb_set_config( + const pjmedia_codec_amrnb_config* cfg); + +PJ_END_DECL + + +/** + * @} + */ + +#endif /* __PJMEDIA_CODEC_OPENCORE_AMRNB_H__ */ + diff --git a/pjmedia/include/pjmedia-codec/passthrough.h b/pjmedia/include/pjmedia-codec/passthrough.h new file mode 100644 index 0000000..775af19 --- /dev/null +++ b/pjmedia/include/pjmedia-codec/passthrough.h @@ -0,0 +1,277 @@ +/* $Id: passthrough.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJMEDIA_CODECS_PASSTHROUGH_H__ +#define __PJMEDIA_CODECS_PASSTHROUGH_H__ + +/** + * @file pjmedia-codec/passthrough.h + * @brief Passthrough codecs. + */ + +#include <pjmedia-codec/types.h> + +/** + * @defgroup PJMED_PASSTHROUGH_CODEC Passthrough Codecs + * @ingroup PJMEDIA_CODEC_CODECS + * @brief Implementation of passthrough codecs + * @{ + * + * This section describes functions to initialize and register passthrough + * codecs factory to the codec manager. After the codec factory has been + * registered, application can use @ref PJMEDIA_CODEC API to manipulate + * the codec. + * + * Passthrough codecs are codecs wrapper that does NOT perform encoding + * or decoding, it just PACK and PARSE encoded audio data from/into RTP + * payload. This will accomodate pjmedia ports which work with encoded + * audio data, e.g: encoded audio files, sound device with capability + * of playing/recording encoded audio data. + * + * This codec factory contains various codecs, i.e: G.729, iLBC, + * AMR, and G.711. + * + * + * \section pjmedia_codec_passthrough_g729 Passthrough G.729 + * + * G.729 supports 16-bit PCM audio signal with sampling rate 8000Hz, + * frame length 10ms, and resulting in bitrate 8000bps. + * + * \subsection codec_setting Codec Settings + * + * General codec settings for this codec such as VAD and PLC can be + * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param. + * Please see the documentation of #pjmedia_codec_param for more info. + * + * Note that G.729 VAD status should be signalled in SDP, see more + * description below. + * + * \subsubsection annexb Annex B + * + * The capability of VAD/DTX is specified in Annex B. + * + * By default, Annex B is enabled. This default setting of Annex B can + * be modified using #pjmedia_codec_mgr_set_default_param(). + * + * In #pjmedia_codec_param, Annex B is configured via VAD setting and + * format parameter "annexb" in the SDP "a=fmtp" attribute in + * decoding fmtp field. Valid values are "yes" and "no", + * the implementation default is "yes". When this parameter is omitted + * in the SDP, the value will be "yes" (RFC 4856 Section 2.1.9). + * + * Here is an example of modifying default setting of Annex B to + * be disabled using #pjmedia_codec_mgr_set_default_param(): + \code + pjmedia_codec_param param; + + pjmedia_codec_mgr_get_default_param(.., ¶m); + ... + // Set VAD + param.setting.vad = 0; + // Set SDP format parameter + param.setting.dec_fmtp.cnt = 1; + param.setting.dec_fmtp.param[0].name = pj_str("annexb"); + param.setting.dec_fmtp.param[0].val = pj_str("no"); + ... + pjmedia_codec_mgr_set_default_param(.., ¶m); + \endcode + * + * \note + * The difference of Annex B status in SDP offer/answer may be considered as + * incompatible codec in SDP negotiation. + * + * + * \section pjmedia_codec_passthrough_ilbc Passthrough iLBC + * + * The iLBC codec is developed by Global IP Solutions (GIPS), formerly + * Global IP Sound. The iLBC offers low bitrate and graceful audio quality + * degradation on frame losses. + * + * The iLBC codec supports 16-bit PCM audio signal with sampling rate of + * 8000Hz operating at two modes: 20ms and 30ms frame length modes, resulting + * in bitrates of 15.2kbps for 20ms mode and 13.33kbps for 30ms mode. + * + * \subsection codec_setting Codec Settings + * + * General codec settings for this codec such as VAD and PLC can be + * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param. + * Please see the documentation of #pjmedia_codec_param for more info. + * + * \subsubsection mode Mode + * + * The default mode should be set upon initialization, see + * #pjmedia_codec_passthrough_init2(). After the codec is initialized, the + * default mode can be modified using #pjmedia_codec_mgr_set_default_param(). + * + * In #pjmedia_codec_param, iLBC mode can be set by specifying SDP + * format parameter "mode" in the SDP "a=fmtp" attribute for decoding + * direction. Valid values are "20" and "30" (for 20ms and 30ms mode + * respectively). + * + * Here is an example to set up #pjmedia_codec_param to use mode 20ms: + * \code + pjmedia_codec_param param; + ... + // setting iLBC mode in SDP + param.setting.dec_fmtp.cnt = 1; + param.setting.dec_fmtp.param[0].name = pj_str("mode"); + param.setting.dec_fmtp.param[0].val = pj_str("20"); + ... + \endcode + * + * + * \section pjmedia_codec_passthrough_amr Passthrough AMR + * + * IPP AMR supports 16-bit PCM audio signal with sampling rate 8000Hz, + * 20ms frame length and producing various bitrates that ranges from 4.75kbps + * to 12.2kbps. + * + * \subsection codec_setting Codec Settings + * + * General codec settings for this codec such as VAD and PLC can be + * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param. + * Please see the documentation of #pjmedia_codec_param for more info. + * + * \subsubsection bitrate Bitrate + * + * By default, encoding bitrate is 7400bps. This default setting can be + * modified using #pjmedia_codec_mgr_set_default_param() by specifying + * prefered AMR bitrate in field <tt>info::avg_bps</tt> of + * #pjmedia_codec_param. Valid bitrates could be seen in + * #pjmedia_codec_amrnb_bitrates. + * + * \subsubsection payload_format Payload Format + * + * There are two AMR payload format types, bandwidth-efficient and + * octet-aligned. Default setting is using octet-aligned. This default payload + * format can be modified using #pjmedia_codec_mgr_set_default_param(). + * + * In #pjmedia_codec_param, payload format can be set by specifying SDP + * format parameters "octet-align" in the SDP "a=fmtp" attribute for + * decoding direction. Valid values are "0" (for bandwidth efficient mode) + * and "1" (for octet-aligned mode). + * + * \subsubsection mode_set Mode-Set + * + * Mode-set is used for restricting AMR modes in decoding direction. + * + * By default, no mode-set restriction applied. This default setting can be + * be modified using #pjmedia_codec_mgr_set_default_param(). + * + * In #pjmedia_codec_param, mode-set could be specified via format parameters + * "mode-set" in the SDP "a=fmtp" attribute for decoding direction. Valid + * value is a comma separated list of modes from the set 0 - 7, e.g: + * "4,5,6,7". When this parameter is omitted, no mode-set restrictions applied. + * + * Here is an example of modifying AMR default codec param: + \code + pjmedia_codec_param param; + + pjmedia_codec_mgr_get_default_param(.., ¶m); + ... + // set default encoding bitrate to the highest 12.2kbps + param.info.avg_bps = 12200; + + // restrict decoding bitrate to 10.2kbps and 12.2kbps only + param.setting.dec_fmtp.param[0].name = pj_str("mode-set"); + param.setting.dec_fmtp.param[0].val = pj_str("6,7"); + + // also set to use bandwidth-efficient payload format + param.setting.dec_fmtp.param[1].name = pj_str("octet-align"); + param.setting.dec_fmtp.param[1].val = pj_str("0"); + + param.setting.dec_fmtp.cnt = 2; + ... + pjmedia_codec_mgr_set_default_param(.., ¶m); + \endcode + * + * + * \section pjmedia_codec_passthrough_g711 Passthrough G.711 + * + * The G.711 is an ultra low complexity codecs and in trade-off it results + * in high bitrate, i.e: 64kbps for 16-bit PCM with sampling rate 8000Hz. + * + * The factory contains two main compression algorithms, PCMU/u-Law and + * PCMA/A-Law. + * + * \subsection codec_setting Codec Settings + * + * General codec settings for this codec such as VAD and PLC can be + * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param. + * Please see the documentation of #pjmedia_codec_param for more info. + */ + +PJ_BEGIN_DECL + + +/** + * Codec passthrough configuration settings. + */ +typedef struct pjmedia_codec_passthrough_setting +{ + unsigned fmt_cnt; /**< Number of encoding formats + to be enabled. */ + pjmedia_format *fmts; /**< Encoding formats to be + enabled. */ + unsigned ilbc_mode; /**< iLBC default mode. */ +} pjmedia_codec_passthrough_setting; + + +/** + * Initialize and register passthrough codecs factory to pjmedia endpoint, + * all supported encoding formats will be enabled. + * + * @param endpt The pjmedia endpoint. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_passthrough_init( pjmedia_endpt *endpt ); + + +/** + * Initialize and register passthrough codecs factory to pjmedia endpoint + * with only specified encoding formats enabled. + * + * @param endpt The pjmedia endpoint. + * @param setting The settings. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_passthrough_init2( + pjmedia_endpt *endpt, + const pjmedia_codec_passthrough_setting *setting); + + +/** + * Unregister passthrough codecs factory from pjmedia endpoint. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_passthrough_deinit(void); + + +PJ_END_DECL + + +/** + * @} + */ + +#endif /* __PJMEDIA_CODECS_PASSTHROUGH_H__ */ + diff --git a/pjmedia/include/pjmedia-codec/speex.h b/pjmedia/include/pjmedia-codec/speex.h new file mode 100644 index 0000000..12b3fa4 --- /dev/null +++ b/pjmedia/include/pjmedia-codec/speex.h @@ -0,0 +1,150 @@ +/* $Id: speex.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJMEDIA_CODEC_SPEEX_H__ +#define __PJMEDIA_CODEC_SPEEX_H__ + +/** + * @file speex.h + * @brief Speex codec header. + */ + +#include <pjmedia-codec/types.h> + +/** + * @defgroup PJMED_SPEEX Speex Codec Family + * @ingroup PJMEDIA_CODEC_CODECS + * @brief Implementation of Speex codecs (narrow/wide/ultrawide-band). + * @{ + * + * This section describes functions to initialize and register speex codec + * factory to the codec manager. After the codec factory has been registered, + * application can use @ref PJMEDIA_CODEC API to manipulate the codec. + * + * The Speex codec uses multiple bit rates, and supports ultra-wideband + * (32 kHz sampling rate), wideband (16 kHz sampling rate) and narrowband + * (telephone quality, 8 kHz sampling rate) + * + * By default, the speex codec factory registers three Speex codecs: + * "speex/8000" narrowband codec, "speex/16000" wideband codec, and + * "speex/32000" ultra-wideband codec. This behavior can be changed by + * specifying #pjmedia_speex_options flags during initialization. + * + * + * \section codec_setting Codec Settings + * + * \subsection general_setting General Settings + * + * General codec settings for this codec such as VAD and PLC can be + * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param. + * Please see the documentation of #pjmedia_codec_param for more info. + * + * \subsection specific_setting Codec Specific Settings + * + * The following settings are applicable for this codec. + * + * \subsubsection quality_vs_complexity Quality vs Complexity + * + * The Speex codec quality versus computational complexity and bandwidth + * requirement can be adjusted by modifying the quality and complexity + * setting, by calling #pjmedia_codec_speex_set_param(). The RFC 5574 + * Section 5 shows the relationship between quality setting and the + * resulting bitrate. + * + * The default setting of quality is specified in + * #PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY. And the default setting of + * complexity is specified in #PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY. + */ + +PJ_BEGIN_DECL + + +/** + * Bitmask options to be passed during Speex codec factory initialization. + */ +enum pjmedia_speex_options +{ + PJMEDIA_SPEEX_NO_NB = 1, /**< Disable narrowband mode. */ + PJMEDIA_SPEEX_NO_WB = 2, /**< Disable wideband mode. */ + PJMEDIA_SPEEX_NO_UWB = 4, /**< Disable ultra-wideband mode. */ +}; + + +/** + * Initialize and register Speex codec factory to pjmedia endpoint. + * + * @param endpt The pjmedia endpoint. + * @param options Bitmask of pjmedia_speex_options (default=0). + * @param quality Specify encoding quality, or use -1 for default + * (@see PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY). + * @param complexity Specify encoding complexity , or use -1 for default + * (@see PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY). + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_speex_init( pjmedia_endpt *endpt, + unsigned options, + int quality, + int complexity ); + + +/** + * Initialize Speex codec factory using default settings and register to + * pjmedia endpoint. + * + * @param endpt The pjmedia endpoint. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_speex_init_default(pjmedia_endpt *endpt); + + +/** + * Change the settings of Speex codec. + * + * @param clock_rate Clock rate of Speex mode to be set. + * @param quality Specify encoding quality, or use -1 for default + * (@see PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY). + * @param complexity Specify encoding complexity , or use -1 for default + * (@see PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY). + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_speex_set_param(unsigned clock_rate, + int quality, + int complexity); + + +/** + * Unregister Speex codec factory from pjmedia endpoint and deinitialize + * the Speex codec library. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_speex_deinit(void); + + +PJ_END_DECL + +/** + * @} + */ + +#endif /* __PJMEDIA_CODEC_SPEEX_H__ */ + diff --git a/pjmedia/include/pjmedia-codec/types.h b/pjmedia/include/pjmedia-codec/types.h new file mode 100644 index 0000000..a18fa30 --- /dev/null +++ b/pjmedia/include/pjmedia-codec/types.h @@ -0,0 +1,126 @@ +/* $Id: types.h 3664 2011-07-19 03:42:28Z nanang $ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJMEDIA_CODEC_TYPES_H__ +#define __PJMEDIA_CODEC_TYPES_H__ + +/** + * @file types.h + * @brief PJMEDIA-CODEC types and constants + */ + +#include <pjmedia-codec/config.h> +#include <pjmedia/codec.h> + +/** + * @defgroup pjmedia_codec_types PJMEDIA-CODEC Types and Constants + * @ingroup PJMEDIA_CODEC + * @brief Constants used by PJMEDIA-CODEC + * @{ + */ + + + +/** + * These are the dynamic payload types that are used by audio codecs in + * this library. Also see the header file <pjmedia/codec.h> for list + * of static payload types. + */ +enum pjmedia_audio_pt +{ + /* According to IANA specifications, dynamic payload types are to be in + * the range 96-127 (inclusive). This enum is structured to place the + * values of the payload types specified below into that range. + * + * PJMEDIA_RTP_PT_DYNAMIC is defined in <pjmedia/codec.h>. It is defined + * to be 96. + * + * PJMEDIA_RTP_PT_TELEPHONE_EVENTS is defined in <pjmedia/config.h>. + * The default value is 96. + */ +#if PJMEDIA_RTP_PT_TELEPHONE_EVENTS + PJMEDIA_RTP_PT_START = PJMEDIA_RTP_PT_TELEPHONE_EVENTS, +#else + PJMEDIA_RTP_PT_START = (PJMEDIA_RTP_PT_DYNAMIC-1), +#endif + + PJMEDIA_RTP_PT_SPEEX_NB, /**< Speex narrowband/8KHz */ + PJMEDIA_RTP_PT_SPEEX_WB, /**< Speex wideband/16KHz */ + PJMEDIA_RTP_PT_SPEEX_UWB, /**< Speex 32KHz */ + PJMEDIA_RTP_PT_L16_8KHZ_MONO, /**< L16 @ 8KHz, mono */ + PJMEDIA_RTP_PT_L16_8KHZ_STEREO, /**< L16 @ 8KHz, stereo */ + //PJMEDIA_RTP_PT_L16_11KHZ_MONO, /**< L16 @ 11KHz, mono */ + //PJMEDIA_RTP_PT_L16_11KHZ_STEREO, /**< L16 @ 11KHz, stereo */ + PJMEDIA_RTP_PT_L16_16KHZ_MONO, /**< L16 @ 16KHz, mono */ + PJMEDIA_RTP_PT_L16_16KHZ_STEREO, /**< L16 @ 16KHz, stereo */ + //PJMEDIA_RTP_PT_L16_22KHZ_MONO, /**< L16 @ 22KHz, mono */ + //PJMEDIA_RTP_PT_L16_22KHZ_STEREO, /**< L16 @ 22KHz, stereo */ + //PJMEDIA_RTP_PT_L16_32KHZ_MONO, /**< L16 @ 32KHz, mono */ + //PJMEDIA_RTP_PT_L16_32KHZ_STEREO, /**< L16 @ 32KHz, stereo */ + //PJMEDIA_RTP_PT_L16_48KHZ_MONO, /**< L16 @ 48KHz, mono */ + //PJMEDIA_RTP_PT_L16_48KHZ_STEREO, /**< L16 @ 48KHz, stereo */ + PJMEDIA_RTP_PT_ILBC, /**< iLBC (13.3/15.2Kbps) */ + PJMEDIA_RTP_PT_AMR, /**< AMR (4.75 - 12.2Kbps) */ + PJMEDIA_RTP_PT_AMRWB, /**< AMRWB (6.6 - 23.85Kbps)*/ + PJMEDIA_RTP_PT_AMRWBE, /**< AMRWBE */ + PJMEDIA_RTP_PT_G726_16, /**< G726 @ 16Kbps */ + PJMEDIA_RTP_PT_G726_24, /**< G726 @ 24Kbps */ + PJMEDIA_RTP_PT_G726_32, /**< G726 @ 32Kbps */ + PJMEDIA_RTP_PT_G726_40, /**< G726 @ 40Kbps */ + PJMEDIA_RTP_PT_G722_1_16, /**< G722.1 (16Kbps) */ + PJMEDIA_RTP_PT_G722_1_24, /**< G722.1 (24Kbps) */ + PJMEDIA_RTP_PT_G722_1_32, /**< G722.1 (32Kbps) */ + PJMEDIA_RTP_PT_G7221C_24, /**< G722.1 Annex C (24Kbps)*/ + PJMEDIA_RTP_PT_G7221C_32, /**< G722.1 Annex C (32Kbps)*/ + PJMEDIA_RTP_PT_G7221C_48, /**< G722.1 Annex C (48Kbps)*/ + PJMEDIA_RTP_PT_G7221_RSV1, /**< G722.1 reserve */ + PJMEDIA_RTP_PT_G7221_RSV2, /**< G722.1 reserve */ + + /* Caution! + * Ensure the value of the last pt above is <= 127. + */ +}; + +/** + * These are the dynamic payload types that are used by video codecs in + * this library. + */ +enum pjmedia_video_pt +{ + /* Video payload types */ + PJMEDIA_RTP_PT_VID_START = (PJMEDIA_RTP_PT_DYNAMIC-1), + PJMEDIA_RTP_PT_H263P, + PJMEDIA_RTP_PT_H264, + PJMEDIA_RTP_PT_H264_RSV1, + PJMEDIA_RTP_PT_H264_RSV2, + PJMEDIA_RTP_PT_H264_RSV3, + PJMEDIA_RTP_PT_H264_RSV4, + + /* Caution! + * Ensure the value of the last pt above is <= 127. + */ +}; + + +/** + * @} + */ + + +#endif /* __PJMEDIA_CODEC_TYPES_H__ */ |