Hi Have you considered using a sorted linked list for storing packets? Currently there is a circular queue in static array. With a sorted linked list, we could have different buffer length for different codecs, and buffer size could change dynamically. For example if we detect that jitter is high and there are lots of missing frames we could extend the buffer a little bit and introduce small delay in playback. Insertion into a linked list would be cheap if there are no missing frames, and slightly more expensive if there are some missing ones and arriving out of order (this is a constant operation right now). Pulling frames out of MprDejitter would be a constant operation in comparison to current code, which basically needs buffersize loops since it begins the loop after the newest frame (if frames arrive in order and there is no loss). Frames in linked list would be sorted according to rtp timestamp as sequence numbers could cause problems. It would simplify the code in MprDej! itter and in the G711 u and A decoder decodeIn function substantialy. Also gsm and speex would use it. There would be 1 jitter buffer for each codec.
If we use sorted linked list we can also compute statistics like how many frames in order (without missing slots) do we have in the list from the head. For example if we detect that we only have some missing frames in next 100ms, we can increase the delay before playback until it improves (it would have to detect somehow when other side simply stops sending rtp packets). We would have to drop very old frames during insertion (the buffer would have to be notified about the minimum timestamp that it should accept - that would be the rtp timestamp of last played frame). It would be simpler than in the current implementation, as we would know that frames in the head would be certainly accepted by decoder, whereas currently we don't know this when we loop through the array as decoder decides whether it wants the frame or not. Deciding which frame should be played and which not should be the work of jitter buffer only, decoder should not interfere (only supply last played frame). I have some code that works using linked lists (not UtlSortedList, but custom implementation, I didn't want to add too much penalty) without the improvements. I would like to hear whether you think that replacing fixed arrays with linked list is the way to go. Jaro _______________________________________________ sipxtapi-dev mailing list [email protected] List Archive: http://list.sipfoundry.org/archive/sipxtapi-dev/
