This commit introduces a new RTP transport model,
based on the AmRtpTransport abstraction, providing a more modular and
efficient approach to RTP handling compared to the legacy model.
General things:
- Introduction of new RTP receiver and transport abstractions
- The new model coexists with the legacy RTP handling
to preserve backward compatibility
Architecture overview:
- A new AmRtpTransport layer is introduced to encapsulate RTP transport logic
and decouple it from AmRtpStream and session-level code
- Transport-specific functionality is implemented via dedicated classes:
- AmRtpTransport: base abstraction responsible for RTP/RTCP packet flow,
lifecycle management, and interaction with streams
- AmRtpUdpSocket: UDP-based RTP socket implementation
- AmRtpSocketPair: manages RTP/RTCP socket pairs and their coordination
- AmRtpStream is refactored to rely on the transport interface
instead of directly managing sockets and low-level I/O
Integration details:
- SIP session and dialog logic (AmSession, AmSipDialog) is updated to work with
the new transport model
- SBC call legs and call profiles are extended to support transport selection
and lifecycle handling
- SDP processing (AmSdp) is updated to reflect transport capabilities and
address handling changes
This refactoring improves separation of concerns, reduces coupling between RTP
streaming and transport mechanics, and provides a cleaner foundation for future
RTP extensions and optimizations.
Code provenance and license:
- part of the code was written by Fokus GmbH
- part of the code was written by Sipwise GmbH
- part of the code base copyrighted by Fokus GmbH was provided by them in
the form of backports under the GPL license.
- these changes are covered by the GPL, matching the existing project license
Change-Id: I313c4abd9b54f805c1e668c019cf6fb8c4a9e46d
If the Content-Length is empty, then it makes no sense
to parse and filter application/sdp body.
Otherwise a parser is going to fail and answer with 488.
Change-Id: I92cdd19319c6f4a4edcfbaeec7bad1be12c8a0b0
Add parsing of Content-Length, for cases
were this length matters (e.g. ct length > 0,
but suddenly there is no SDP body).
Also add a getter for the AmContentType's length.
Change-Id: I92cdd19319c6f4a4edcfbaeec7bad1be12c8a0b1
Reverse inheritence between singleton class and its base.
Change singleton template so that the singleton class doesn't inherit
from its base, but rather that the singelton class inherits from the
singleton template. This removes the need to keep the singleton base
classes separate (with the underscore prefix) plus a `typedef` for the
singleton class, and instead makes the class itself become the
singleton. (The exception being intermediate classes that have multiple
other derived classes, which is only the wheeltimer).
This makes for cleaner typing, but requires use of listing the singleton
template as friend class.
No functional changes.
Change-Id: Ic45cb01f7870ce0ba97188e58340b10fdc0380cb
Preamble: no functional changes.
AmSdp::parse() mixes int values with bool,
what makes the behavior not really clear, not defined
and can lead to the unpredicted result (even though the
compiler *should* actually fix that, but one ought to
not rely on this).
Hence make the parse method only be working with bool values.
Then, reverse the return value so that it's clear
that wrongly parsed is `false`, and good parsed is `true`.
Refactor all users accordingly.
Also rework those users, who indeed need `int` value
be returned, e.g. when having -1.
Do the same thing with the `parse_sdp_line_ex()` helper,
whereas parse() is the only user of it. And also reverse
the interpretation of true/false.
Then, make `parse()` working with a plain `char*`, so not a const.
Because doing a tricks like:
cast `char*` to const (user level) -> cast `const char*` to non-const
in a function (in a old C-like manner), has really no sense.
Refactor everything accordingly.
Other than that, refactor AmMimeBody:
Refactor it to work with a plain `char *` pointer instead of working
with `unsigned char *`, which nowadays has really no sense and
rather is a rudiment of C-like code base coming from the past.
Convert `payload` from `unsigned char*` to `char *` accordingly.
Refactor everything in AmMimeBody implementation accordingly.
Remove rudiment C-like casting everywhere, where possible.
Update `parseMultipart()` to work with a plain `const char *`
instead of `const unsigned char*`
P.S.: leave a list of TODO's for further rework, which
is not directly related to this scope of rework.
Change-Id: Ie1e132429245e0d2cc740d5b1c1fc17cf037a820
When using that, the return value must always
be checked, because the parsing itself can indeed fail.
Fixes such things as:
** CID 583412: Error handling issues (CHECKED_RETURN)
/core/AmB2BSession.cpp: 340 in AmB2BSession::acceptPendingInvite(AmSipRequest *, const AmMimeBody *)()
_____________________________________________________________________________________________
*** CID 583412: Error handling issues (CHECKED_RETURN)
/core/AmB2BSession.cpp: 340 in AmB2BSession::acceptPendingInvite(AmSipRequest *, const AmMimeBody *)()
334 return;
335 }
336
337 /* port must reflect actual port in SDP offer coming in */
338 if (sdp) {
339 AmSdp fake_sdp;
>>> CID 583412: Error handling issues (CHECKED_RETURN)
>>> Calling "parse" without checking return value (as is done elsewhere 12 out of 15 times).
340 fake_sdp.parse((const char *)sdp->getPayload());
341 desired_port = getMediaPort(fake_sdp);
342 }
343
344 if (desired_port) {
345 ILOG_DLG(L_DBG, "Desired port for fake 200OK is '%d'\n", desired_port);
Change-Id: I7bd177a624ebe2df2629863eb31f97f99bd921bb
Set the port in fake SDP answer (to the other side)
coming from the leg, which now replaces the previously
existing one, to the port gotten from the replace INVITE.
Otherwise, if to use the port from the pending transaction
(towards pick-up'er) it confuses rtpengine with a case
when same port talks to himself, and then can later be
used to update the pick-uper's leg once again.
Change-Id: I4c001f7956a005b64285c05586839f01216cfd91
Force the leg being connected instead of the replaced one
to the rtp_relay_mode = RTP_Direct, because otherwise
legs can get SEMS involved into rtp relay after a transfer
is finished.
Change-Id: Ifb55feaa7813fc303a663ac132b0bfe175772ce0
Make the AmOfferAnswer model actual and introduce
according class API updates.
Accordingly update CallLeg, SBCCallLeg and AmSipDialog.
Change-Id: Iab26f4a7577af56df68ffe693859eaac08913b7f
If the CallLeg isn't SIP relayable, then makes no sense
to relay INVITE to the other leg, otherwise it gets stuck
on the other side.
Change-Id: I43dff24981084885a20f697537419a6dac75b806
When this leg being reconnected, is still in progress
of posting remaining events to update the other side
(the reconnect originator), don't consider it as
sip relay ready. Otherwise any INVITE updates coming
to it, will lead to stumbled INVITEs coming to the other leg,
but without a possibility to use it here (because e.g. this
other side never seen 200OK answer even).
Change-Id: I183d0f70433c156030de38238db395e2c1372352
We can now use the sets to iterate the bindings in order of their
expiry and exit the loop when we encounter the first one with an expiry
in the future.
Change-Id: I093bea9807b4a432ac965b402394edc43eef5a1f
Add an ordered set of all AorEntry objects, ordered by expire time.
Amend modifier methods to update the set whenever some expire time is
updated or an entry or binding removed.
Change-Id: I2afe5becfa2124dbc8c33b38fe1a3e6d4b8a20d5
Move deletion of bindings into AorHash, similar to how expire times are
set. This makes it possible to manage expiry in a central place.
Change-Id: I76a72881ed202e85fb70e9d8526bac55863d07db
Make AorEntry keep an ordered set of all bindings, ordered by expire
time. This makes it easy to quickly tell when the next binding is set to
expire, and which one. Store iterators to bindings in the set so that
they can be used to directly remove the binding when expired.
Change-Id: Ib63c15d5f6e8990e2f4d237726be54da76194a20
Provide accessor methods. Put the setter into AorHash and require
iterators. All bindings must be in an AorEntry container and all
AorEntry objects must be in the AorHash container. By putting the setter
in AorHash and using iterators we can make sure that the binding is in
the container already and that expiry values are kept consistent.
Change-Id: I1c5140d1a7547059f61e47cd317680fcb6eae9fe
Provide a proper class for key matching/ordering instead of
hand-crafting a key to be used as index in several places. Use a simple
ordered map instead of the bucket-based approach.
Change-Id: I9e1918a48e103b655caac160c125a0393d261fca
Put all AorEntry objects into a single hash map. Eliminates the need for
AorBucket. Use an unorered hash map for performance. Use lock guards
instead of manual lock/unlock. Remove an unused argument to gbc().
Switch to the full tick cycle length instead of the tick-based one as
there are no more buckets to iterate.
Change-Id: I7da3bacaa5a28b7e628695ab879394fc6d56f5d2
Simplify the little-used RegisterCache alias hash by using the new
hash_map template. Eliminates the need for AliasBucket. Use an unordered
hash map for performance. Use lock guards instead of manual lock/unlock.
Manually `delete` contained objects as our table's .erase() doesn't do
that.
Change-Id: Ia9721460ce8264fc0a90184a91beca46012b64dd
Instead of relying on a short tick duration to make sure the thread
exits when requested, add a dedicated condition flag and variable. Use
AmThread on_stop to set it and wake up the thread. Use the condition
variable's timed wait instead of nanosleep for the ticks.
This somewhat duplicates what other threads are doing, and what
stop_requested() is doing, and should be unified into a single mechanism
provided by AmThread in the future.
Change-Id: I364e747b4acc1986fa262588c47d83c063ff2d69
For newly created call profiles use the move operation
instead of copy one.
Fixes:
CID 542292:Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)
Change-Id: Ia130fc3e32d23e63f3d41fc6261e90ecf742ecf7
Store integers as long to reduce likelihood of overflows. Retain
overloaded accessors for compatibility.
Use time_t and suseconds_t for timestamps.
Fix up formatting strings to match the new types and to also fix
incorrect formatting of decimal values.
Remove unused methods.
Change-Id: I58bfcd8a34bef2363eac06242dfedf6aae8451e0
Add missing initialisers and fix order.
In some cases the member was actually unused and could just be removed.
Change-Id: I0f0c927eb8271c35dcfd371f225847f62bea2812
Warned-by: Coverity
We are passing here null pointer (so `this->dlg->getCallid()`)
which isn't good.
Just use a default `WARN()` instead.
Fixes:
*** CID 549008: Null pointer dereferences (FORWARD_NULL)
/apps/sbc/CallLeg.cpp: 193 in CallLeg::CallLeg(const CallLeg*, AmSipDialog *, AmSipSubscription *)()
187
188 // enable OA for the purpose of hold request detection
189 if (dlg) {
190 dlg->setOAEnabled(true);
191 dlg->setOAForceSDP(false);
192 }
>>> CID 549008: Null pointer dereferences (FORWARD_NULL)
>>> Passing null pointer "this->dlg->getCallid()" to "c_str", which dereferences it.
[Note: The source code implementation of the function has been overridden by a builtin model.]
193 else ILOG_DLG(L_WARN, "can't enable OA!\n");
194
195 // code below taken from createCalleeSession
196
197 const AmSipDialog* caller_dlg = caller->dlg;
198
Change-Id: If1f62386c9a2d3f6df4a12a2b157802b8a0677fa
These are all instances of an object being put into a container just
before it goes out of scope. Use move semantics to avoid copying.
Change-Id: I9c40a56c4a67df2b8e244d51f068b50ec286f5bf
Warned-by: Coverity
Make the way we get call-id when calling ILOG_DLG()
file specific, which allows to define locally
(within a target file) how to get the call-id value.
Change-Id: I4af87edf9d1ea52d9678b3354bc797cf1f5f0b54
Use overloading for the various flavours of str2int functions. This has
the benefit of automatically choosing the appropriate function for
aliased types that may be one or the other underlying type, such as
size_t.
Do a mass renaming of all relevant instances.
Change-Id: I7abb6b9031ee53332d2b04a6cba4a6cc667a4807
Use smart pointers instead of handling with new/delete.
Fixes:
Resource leak (RESOURCE_LEAK)
leaked_storage: Variable rev going out of scope leaks the storage it points to.
Change-Id: I33dfe6c4a74a01774093dc500248c3ed613b5710
Introduce `ILOG_DLG()` call-id logging based on `dlg`.
This commit only introduces a usage of it for
CallLeg and SBCCallLeg classes.
Later commits will spread this usage over all
AmB2BSession based classes.
Change-Id: I18ad8ba5129cb8912f401bb089ad82dbf9909a18