If with the sendonly SDP offer capable of MoH,
there is a flag `repeat-duration` coming at the
same time, then warn a user of rtpengine
that the configuration option is used with MoH
and it's not possible to take the flag's value.
Change-Id: Iacf3ddd85749da3ad98758e386952ab7cec5ca8d
Introduce `moh-max-repeats` configuration option,
which controls the `rtpe_config.moh_max_repeats`
used when initializing media player options
for the music-on-hold functionality.
By default is always set to 999,
if not defined otherwise.
Change-Id: I247dc532a6871934e44f9c4002313363356937fb
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
Sendrecv mode flag controls whether the sendrecv
state is forced to sendrecv, instead of the default
one sendonly, in the SDP body going towards recipient
(the one who will receive the MoH media).
Is declared as: moh=[mode=sendrecv]
Can be useful for corner cases, where the remote side
wants to see sendrecv state for whatever reason,
when getting MoH media and hence also remain in sendrecv
state in regards of the MoH originator.
Must be advertised once during the session origination,
nd then will affect the SDP body as soon as SDP sendonly
body is received (from the behalf of one, who advertised MoH
capabilities).
Backwards compatibility: doesn't affect non-MoH calls.
And doesn't affect offer/answer exchanges within MoH calls,
which do not put the remote side on hold.
Additionally: introduce a common function for the MoH flags
handling: `call_ml_moh_handle_flags()`, which does all
the required iterations/checks for the whole bunch of flags
at once.
Additionally: previously existing MoH tests adopted.
Additionally: new test introduced to check the SDP content,
when using mode sendrecv flag.
Remark: this flag is not mutually exclusive with
the zero-connection MoH flag.
Change-Id: I5bf6699f6890d8b927107cc143a18116efe45087
Zero-connection flag controls whether the connection
address offered in the SDP body going towards recipient
(the one who will receive the MoH media), is set
to all zeroes.
Is declared as: moh=[connection=zero]
Can be useful for older client implementations,
who want to see zeroed media when receiving sendonly
and getting put on hold.
Must be advertised once during the session origination,
and then will affect the SDP body as soon as SDP sendonly
body is received (from the behalf of one, who advertised MoH
capabilities).
SDP body recovers to the real IP addresses being inserted
into recipient's SDP, as soon as the media gets unheld.
Backwards compatibility: doesn't affect non-MoH calls.
And doesn't affect offer/answer exchanges within MoH calls,
which do not put the remote side on hold.
Additionally: previously existing MoH test adopted.
Additionally: new test introduced to check the SDP content,
when using zero-connection flag.
Change-Id: If0c38a3d294e6d5fe3886bee19ff2382e5705f9a
Move conditioning and handling of MoH
into a separate helper to make code a bit
more laconic.
No functional changes.
Change-Id: I89502bbdfe75e0b96c42ac0bde405e3ed04403fa
Add duration limit for the moh functionality.
This is required due to a possibility to get
monologues and hence packet streams stuck
forever and sending audio to recipients
which already don't exist.
A configuration option that controls that:
`moh-max-duration` - gets a value in milliseconds.
By default is set to 1800000 (half an hour).
Change-Id: Id50a0a10ce5b52b3876a3122fb16a71accec90ff
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
Move part of the `call_stop_media_ng` function body
to a separate function, to let it be available
for external function calls not particularly related
to play media NG function call.
Change-Id: I278f7bc5a6663e9232e812d10f6902616c67c497
Make most of implementations static to file
because used only locally:
- `media_player_play_file()`
- `media_player_play_blob()`
- `media_player_play_db()`
- `media_player_add_file()`
- `media_player_add_blob()`
- `media_player_add_db()`
Change-Id: I0db13e1f851e6c59d29ffb5adf5cb8d01bfd5bcc
`media_player_opts_t` is already used to pass
blob, file and db_id, hence makes no sense to pass
it one more time and reset parameters of
`media_player_opts_t` strcuture in actual implementation
to the same value again.
Change-Id: I97f4236b2c9565f12af44dc4aba85ebfc6d8cefa
Use `media_player_opts_t` object to pass file, blob and db_id
parameters via the following functions:
- `media_player_add_file()`
- `media_player_add_blob()`
- `media_player_add_db()`
Change-Id: I7612cd63d08bc00911ba68c0a5a81796d50d4722
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
Move part of the `call_play_media_ng` function body
to a separate function, to let it be available
for external function calls not particularly related
to play media NG function call.
Change-Id: Iaf4e8f72f1492446508fd6b49ba36434cae5f5f0
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
In many transcoding scenarios resampling is not actually required. We
can shortcut the operation by just returning the original frame, instead
of a cloned and newly allocated one. We just need to distinguish between
the cases to determine whether the frame returned by resample_frame()
needs to be freed.
Change-Id: I3f36a46bd3b967f140c8353119fdb24ad8363c15
Some compilers seem to think that there is some uninitialised usage
here. Work around this.
Closes#1891
Change-Id: Ic97a4b589fd2a0c33418a209557b7ce29009c7bf
If recording-method is pcap, then proc is zero-initialized, so
meta_filepath is empty. This shows many logs such as:
[core] Failed to open recording metadata file '(null)' for writing: Bad address
Prevent them by returning earlier.
Closes#1889
Change-Id: Ifeb3038f9a5c0bd6a9b7dd92842dd61783b40263
Use an object with local storage for sdp_address instead of just setting
a pointer. This makes it possible to put a different address.
Change-Id: I92e69b6a9eba9d0caa3853b3dcb134951d76b145
For some reason gcc 10.2.1 complains about this instance with
control_ng_flags_parser.c: In function ‘parse_transports’:
control_ng_flags_parser.c:299:2: warning: missing initializer for field ‘remainder’ of ‘rtpp_pos’ [-Wmissing-field-initializers]
299 | call_ng_main_flags(&dummy_parser, &STR_CONST("transport-protocol"), &(rtpp_pos) {.cur = STR(val)}, out);
| ^~~~~~~~~~~~~~~~~~
In file included from ./log.h:7,
from ../lib/obj.h:105,
from ../include/control_ng_flags_parser.h:7,
from control_ng_flags_parser.c:1:
../include/types.h:48:6: note: ‘remainder’ declared here
48 | str remainder;
| ^~~~~~~~~
but doesn't complain about other instances of the same usage. Oh well.
Make it shut up.
Change-Id: I6989e3c63b075b6c8f258a824557b767123dc0f6
The opmode is already determined uniquely when processing the NG
command. There is no need to explicitly set it again elsewhere. Simply
carry along the originally determined opmode.
Change-Id: I16924264b0337423aff6763c70a4b2c6dd3687db