summaryrefslogtreecommitdiff
path: root/pjmedia
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-01-07 18:33:25 +0000
committerBenny Prijono <bennylp@teluu.com>2008-01-07 18:33:25 +0000
commit7c7d7c0550a3d340f294595fff9597c5c2a65bc9 (patch)
tree7df70e99ed38897d828bcfb64552135c75a3fdb9 /pjmedia
parentfda9407ea64cc29840e72e848aea24941d0ac540 (diff)
Ticket #439: don't call encode() if input is FRAME_TYPE_NONE
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1667 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia')
-rw-r--r--pjmedia/src/pjmedia/stream.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/pjmedia/src/pjmedia/stream.c b/pjmedia/src/pjmedia/stream.c
index ba883344..83fecf23 100644
--- a/pjmedia/src/pjmedia/stream.c
+++ b/pjmedia/src/pjmedia/stream.c
@@ -140,11 +140,6 @@ static const char digitmap[16] = { '0', '1', '2', '3',
'8', '9', '*', '#',
'A', 'B', 'C', 'D'};
-/* Zero PCM frame */
-#define ZERO_PCM_MAX_SIZE 1920 /* 40ms worth of PCM @ 48KHz */
-static pj_int16_t zero_frame[ZERO_PCM_MAX_SIZE];
-
-
/*
* Print error.
*/
@@ -573,7 +568,12 @@ static pj_status_t put_frame_imp( pjmedia_port *port,
inc_timestamp = PJMEDIA_DTMF_DURATION - ts_len;
}
- } else if (frame->type != PJMEDIA_FRAME_TYPE_NONE) {
+ /* No need to encode if this is a zero frame.
+ * See http://www.pjsip.org/trac/ticket/439
+ */
+ } else if (frame->type != PJMEDIA_FRAME_TYPE_NONE &&
+ frame->buf != NULL)
+ {
unsigned ts, codec_samples_per_frame;
/* Repeatedly call encode if there are multiple frames to be
@@ -729,13 +729,11 @@ static pj_status_t put_frame( pjmedia_port *port,
* instead so that encoder can decide whether or not to transmit
* silence frame.
*/
- if (frame->type == PJMEDIA_FRAME_TYPE_NONE &&
- samples_per_frame <= ZERO_PCM_MAX_SIZE)
- {
+ if (frame->type == PJMEDIA_FRAME_TYPE_NONE) {
pj_memcpy(&tmp_zero_frame, frame, sizeof(pjmedia_frame));
frame = &tmp_zero_frame;
- tmp_zero_frame.buf = zero_frame;
+ tmp_zero_frame.buf = NULL;
tmp_zero_frame.size = samples_per_frame * 2;
tmp_zero_frame.type = PJMEDIA_FRAME_TYPE_AUDIO;
}
@@ -755,7 +753,7 @@ static pj_status_t put_frame( pjmedia_port *port,
pj_memcpy(&tmp_in_frame, frame, sizeof(pjmedia_frame));
frame = &tmp_in_frame;
- tmp_in_frame.buf = zero_frame;
+ tmp_in_frame.buf = NULL;
tmp_in_frame.size = samples_per_frame * 2;
tmp_in_frame.type = PJMEDIA_FRAME_TYPE_AUDIO;
}