Index: libmpdemux/demux_rtp.cpp =================================================================== --- libmpdemux/demux_rtp.cpp (revision 24301) +++ libmpdemux/demux_rtp.cpp (working copy) @@ -358,18 +358,27 @@ ////////// Extra routines that help implement the above interface functions: -#define MAX_RTP_FRAME_SIZE 50000 +#define MAX_RTP_FRAME_SIZE 4194304 // >= the largest conceivable frame composed from one or more RTP packets +unsigned long rtp_frame_size = 65536; + static void afterReading(void* clientData, unsigned frameSize, - unsigned /*numTruncatedBytes*/, + unsigned truncSize, struct timeval presentationTime, unsigned /*durationInMicroseconds*/) { - int headersize = 0; - if (frameSize >= MAX_RTP_FRAME_SIZE) { - fprintf(stderr, "Saw an input frame too large (>=%d). Increase MAX_RTP_FRAME_SIZE in \"demux_rtp.cpp\".\n", - MAX_RTP_FRAME_SIZE); - } + int headersize = 0, size = frameSize + truncSize; + size += size / 2; + if (size > rtp_frame_size) { + int i; + int j = size - 1; + for (i = 0; j >>= 1; i++); + rtp_frame_size = 1 << (i + 1); + if (rtp_frame_size > MAX_RTP_FRAME_SIZE) { + fprintf(stderr, "Saw an input frame too large (>=%d). Increase MAX_RTP_FRAME_SIZE in \"demux_rtp.cpp\".\n", + MAX_RTP_FRAME_SIZE); + rtp_frame_size = MAX_RTP_FRAME_SIZE; + } ReadBufferQueue* bufferQueue = (ReadBufferQueue*)clientData; demuxer_t* demuxer = bufferQueue->ourDemuxer(); RTPState* rtpState = (RTPState*)(demuxer->priv); @@ -482,7 +491,7 @@ // Allocate a new packet buffer, and arrange to read into it: if (!bufferQueue->nextpacket) { - dp = new_demux_packet(MAX_RTP_FRAME_SIZE); + dp = new_demux_packet(rtp_frame_size); bufferQueue->dp = dp; if (dp == NULL) return NULL; } @@ -498,7 +507,7 @@ #endif // Schedule the read operation: bufferQueue->blockingFlag = 0; - bufferQueue->readSource()->getNextFrame(&dp->buffer[headersize], MAX_RTP_FRAME_SIZE - headersize, + bufferQueue->readSource()->getNextFrame(&dp->buffer[headersize], rtp_frame_size - headersize, afterReading, bufferQueue, onSourceClosure, bufferQueue); // Block ourselves until data becomes available: