summaryrefslogtreecommitdiff
path: root/pjmedia
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2011-02-18 09:34:28 +0000
committerNanang Izzuddin <nanang@teluu.com>2011-02-18 09:34:28 +0000
commitf5685f7b793f56489a16df6c808898d29cc4bbb5 (patch)
tree825e56a081071856966a301892d047290337a2bd /pjmedia
parent18cecc69115001ad1b6e980ce7fa13dc3b059c1a (diff)
Fix #1199:
- Modified G722 frame time to 10ms (was 20ms) and frame per packet to 2 (was 1). - Updated the detection mechanism of remote G722 frame-length in the stream to be flexible to any G722 frame length setting (was assumed to be always 20ms). git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3416 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia')
-rw-r--r--pjmedia/src/pjmedia-codec/g722.c6
-rw-r--r--pjmedia/src/pjmedia/stream.c29
2 files changed, 24 insertions, 11 deletions
diff --git a/pjmedia/src/pjmedia-codec/g722.c b/pjmedia/src/pjmedia-codec/g722.c
index 5b43a61b..fbe90bd8 100644
--- a/pjmedia/src/pjmedia-codec/g722.c
+++ b/pjmedia/src/pjmedia-codec/g722.c
@@ -38,9 +38,9 @@
#define THIS_FILE "g722.c"
/* Defines */
-#define PTIME (20)
+#define PTIME (10)
#define SAMPLES_PER_FRAME (16000 * PTIME /1000)
-#define FRAME_LEN (160)
+#define FRAME_LEN (80)
#define PLC_DISABLED 0
/* Tracing */
@@ -291,7 +291,7 @@ static pj_status_t g722_default_attr( pjmedia_codec_factory *factory,
attr->info.frm_ptime = PTIME;
attr->info.pt = PJMEDIA_RTP_PT_G722;
- attr->setting.frm_per_pkt = 1;
+ attr->setting.frm_per_pkt = 2;
attr->setting.vad = 1;
attr->setting.plc = 1;
diff --git a/pjmedia/src/pjmedia/stream.c b/pjmedia/src/pjmedia/stream.c
index b0882315..7f9e56b3 100644
--- a/pjmedia/src/pjmedia/stream.c
+++ b/pjmedia/src/pjmedia/stream.c
@@ -1718,19 +1718,26 @@ static void on_rx_rtp( void *data,
stream->rtp_rx_last_cnt > 0)
{
unsigned peer_frm_ts_diff;
+ unsigned frm_ts_span;
+ /* Calculate actual frame timestamp span */
+ frm_ts_span = stream->port.info.samples_per_frame /
+ stream->codec_param.setting.frm_per_pkt/
+ stream->port.info.channel_count;
+
+ /* Get remote frame timestamp span */
peer_frm_ts_diff =
((pj_uint32_t)ts.u64-stream->rtp_rx_last_ts) /
stream->rtp_rx_last_cnt;
- /* Possibilities remote's samples per frame for G.722
- * are only 160 and 320, this validation is needed
- * to avoid wrong decision because of silence frames.
+ /* Possibilities remote's samples per frame for G.722
+ * are only (frm_ts_span) and (frm_ts_span/2), this
+ * validation is needed to avoid wrong decision because
+ * of silence frames.
*/
if (stream->codec_param.info.pt == PJMEDIA_RTP_PT_G722 &&
- (peer_frm_ts_diff==stream->port.info.samples_per_frame
- || peer_frm_ts_diff ==
- stream->port.info.samples_per_frame >> 1))
+ (peer_frm_ts_diff == frm_ts_span ||
+ peer_frm_ts_diff == (frm_ts_span>>1)))
{
if (peer_frm_ts_diff < stream->rtp_rx_ts_len_per_frame)
stream->rtp_rx_ts_len_per_frame = peer_frm_ts_diff;
@@ -1752,6 +1759,11 @@ static void on_rx_rtp( void *data,
ts_span = stream->rtp_rx_ts_len_per_frame;
+ /* Adjust the timestamp of the parsed frames */
+ for (i=0; i<count; ++i) {
+ frames[i].timestamp.u64 = ts.u64 + ts_span * i;
+ }
+
} else {
ts_span = stream->codec_param.info.frm_ptime *
stream->codec_param.info.clock_rate /
@@ -2140,8 +2152,9 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
stream->rtp_rx_last_cnt = 0;
stream->rtp_tx_ts_len_per_pkt = stream->enc_samples_per_pkt /
stream->codec_param.info.channel_cnt;
- stream->rtp_rx_ts_len_per_frame = stream->port.info.samples_per_frame /
- stream->codec_param.info.channel_cnt;
+ stream->rtp_rx_ts_len_per_frame = stream->port.info.samples_per_frame /
+ stream->codec_param.setting.frm_per_pkt /
+ stream->codec_param.info.channel_cnt;
if (info->fmt.pt == PJMEDIA_RTP_PT_G722) {
stream->has_g722_mpeg_bug = PJ_TRUE;