From 16e91574526a166be70846afe560f026f27a02a8 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Fri, 28 Mar 2014 07:44:31 +0000 Subject: Fix #1754: Fixed crash in video stream when encoder returns zero payload length. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4805 74dad513-b988-da41-8d7b-12977e46ad98 --- pjmedia/src/pjmedia/vid_stream.c | 47 ++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 21 deletions(-) (limited to 'pjmedia') diff --git a/pjmedia/src/pjmedia/vid_stream.c b/pjmedia/src/pjmedia/vid_stream.c index b6cc36dc..9a9aff90 100644 --- a/pjmedia/src/pjmedia/vid_stream.c +++ b/pjmedia/src/pjmedia/vid_stream.c @@ -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; -- cgit v1.2.3