laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/39497?usp=email )
Change subject: setup.py: install esim.asn1 resources, install esim.saip
......................................................................
setup.py: install esim.asn1 resources, install esim.saip
These changes are necessary to successfully run
./tests/unittests/test_esim_saip.py with a pySim installed via
'pip install'.
For example:
virtualenv venv
source venv/bin/activate
git clone ssh://gerrit.osmocom.org:29418/pysim
pip install pysim/
cd pysim
./tests/unittests/test_esim_saip.py
Before this patch, that would result first in package pySim.esim.saip
being unknown (not installed at all), and when that is added to
setup.py, in this error:
Traceback (most recent call last):
File "/home/moi/osmo-dev/src/pysim/tests/unittests/./test_esim_saip.py", line 23, in <module>
from pySim.esim.saip import *
File "/home/moi/s/esim/sysmo_esim_mgr/venv/lib/python3.13/site-packages/pySim/esim/saip/__init__.py", line 41, in <module>
asn1 = compile_asn1_subdir('saip')
File "/home/moi/s/esim/sysmo_esim_mgr/venv/lib/python3.13/site-packages/pySim/esim/__init__.py", line 56, in compile_asn1_subdir
for i in resources.files('pySim.esim').joinpath('asn1').joinpath(subdir_name).iterdir():
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/lib/python3.13/pathlib/_local.py", line 577, in iterdir
with os.scandir(root_dir) as scandir_it:
~~~~~~~~~~^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/moi/s/esim/sysmo_esim_mgr/venv/lib/python3.13/site-packages/pySim/esim/asn1/saip'
After this patch, the test completes successfully.
......
----------------------------------------------------------------------
Ran 6 tests in 0.067s
OK
Related: sysmocom's eSIM manager product that is currently in
development needs to fully use pySim.esim.saip, ideally from a regular
'pip install', and not from using the pySim source tree directly.
Related: SYS#6768
Change-Id: I0d7d6962a308eccca589a42c22546d508ff686f5
---
M setup.py
1 file changed, 10 insertions(+), 1 deletion(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/setup.py b/setup.py
index f90e07b..c982ce0 100644
--- a/setup.py
+++ b/setup.py
@@ -8,6 +8,7 @@
'pySim.apdu',
'pySim.apdu_source',
'pySim.esim',
+ 'pySim.esim.saip',
'pySim.global_platform',
'pySim.legacy',
'pySim.transport',
@@ -31,11 +32,19 @@
"pycryptodomex",
"packaging",
"smpp.pdu @ git+https://github.com/hologram-io/smpp.pdu",
+ "asn1tools",
],
scripts=[
'pySim-prog.py',
'pySim-read.py',
'pySim-shell.py',
'pySim-trace.py',
- ]
+ ],
+ package_data={
+ 'pySim.esim':
+ [
+ 'asn1/rsp/*.asn',
+ 'asn1/saip/*.asn',
+ ],
+ },
)
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/39497?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I0d7d6962a308eccca589a42c22546d508ff686f5
Gerrit-Change-Number: 39497
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Attention is currently required from: neels.
laforge has posted comments on this change by neels. ( https://gerrit.osmocom.org/c/pysim/+/39496?usp=email )
Change subject: .gitignore: dist subdir, may be created by pip
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/39496?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ib23a687845842bd25d83f87aa00ae0c278abc842
Gerrit-Change-Number: 39496
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Comment-Date: Sun, 09 Feb 2025 07:15:19 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
neels has uploaded a new patch set (#2). ( https://gerrit.osmocom.org/c/pysim/+/39497?usp=email )
Change subject: setup.py: install esim.asn1 resources, install esim.saip
......................................................................
setup.py: install esim.asn1 resources, install esim.saip
These changes are necessary to successfully run
./tests/unittests/test_esim_saip.py with a pySim installed via
'pip install'.
For example:
virtualenv venv
source venv/bin/activate
git clone ssh://gerrit.osmocom.org:29418/pysim
pip install pysim/
cd pysim
./tests/unittests/test_esim_saip.py
Before this patch, that would result first in package pySim.esim.saip
being unknown (not installed at all), and when that is added to
setup.py, in this error:
Traceback (most recent call last):
File "/home/moi/osmo-dev/src/pysim/tests/unittests/./test_esim_saip.py", line 23, in <module>
from pySim.esim.saip import *
File "/home/moi/s/esim/sysmo_esim_mgr/venv/lib/python3.13/site-packages/pySim/esim/saip/__init__.py", line 41, in <module>
asn1 = compile_asn1_subdir('saip')
File "/home/moi/s/esim/sysmo_esim_mgr/venv/lib/python3.13/site-packages/pySim/esim/__init__.py", line 56, in compile_asn1_subdir
for i in resources.files('pySim.esim').joinpath('asn1').joinpath(subdir_name).iterdir():
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/lib/python3.13/pathlib/_local.py", line 577, in iterdir
with os.scandir(root_dir) as scandir_it:
~~~~~~~~~~^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/moi/s/esim/sysmo_esim_mgr/venv/lib/python3.13/site-packages/pySim/esim/asn1/saip'
After this patch, the test completes successfully.
......
----------------------------------------------------------------------
Ran 6 tests in 0.067s
OK
Related: sysmocom's eSIM manager product that is currently in
development needs to fully use pySim.esim.saip, ideally from a regular
'pip install', and not from using the pySim source tree directly.
Related: SYS#6768
Change-Id: I0d7d6962a308eccca589a42c22546d508ff686f5
---
M setup.py
1 file changed, 10 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/97/39497/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/39497?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I0d7d6962a308eccca589a42c22546d508ff686f5
Gerrit-Change-Number: 39497
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-CC: Jenkins Builder
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/39496?usp=email )
Change subject: .gitignore: dist subdir, may be created by pip
......................................................................
.gitignore: dist subdir, may be created by pip
Change-Id: Ib23a687845842bd25d83f87aa00ae0c278abc842
---
M .gitignore
1 file changed, 1 insertion(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/96/39496/1
diff --git a/.gitignore b/.gitignore
index 2eb3d89..f03107a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,4 @@
/.local
/build
/pySim.egg-info
+dist
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/39496?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ib23a687845842bd25d83f87aa00ae0c278abc842
Gerrit-Change-Number: 39496
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/39497?usp=email )
Change subject: setup.py: install esim.asn1 resources, install esim.saip
......................................................................
setup.py: install esim.asn1 resources, install esim.saip
These changes are necessary to successfully run
./tests/unittests/test_esim_saip.py with a pySim installed via
'pip install'.
For example:
virtualenv venv
source venv/bin/activate
git clone ssh://gerrit.osmocom.org:29418/pysim
pip install pysim/
cd pysim
./tests/unittests/test_esim_saip.py
Before this patch, that would result first in package pySim.esim.saip being unknown
(not installed at all), and when that is added to setup.py, in this error:
Traceback (most recent call last):
File "/home/moi/osmo-dev/src/pysim/tests/unittests/./test_esim_saip.py", line 23, in <module>
from pySim.esim.saip import *
File "/home/moi/s/esim/sysmo_esim_mgr/venv/lib/python3.13/site-packages/pySim/esim/saip/__init__.py", line 41, in <module>
asn1 = compile_asn1_subdir('saip')
File "/home/moi/s/esim/sysmo_esim_mgr/venv/lib/python3.13/site-packages/pySim/esim/__init__.py", line 56, in compile_asn1_subdir
for i in resources.files('pySim.esim').joinpath('asn1').joinpath(subdir_name).iterdir():
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/lib/python3.13/pathlib/_local.py", line 577, in iterdir
with os.scandir(root_dir) as scandir_it:
~~~~~~~~~~^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/moi/s/esim/sysmo_esim_mgr/venv/lib/python3.13/site-packages/pySim/esim/asn1/saip'
After this patch, the test completes successfully.
......
----------------------------------------------------------------------
Ran 6 tests in 0.067s
OK
Related: sysmocom's eSIM manager product that is currently in
development needs to fully use pySim.esim.saip, ideally from a regular
'pip install', and not from using the pySim source tree directly.
Related: SYS#6768
Change-Id: I0d7d6962a308eccca589a42c22546d508ff686f5
---
M setup.py
1 file changed, 10 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/97/39497/1
diff --git a/setup.py b/setup.py
index f90e07b..c982ce0 100644
--- a/setup.py
+++ b/setup.py
@@ -8,6 +8,7 @@
'pySim.apdu',
'pySim.apdu_source',
'pySim.esim',
+ 'pySim.esim.saip',
'pySim.global_platform',
'pySim.legacy',
'pySim.transport',
@@ -31,11 +32,19 @@
"pycryptodomex",
"packaging",
"smpp.pdu @ git+https://github.com/hologram-io/smpp.pdu",
+ "asn1tools",
],
scripts=[
'pySim-prog.py',
'pySim-read.py',
'pySim-shell.py',
'pySim-trace.py',
- ]
+ ],
+ package_data={
+ 'pySim.esim':
+ [
+ 'asn1/rsp/*.asn',
+ 'asn1/saip/*.asn',
+ ],
+ },
)
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/39497?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I0d7d6962a308eccca589a42c22546d508ff686f5
Gerrit-Change-Number: 39497
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
falconia has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/39495?usp=email )
Change subject: trau: implement TFO frame encoding function
......................................................................
trau: implement TFO frame encoding function
Most differences between regular TRAU frames of TS 48.060 & 48.061
and TFO frames of TS 28.062 matter only in the frame decoding
direction. In the encoding direction, regular osmo_trau_frame_encode()
would have been sufficient for both frame types if it weren't for
the quirk of setting C1..C5 bits. osmo_trau_frame_encode() sets
these bits per its own mind for most frame types, ignoring the bits
passed by the user in fr->c_bits[]. This API behavior cannot be
changed without breaking existing users, but it is bad for TFO.
Solution: implement new osmo_trau_frame_encode_tfo() function
for TFO applications. As an additional benefit, the output buffer
space requirement is reduced because there is no possibility of
output frame extension for timing alignment.
Change-Id: I6e0ab4e5115f0aa6979ce93955b0e95b09041091
---
M include/osmocom/trau/trau_frame.h
M src/trau/trau_frame.c
2 files changed, 120 insertions(+), 37 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/95/39495/1
diff --git a/include/osmocom/trau/trau_frame.h b/include/osmocom/trau/trau_frame.h
index 8bdeb73..dd14f27 100644
--- a/include/osmocom/trau/trau_frame.h
+++ b/include/osmocom/trau/trau_frame.h
@@ -151,6 +151,8 @@
/* TFO frames are slightly modified TRAU-UL frames, and thus require slightly
* modified encoding and decoding functions. */
+int osmo_trau_frame_encode_tfo(ubit_t *bits, size_t n_bits, const struct osmo_trau_frame *fr);
+
int osmo_trau_frame_decode_tfo_16k(struct osmo_trau_frame *fr, const ubit_t *bits);
int osmo_trau_frame_decode_tfo_hr1(struct osmo_trau_frame *fr, const ubit_t *bits);
int osmo_trau_frame_decode_tfo_amr_8k(struct osmo_trau_frame *fr, const ubit_t *bits);
diff --git a/src/trau/trau_frame.c b/src/trau/trau_frame.c
index df4404d..fb98247 100644
--- a/src/trau/trau_frame.c
+++ b/src/trau/trau_frame.c
@@ -238,30 +238,34 @@
}
/* TS 08.60 Section 3.1.1 */
-static int encode16_fr(ubit_t *trau_bits, const struct osmo_trau_frame *fr)
+static int encode16_fr(ubit_t *trau_bits, const struct osmo_trau_frame *fr, bool is_tfo)
{
const ubit_t *cbits5;
int i;
int d_idx = 0;
- switch (fr->type) {
- case OSMO_TRAU16_FT_IDLE:
- if (fr->dir == OSMO_TRAU_DIR_UL)
- cbits5 = ft_idle_up_bits;
- else
- cbits5 = ft_idle_down_bits;
- break;
- case OSMO_TRAU16_FT_FR:
- if (fr->dir == OSMO_TRAU_DIR_UL)
- cbits5 = ft_fr_up_bits;
- else
- cbits5 = ft_fr_down_bits;
- break;
- case OSMO_TRAU16_FT_EFR:
- cbits5 = ft_efr_bits;
- break;
- default:
- return -EINVAL;
+ if (is_tfo) {
+ cbits5 = fr->c_bits;
+ } else {
+ switch (fr->type) {
+ case OSMO_TRAU16_FT_IDLE:
+ if (fr->dir == OSMO_TRAU_DIR_UL)
+ cbits5 = ft_idle_up_bits;
+ else
+ cbits5 = ft_idle_down_bits;
+ break;
+ case OSMO_TRAU16_FT_FR:
+ if (fr->dir == OSMO_TRAU_DIR_UL)
+ cbits5 = ft_fr_up_bits;
+ else
+ cbits5 = ft_fr_down_bits;
+ break;
+ case OSMO_TRAU16_FT_EFR:
+ cbits5 = ft_efr_bits;
+ break;
+ default:
+ return -EINVAL;
+ }
}
encode_sync16(trau_bits);
@@ -314,17 +318,21 @@
}
/* TS 08.60 Section 3.1.2 */
-static int encode16_amr(ubit_t *trau_bits, const struct osmo_trau_frame *fr)
+static int encode16_amr(ubit_t *trau_bits, const struct osmo_trau_frame *fr, bool is_tfo)
{
- const ubit_t *cbits5 = ft_amr_bits;
int i, d_idx;
encode_sync16(trau_bits);
- /* C1 .. C5 */
- memcpy(trau_bits + 17, cbits5 + 0, 5);
- /* C6 .. C15 */
- memcpy(trau_bits + 17 + 5, fr->c_bits + 5, 15 - 5);
+ if (is_tfo) {
+ /* C1 .. C15 */
+ memcpy(trau_bits + 17, fr->c_bits, 15);
+ } else {
+ /* C1 .. C5 */
+ memcpy(trau_bits + 17, ft_amr_bits, 5);
+ /* C6 .. C15 */
+ memcpy(trau_bits + 17 + 5, fr->c_bits + 5, 15 - 5);
+ }
trau_bits[32] = 1;
/* C16 .. C25 */
@@ -549,7 +557,7 @@
fr_idle_frame.c_bits[11] = 1; /* C12 (UFE), good frame */
fr_idle_frame.c_bits[15] = 1; /* C16 (SP), no DTX */
- encode16_fr(encoded_idle_frame, &fr_idle_frame);
+ encode16_fr(encoded_idle_frame, &fr_idle_frame, false);
dbits_initted = 1; /* set it to 1 to not call it again */
}
return encoded_idle_frame;
@@ -843,7 +851,7 @@
}
/* TS 08.61 Section 5.2.1.1 */
-static int encode8_hr(ubit_t *trau_bits, const struct osmo_trau_frame *fr)
+static int encode8_hr(ubit_t *trau_bits, const struct osmo_trau_frame *fr, bool is_tfo)
{
int i, d_idx = 0;
@@ -858,11 +866,15 @@
/* C1 .. C5 */
ubit_t *cbits_out = trau_bits + 1 * 8 + 1;
if (fr->dir == OSMO_TRAU_DIR_UL) {
- cbits_out[0] = 0;
- cbits_out[1] = 0;
- cbits_out[2] = 0;
- cbits_out[3] = 1;
- cbits_out[4] = 0;
+ if (is_tfo) {
+ memcpy(cbits_out, fr->c_bits, 5);
+ } else {
+ cbits_out[0] = 0;
+ cbits_out[1] = 0;
+ cbits_out[2] = 0;
+ cbits_out[3] = 1;
+ cbits_out[4] = 0;
+ }
} else {
cbits_out[0] = 0;
cbits_out[1] = 0;
@@ -1241,9 +1253,21 @@
/*! Encode a TRAU frame from its decoded representation to a sequence of unpacked bits.
* \param[out] bits caller-allocated buffer for unpacked outpud bits
- * \param[in] n_bits size of 'bits' oputput buffer in number of unpacked bits
+ * \param[in] n_bits size of 'bits' output buffer in number of unpacked bits
* \param[in] fr decoded representation of TRAU frame to be encoded
- * \return 0 number of unpacked output bits generated; negative in case of error */
+ * \return 0 number of unpacked output bits generated; negative in case of error
+ *
+ * This function exhibits a behavioral quirk which users need to be aware of:
+ * for many frame types, the first 5 bits out of user-provided fr->c_bits[]
+ * (corresponding to C1..C5) are ignored and replaced with internally supplied
+ * constant values, where the function "knows" what the correct frame type code
+ * should be. This behavioral quirk is arguably a design defect, but it cannot
+ * be changed without breaking some existing applications that rely on this
+ * behavior and skip setting those bits themselves. For TFO applications
+ * where C1..C5 may need to be modified (especially TFO-AMR where this C1..C5
+ * modification must be done before CRC computation), please use
+ * osmo_trau_frame_encode_tfo().
+ */
int osmo_trau_frame_encode(ubit_t *bits, size_t n_bits, const struct osmo_trau_frame *fr)
{
/* check for sufficient space provided by caller in output buffer */
@@ -1287,11 +1311,11 @@
switch (fr->type) {
case OSMO_TRAU16_FT_FR:
case OSMO_TRAU16_FT_EFR:
- return encode16_fr(bits, fr);
+ return encode16_fr(bits, fr, false);
case OSMO_TRAU16_FT_HR:
return encode16_hr(bits, fr);
case OSMO_TRAU16_FT_AMR:
- return encode16_amr(bits, fr);
+ return encode16_amr(bits, fr, false);
case OSMO_TRAU16_FT_OAM:
return encode16_oam(bits, fr);
case OSMO_TRAU16_FT_IDLE:
@@ -1305,7 +1329,7 @@
case OSMO_TRAU16_FT_EDATA:
return encode16_edata(bits, fr);
case OSMO_TRAU8_SPEECH:
- return encode8_hr(bits, fr);
+ return encode8_hr(bits, fr, false);
case OSMO_TRAU8_DATA:
return encode8_data(bits, fr);
case OSMO_TRAU8_OAM:
@@ -1322,6 +1346,63 @@
}
}
+/*! Encode a TFO frame from its decoded representation to a sequence of unpacked bits.
+ * \param[out] bits caller-allocated buffer for unpacked outpud bits
+ * \param[in] n_bits size of 'bits' output buffer in number of unpacked bits
+ * \param[in] fr decoded representation of TRAU frame to be encoded
+ * \return 0 number of unpacked output bits generated; negative in case of error
+ *
+ * Compared to regular osmo_trau_frame_encode(), this TFO-specific TRAU frame
+ * encoding function restricts the set of possible frame types to those that
+ * are valid for TFO, restricts the direction to TRAU-UL, reduces the output
+ * space requirement (there is no timing alignment extension) and always uses
+ * all fr->c_bits provided by the application.
+ */
+int osmo_trau_frame_encode_tfo(ubit_t *bits, size_t n_bits, const struct osmo_trau_frame *fr)
+{
+ /* TFO frames are TRAU-UL only */
+ if (fr->dir != OSMO_TRAU_DIR_UL)
+ return -EINVAL;
+
+ /* check for sufficient space provided by caller in output buffer */
+ /* there is no timing alignment in TRAU-UL direction! */
+ switch (fr->type) {
+ case OSMO_TRAU16_FT_FR:
+ case OSMO_TRAU16_FT_EFR:
+ case OSMO_TRAU16_FT_AMR:
+ if (n_bits < 1 * 40 * 8)
+ return -ENOSPC;
+ break;
+ case OSMO_TRAU8_SPEECH:
+ case OSMO_TRAU8_AMR_LOW:
+ case OSMO_TRAU8_AMR_6k7:
+ case OSMO_TRAU8_AMR_7k4:
+ if (n_bits < 1 * 20 * 8)
+ return -ENOSPC;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ switch (fr->type) {
+ case OSMO_TRAU16_FT_FR:
+ case OSMO_TRAU16_FT_EFR:
+ return encode16_fr(bits, fr, true);
+ case OSMO_TRAU16_FT_AMR:
+ return encode16_amr(bits, fr, true);
+ case OSMO_TRAU8_SPEECH:
+ return encode8_hr(bits, fr, true);
+ case OSMO_TRAU8_AMR_LOW:
+ return encode8_amr_low(bits, fr);
+ case OSMO_TRAU8_AMR_6k7:
+ return encode8_amr_67(bits, fr);
+ case OSMO_TRAU8_AMR_7k4:
+ return encode8_amr_74(bits, fr);
+ default:
+ return -EINVAL;
+ }
+}
+
/*! Decode/parse a 16k TRAU frame from unpacked bits to decoded format.
* \param[out] fr caller-allocated output data structure
* \param[in] bits unpacked bits containing raw TRAU frame; must be aligned
--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/39495?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I6e0ab4e5115f0aa6979ce93955b0e95b09041091
Gerrit-Change-Number: 39495
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
falconia has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/39494?usp=email )
Change subject: trau: implement TFO frame decoding functions
......................................................................
trau: implement TFO frame decoding functions
TFO frames of 3GPP TS 28.062 are slightly modified TRAU-UL frames,
and thus require slightly modified encoding and decoding functions.
Adding TFO frame encoding and decoding functions to libosmotrau
will allow TFO applications (sw implementations of a TFO-capable
speech transcoder) to reuse those parts of TRAU frame encoding and
decoding that are common between regular TRAU frames and TFO.
Change-Id: Ia095598622645068d62301bc4bf7de9f68065e84
---
M include/osmocom/trau/trau_frame.h
M src/trau/trau_frame.c
2 files changed, 116 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/94/39494/1
diff --git a/include/osmocom/trau/trau_frame.h b/include/osmocom/trau/trau_frame.h
index 5f1d708..8bdeb73 100644
--- a/include/osmocom/trau/trau_frame.h
+++ b/include/osmocom/trau/trau_frame.h
@@ -148,4 +148,11 @@
/*! Determine the time alignment in us requested by CCU in a UL frame */
int osmo_trau_frame_dl_ta_us(const struct osmo_trau_frame *fr);
+/* TFO frames are slightly modified TRAU-UL frames, and thus require slightly
+ * modified encoding and decoding functions. */
+
+int osmo_trau_frame_decode_tfo_16k(struct osmo_trau_frame *fr, const ubit_t *bits);
+int osmo_trau_frame_decode_tfo_hr1(struct osmo_trau_frame *fr, const ubit_t *bits);
+int osmo_trau_frame_decode_tfo_amr_8k(struct osmo_trau_frame *fr, const ubit_t *bits);
+
/* }@ */
diff --git a/src/trau/trau_frame.c b/src/trau/trau_frame.c
index 21e4f00..df4404d 100644
--- a/src/trau/trau_frame.c
+++ b/src/trau/trau_frame.c
@@ -1379,6 +1379,49 @@
}
}
+/*! Decode/parse a 16k TFO frame from unpacked bits to decoded format.
+ * \param[out] fr caller-allocated output data structure
+ * \param[in] bits unpacked bits containing raw TFO frame; must be aligned
+ * \returns 0 in case of success; negative on error
+ *
+ * TFO applications that need to decode TFO frames of TS 28.062 section 5.2.1
+ * (FR/EFR) or section 5.2.2.1 (AMR_TFO_16k) should use this function instead
+ * of regular osmo_trau_frame_decode_16k() in order to get appropriately
+ * modified handling of C1..C5 frame type bits:
+ *
+ * - C5 needs to be ignored because it is EMBED bit in TFO frames;
+ * - For interoperability with other potential TFO-AMR implementations
+ * out in the world that aren't GSM AMR-FR, we need to recognize additional
+ * C1..C4 bit patterns as being AMR equivalents: see Table 5.2.2.1-2 in
+ * 3GPP TS 28.062.
+ */
+int osmo_trau_frame_decode_tfo_16k(struct osmo_trau_frame *fr, const ubit_t *bits)
+{
+ uint8_t cbits4 = get_bits(bits, 17, 4);
+ /* We don't look at bit C5 because it is EMBED bit in TFO frames */
+
+ fr->type = OSMO_TRAU_FT_NONE;
+ fr->dir = OSMO_TRAU_DIR_UL; /* TFO frames are modified TRAU-UL */
+ fr->dl_ta_usec = 0;
+
+ switch (cbits4) {
+ case TRAU_FT_FR_UP >> 1:
+ fr->type = OSMO_TRAU16_FT_FR;
+ return decode16_fr(fr, bits, fr->dir);
+ case TRAU_FT_EFR >> 1:
+ fr->type = OSMO_TRAU16_FT_EFR;
+ return decode16_fr(fr, bits, fr->dir);
+ case TRAU_FT_AMR >> 1:
+ case 0x4: /* HR_AMR */
+ case 0x6: /* UMTS_AMR_2 */
+ case 0xB: /* OHR_AMR */
+ fr->type = OSMO_TRAU16_FT_AMR;
+ return decode16_amr(fr, bits, fr->dir);
+ default:
+ return -EINVAL;
+ }
+}
+
#define TRAU8_FT_AMR_NO_SPEECH_CMI 0x10 /* 1, 0, 0, 0, 0 */
#define TRAU8_FT_AMR_NO_SPEECH_CMR 0x14 /* 1, 0, 1, 0, 0 */
#define TRAU8_FT_AMR_475_515_590 0..7
@@ -1521,4 +1564,70 @@
return -EINVAL;
}
+/*! Decode/parse an HRv1 TFO frame from unpacked bits to decoded format.
+ * \param[out] fr caller-allocated output data structure
+ * \param[in] bits 160 bits containing the lsb extracted from PCM samples;
+ * must be aligned
+ * \returns 0 in case of success; negative on error
+ *
+ * TFO applications that need to decode TFO frames of TS 28.062 section 5.3.1
+ * (GSM_HR codec) should use this function instead of regular
+ * osmo_trau_frame_decode_8k() in order to get these two behavior
+ * modifications:
+ *
+ * - The sync pattern check needs to be skipped because the sync pattern
+ * may be partially overwritten by embedded TFO messages;
+ * - C5 needs to be ignored because it is EMBED bit in TFO frames.
+ *
+ * In the case of TFO, unlike regular TRAU-UL frames on Abis/Ater, there is
+ * no need to distinguish between HRv1 and AMR-8k frames by their respective
+ * sync patterns: per TS 28.062, these two TFO frame types never occur
+ * in the same bit position in TFO-superimposed PCM speech octets.
+ * Because HRv1 is the only TFO frame type that can occur in the configuration
+ * of TS 28.062 section 5.3 (only the one lsb in each PCM speech octet is
+ * overwritten), this function skips all attempts at frame type classification:
+ * the TFO application is responsible for detecting the presence of valid
+ * TFO frames for the negotiated codec type.
+ */
+int osmo_trau_frame_decode_tfo_hr1(struct osmo_trau_frame *fr, const ubit_t *bits)
+{
+ fr->type = OSMO_TRAU8_SPEECH;
+ fr->dir = OSMO_TRAU_DIR_UL; /* TFO frames are modified TRAU-UL */
+ fr->dl_ta_usec = 0;
+ return decode8_hr(fr, bits, fr->dir);
+}
+
+/*! Decode/parse an AMR_TFO_8+8k frame from unpacked bits to decoded format.
+ * \param[out] fr caller-allocated output data structure
+ * \param[in] bits 160 bits containing the second lsb extracted from
+ * PCM samples; must be aligned
+ * \returns 0 in case of success; negative on error
+ *
+ * This function is provided for TFO applications that need to decode
+ * TFO frames of TS 28.062 section 5.2.2.2, format named AMR_TFO_8+8k.
+ * The second lsb extracted from PCM samples is the entity being decoded here.
+ * Compared to osmo_trau_frame_decode_8k(), the present function requires
+ * the direction to be TRAU-UL (as always the case in TFO) and accepts
+ * only AMR-8k frame types.
+ */
+int osmo_trau_frame_decode_tfo_amr_8k(struct osmo_trau_frame *fr, const ubit_t *bits)
+{
+ fr->type = OSMO_TRAU_FT_NONE;
+ fr->dir = OSMO_TRAU_DIR_UL; /* TFO frames are modified TRAU-UL */
+ fr->dl_ta_usec = 0;
+
+ if (is_amr_low(bits)) {
+ fr->type = OSMO_TRAU8_AMR_LOW;
+ return decode8_amr_low(fr, bits, fr->dir);
+ } else if (is_amr_67(bits)) {
+ fr->type = OSMO_TRAU8_AMR_6k7;
+ return decode8_amr_67(fr, bits, fr->dir);
+ } else if (is_amr_74(bits)) {
+ fr->type = OSMO_TRAU8_AMR_7k4;
+ return decode8_amr_74(fr, bits, fr->dir);
+ }
+
+ return -EINVAL;
+}
+
/* }@ */
--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/39494?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: Ia095598622645068d62301bc4bf7de9f68065e84
Gerrit-Change-Number: 39494
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>