Commit Graph

57 Commits

Author SHA1 Message Date
Eric Wild 2d5fbe439b aarch64: add get_cycles
borrowed from arch/arm64/include/asm/arch_timer.h

Change-Id: I489fb8346fbc7440f40695f01d80a89b90761165
2023-07-09 10:09:56 +02:00
Vadim Yanitskiy 89c1082b3d Make RTP payload type configurable
For a long time the RTP payload type was hard-coded for outgoing
frames. The problem is that according to RFC 3551 only GSM FR has
a static payload type value (see table 4, value 3). For other
codecs the payload type may be negotiated between the both
sides dynamically (i.e. in range 96-127).

Let's allow a binary/API user to configure this manually.

Change-Id: Ia07ed4e13b4a70c8bb4181564a8190861fd269da
Closes: OS#2482
2018-07-09 22:16:45 +07:00
Vadim Yanitskiy 3f22f18790 Implement ECU (Error Concealment Unit) block for FR
In I06a21f60db01bfe1c2b838f93866fad1d53fdcd1 the Error Concealment
Unit API for FR codec was introduced. This change implements a
corresponding block.

Note: at the moment, only Full Rate is supported by the ECU API.

Change-Id: Ia929ee04f6be3d842c6ef7bc40cce0fdab16e90a
2018-06-29 20:54:04 +07:00
Vadim Yanitskiy 6f34c8f301 procqueue: introduce and use shared cat_name definitions
Let's use the common string representation for item category
names, defined in the shared header, instead of defining
them in every file.

Change-Id: Ie0c449d77fa383cad27f67b8ce902bd071342dbb
2018-01-15 00:25:44 +06:00
Vadim Yanitskiy 3839a88ea6 procqueue: separate queue check function
In order to give advanced control over a processing queue,
it would be better to have the checking function separated from
the osmo_gapk_pq_prepare(). Moreover, this change introduces an
additional 'strict' checking mode that requires a queue to have
a source item first and a sink item in the last position.
2017-12-31 12:20:59 +01:00
Vadim Yanitskiy 459791c488 procqueue: add item catedory and sub-category fields
This change adds two meta-information fields to the processing
queue item structure. Both of them will be used for more
detailed logging and for the human-readable processing
queue description.
2017-12-31 12:20:59 +01:00
Vadim Yanitskiy 408be3638b procqueue: add item type enum (source, sink, proc)
There are currently three types of prcessing queue items:

  - source (file, alsa, rtp)
  - proc (format, codec)
  - sink (file, alsa, rtp)

Let's assign corresponding type for each item.
This would facilitate logging and the queue checking.
2017-12-31 12:20:59 +01:00
Vadim Yanitskiy 2286a36ace procqueue: add human-readable name to osmo_gapk_pq
Since this change, every processing queue may optionally have
an associated human-readable name. If name is not required,
NULL should be passed to the osmo_gapk_pq_create().
2017-12-31 12:20:59 +01:00
Vadim Yanitskiy 262ae0f98f libosmogapk: drop an 'osmo' prefix from internal log variables
It would be better to have an 'osmo_gapk' prefix for exposed
symbols only. Both internal logging variables aren't exposed,
so they shouldn't have one.
2017-12-31 12:20:59 +01:00
Vadim Yanitskiy f23b747364 libosmogapk: introduce the internal root talloc context
In order to simplify memory leak debugging, this change introduces
the library's internal talloc context that may be changed by
external application by calling the osmo_gapk_set_talloc_ctx().
2017-12-31 12:20:59 +01:00
Vadim Yanitskiy 1f6f807bb3 procqueue: add processing state callback
In some cases it's required to wait for some queue items
to finish processing. For example, the ALSA sink writes the
audio samples to the buffer in non-blocking mode, so as soon
as all of them will be written, a program may finish execution,
causing the playback abort.

