Skip to content

Commit

Permalink
Fix #1754: Fixed crash in video stream when encoder returns zero payl…
Browse files Browse the repository at this point in the history
…oad length.

git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4805 74dad513-b988-da41-8d7b-12977e46ad98
  • Loading branch information
nanang committed Mar 28, 2014
1 parent d528296 commit bec5e77
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions pjmedia/src/pjmedia/vid_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,29 +880,34 @@ static pj_status_t put_frame(pjmedia_port *port,
return status;
}

// Copy RTP header to the beginning of packet
pj_memcpy(channel->buf, rtphdr, sizeof(pjmedia_rtp_hdr));

// Send the RTP packet to the transport.
status = pjmedia_transport_send_rtp(stream->transport,
(char*)channel->buf,
frame_out.size +
sizeof(pjmedia_rtp_hdr));
if (status != PJ_SUCCESS) {
enum { COUNT_TO_REPORT = 20 };
if (stream->send_err_cnt++ == 0) {
LOGERR_((channel->port.info.name.ptr,
"Transport send_rtp() error",
status));
/* When the payload length is zero, we should not send anything,
* but proceed the rest normally.
*/
if (frame_out.size != 0) {
// Copy RTP header to the beginning of packet
pj_memcpy(channel->buf, rtphdr, sizeof(pjmedia_rtp_hdr));

// Send the RTP packet to the transport.
status = pjmedia_transport_send_rtp(stream->transport,
(char*)channel->buf,
frame_out.size +
sizeof(pjmedia_rtp_hdr));
if (status != PJ_SUCCESS) {
enum { COUNT_TO_REPORT = 20 };
if (stream->send_err_cnt++ == 0) {
LOGERR_((channel->port.info.name.ptr,
"Transport send_rtp() error",
status));
}
if (stream->send_err_cnt > COUNT_TO_REPORT)
stream->send_err_cnt = 0;
/* Ignore this error */
}
if (stream->send_err_cnt > COUNT_TO_REPORT)
stream->send_err_cnt = 0;
/* Ignore this error */
}

pjmedia_rtcp_tx_rtp(&stream->rtcp, (unsigned)frame_out.size);
total_sent += frame_out.size;
pkt_cnt++;
pjmedia_rtcp_tx_rtp(&stream->rtcp, (unsigned)frame_out.size);
total_sent += frame_out.size;
pkt_cnt++;
}

if (!has_more_data)
break;
Expand Down

0 comments on commit bec5e77

Please sign in to comment.