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
Complete overhaul of the codec handling code:
*) obsolete flags `asymmetric codecs`, `symmetric codecs`, `reorder
codecs`
*) support proper codec offer/answer
*) split codec manipulation (strip/offer/accept/etc) into separate
functions for clarity and better code maintenance
*) fully update codec handlers in both directions after an answer
*) explicit allocation and handling of codecs and payload types in a
codec_store object
*) improve codec matchup logic during answer
*) more explicit handling of supplemental codecs (CN/DTMF)
*) remove now obsolete hacks for handling certain use cases
Change-Id: I996705ba8fe339524c2f70e6bb0fd854f9a1f4fb
GLib 2.68 deprecates g_memdup() in favour of g_memdup2() as the former
was using a guint second argument which could lead to integer overflows
(gsize should be used instead).
Change-Id: Iaa3e3b1ecaab00d1ac887c915397b15b7204dd11
Recent ffmpeg versions have removed AVPacket from the public ABI,
therefore deprecating av_init_packet on statically allocated objects.
The replacement is av_packet_alloc()/av_packet_free().
Change-Id: I5f93fbd19e43413c3328e143cc9147fbdf12d910
When building using with_transcoding=no we should not expect spandsp to
be available as it's not even being used.
closes#1267
Change-Id: I2c8e0407b4dd46cfdd5322cd377b664955ad7c74
Using GStringChunk as a general purpose allocator leads to unaligned
memory access, which is a no-no on some archs.
Change-Id: Iea896d574da056c94932503c26c7bdf7f49be178
This makes the type in line with string(3) functions and eliminates some
compiler warnings.
Also update the related bencode data type.
Change-Id: I7ef4024f4b5a0f737b3dbe03bcd078032395bce6
If the CFLAGS already contain -O0, skip adding the hardening flags, as
they force inclusion of -O2
Change-Id: I12ab0a61fff169954c73f3a714e563234c841483
If the length of the string is zero, the pointer to the buffer may be
null. ASAN flags these as invalid/undefined, so don't do that.
Change-Id: Ic55498465c53a78e1bd44c42d1a60f9bd3336473
Since dh_auto_test doesn't execute the test suites through make
directly, but instead runs `make -s -n` and then executes the output,
the integrated build tests fail since the sub-make doesn't return an
error as it should when attempting to build with the wrong .h
alternative, resulting in always the first .h alternative being used.
Fix this by using a wrapper script instead.
Also adjust some other related minor build details.
closes#1202
Change-Id: I4b6436295c6b39117bd06df53aa5afc7118ad6a1
Whether a bit-field is signed or unsigned is implementation specific, so
we should be explicit about this.
Change-Id: I744df3d24bc08e95fa816ba4135f19cd3a5dcb17
Warned-by: lgtm
While these usages are not supposed to be security sensitive, it's still
best to avoid the usage altogether so that we do not need to think about
it. Add a taint macro so that this does not regress in the future.
Change-Id: Ic75861ed1b7ce9dfca4f897de8be2408204ce3cb
Warned-by: coverity
We only do 1 decrements/increments so the check for the upper-bound will
always catch any downward wrap-around or an upward out-of-bound.
Change-Id: Ibdb9a69e1a55f34ffca56721c310efc505b86f99
Warned-by: coverity
The dtmf_freqs array contains one less element than the check was
allowing for.
Change-Id: I783fa6bcd0bd79fad9886ee53e7a990e504ecff8
Warned-by: coverity
Make sure G.722 rate multiplies is applied in the right places
Don't trust encoders to return proper timestamps, but instead track them
explicitly based on frame duration
Change-Id: Ia9fa96cf662da97159fa170c3a3f37516889e1bd
Link the attribute value to each RTP payload type and only output it if
PT is still present
Also merge PT attribute printing into a single loop
closes#1128
Change-Id: I494498ca806b795045e9e5bbb82174fa4aef8b2b
* use auto cleanup buffer variable
* use g_vasprintf instead of libc vasprintf
* rename length variable for clarity
Change-Id: Ibebb8cccd51aa2f5cf3704b73bf82472b73d6f19
On some systems (e.g. Github Travis) make seems to have a problem with
its job control, resulting in a race condition where multiple make
instances try to build the same file at the same time. For most files
this is not a problem, but those auto-generated using an append
operation (>>) the output file can become garbled. Solve this by using
an atomic file creation method.
Change-Id: I1acb2387e2ca6ca30ddc3742143fd910032bfbb0
Why:
* When running make clean, the following files are not cleaned:
daemon/dtmf_rx_fillin-test.c
daemon/dtmf_rx_fillin-test
daemon/fix_frame_channel_layout-test.c
daemon/fix_frame_channel_layout-test
...
required to distinguish between 20-ms and 30-ms modes, both for encoding
and decoding
add support for the iLBC mode= format parameter and dynamic mode
switching
closes#854
Change-Id: Icb6f0ec80df86d27681c689c168b24f163a2db06
Log lines written to stderr that are consumed by journald will already
have timestamps added to them. Drop the redundant unixtime output for
this use case.
Change-Id: I34886a69a0ef90de2eb84ee8f446cbad624302c1
Codecs that were implicitly accepted for transcoding had no option to
set their parameters (such as bitrate) for encoding. The codec-set
option adds this.
fixes#681
Change-Id: Ib238eb73a507af168c366579abc80da07250fe88