Skip to content

Commit 001856e

Browse files
authored
Add support for G.722 as passthrough codec. (#4390)
1 parent 9b84df0 commit 001856e

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

pjlib/include/pj/config_site_sample.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@
234234
#define PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMU 1
235235
#define PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMA 1
236236
#define PJMEDIA_HAS_PASSTHROUGH_CODEC_AMR 1
237+
#define PJMEDIA_HAS_PASSTHROUGH_CODEC_G722 0
237238
#define PJMEDIA_HAS_PASSTHROUGH_CODEC_G729 1
238239
#define PJMEDIA_HAS_PASSTHROUGH_CODEC_ILBC 1
239240

@@ -263,6 +264,7 @@
263264
#define PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMU 1
264265
#define PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMA 1
265266
#define PJMEDIA_HAS_PASSTHROUGH_CODEC_AMR 1
267+
#define PJMEDIA_HAS_PASSTHROUGH_CODEC_G722 0
266268
#define PJMEDIA_HAS_PASSTHROUGH_CODEC_G729 1
267269
#define PJMEDIA_HAS_PASSTHROUGH_CODEC_ILBC 1
268270

@@ -289,6 +291,7 @@
289291
#define PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMU 1
290292
#define PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMA 1
291293
#define PJMEDIA_HAS_PASSTHROUGH_CODEC_AMR 0
294+
#define PJMEDIA_HAS_PASSTHROUGH_CODEC_G722 0
292295
#define PJMEDIA_HAS_PASSTHROUGH_CODEC_G729 0
293296
#define PJMEDIA_HAS_PASSTHROUGH_CODEC_ILBC 0
294297

pjmedia/include/pjmedia-codec/config.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,15 @@
319319
# define PJMEDIA_HAS_PASSTHROUGH_CODEC_AMR 1
320320
#endif
321321

322+
/**
323+
* Enable G.722 passthrough codec.
324+
*
325+
* Default: 1
326+
*/
327+
#ifndef PJMEDIA_HAS_PASSTHROUGH_CODEC_G722
328+
# define PJMEDIA_HAS_PASSTHROUGH_CODEC_G722 1
329+
#endif
330+
322331
/**
323332
* Enable G.729 passthrough codec.
324333
*
@@ -372,6 +381,14 @@
372381
# define PJMEDIA_HAS_G7221_CODEC 0
373382
#endif
374383

384+
/* If passthrough and G.722 is enabled, disable the software
385+
* G.722 codec
386+
*/
387+
#if PJMEDIA_HAS_PASSTHROUGH_CODECS && PJMEDIA_HAS_PASSTHROUGH_CODEC_G722
388+
# undef PJMEDIA_HAS_G722_CODEC
389+
# define PJMEDIA_HAS_G722_CODEC 0
390+
#endif
391+
375392
/**
376393
* Enable OpenCORE AMR-NB codec.
377394
* See https://github.com/pjsip/pjproject/issues/1388 for some info.

pjmedia/include/pjmedia/format.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ typedef enum pjmedia_format_id
7878
/** AMR narrowband */
7979
PJMEDIA_FORMAT_AMR = PJMEDIA_FORMAT_PACK(' ', 'A', 'M', 'R'),
8080

81+
/** ITU G.722 */
82+
PJMEDIA_FORMAT_G722 = PJMEDIA_FORMAT_PACK('G', '7', '2', '2'),
83+
8184
/** ITU G.729 */
8285
PJMEDIA_FORMAT_G729 = PJMEDIA_FORMAT_PACK('G', '7', '2', '9'),
8386

pjmedia/src/pjmedia-codec/passthrough.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@ codec_desc[] =
186186
},
187187
# endif
188188

189+
# if PJMEDIA_HAS_PASSTHROUGH_CODEC_G722
190+
{1, "G722", PJMEDIA_RTP_PT_G722, PJMEDIA_FORMAT_G722,
191+
16000, 1, 160,
192+
64000, 64000, 2, 1, 1
193+
},
194+
# endif
195+
189196
# if PJMEDIA_HAS_PASSTHROUGH_CODEC_G729
190197
{1, "G729", PJMEDIA_RTP_PT_G729, PJMEDIA_FORMAT_G729,
191198
8000, 1, 80,
@@ -684,11 +691,8 @@ static pj_status_t codec_open( pjmedia_codec *codec,
684691
{
685692
codec_private_t *codec_data = (codec_private_t*) codec->codec_data;
686693
struct codec_desc *desc = &codec_desc[codec_data->codec_idx];
687-
pj_pool_t *pool;
688694
int i, j;
689695

690-
pool = codec_data->pool;
691-
692696
/* Cache samples per frame value */
693697
codec_data->samples_per_frame = desc->samples_per_frame;
694698

@@ -770,7 +774,7 @@ static pj_status_t codec_open( pjmedia_codec *codec,
770774
}
771775
}
772776

773-
s = PJ_POOL_ZALLOC_T(pool, amr_settings_t);
777+
s = PJ_POOL_ZALLOC_T(codec_data->pool, amr_settings_t);
774778
codec_data->codec_setting = s;
775779

776780
s->enc_mode = enc_mode;
@@ -839,7 +843,7 @@ static pj_status_t codec_open( pjmedia_codec *codec,
839843
*/
840844
if (enc_fmtp_mode != dec_fmtp_mode) {
841845
enc_fmtp_mode = dec_fmtp_mode = DEFAULT_MODE;
842-
PJ_LOG(4,(pool->obj_name,
846+
PJ_LOG(4,(codec_data->pool->obj_name,
843847
"Normalized iLBC encoder and decoder modes to %d",
844848
DEFAULT_MODE));
845849
}

0 commit comments

Comments
 (0)