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: https://svn.pjsip.org/repos/pjproject/trunk@505 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
Benny Prijono 2006-06-14 20:02:05 +00:00
parent d2ea4eaaf8
commit 0e13f80a1e
1 changed files with 11 additions and 10 deletions

View File

@ -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;