Commit Graph

28 Commits

Author SHA1 Message Date
Pau Espin 3b0991e80f osmux: Allocate struct osmux_out_handle through API
Until now, the osmux_out_handle was allocated by the client, and passed
to the API to initialize it. This makes it really hard to improve the
implementation without breaking the ABI.

Let's break the ABI now one last time (hopefully) by allocating the
struct through an API. With only this change, the already built users
(osmo-mgw, openbsc) can still work fine, since there's no change on the
struct osmux_out_handle. However, they will somehow break next time the
struct is changed until they are ported to the same API (easy to do).

Related: OS#5987
Change-Id: Ie8df581f375c9a183a7af60b431561bda82f6e34
2022-09-02 11:29:05 +02:00
Neels Hofmeyr 6413a6b53f osmux_test: don't use color logging
Change-Id: I7b0c8d311123f4fa0aeedf3938c8628a4442daf7
2019-11-20 05:03:37 +01:00
Pau Espin 366f0dbf81 tests: osmux_test: Hardcode h_output values set by random()
osmux implementation randomizes those values. It seems build in OBS
sometimes provide different values than the ones expected in the test
result. Let's hardcode them to make sure we always have the same values
regarless of the random() implementation.

Values chosen are the one matching the current expected test output so
it doesn't need any change.

Change-Id: Icc553c83ddff41900ae3d5990a655c29c9073e01
2019-10-18 09:27:50 +00:00
Pau Espin 77ba4e61cb tests: osmux_test: Provide More accurate logging expectancies
Change-Id: I85722ebcb5486426dfe76cdca1b8a0692bb5b111
2019-10-04 18:39:47 +02:00
Pau Espin 71abacdda0 tests: osmux_test: Use fake time also for monotonic clock
Currently osmux related code uses both gettimeofday on some parts and
clock_gettime(CLOCK_MONOTONIC) on others (for different purposes).

Let's fake both clocks and not only the one used by gettimeofday API.

Change-Id: I4e1a0eb4f8c4ea1bc0f963afa18b116d3af9978c
2019-10-04 12:43:43 +02:00
Pau Espin f0f1ebf70e osmux: Extend osmux_out_handle and add new API to set rtp payload_type
Previously payload_type was always hardcoded to 98 for generated rtp
packets from incoming osmux frame.

Change-Id: I5cbeb494a8932953d9fd2dc24dacf8cd97fd84e4
2019-05-17 17:12:56 +02:00
Pau Espin df0ad6c1a4 osmux: Move examples and tests to use new output APIs
Change-Id: Ie69c427308eb7d81aedab7fbb71f1bdaf43f0275
2018-04-19 18:24:25 +02:00
Pau Espin e259c8ab18 osmux: Set Marker bit on osmux frame loss detected
Until this patch, we didn't notify in any way to the RTP reader when an
Osmux frame was lost. Instead, we updated the seq&timestamp as if there
was no lost, and as a result the RTP reader would only see a steady
increase of delay every time an osmux frame was lost.

As the batch_factor for the lost packet is unknown, we cannot assume any
number of amr payloads lost, and thus we cannot simply increment seq and
timestamp for a specific amount. Instead, the only viable solution seems
to set the M marker bit in the first rtp packet generated after a
non-consecutive osmux frame is received.

The implementation may act differently with the first generated RTP
packet based on the first osmux seq number used for the stream. In case
0 it's used as first osmux seq number, M will be set depending on
request from original RTP packet having the M bit set. If it's not 0,
the first RTP packer will unconditionally have the M bit. That's not an
issue because it's anyway expect for receiver to sync on the first
packet.

Related: OS#3185

Change-Id: I2efed6d726a1b8e77e686c7a5fe1940d3f4901a7
2018-04-19 18:24:25 +02:00
Pau Espin d5b68e2c70 tests: use osmo_init_logging2
Change-Id: Icc84bbd53e1589e26e445e3460024e77162bd76f
2018-04-17 11:41:13 +02:00
Pablo Neira Ayuso 14af167a55 osmux: fix buffer management mess in snprintf() calls
SNPRINTF_BUFFER_SIZE() looks too complex, previous version maintains two
different variables to account for the remaining space in the buffer,
one of them is always decremented based on what snprintf() returns,
which may result in underflow. These variables are swapped - not used
consistently - all over this code.

Replace this macro by a simplified version, with one single parameter to
account for remaining space. This macro also deals with two corner
cases:

1) snprintf() fails, actually never happens in practise, but
   documentation indicates it may return -1, so let's catch this case
   from here to stick to specs.

2) There is not enough space in the buffer, in that case, keep
   increasing offset, so we know how much would have been printed, just
   like snprintf() does.

Thanks to Pau Espin for reporting, and Holger for clues on this.
I have run osmux_test and, at quick glance, it looks good.

Change-Id: I5b5d6ec57a02f57c23b1ae86dbd894bad28ea797
2017-09-11 18:06:37 +00:00
Pau Espin e786055567 osmux: Slightly improve output format of osmux_snprintf
The buffer for osmux_test is increased as the former doesn't seem to be
able to cope with the whole output.

Change-Id: Ic838dd9d7ad89b4510ccfa58c0390c69a075b616
2017-08-14 17:24:11 +02:00
Pau Espin 3460ad7f31 osmux: Use osmo_gettimeofday for testing puroposes
This way we can use fake time and osmux_test take 700ms instead of
>2sec to run.

Change-Id: Ic39cab74400aca8262a00c0d06884230b1a15ca3
2017-04-27 08:50:01 +00:00
Pau Espin e98afe5808 osmux: Add RTP marker bit support
According to RFC4867 (RTP payload format for AMR):
"The RTP header marker bit (M) SHALL be set to 1 if the first frameblock
carried in the packet contains a speech frame which is the first in a
talkspurt.  For all other packets the marker bit SHALL be set to zero (M=0)."