To prevent that, this change extends the library's API, allowing
each queue item to have a processing state callback that returns
a positive integer if processing is not finished yet,
and 0 otherwise.
2017-12-31 12:20:59 +01:00
Vadim Yanitskiy c35ba8a725 libosmogapk: use Osmocom logging framework
Since this change, the libosmogapk uses the Osmocom logging
framework. By default, logging is disabled and could be enabled
by the external applications calling the osmo_gapk_log_init()
with a desired log target as an argument.
2017-12-31 12:20:59 +01:00
Vadim Yanitskiy 539af39e29 procqueue: use linuxlist to store queue items
The usage of linuxlist is more flexible than having a limited
array of pointers. This approach allows to have as much items
in a processing queue as required.
2017-12-31 12:20:59 +01:00
Vadim Yanitskiy 304fa73421 procqueue: store output buffers inside queue items
An output buffer belongs to its queue item, so it will be more
correctly to store its pointer inside the osmo_gapk_pq_item.
2017-12-31 12:20:59 +01:00
Vadim Yanitskiy 3be9c7ae3c procqueue: use unsigned int for I/O frame size fields
A frame size cannot be negative, so 'unsigned' is more
suitable for frame size fields.
2017-12-31 12:20:59 +01:00
Vadim Yanitskiy cda8995ac8 benchmark: add functions to get cycle and frame count
To simplify the benchrarking process via the library API, this
change introduces two new functions, which are intended to
provide total cycle and frame count.
2017-12-31 12:20:59 +01:00
Vadim Yanitskiy 72218e7da0 benchmark: allocate memory dynamically
Having statically allocated memory for benchmark data of every
codec causes high memory usage, especially if actual benchmarking
is not required for a particular use case. Instead of that, let's
provide an optional opportunity to enable benchmarking for a
particular codec by calling the osmo_gapk_bench_enable(). The
required amount of memory would be allocated, and then can be
freed by calling the osmo_gapk_bench_free() or manually.
2017-12-31 12:20:59 +01:00
Vadim Yanitskiy c9a75e59c6 benchmark: get rid of 'static inline' definition
The usage of a 'static inline' function definition in the 'bench.h'
is resulting in separate independent function definitions in each
translation unit from which the header is included. This is
increasing the size of compiled code unnecessarily.
2017-12-31 12:20:59 +01:00
Vadim Yanitskiy ba46856bb4 benchmark: move benchmark impl to a private header
There is no need to expose the implementation details of both
BENCHMARK_START and BENCHMARK_STOP macros via public header.
This change moves them to a separate private header 'bench.h'.
2017-12-31 12:20:59 +01:00
Vadim Yanitskiy 349219c148 benchmark: move benchmark_dump() outside the library
The benchmark_dump() is only used by the osmo-gapk binary, and
is intended to prepare and print benchmarking results to stderr,
what is most likely unusable for the library users.
2017-12-31 12:20:59 +01:00
Vadim Yanitskiy a8d46571ce Add an 'osmo_gapk' prefix to the exposed symbols
To avoid a naming conflict between libosmogapk and other projects
during linkage, all the exposed symbols should have an unique
prefix. Let's use 'osmo_gapk' for that.
2017-12-31 12:20:59 +01:00
Vadim Yanitskiy 9cba760ba2 procqueue: expose the processing queue struct definition
To be able to use processing queues from outside, the pq struct
should be shared in the corresponding header file.
2017-12-31 12:20:59 +01:00
Vadim Yanitskiy 5f941573b0 Use '#pragma once' instead of include guard
The most compilers today do support the '#pragma once', which is
designed to cause the current source file to be included only once
in a single compilation. One has several advantages, including:
less code, avoidance of name clashes, and sometimes improvement
in compilation speed.

See: https://en.wikipedia.org/wiki/Pragma_once for details.
2017-12-31 12:20:59 +01:00
Vadim Yanitskiy 30209ceddd Install GAPK headers to '${includedir}/osmocom/gapk/'
To be able to use the library, external applications need to know,
which symbols are exposed. This information is provided by header
files, which are being installed to a system's ${includedir}
since this change.
2017-12-31 12:20:59 +01:00
Harald Welte 848db7b662 Add support for RTP with GSM-HR payload according to RFC5993
This is incompatible with the ETSI TS 101 318 format!
2017-05-28 16:18:09 +02:00
Harald Welte dc3589a6be Add support for RTP with GSM-HR payload according to ETSI TS 101 318 2017-05-28 16:18:09 +02:00
Harald Welte f62e7a4936 Add "rtp-efr" format support for RTP payload according to RFC3551 4.5.9
The RTP EFR payload is a bit like the FR payload: one nibble magic
marker, then followed by the actual codec bits.  So we need to
add/remove that magic marker and shift the remainder by one nibble.
2017-05-28 16:18:09 +02:00
Harald Welte 526fc6e5e9 Fix HR codec block sizes
The ETSI reference codec actually uses an array of 20/22 16bit values
rather than a "canonical" format.  The conversion is what fmt_hr_ref.c
is doing.  However, codec_hr.c must then subsequently not check for the
canonical input/output sizes, but those specific to it.
2017-05-28 16:18:09 +02:00
Harald Welte 8b01f0ca05 Add AMR codec support
After merging this change, there is support for the AMR codec (by means
of libopencore-amr, which is already used for EFR).

