UDP packets sent in response to a UDP request should have the same
source address as the request's destination address.
This can be achieved with sockets bound to a specific address, but in
the case of ANY-bound sockets, we can use the PKTINFO mechanism to do
this.
Extend control_ng_process() to accept an extra socket address
corresponding to the local address to use. Extend the signature of the
callback function (to do the actual sending) accordingly.
Extend socket_sendiov() to be able to set the PKTINFO cmsg when sending
a packet.
Add socket_sendto_from() as a convenience wrapper.
Extend control_udp_incoming() to pass the address from
udp_buf->local_addr back to socket_sendiov().
Change-Id: Idd019fdcfd796098e7807427e6686d4b05de35d1
Looks like glib at some point started resetting an existing string array
that a config option is pointing to if that config option isn't present
at all. Work around this by explicitly resetting the pointed-to variable
to NULL, and then fixing up the contents on the second pass: either use
the setting from the config file or the one from the command line, and
free the other one.
Change-Id: Ida89d71e54fc30b4cce3277107e2185737f54a51
Similar to recvfrom_ts, this return the local (destination) address of
the received packet, extracted from the PKTINFO struct.
Change-Id: Icfed12eb7d9bf6c9d707318e85363fcff8d9aca6
It actually uses a shared config setting from the lib (stack size) so
the function itself also belongs in the lib.
Change an argument type to bool.
Change-Id: I8be68008fcfc058cb29069102eb00497b66897a5
Make silent this:
In file included from spandsp_logging-test.c:9:
spandsp_logging.h: In function ‘my_span_set_log’:
spandsp_logging.h:5:9: error: too few arguments to function ‘span_log_set_message_handler’
5 | span_log_set_message_handler(ls, h);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from spandsp_logging-test.c:7:
/usr/local/include/spandsp/logging.h:125:20: note: declared here
125 | SPAN_DECLARE(void) span_log_set_message_handler(logging_state_t *s, message_handler_func_t func, void *user_data);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from spandsp_logging-test.c:9:
spandsp_logging.h: In function ‘my_span_mh’:
spandsp_logging.h:8:9: error: too few arguments to function ‘span_set_message_handler’
8 | span_set_message_handler(h);
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from spandsp_logging-test.c:7:
/usr/local/include/spandsp/logging.h:127:20: note: declared here
127 | SPAN_DECLARE(void) span_set_message_handler(message_handler_func_t func, void *user_data);
| ^~~~~~~~~~~~~~~~~~~~~~~~
spandsp_logging-test.c: In function ‘main’:
spandsp_logging-test.c:18:29: warning: passing argument 2 of ‘my_span_set_log’ from incompatible pointer type [-Wincompatible-pointer-types]
18 | my_span_set_log(ls, logfunc);
| ^~~~~~~
| |
| void (*)(int, const char *)
In file included from spandsp_logging-test.c:9:
spandsp_logging.h:4:73: note: expected ‘message_handler_func_t’ {aka ‘void (*)(void *, int, const char *)’} but argument is of type ‘void (*)(int, const char *)’
4 | INLINE void my_span_set_log(logging_state_t *ls, message_handler_func_t h) {
| ~~~~~~~~~~~~~~~~~~~~~~~^
t38.c: In function ‘t38_gateway_pair’:
t38.c:419:29: warning: passing argument 2 of ‘my_span_set_log’ from incompatible pointer type [-Wincompatible-pointer-types]
419 | my_span_set_log(ls, spandsp_logging_func);
| ^~~~~~~~~~~~~~~~~~~~
| |
| void (*)(int, const char *)
In file included from t38.c:11:
spandsp_logging.h:4:73: note: expected ‘message_handler_func_t’ {aka ‘void (*)(void *, int, const char *)’} but argument is of type ‘void (*)(int, const char *)’
4 | INLINE void my_span_set_log(logging_state_t *ls, message_handler_func_t h) {
| ~~~~~~~~~~~~~~~~~~~~~~~^
Change-Id: Ib67db21e1d1ea684fd312bbaf9a8ec7a7542e3cb
This is a dependency of the poller and so is needed in lib/ as well to
make it usable.
Also consolidate the type.
Change-Id: I70ec8a200d6cd65710ac93636a9495cf24c35ef4
Make sure we don't try to send on closed sockets or to endpoints which
haven't been initialised.
Fixes unexpected fallout from 83c7336e
Change-Id: If73d61e52edeb72257515adab7428ecef82c2797
Introduce rtpe_has_cpu_flag() and associated enum to test for specific
CPU flags. Use singleton approach to do the CPUID only once.
Convert simd_float2int16_array() to float2int16_array() as an ifunc. The
resolver function uses rtpe_has_cpu_flag() to determine which
implementation to use.
If no SIMD implementation is available, use the linked evs_syn_output()
from the shared object as before, with an intermediate wrapper function,
which is needed as the dlopen() happens only after the
float2int16_array() is resolved.
Change-Id: I34fa03433ba5d6fa7d6d4f290455015db29fdd74
If the forwarded streams of a call are later combined without the inserted
silence, the resulting mix may end up with them out of sync. This
is already handled when outputting mixed files so the same functionality
from mix.c has been added for tls forwarding
Pandoc is available even on stretch, and unlike ronn is
actively maintained.
Fix -- markdown escaping.
Use __x__ for bold, and *x* for italics.
Remove .8.ronn symlinks.
Change-Id: Iff70e2b405f3b9ede856abf94d42fc51afb9f809
For a compatibility reasons (with other doc files and with RTD)
the `rtpengine.pod` and `rtpengine-recording.pod` file get
converted to the Markdown syntax.
The compilation of MD syntax synopsis files will work
using `ronn` application, which converts them to man pages.
Change-Id: I75b54a712786a0a237c51c702ed1a2cc09e3a033
Use the address family of the address object to do the conversion, not
the family of the socket. This allows for v4-in-v6 socket usage.
Change-Id: I4d23b7036207e71f5e70706d621d8ec2b7ca0934
Generate the output fmtp= string based on the preferences received from
the opposite side. Also add the required format printing function.
Change-Id: I12124efe0b9876c6571bc32c1c45744af80b83d3
If the remote Opus decoder prefers receiving single-channel encoded
audio, honour it and send them single-channel audio.
Change-Id: I4bf952b9f922099c95e19b0ab51fbdffb2cc19db
This commit parses out the string, but doesn't do anything with the
values except for the FEC flag. Move the FEC on/off switch from the
extra codec options into the `fmtp` string.
Change-Id: I51f74f7cb62dd49a9af9815920f077bf300cfa33
In order to actually select codec options in the selection function, we
need to parse the `fmtp` string out first.
Change-Id: I43fe2d61c36c48c093e92681f7578adda0252cb0
Track audio writes in the mix buffer to set the `active` flag to true
whenever a write occurs, which makes it possible to create the buffer in
an inactivate state and implicitly set it active on demand.
Handle the mix buffer not returning any data in the RTP sending logic
(which is what happens for an inactive buffer) by simply not sending any
packets.
Change-Id: Iaeb0f6deadb3d90020c8c62872735cc94db80504
... as an extra offset for newly added sources, based on the difference
between the last runtime (read time) of the buffer and the current time.
Change-Id: Ie99e24f0697f0950f0fcfa1e5e58b8f4be134018
A simple circular audio buffer that allows mixing multiple sources of
audio. Sources are tracked by SSRC and all sources are expected to
provide audio in the same format (same clock rate, channels, sample
format).
Only one consumer per buffer is supported, which is expected to retrieve
buffered audio at regular intervals (ptime) and so continuously empty
the buffer.
The first audio source to write into the buffer at the leading edge of
the circular buffer has its audio simply copied into the buffer, with
the leading edge advanced, while other later sources writing into the
buffer mixed into the existing buffered audio at their respective write
positions.
Change-Id: I0f6642b036944508f2a33420359de488ef8b991c
For source files generated from the "strhash" helper script, output line
and file number information into the generated .c source to help gdb and
other tools correspond the compiled code with the correct source code.
Change-Id: Ieddc86ab59b41ab26942e8a7d3c24e7800e9936f
If the expected buffer to hold a packet was determined incorrectly, log
a warning instead of throwing an assertion.
closes#1591
Change-Id: I4169378a27b27fed51e453e6d2da8014259c659e
Prevent a wrongly advertised (too small) a=ptime from producing too
small buffers to hold encoded packets by flagging codecs with a fixed or
minimum frame size as such.
This is relevant to libavcodec only as the code determines the expected
frame size from the clock rate and the ptime.
closes#1591
Change-Id: I9f5c56d45f2aad56951b19d846ddbfa4b7bd7e7d
This type is used as const everywhere except internally, so make it part
of the typedef for brevity.
Change-Id: Ic4afe037b392239a991d5380c6708903011da29e
Instead of going through ffmpeg to en/decode Opus, use libopus directly,
which allows us to benefit from additional features that aren't
available when going through ffmpeg.
Change-Id: I017c276cfa9755cefe95c8da26691446b718d4c8
Some codecs (e.g. Opus) can natively encode audio with various clock
rates without producing an output that is locked to that clock rate and
without requiring resampling the input. Add an appropriate callback
function and adapt tests.
Change-Id: Id788c4d4c05e20f93cce7e910f9f265b381cbe34
G.722 uses 4 bits per sample, not 8. This error was negated by the ptime
incorrectly being adjusted by the clock rate multiplier.
Change-Id: I125c897ee9cbdac29278be9b6451d82b48ff94c2
This makes it possible to have codecs running at variable clock rates
that differ from their RTP clock rates.
Change-Id: Ia2f5effb82eefe8c3028573ba0a6697da28473b1
Instead of just having an integer multiplier, support a fractional
factor. This allows us to have the RTP clock rate run faster than the
audio clock rate, and not just slower by an integer factor.
Change-Id: I7681cf369c43d8424ca2d2ebeffe932595d271ec
Introduce an additional function for codec matching. Different functions
match different parts of an RTP payload type object and the referenced
codecs.
Change-Id: I2e488eaa7f69a55322db748fd40c8d1195e38605
We have no use for -1/0/1 return values. Change the return type to bool
to make things more clear.
Change-Id: Iedf1d8278c6dfddddb328ce7b3b1dbae132a39b7
Parsing out the a=fmtp string has been left up to the codec init
function until now, with the values that resulted from the parsing being
stored only within the codec. Convert this to an explicit method to
parse the a=fmtp string, and introduce a dedicated struct to store the
resulting values.
Functionally this change is a no-op.
Change-Id: Ia84e26d632ed5209b4439fd82c1e4e38850fd024
This include only serves to define one type, which is used only as a
pointer. Use an empty typedef declaration instead.
Change-Id: I7d2cc8b97303b9363a5bfe363fffeea09ee56686
At least the recording daemon uses the linesize directly, so this needs
to be corrected after returning a frame from the resampler.
Change-Id: Ia940d8acbbee3fb2d6564474ecb93ae27422d8af
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
Starting with release 5.1, ffmpeg obsoletes the `channels` and
`channel_layout` fields, replacing them with a unified `ch_layout`
struct of type AVChannelLayout. Add wrapper defines into the
compile-time build-test headers fix_frame_channel_layout*.h to
accommodate both new and old versions.
Change-Id: I3d43b85dc3140155a61b1cf2269cda166ad88e9a
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1012766
> Whilst working on the Reproducible Builds effort [0] we noticed that
> rtpengine could not be built reproducibly.
>
> Whilst it did use the value from debian/changelog, the RELEASE_DATE
> variable changed due to underlying system timezone setting. A patch
> is attached that passes -u/--utc to the call to date(1).
>
> [0] https://reproducible-builds.org/
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
Handling of dual stack v4/v6 was previously done by the individual
listener objects for INADDR_ANY listening addresses. If listening on
INADDR_ANY was requested, then each listener would create two instances,
one for IPv4 and one for IPv6. This works fine for INADDR_ANY but fails
for listening on host names that resolve to multiple addresses, such as
`localhost`.
Solve this by relieving the listener objects from handling this and
instead handle it in the code setting up the listeners. If a host name
resolves to multiple addresses, then set up multiple listeners (up to
two supported currently). This allows us to listen on `localhost` by
default and have both 127.0.0.1 and ::1 active. INADDR_ANY is handled
specially by also setting up :: in that case.
Change-Id: I2a1e1d7090d7d23863c7a9bb1e89b85ad2ea44f4
Needed to be able to set graphite socket timeout.
Useful when one wants rtpengine to force the graphite connection
to fail faster, in case graphite server gets filtered while
connection is ongoing.
This is useful because we log to stderr, which technically would allow
unlimited log line length, but this is in fact turned over to syslog,
which truncates log lines that are too long.
Change-Id: Iee8994842335ab1cf94941c14eced01e29120bc9
libcs are implementing changes to fix the year 2038 issue on 32 bit
platforms (see [1]). musl libc already went ahead and implemented it,
starting with musl-1.2.0 (see [2]).
This commit adds a new definition to lib/loglib.h:
TIME_T_INT_FMT
If __USE_TIME_BITS64 is defined (by a time64 libc, see [1]), it's set to
the proper conversions for type int64_t, PRId64. If __USE_TIME_BITS64 is
not defined, the status quo remains unchanged ("%ld" is used).
The new definition is used in the different parts of rtpengine, where
appropriate.
Note: Richard confirmed that the "%u" format in daemon/cdr.c is not
needed, so this gets swept under the rug.
These changes get rid of the new warnings that appeared with musl-1.2.0.
Below an example warning:
In file included from ./log.h:6,
from ../include/obj.h:94,
from ../include/media_socket.h:9,
from ../include/call.h:26,
from ../include/redis.h:15,
from redis.c:1:
redis.c: In function 'redis_check_conn':
../lib/loglib.h:56:30: warning: format '%ld' expects argument of type 'long int', but argument 5 has type 'time_t' {aka 'long long int'} [-Wformat=]
56 | __ilog(prio, "[%s] " fmt, log_level_names[system], ##__VA_ARGS__); \
| ^~~~~~~
../lib/loglib.h:64:39: note: in expansion of macro 'ilogsn'
64 | #define ilogs(system, prio, fmt, ...) ilogsn(log_level_index_ ## system, prio, fmt, ##__VA_ARGS__)
| ^~~~~~
../lib/loglib.h:63:30: note: in expansion of macro 'ilogs'
63 | #define ilog(prio, fmt, ...) ilogs(core, prio, fmt, ##__VA_ARGS__)
| ^~~~~
redis.c:887:17: note: in expansion of macro 'ilog'
887 | ilog(LOG_WARNING, "Redis server %s is disabled. Don't try RE-Establishing for %ld more seconds",
| ^~~~
[1] https://sourceware.org/glibc/wiki/Y2038ProofnessDesign
[2] https://musl.libc.org/time64.html
Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
Rebuilding everything every time a header file changes might be
overkill, but it's easy addition and much less hassle than .d files.
Change-Id: I11aeddbcc5ecc48dfca2adf249129c936c7f6d30
commit b0c722da69ad088a2eddced12b37c0546a514890
Author: Daniel Hauptmann <dhauptmann@sipwise.com>
Date: Mon Jul 26 15:35:51 2021 +0200
changed flag bit length
in call_interfaces.h changed bit length of reuse_codec from 0 to 1
commit 0313a747532d5987f25fa9edb202aa460bf98dd1
Author: Daniel Hauptmann <dhauptmann@sipwise.com>
Date: Mon Jul 26 15:29:20 2021 +0200
inversed reuse_codec logic
in test-transcode.c and call.c, reuse_codec = 0 (default) will now result in using codec_store_populate instead of codec_store_populate_reuse
commit b876bd686bd30df21a5962aca16fc1c85574f554
Author: Daniel Hauptmann <dhauptmann@sipwise.com>
Date: Mon Jul 26 15:18:19 2021 +0200
adding option to minimalize changes in the codec_store_population
added function codec_store_populate_reuse in codec.c which replaces codec_store_populate but makes fewer changes to the GLists with the old and new codecs
added flag to enable this feature (disabled by default)
commit 6fd0b701c9589b2fae00300801e02a9b5cc397ab
Author: Daniel Hauptmann <dhauptmann@sipwise.com>
Date: Mon Jul 26 14:44:42 2021 +0200
Added Option to minimize change in the codecs
In codec.c added function to populate codec store with the fewest changes between the old and new GList which contains the codecs.
Added new testroutine in test-transcode.c line 1500
Added flag to call_interfaces.h to optionally enable this feature
Change-Id: If58d9a07d114b05dfb75553a87eb4372ae949fbb
commit 3bf554a8fbae7e948343699f40d935693618b764
Author: Daniel Hauptmann <dhauptmann@sipwise.com>
Date: Fri Jul 23 13:58:02 2021 +0200
changing codec-exchange behaviour
in codec.c line 3288 function codec_store_populate now doesnt empty dst and copy new codec from src to it, instead codecs from src will be appended to dst and codec from dst, which are not
being contained by src are being removed
Change-Id: Id6b7ee65595f9cc5c71ef557c7bac5ee38f97cbe
If encoder_config errors out for some reason, avpkt may end up
uninitialised. Make sure there is an avpkt when flushing/closing the
encoder. Also make the encoder input more resilient against
half-initialised encoders for the same reason.
closes#1312
Change-Id: I44ebcf6e35f1c383aa5c8202b5d9bbf968b0d5f1