From 33ab6199e28a5eb031badc78cdda347a7ec81701 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Tue, 2 May 2006 17:51:04 +0000 Subject: Rename hard coded constants (such as ptime) in G711 to a macro for better aesthetic git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@429 74dad513-b988-da41-8d7b-12977e46ad98 --- pjmedia/src/pjmedia/g711.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pjmedia/src/pjmedia/g711.c b/pjmedia/src/pjmedia/g711.c index 634ead5e..2a4bc2f8 100644 --- a/pjmedia/src/pjmedia/g711.c +++ b/pjmedia/src/pjmedia/g711.c @@ -32,6 +32,8 @@ #define G711_BPS 64000 #define G711_CODEC_CNT 0 /* number of codec to preallocate in memory */ +#define PTIME 20 +#define FRAME_SIZE (8000 * PTIME / 1000) /* These are the only public functions exported to applications */ PJ_DECL(pj_status_t) g711_init_factory (pjmedia_codec_factory *factory, pj_pool_t *pool); @@ -229,7 +231,7 @@ static pj_status_t g711_default_attr (pjmedia_codec_factory *factory, attr->channel_cnt = 1; attr->avg_bps = G711_BPS; attr->pcm_bits_per_sample = 16; - attr->ptime = 20; + attr->ptime = PTIME; attr->pt = id->pt; /* Default all flag bits disabled. */ @@ -370,13 +372,13 @@ static pj_status_t g711_get_frames(pjmedia_codec *codec, PJ_UNUSED_ARG(codec); PJ_ASSERT_RETURN(frame_cnt, PJ_EINVAL); - while (pkt_size >= 160 && count < *frame_cnt) { + while (pkt_size >= FRAME_SIZE && count < *frame_cnt) { frames[0].type = PJMEDIA_FRAME_TYPE_AUDIO; frames[0].buf = pkt; - frames[0].size = 160; + frames[0].size = FRAME_SIZE; - pkt = ((char*)pkt) + 160; - pkt_size -= 160; + pkt = ((char*)pkt) + FRAME_SIZE; + pkt_size -= FRAME_SIZE; ++count; } -- cgit v1.2.3