In terms of gapk formats, we introdude
* the "amr-opencore" format, which serves both as the canonical format,
  and as the input format to opencore-amrnb itself.
* the "rtp-amr" format, which is the payload of RFC4867 octet-aligned mode

You can use the following command for a real-time RTP playback for AMR
frames:
  ./gapk -I 0.0.0.0/30000 -f rtp-amr -A default -g rawpcm-s16le
2017-05-28 14:29:59 +02:00
Harald Welte 494d92c3c7 more API documentation 2017-05-28 10:44:10 +02:00
Harald Welte 5912848d2e prepare gapk for dealing with variable-length frames
The existing architecture was modelled around fixed-length codec frame
sizes, which of course fails with multi-rate codecs such as AMR.
2017-05-28 10:44:06 +02:00
Harald Welte 62688b60c2 introduce #defines for canonical length + use them 2017-05-28 10:20:26 +02:00
Harald Welte 2ae47af0be Add ALSA input/output support to GAPK
The ALSA source/sink uses the pcm-s16le format.
2017-05-28 01:56:33 +02:00
Sylvain Munaut d192d8c017 benchmark: Fix cpuid clobbering
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2016-01-01 13:17:37 +01:00
Harald Welte d72b0f654f ensure all gapk header files are included in 'dist' 2015-11-05 21:41:09 +01:00
Harald Welte 7a04624563 Add cycle benchmarking support
This enables benchmarking of the codec.  It will print
the amount of CPU cycles needed for encoding/decoding a single
20ms frame on average.
2014-05-08 19:18:01 +02:00
Harald Welte ce94d971e1 gapk: Add support for RTP input/output streams
Instead of having only file-based I/O, this enables gapk to receive and
send RTP streams, e.g. from live GSM network equipment like
sysmoBTS/nanoBTS.

Support is currently simplistic.  On transmit, there is hard-coded codec
type of full-rate GSM.  On receive-side, we should auto-detect the
format based on frame size and/or payload type, but we don't do that yet
at all.
2013-02-11 11:38:23 +01:00
Sylvain Munaut e2c5719d74 format/fmt_ti: Add support for EFR variant
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-02-25 18:12:25 +01:00
Sylvain Munaut b1525d67fe format/fmt_ti: Add support for HR variant
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-02-25 16:58:36 +01:00
Sylvain Munaut cfaec3a2f6 format: Add support for the TI calypso/locosto dumped buffer format
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-02-25 15:31:54 +01:00
Sylvain Munaut 0d2a82c312 [1/4] HR support: Add autotools skeleton for libgsmhr
Not functional yet, just the autotools magic to make a library

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-11-12 20:36:14 +01:00
Sylvain Munaut 456758c808 format: Add support for Raw PCM Signed 16 bits Little Endian
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-11-11 22:58:20 +01:00
Sylvain Munaut 9843418a33 procqueue: Add Codec tasks
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-11-11 20:45:24 +01:00
Sylvain Munaut 792d04135e procqueue: Add format conversion tasks
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-11-11 20:45:24 +01:00
Sylvain Munaut d9fb0e37c8 procqueue: Add file related tasks
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-11-11 20:45:24 +01:00
Sylvain Munaut 3c0a4fba8a procqueue: Add some mechanism to queue 'processing items' on the frames
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-11-11 20:45:24 +01:00
Sylvain Munaut 24b761218f format: Add function to get format by name
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-11-11 20:26:41 +01:00
Sylvain Munaut ef7ada56ce codec: Add fields in struct codec_desc to support encoding/decoding
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-11-11 20:26:41 +01:00
Sylvain Munaut 723df06dff format: Add support for .amr files encapsulating EFR data
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-11-11 20:26:41 +01:00
Sylvain Munaut 16f8d7f448 format: Add fields in format descriptor for fixed headers
Very simple header support, but that's all we need for AMR

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-11-11 20:26:41 +01:00