This information bit provides a way for the receiver to better
synchronize the delay with ther sender.

This is specially useful if AMR DTX features are supported and
enabled on the sender.

Change-Id: I0315658159429603f1d80a168718b026015060e9
2017-04-27 08:50:01 +00:00
Neels Hofmeyr f468e720ad osmux-test: remove real-time constraint by default
Introduce a local #define to disable the real-time constraint from osmux-test.
It would make sense to remove this completely, but in case anyone may be
interested in the timing on a specific platform, I've just #defined it away.

The real-time constraint to pass or fail the test is a bad idea in terms of our
build server. Whenever the server is loaded, the tests will fail for no reason,
like here: https://gerrit.osmocom.org/474
The real time to calculate is highly dependent also on the hardware platform.
The arbitrarity of the time constraint is sort of proven by dd24cdd95f
which simply doubles the time to pass the test.

Change-Id: Ic1da4bd22411652334f73195b2e37853e0738906
2016-07-07 14:13:16 +02:00
Neels Hofmeyr e03b3bc757 osmux_test.c: tweak error report 2016-02-29 15:49:10 +01:00
Pablo Neira Ayuso 552bae6081 tests: osmux: iterate 64 times in osmo_test_loop()
Instead of 63, this resolves major "definitely lost" remaining leak that
valgrind reports regarding msgb.
2015-07-21 12:04:58 +02:00
Pablo Neira Ayuso 41d5c3081a tests: osmux: fix msgb leaks 2015-07-21 11:05:41 +02:00
Pablo Neira Ayuso f9407cc668 tests: osmux: test circuit reopening after closure
Make sure circuit routines works correctly.
2015-07-21 11:05:41 +02:00
Pablo Neira Ayuso b8bdc290d0 tests: osmux: validate dummy padding with no voice data interaction
Make sure that early dummy bandwitch preallocation works fine in the absence of
any kind of voice traffic.
2015-07-21 11:05:40 +02:00
Pablo Neira Ayuso 386e7755a7 tests: osmux: test online deactivation of dummy padding
Add RTP packets to circuit with dummy padding enabled to test automatic
deactivation once when start seeing real voice traffic.
2015-07-21 11:05:34 +02:00
Pablo Neira Ayuso b36951e6e3 tests: osmux: factor out main test loop
Move main test loop routine to the new osmux_test_loop() function.
2015-07-21 11:02:30 +02:00
Pablo Neira Ayuso 635bef7363 tests: osmux: adapt it to use the new circuit API
This also introduces a spare circuit that contains no voice data to test
bandwidth preallocation through the new osmux dummy frame type.
2015-07-21 10:24:23 +02:00
Pablo Neira Ayuso fe9823b6d5 tests: osmux: no need to skip RTP message anymore
With the fan-out approach to test multi-batch added int (078d532 tests:
osmux: test multi-batch support), this doesn't need the explicit
skip as there are already gaps to be filled.
2013-12-16 12:55:26 +01:00
Pablo Neira Ayuso 078d532930 tests: osmux: test multi-batch support
Extend this to test multi-batch in one packet support, eg.

OSMUX message (len=158) OSMUX seq=016 ccid=000 ft=1 ctr=6 amr_f=0 amr_q=1
amr_ft=02 amr_cmr=02 ff d4 f9 ff fb e7 eb f9 9f f8 f2 26 33 65 54 ff d4 f9 ff
fb e7 eb f9 9f f8 f2 26 33 65 54 ff d4 f9 ff fb e7 eb f9 9f f8 f2 26 33 65 54
ff d4 f9 ff fb e7 eb f9 9f f8 f2 26 33 65 54 ff d4 f9 ff fb e7 eb f9 9f f8 f2
26 33 65 54 ff d4 f9 ff fb e7 eb f9 9f f8 f2 26 33 65 54 ff d4 f9 ff fb e7 eb
f9 9f f8 f2 26 33 65 54 ]OSMUX seq=017 ccid=001 ft=1 ctr=2 amr_f=0 amr_q=1
amr_ft=02 amr_cmr=02 ff d4 f9 ff fb e7 eb f9 9f f8 f2 26 33 65 54 ff d4 f9 ff
fb e7 eb f9 9f f8 f2 26 33 65 54 ff d4 f9 ff fb e7 eb f9 9f f8 f2 26 33 65 54 ]
2013-12-16 10:43:20 +01:00
Pablo Neira Ayuso dd24cdd95f tests: osmux-test: double timing validation threshold
Double timing validation to avoid hitting errors easily.
2013-05-27 11:19:35 +02:00
Pablo Neira Ayuso bd847cd71b tests: osmux_test: exercise osmux_replay_lost_packets
Emulate RTP message loss to test osmux_replay_lost_packets code
in src/osmux.c.

After this test, lcov reports 90.3% line coverage of osmux.c
2013-05-24 13:12:14 +02:00
Pablo Neira Ayuso 9d6d126c23 tests: osmux_test: deadline after 10 seconds
If the test takes longer than 10 seconds (it barely takes less than
a second according to `time'), bail out and report an error.
2013-05-24 11:22:41 +02:00
Pablo Neira Ayuso 479fba171b add testsuite infrastructure and osmux test
This patch adds the testsuite infrastructure and it populates it
with one test for osmux.

The osmux tests makes sure that:

* We get the same number of RTP messages in the input and the output path.
* The payload of the RTP message is reconstructed correctly.
* The reconstructed timing is correct.
2013-05-24 02:20:50 +02:00