[Live-devel] [ Propose ] Fix multi-thread issue when RTCPInstance new OutPacketBuffer
JW Liao
pr.jwei at gmail.com
Sun May 25 04:07:43 PDT 2014
*Environment*
1. Create multiple RTSP server in one process and every server is
different thread ( multi-thread ).
2. Create 100 session to play video from the multiple RTSP server at the
same time, so every server will be handle some sessions.
*Warning Message :*
- 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.)
- 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.)
- 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.)
- 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.)
*Root Cause :*
- *OutPacketBuffer::maxSize* type is *static*, when multi-thread
running, the value will be modified at class *RTCPInstance* constructor,
show source code below:
// A hack to save buffer space, because RTCP packets are always small:
unsigned savedMaxSize = OutPacketBuffer::maxSize;
*OutPacketBuffer::maxSize* = maxRTCPPacketSize;
fOutBuf = new OutPacketBuffer(preferredPacketSize, maxRTCPPacketSize);
OutPacketBuffer::maxSize = savedMaxSize;
if (fOutBuf == NULL) return;
*Analysis :*
- *RTCPInstance* constructor modify *OutPacketBuffer::maxSize* just want
to help class *OutPacketBuffer* constructor compute *maxNumPackets*,
show source below :
*MediaSink.cpp*
OutPacketBuffer::OutPacketBuffer(unsigned preferredPacketSize,unsigned
maxPacketSize)
: fPreferred(preferredPacketSize), fMax(maxPacketSize),
fOverflowDataSize(0) {
unsigned *maxNumPackets* = (*maxSize* + (maxPacketSize-1))/maxPacketSize;
fLimit = maxNumPackets*maxPacketSize;
fBuf = new unsigned char[fLimit];
resetPacketStart();
resetOffset();
resetOverflowData();
}
*Resolve :*
- Add new constructor for OutPacketBuffer and pre-compute
the maxNumPackets value then pass it.
*RTCP.cpp*
#if 0
// A hack to save buffer space, because RTCP packets are always small:
unsigned savedMaxSize = OutPacketBuffer::maxSize;
OutPacketBuffer::maxSize = maxRTCPPacketSize;
fOutBuf = new OutPacketBuffer(preferredPacketSize, maxRTCPPacketSize);
OutPacketBuffer::maxSize = savedMaxSize;
if (fOutBuf == NULL) return;
#else
*unsigned maxNumPackets = (maxRTCPPacketSize +
(maxRTCPPacketSize-1))/maxRTCPPacketSize;*
fOutBuf = new OutPacketBuffer(preferredPacketSize, maxRTCPPacketSize,
*maxNumPackets*);
if (fOutBuf == NULL) return;
#endif
*MediaSink.cpp*
OutPacketBuffer::OutPacketBuffer(unsigned preferredPacketSize,unsigned
maxPacketSize, *unsigned maxNumPackets*)
: fPreferred(preferredPacketSize), fMax(maxPacketSize),
fOverflowDataSize(0) {
fLimit = maxNumPackets*maxPacketSize;
fBuf = new unsigned char[fLimit];
resetPacketStart();
resetOffset();
resetOverflowData();
}
BR
ChunWei
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20140525/3ce8ba24/attachment-0001.html>
More information about the live-devel
mailing list