Don't explicitly set the "non forwarding" flag just because an RTCP
stream is being kernelised. The distinction between RTP and RTCP,
together with zero-length outputs setting "non forwarding" automatically
takes care of it.
Change-Id: Ie363fc369b7ace21ed172a0ec141c83afd1ba21b
Make it possible for a looper thread function to break out of the loop
by returning an appropriate status code.
Change-Id: I22e7789270eed4bf3340e7dae941929de58700ea
Perform endpoint address check before doing ingress SSRC handling. We
don't want to act on an apparent SSRC change if the endpoint address
doesn't match and the packet should have been ignored.
Closes#1655
Change-Id: I251e23b1583b1916c7c4904cf40d3b37b3533117
As this is running in a separate thread now, rtpe_now needs to be set
excplicitly in each iteration.
Fix-up for 6fe9cc9
Change-Id: Icb1ec8a27389bb48ee893a9a29e4e1c11447d61c
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
Add a flag to inhibit kernel mode while DTMF injection is active. Tie in
DTMF playback trigger function: Remove stream from kernel, set inhibit
flag, play DTMF, then unset inhibit flag when all events have been
injected.
Change-Id: I533ec95a676bc7edf4dd973217f8d9499f1e22b6
DTMF requires the "end" event to be sent multiple times, requiring
sequence number adjustments after DTMF injection has finished. Add
support for this to the kernel module.
Change-Id: Ie5c8f18eda39553a6ebbdd35ef2341be01f2a59f
Instead of doing two calls to the kernel every time a forwarding stream
is deleted (one to update the stats and one to delete), combine these
two into a single call using REMG_DEL_TARGET_STATS.
Change-Id: I9fcb148930c24bc866f842a50edd613fb6296de0
Separate out the call to kernel_update_stats() from the function
actually consuming the stats and updating the userspace internal
counters.
Functional no-op.
Change-Id: I4d357e2649c31db7839d8f1369bca9750ef7eae2
Using a pointer array instead of a linked lists allows us to directly
reference a media section by index number, without having to spool into
the linked list.
No functional changes.
Change-Id: I8b0e93f0c2e9addbcb4c938894118ed4a6aec768
Just fixing of some typos introduced before by this commits list:
- 3444febebc
- 21562866ce
- c024b54dc3
Change-Id: I9b7f6ed5c67f1a5f31bb37ef776cf943096f1d2f
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
There's a mixture of RTPengine and RTPEngine, though we lowercase it
entirely most of the time, so let's stick to this and unify its style.
While at it remove the "the" article for rtpengine as well,
where applicable.
Change-Id: Idbad9313499942ad12ade2c9ce76fe3ec4cd2762
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)
When a receiving socket doesn't match the socket we were expecting, make
sure that the receiving socket is actually one of the sockets we want to
use at this point before blindly switching the socket.
This fixes a race condition after a re-invite: A new set of sockets has
been opened, but an old/delayed RTP packet still arrives on one of the
old ports. In this case we don't want to switch the local socket.
Change-Id: I4e2b87ad608b1a9c6a0bb2eae5c305fd79be70d5
(cherry picked from commit 304a1b11ef6679b4ab133c1c44bb0f180903d948)
In some cases it's possible that some packets still arrive in userspace
immediately after a stream has been pushed to the kernel, for example if
some packets are already in the queue or if there is some processing
delay (e.g. writing to Redis). Allow for a short delay before counting a
stream as userspace if it has been pushed to the kernel.
Change-Id: I55a6e255868c8c2a9e93355a4aa2287f07b3748d
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
Only skip forwarding unknown payload types in the kernel module if
there's reason to skip them, i.e. when we know that certain payload
types must be handled in userspace. Use an explicit flag to signal this
to the kernel module instead of implicitly doing it for anything that is
RTP.
Change-Id: I655317afe64a27252bf7b8be6c78418db2e1ccef
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
The packet must be decrypted first before RTP padding can be considered,
as the padding count is part of the encrypted payload as well.
Change-Id: I6aecff636efd420401856bb8110b3d784f989179
This makes it possible to have different media silencing options for
different outputs. Functionally this commit alone is a no-op.
Change-Id: I967c3e07ea4645bb49ccb76db12d51ded2d72f06
Make kernelize_one eturn the list of sorted payload types back to the
calling function instead of only keeping it temporarily. This makes it
possible to re-use the list in repeated invocations of the same
function.
Change-Id: I696b4d033715bb60c80c8b932b80d558f364a5c5
Don't keep the flag for "no kernel support" set indefinitely as
conditions might change, re-enabling kernel support at a later time.
Change-Id: Id8f456b653f1ea3d6a9db1ff3a0800d3cca8fcc5
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
Zero SSRC are technically invalid, but the code accepts them as valid
and therefore sets up things like crypto contexts for zero SSRCs.
Consequently it's possible to have a zero SSRC first in the list of
SSRCs and other valid SSRCs later in the list, which means we can't use
the presence of a non-zero SSRC first in the list as a flag to determine
whether SSRC tracking is in use or not. Use an explicit flag instead.
Change-Id: I88736e5d6b0f66c58f8d675137231760951e7610
Don't increase the index pointer before using it. This fixes slots 1 and
2 being filled before slot 0, which ends up filling slots 0 and 2 first
(due to swapping with slot 0), leaving slot 1 empty.
Change-Id: If34cf561fcb153edde6408252c3286c8c80991bc
When ports are closed early (while the call is still running), we must
first update a slave rtpengine with this new information (that these
ports are now closed) before actually releasing the ports ourselves. Not
doing so leads to a race condition where the master instance re-uses a
port that was just closed before the slave instance knows about the port
being closed.
We implement this using a thread-local list to keep track of ports that
were released while processing a control message, and process this list
to actually close the ports only after Redis has been updated.
Additional calls to the function to close the ports are placed in
strategic locations to make sure this is triggered in every code path.
closes#1495
Change-Id: I803f4594f30ca315da0b84c6e76893f54ca3a7c9
Initialising the other members of this struct is not really necessary as
they're not used in the hash lookup. But let's do it anyway.
Change-Id: Ia7cf982fe91e9c4d273b1fc2d2ee8b19ce345a13
Warned-by: coverity
There's no need to open ports on non-primary interfaces if ICE is not in
use as these ports will not be used or seen by anyone.
This mostly obsoletes the `save-interface-ports` config option, with the
exception of ICE advertised by the offerer. We currently have no option
to reject ICE from the offerer during the offer phase, so ports would
always be opened on that side.
Relevant to #1164 and 001abe5
Change-Id: I43df70bc0ec49b81f63aec97c776e48617b2acfd
We must now hold the master lock for reads from the socket as the socket
may get closed after the poller has already fired an event for it.
Change-Id: I1ab4b38f09988e8569a70c449de17c208ef2aa96
This is useful for functions which are used both from a timer and from
other callers. These functions would reset the logging context at their
end to free the reference held by the logging context, which would
wrongly reset the logging context when the same function was called from
a different code path. Using a stack with push/pop semantics makes it
safe to use these functions from any code path.
Additionally introduce an explicit reset function that clears the entire
stack regardless of context. This reset function is called at the end of
every work iteration in every worker thread, just in case not everything
was popped from the stack.
Change-Id: I0e2c142b95806b26473c65a882737e39d161d24d
Not only check for the presence of a sink, but also check for a sink FD.
Treat a sink without an FD as if there is no sink.
Closes#1401
Change-Id: I04c0be33f8cae39399674ca0a87185a729daa843
Flag a socket with an error strike when packets are received too fast,
and refuse processing once too many strikes have occurred. This should
prevent forwarding loops from taking down the system.
Change-Id: Idc574f2f1dbbcb156efc37a80e903dc4e60ef1b1