Introduce global generic memory arena variable, instead of having just
a call-specific memory arena. This makes it possible to use memory arena
outside of call contexts. Define previous call-specific functions in
terms of the generic ones.
Change-Id: Icde4f63f02dacbf8abfbaf107ea8b5bbe18d5eb8
Support inactive hold, because some
client implementations (such as Zoiper5)
are using `a=inactive` for their holds.
For us this means, either of this
puts the other side on hold:
- `sendonly: !MEDIA_ISSET(media, SEND) && MEDIA_ISSET(media, RECV)`
- `inactive: !MEDIA_ISSET(media, SEND) && !MEDIA_ISSET(media, RECV)`
Change-Id: I75562eee60220885e233fa965bf22da92850a8f4
Make the macro return the appropriate pointer type, and make sure the
free function takes an argument of the same type. This also eliminates
some boilerplate type-casting code.
Change-Id: I3094271fa2c53ec93b9ff9f837d461cf422e0f12
Make `moh-max-duration` available for both
music-on-hold functionality as well as
for the media player.
For that to work, do the following:
- keep `moh-max-duration` config option only for MoH,
if not set (so 0) by default is 1800000ms (half an hour)
- for the play media functionality introduce flag option
`repeat-duration`, by default is disabled
Policy changes:
- duration counter can be used in common with repeats
counter, but then takes a precedence over it.
Hence if first a duration is underflown, then EOF triggered.
Otherwise if the duration counter is still positive, but
repeats are negative, then do EOF based on repeats.
- the repeats counter will always count down during each
iteration, even when used together with the duration counter
For MoH to survive, the repeats counter is simple set to 999
to let the duration counter always win over repeats one
- MoH cannot take duration disabled, since otherwise
would make no sense for it. Hence always takes internally
defined value 1800000ms (half an hour) if not defined
by the configuration option
Backwards compatibility:
- is kept in regards of repeats counter
- is kept in regards of the play media functionality
Change-Id: I48ff3c17c9bed31f80c3106b275b703a9ccb4b26
Introduced Music on Hold functionality:
- available only for the offer/answer model,
no other scenarios (publish, subscriber etc.)
are covered with it
- it gets advertised always at the beginning of
the call (original offer/answer exchange)
- can be added for both sides: offerer/answerer
- the one who advertises its MoH capabilities
with its SDP offer or answer, can later trigger
MoH using sendonly SDP and unhold remote
party using sendrecv SDP
- MoH covers only audio type of media sessions
- there is no specific selection of media sections
to be held, thus, if one audio media puts the
call on hold, the whole call is held
- list of parameters to be given when advertising
MoH capabilities: a sound source (file, blob or db source);
sendonly/sendrecv hold; zero-connection hold;
At least an audio file source must be given
- MoH cannot be mixed with the play media functionality,
the last one triggered will override previous one
- MoH must be unheld to stop the media being sent
towards a recipient, otherwise only a termination
of monologues will stop this packets stream
Change-Id: Iefd83ced79c14dadad936348a1d529007d6e7b3b
Rename the following functions into
something more relevant so that it
doesn't correlate with the general
init function `media_player_init()`
which isn't call specific.
- `media_player_init_file()` > `media_player_add_file()`
- `media_player_init_blob()` > `media_player_add_blob()`
- `media_player_init_db()` > `media_player_add_db()`
Change-Id: I8efd877bfd4c7c300aec7efe6fbbb654f52de460
Pass file, blob and db_id via `media_player_opts_t`
structure members instead of using separate arguments
in `call_play_media_for_ml()`.
Change-Id: I8c3b9b7f5ab61238d35463c304246f31a922ac6f
This function connects two call legs (two monologues), possibly from
different call IDs, into a single media flow. It pays attention to media
types and automatically engages transcoding if needed. The order of
media sections of different types can be differend between the call legs
that are being connected. Subsequent reinvites will produce SDPs with
the media sections in the correct order.
Change-Id: I40c3363997de169edc553733d52acdfd9f0181ad
This function retrieves two calls from the global call hash while
avoiding deadlocks. This is needed because a "call_get(A) + call_get(B)"
would deadlock against a concurrent "call_get(B) + call_get(A)"
Unused at this point.
Change-Id: I95127ce1afa19386a847984ca26eb7d7368e6569
This function merges two distinct call objects into one. All contained
objects are moved, and the "source" call is then destroyed. Both call
IDs can then be used to refer to the same internal call objects. Call ID
aliases are kept in a list in the call object.
Change-Id: I8a37775fe0dc3e7ccfeb83e2a3b7d751601450fc
Create a dedicated helper function to remove a call from the global call
hash based on a particular call ID.
No-op as this just splits out the relevant code.
Change-Id: I24e4bd89be882a1d941c5e09cada9cb055982f24
When media subscriptions are removed implicitly by
__subscribe_medias_both_ways(), we must update all RTP sink pointers of
all the streams of the affected medias. Otherwise these sinks will be
left unchanged despite the subscriptions having been removed.
Change-Id: I6d1ac3bb5cb27443c31f0f3b9ce8f47c416cd3ce
To support scenarios with mismatched media sections between two sides of
a call that aren't based on explicit SDP manipulations, attempt to
lookup the peer media based on an existing subscription also for offers.
Add extra checks (media type, media ID, monologue pointer) to make sure
that the obtained media object is actually the correct one.
Use a fallback on the existing index-based lookup in case no matching
media can be found.
As a side effect, the numbering and ordering of media objects created
during offer/answer is now reversed as the function is called in a
different order. Adapt tests as needed.
Change-Id: Ia5351f7d4fed03098c6be6bea3d4c74f52b8a76b
The `answer` processing empties out the list of codecs and leaves only
those that were accepted in the answer. Side effect of this is that if
another answer with a different list of codecs comes through, them the
codec-accept function is missing the original list of offered codecs and
can yield an incorrect result.
Fix this by storing a copy of the offered codecs at the end of the
`offer` processing, and then restore this list at the beginning of each
`answer` message.
Change-Id: I3c714e80689f3c5689637cc7d1eb2f203c292a15
There is enough overlap between the two enums that it doesn't make sense
to carry along both. Unify.
Change-Id: I9de8fbdb8d78a2002d8c1b62cea57188c937d61d
Allow to-tag updates in answers only until a non-provisional response is
received. Add a flag to optionally suppress this feature.
Change-Id: I67110ede662f618ba5a355500d3d84050e6318cc
If we receive an answer from a to-tag that hasn't previously seen and no
corresponding monologue exists (created from a previous offer),
previously we would treat this is a separate and new call branch, create
a brand new monologue and dissociate the previous one. This may lead to
unexpected results as this new monologue has been created without the
same initialisation as was done for the original one, and so may be left
with incorrect or incomplete data (e.g. SRTP keys, codec information,
interface bindings, etc).
Improve this by treating an unexpected and unseen to-tag as an alias to
the already existing to-tag. Going forward both tags can be used
interchangeably to refer to the same monologue.
Add a flag to suppress this new behaviour, in case some situation is
made worse by it.
Change-Id: Ie8f838eebd50d29d3549031998a2eb1f610b04bb
Refactor media level manipulations, no funcitonal change.
Just add a separate static function that does
all the job to create fictitious (zeroed) media.
Change-Id: Ifa39e31cdeaa093710cf8b834e7e08881056212f
In order to be able to control, which media types
one wants to have in the call session,
add support of the "sdp-media-remove" flag.
Syntax:
"sdp-media-remove" : ["<media-type>", "<media-type>", ...]
Additionally, add according unit tests.
Change-Id: Ic52456f8124319992ea9ca8c161daefb1df46b59
During the monologues lookup in
`call_get_dialogue()`,
instead of relying on the very first available
other side subscription, when doing a lookup
of this side, try to look into all of them
to find available media with existing subs.
Change-Id: If232cd25f26a2bc56eb1f401ba5c2c8a13e3e463
While handling offer/answer exchanges, do:
- index based lookup for sender's side (both offers and answers)
- index based lookup for receiver's side, but for offer only
- subscription based lookup for receiver's side, but for answer
Additionally: fix "media playback after delete" test,
because each new offer/answer exchange towards new branch,
means to have new via-branch value.
Change-Id: I078b7f7e58fa1aafbd8e68662f5f14ecb15b53c0
Don't unsubscribe offer from its existing
subscriptions, because it may have multiple
branched receiver's monologues, and hence medias.
Change-Id: I5caf515f35688041b684fbea9bf05ae559d43e15
When calling `__subscribe_medias_both_ways()`,
add sender to receiver, and not the other way.
This is just for simplicity of code reading
(so kinda: from -> to).
Change-Id: I7df889b7744c1fc3c1bec5016adbe6924e5396c3
If a monologue is determined to get a new to-tag, don't just overwrite
the previous to-tag, but also save the old one as an alias. Leave the
old one in the hash table as well so that future lookups can use either
to-tag.
Change-Id: I5d2d5cc17c85ec4ca2d8a20c501d2cdb6d793b61
The `if` block ends with a goto, so the indent for the `else` block is
not needed. Remove it for readability.
Change-Id: I0ab88246cfebf105c2256d129890925706917618
Add a getter function for retrieval of top
most media from given media.
Currently existing getter for the top most
monologue's media subscription, just rename
so it makes more sense and is better to
differentiate:
`call_get_top_media_subscription()` -> `call_ml_get_top_ms()`
Change-Id: I5bf13b69b4d5f67cd6b53018b5a16d759542cd41
Always create the offer/answer subscriptions during an offer/answer
exchange, making sure that no other offer/answer subscriptions can
exist.
Change-Id: I95e584c24e7ba74f2ead36d0c23976ef1f2e461c
Make sure stats are always added to the `delete` message.
Fixes stats being missing in case of `delete` without from-tag.
Change-Id: I635cc87b91d3e488696f33380b12dc68a24e51ad
Not needed any more. All strings reside in the call's memory arena, and
SDP rewriting isn't a thing any more.
Change-Id: I594b85fe26f44fa25312eb97fb65de238fc18920
Instead of keeping one global hash/list of all received ICE fragments,
indexed by string call ID and from-tag, move the hash/list of ICE
fragments into the call object, now indxed only by the from-tag.
This requires a call object to exist before an ICE fragment can be
stored. Change the order of operations to always create a call object
first, then parse the SDP, then check for ICE fragment processing. The
determining factor now is only whether the monologue exists.
Duplicate the raw SDP into the call's memory arena instead of onto the
heap.
ICE fragments now don't need to store the pre-parsed SDP any more, and
the trickle ICE handling code is guaranteed to always have the fully
parsed SDP information.
Strings for fragment indexes can now be allocated from the call's memory
arena.
Obsolete the extra thread used to delete old ICE fragments. This is now
done in-line with regular call timeout processing.
Change-Id: I7acbc4c52666c4cdf1c02324bf33cf0bfcb4f0d0
Flag the media via stream params, when it's
trickle or non-trickle offer/answer, and,
unflag it always only when it's non-trickle.
Change-Id: Ia85ce5792684a4121e224aff1a8e941e061fe5a8