summaryrefslogtreecommitdiff
path: root/pjmedia
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-06-14 20:02:05 +0000
committerBenny Prijono <bennylp@teluu.com>2006-06-14 20:02:05 +0000
commit9e09525cc5f7078a43b2564d7354f218787fe34d (patch)
tree4553e1e88f187a5610fc4cca710459bd5e1ebd4c /pjmedia
parentd2a4d323d464da55c966dca34a906f659f1b9573 (diff)
Fixed couple of bugs in stream: (1) race condition when transport callback is called when stream is not fully initialized, and (2) timestamp is not incremented when NULL frame is fed in put_frame()
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@505 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia')
-rw-r--r--pjmedia/src/pjmedia/stream.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/pjmedia/src/pjmedia/stream.c b/pjmedia/src/pjmedia/stream.c
index bbf161ff..38891225 100644
--- a/pjmedia/src/pjmedia/stream.c
+++ b/pjmedia/src/pjmedia/stream.c
@@ -453,7 +453,8 @@ static pj_status_t put_frame( pjmedia_port *port,
/* Number of samples in the frame */
- ts_len = frame->size / 2;
+ //ts_len = frame->size / 2;
+ ts_len = port->info.samples_per_frame;
/* Init frame_out buffer. */
frame_out.buf = ((char*)channel->out_pkt) + sizeof(pjmedia_rtp_hdr);
@@ -939,15 +940,6 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
stream->rx_event_pt = info->rx_event_pt ? info->rx_event_pt : -1;
stream->last_dtmf = -1;
- /* Attach transport */
- status = (*tp->op->attach)(tp, stream, &info->rem_addr,
- sizeof(info->rem_addr), &on_rx_rtp,
- &on_rx_rtcp);
- if (status != PJ_SUCCESS)
- goto err_cleanup;
-
- stream->transport = tp;
-
/* Create mutex to protect jitter buffer: */
@@ -1061,6 +1053,15 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
goto err_cleanup;
+ /* Only attach transport when stream is ready. */
+ status = (*tp->op->attach)(tp, stream, &info->rem_addr,
+ sizeof(info->rem_addr), &on_rx_rtp,
+ &on_rx_rtcp);
+ if (status != PJ_SUCCESS)
+ goto err_cleanup;
+
+ stream->transport = tp;
+
/* Success! */
*p_stream = stream;