Avoid repeated calls to the memory allocated for port pool list
management by picking out the list elements without freeing them,
storing them in the stream_fd object, and then returning them to the
list when the port is released.
Change-Id: I67cd5039e62e4d2965e85d7ba7f0454f08f40494
Avoids allocating and duplicating the string. Should be safe as all
strings that use it are allocated in read-write memory.
Requires changing some struct members to non-const.
Change-Id: Idc81a84a1454898c76d8514666c385307043bb6f
The requirement to continuously update stats from the kernel has been
eliminates. Remove all relevant code.
Change-Id: Idc8093b64290b89ff3d015f3e61e4bbe25df6e23
These will be shared between userspace and kernel space and so the
definitions must be part of the kernel includes.
Change-Id: Iabf7a4ecff3638ea1765a6d7341bb24e9955b509
There isn't any immediate benefit to this, but it prepares the code for
use of shared memory for statistics.
Use the opportunity to switch accesses to these to relaxed memory order.
Change-Id: I585fef7579202179fbbcbc1b843d3bbe440a723b
Switch all memory buffers used for RTP I/O from generic stack or heap
allocated memory to the bufferpool implementation. Use a per-thread
bufferpool to minimise lock contention.
This commit is just a one-for-one swap and doesn't use the bufferpool's
reference counting semantics yet.
Change-Id: I9cba4ec97bd0afcd374bf6c0be2b608a46e73e57
In the header files follow the rules:
1. Firstly goes ifndef/define construction, then one empty row.
2. Secondly go system headers, so in angle-brackets, then one empty row.
3. If there are important pre-processor definitions, which affect
the following custom file headers, they are added next, then one empty row.
4. Thirdly custom header files, so in double quotes,
then at least one empty row.
5. If there is "xt_RTPENGINE.h", it's mentioned next, but separately,
then one empty row.
6. Then pre-processor definitions, and one empty row before the code.
In some situations it's allowed to step aside from the rules,
when inclusions are dependent on each other, so on specific sequence,
and also possibly on some inline objects definitions.
But, if possible to follow the rules, it should be done.
Change-Id: I6bec69b508653947c04e7785775373d21112eb58
There's two flavours of this struct being in use, even though the
structs' signatures are the same. One contains socket_t objects, the
other contains stream_fd objects. Separate them out and be explicit
about which is which.
Change-Id: I5ef1d154cc442528149f69be2e6a02625a6c650d
Make it possible for a looper thread function to break out of the loop
by returning an appropriate status code.
Change-Id: I22e7789270eed4bf3340e7dae941929de58700ea
To do the work more efficiently,
and not be dependent on the call_timer runs by poller,
we should move the ports iterations (stats update from the kernel)
functionality to a separate thread, to make it faster and
not be dependent on what happens in the `call_timer` at all.
Since it has nothing to do with the call timers.
As an additional benefit: we unload the `call_timer` runner.
Change-Id: I511529ce504ef3d29f4e9d6d731ffd470d78d27a
Due to multiple threads polling all sockets for read events, it's
possible for one socket to receive a read event in one thread, then
immediately receive another read event in another thread, resulting in
two threads reading packets from the same socket at the same time.
While this is perfectly valid and correctly handled by mutex etc, it can
result in packets being processed out of order. In media passthrough
scenarios which don't do sequencing this can result in packets being
reordered.
Using a simple atomic counter we can ensure that only one thread is
reading from any one socket at a time.
Relevant to #1638
Change-Id: I406491d6ae5e13e618e153ba5463fd9169636016
To do the work more efficiently and not be dependent on
the `call_timer` runs by poller, we should move
the releasing of sockets to a separate thread, to make it
faster and not be dependent on what happens in the `call_timer`
at all. Since it has nothing to do with the call timers.
Since now we have two queues:
- thread scope (local): ports_to_release
- global one: ports_to_release_glob
`sockets_releaser()` uses the ports_to_release_glob,
meanwhile appending in the `call_timer()` happens using the
ports_to_release.
Change-Id: Iadd966ac895b2dd64f81269d4fdf5d83747fe0b7
We have to stop using objects of `struct port_pool` (media_socket.h),
becasue a newer approach introduced for ports allocations deprecates
usage of them.
Deprecated objects:
`port_pool.last_used`
`port_pool.ports_used`
`port_pool.free_list`
`port_pool.free_list_used`
Change-Id: I70e166753da7a43cb3b6b188c83d978b7dbce046
Introduce a reworked port allocation in RTPEngine.
The goal of this rework is to:
- simplify the logic of handling free/engaged ports
- eliminate a bottle neck begotten by overcomplicated logic
- potentially resolve the issue with "ran out of ports"
under heavy loading, when still there must be ports left
in the ports pool
Change-Id: Ifd2b1565611dd3b86c474a1ea5507fc6152fc212
The SRTP decryption context is associated with the local socket. Use the
socket that a packet was actually received on for the decryption context
instead of using the one that it was expected to be received on.
Change-Id: Iddf400a440fc51b4afb370ec827f75e9626b2cfd
(cherry picked from commit 8c3452e50b7aa4f5b7122dbd7221e34143467885)
Based on the information gotten from Richard Fuchs
document the main objects in the code, to let the code be more
understandable for other code readers.
Mainly documented:
- call
- call_monologue
- call_subscription
- call_media
- packet_stream
- stream_fd
- sink_handler
- rtpe_callhash / rtpe_callhash_lock
Change-Id: I0cf122bea2d9c3f198b48da134a70301564ff1f9
Instead of just leaving the transport protocol unset when we know we're
not supposed to be aware of the protocol, add a special entry to
suppress the pointless warning message.
Change-Id: I228c2f1652320627f974d9d7bcb0b1345adce2be
Create a dedicated struct to hold certain attributes shared by both sink
handlers and media subscriptions, as a preparation to simplify handling
these attributs.
Change-Id: I866159c33ed6d6a2873d2cf68c4906ea705d253e