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
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
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
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.
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.
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.
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().
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().
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.
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.
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.
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.
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.
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.
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'.
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.
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.
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.
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.
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.
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.
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
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.