cisco / libsrtp

Library for SRTP (Secure Realtime Transport Protocol)
Other
1.21k stars 474 forks source link

srtp_get_stream is O(n) #417

Open JonathanLennox opened 6 years ago

JonathanLennox commented 6 years ago

LibSRTP stores every ssrc's srtp_stream_ctx_t in a linked list. This means that finding the appropriate context for an ssrc is an O(n) operation. In a large conference, this can be a noticeable performance cost.

A hash table would probably be the best option here.

paulej commented 6 years ago

Fully agree. The SSRC lookup can be painfully slow if there are lot of them. Since these are (in theory) supposed to be random values, a tree might prove to be fairly well balanced most of the time without much effort.

murillo128 commented 2 years ago

We have extracted the current stream list implementation and create an internal api + default linked list implementation in the following PR https://github.com/cisco/libsrtp/pull/612

While this does not allow to plug-in a custom implementation dynamically, it allows compiling libsrtp without the default list implementation and replace it with a custom one instead.