<div dir="ltr"><div><font face="microsoft jhenghei, sans-serif"><br></font></div><div><font face="microsoft jhenghei, sans-serif" size="4"><b><u>Environment</u></b></font></div><div><ol><li><font face="microsoft jhenghei, sans-serif">Create multiple RTSP server in one process and every server is different thread ( <font color="#ff0000">multi-thread</font> ).</font></li>
<li><font face="microsoft jhenghei, sans-serif">Create 100 session to play video from the multiple RTSP server at the same time, so every server will be handle some sessions.</font></li></ol><div><font face="microsoft jhenghei, sans-serif" size="4"><b><u>Warning Message :</u></b></font></div>
</div><span style="font-family:'microsoft jhenghei',sans-serif"><ul><li>MultiFramedRTPSink::afterGettingFrame1(): The input frame data was too large for our buffer size (2884). 1731 bytes of trailing data was dropped! Correct this by increasing "OutPacketBuffer::maxSize" to at least 3181, *before* creating this 'RTPSink'. (Current value is 1450.)<br>
</li><li>MultiFramedRTPSink::afterGettingFrame1(): The input frame data was too large for our buffer size (2884). 9449 bytes of trailing data was dropped! Correct this by increasing "OutPacketBuffer::maxSize" to at least 10899, *before* creating this 'RTPSink'. (Current value is 1450.)<br>
</li><li>MultiFramedRTPSink::afterGettingFrame1(): The input frame data was too large for our buffer size (2884). 350 bytes of trailing data was dropped! Correct this by increasing "OutPacketBuffer::maxSize" to at least 1800, *before* creating this 'RTPSink'. (Current value is 1450.)<br>
</li><li>MultiFramedRTPSink::afterGettingFrame1(): The input frame data was too large for our buffer size (2884). 926 bytes of trailing data was dropped! Correct this by increasing "OutPacketBuffer::maxSize" to at least 2376, *before* creating this 'RTPSink'. (Current value is 1450.)</li>
</ul></span><font face="microsoft jhenghei, sans-serif" size="4"><b><u>Root Cause :</u></b></font><div><ul><li><u>OutPacketBuffer::maxSize</u> type is <u><b>static</b></u>, when multi-thread running, the value will be modified at class <u>RTCPInstance</u> constructor, show source code below:<br>
</li></ul></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><font face="microsoft jhenghei, sans-serif"> // A hack to save buffer space, because RTCP packets are always small:</font></div>
</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><font face="microsoft jhenghei, sans-serif"> unsigned savedMaxSize = OutPacketBuffer::maxSize;</font></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div><font face="microsoft jhenghei, sans-serif"> <font color="#ff0000"><b>OutPacketBuffer::maxSize</b> = maxRTCPPacketSize;</font></font></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div>
<font face="microsoft jhenghei, sans-serif"> fOutBuf = new OutPacketBuffer(preferredPacketSize, maxRTCPPacketSize);</font></div>
</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><font face="microsoft jhenghei, sans-serif"> OutPacketBuffer::maxSize = savedMaxSize;</font></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div><font face="microsoft jhenghei, sans-serif"> if (fOutBuf == NULL) return;</font></div><div><br></div></blockquote></blockquote><span style="color:rgb(0,0,0);line-height:19.699691772460938px;background-color:rgb(251,251,251)"><font face="microsoft jhenghei, sans-serif" size="4"><b><u>Analysis :</u></b></font></span><div>
<ul><li><font face="microsoft jhenghei, sans-serif"><u>RTCPInstance</u> constructor modify <u>OutPacketBuffer::maxSize</u> just want to help class <u>OutPacketBuffer</u> constructor compute <u>maxNumPackets</u>, show source below :<br>
</font></li></ul></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-family:'microsoft jhenghei',sans-serif"><b><u>MediaSink.cpp</u></b></span></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-family:'microsoft jhenghei',sans-serif"><br></span></div><div><span style="font-family:'microsoft jhenghei',sans-serif">OutPacketBuffer::OutPacketBuffer(unsigned preferredPacketSize,</span><span style="font-family:'microsoft jhenghei',sans-serif">unsigned maxPacketSize)</span></div>
</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-family:'microsoft jhenghei',sans-serif"> : fPreferred(preferredPacketSize), fMax(maxPacketSize),</span></div>
</blockquote>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-family:'microsoft jhenghei',sans-serif"> fOverflowDataSize(0) {</span></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div><span style="font-family:'microsoft jhenghei',sans-serif"> <font color="#ff0000">unsigned <b><u>maxNumPackets</u></b> = (<b><u>maxSize</u></b> + (maxPacketSize-1))/maxPacketSize;</font></span></div></blockquote>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-family:'microsoft jhenghei',sans-serif"> fLimit = maxNumPackets*maxPacketSize;</span></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div><span style="font-family:'microsoft jhenghei',sans-serif"> fBuf = new unsigned char[fLimit];</span></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-family:'microsoft jhenghei',sans-serif"> resetPacketStart();</span></div>
</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-family:'microsoft jhenghei',sans-serif"> resetOffset();</span></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div><span style="font-family:'microsoft jhenghei',sans-serif"> resetOverflowData();</span></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-family:'microsoft jhenghei',sans-serif">}</span></div>
<div><span style="font-family:'microsoft jhenghei',sans-serif"><br></span></div>
</blockquote></blockquote><font face="microsoft jhenghei, sans-serif" size="4"><b><u>Resolve :</u></b></font><div><ul><li><span style="font-family:'microsoft jhenghei',sans-serif">Add new constructor for OutPacketBuffer and pre-compute the maxNumPackets value then pass it.</span><br>
</li></ul></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><font face="microsoft jhenghei, sans-serif"><b style="text-decoration:underline">RTCP.cpp</b><br><br><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<font color="#0000ff">#if </font>0</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"> <font color="#cccccc"> // A hack to save buffer space, because RTCP packets are always small:</font></blockquote>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><font color="#cccccc"> unsigned savedMaxSize = OutPacketBuffer::maxSize;</font></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<font color="#cccccc"> OutPacketBuffer::maxSize = maxRTCPPacketSize;</font></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><font color="#cccccc"> fOutBuf = new OutPacketBuffer(preferredPacketSize, maxRTCPPacketSize);</font></blockquote>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><font color="#cccccc"> OutPacketBuffer::maxSize = savedMaxSize;</font></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><font color="#cccccc"> if (fOutBuf == NULL) return;</font></blockquote>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><font color="#0000ff">#else</font></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"> <font color="#ff0000"><b>unsigned maxNumPackets = (maxRTCPPacketSize + (maxRTCPPacketSize-1))/maxRTCPPacketSize;</b></font></blockquote>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"> fOutBuf = new OutPacketBuffer(preferredPacketSize, maxRTCPPacketSize, <b><font color="#ff0000">maxNumPackets</font></b>);</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
if (fOutBuf == NULL) return;</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><font color="#0000ff">#endif</font></blockquote><br><b style="text-decoration:underline">MediaSink.cpp</b><br>
<br></font></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-family:'microsoft jhenghei',sans-serif">OutPacketBuffer::OutPacketBuffer(unsigned preferredPacketSize,</span><span style="font-family:'microsoft jhenghei',sans-serif">unsigned maxPacketSize, <font color="#ff0000"><b>unsigned maxNumPackets</b></font>)</span></div>
</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-family:'microsoft jhenghei',sans-serif"> : fPreferred(preferredPacketSize), fMax(maxPacketSize),</span></div>
</blockquote>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-family:'microsoft jhenghei',sans-serif"> fOverflowDataSize(0) {</span></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div><span style="font-family:'microsoft jhenghei',sans-serif"> fLimit = maxNumPackets*maxPacketSize;</span></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-family:'microsoft jhenghei',sans-serif"> fBuf = new unsigned char[fLimit];</span></div>
</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-family:'microsoft jhenghei',sans-serif"> resetPacketStart();</span></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div><span style="font-family:'microsoft jhenghei',sans-serif"> resetOffset();</span></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-family:'microsoft jhenghei',sans-serif"> resetOverflowData();</span></div>
</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-family:'microsoft jhenghei',sans-serif">}</span></div></blockquote></blockquote><br><div><font face="microsoft jhenghei, sans-serif">BR</font></div>
<div><font face="microsoft jhenghei, sans-serif">ChunWei</font></div></div>