aboutsummaryrefslogtreecommitdiffstats
path: root/tests/codec/codec_ecu_fr_test.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2019-08-01 20:05:05 +0200
committerlaforge <laforge@gnumonks.org>2019-09-02 09:13:50 +0000
commit750d8311f5c0455f2caaa2ae9dba2cc99300c9dd (patch)
treeaebab66fccee63d0b6da29e23ca3944d0d80c2e9 /tests/codec/codec_ecu_fr_test.c
parent766f77c3d9b479b49e6e2bc2b105ceb4889304d3 (diff)
codec/ecu: Introduce new generic Error Concealment Unit abstraction
We don't want to expose the details of a given ECU implementation to the user (e.g. osmo-bts), but have a generic abstraction layer where an ECU implementation can simply register a few call-back functions with the generic core. As the developer and copyright holder of the related code, I hereby state that any ECU implementation using 'struct osmo_ecu_ops' and registering with the 'osmo_ecu_register()' function shall not be considered as a derivative work under any applicable copyright law; the copyleft terms of GPLv2 shall hence not apply to any such ECU implementation. The intent of the above exception is to allow anyone to combine third party Error Concealment Unit implementations with libosmocore, including but not limited to such published by ETSI. Change-Id: I4d33c9c7c2d4c7462ff38a49c178b65accae1915
Diffstat (limited to 'tests/codec/codec_ecu_fr_test.c')
-rw-r--r--tests/codec/codec_ecu_fr_test.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/codec/codec_ecu_fr_test.c b/tests/codec/codec_ecu_fr_test.c
index 3561c442..7ebc558f 100644
--- a/tests/codec/codec_ecu_fr_test.c
+++ b/tests/codec/codec_ecu_fr_test.c
@@ -113,6 +113,8 @@ void test_fr_concealment(void)
int i, rc;
int j = 0;
+ printf("=> Testing FR concealment (simple, consecutive bad frames)\n");
+
while (sample_frame_hex[j] != NULL) {
/* Parse frame from string to hex */
osmo_hexparse(sample_frame_hex[j], frame, GSM_FR_BYTES);
@@ -148,6 +150,8 @@ void test_fr_concealment_realistic()
unsigned int frame_len;
int rc, i = 0;
+ printf("\n=> Testing FR concealment (realistic, various bad frames)\n");
+
while (fr_frames_hex[i] != NULL) {
/* Debug print */
printf("Frame No. %03i:\n", i);
@@ -174,11 +178,54 @@ void test_fr_concealment_realistic()
}
}
+/* Simulate a real life situation: voice frames with a few dropouts, using generic core */
+void test_fr_concealment_realistic_core()
+{
+ struct osmo_ecu_state *state = osmo_ecu_init(NULL, OSMO_ECU_CODEC_FR);
+ uint8_t frame[GSM_FR_BYTES];
+ unsigned int frame_len;
+ int rc, i = 0;
+
+ printf("\n=> Testing FR concealment (realistic, using ECU abstraction)\n");
+
+ OSMO_ASSERT(state);
+
+ while (fr_frames_hex[i] != NULL) {
+ /* Debug print */
+ printf("Frame No. %03i:\n", i);
+
+ /* Good or bad frame? */
+ frame_len = strlen(fr_frames_hex[i]) / 2;
+ if (frame_len == GSM_FR_BYTES) {
+ printf(" * input: %s\n", fr_frames_hex[i]);
+ osmo_hexparse(fr_frames_hex[i], frame, GSM_FR_BYTES);
+ osmo_ecu_frame_in(state, false, frame, GSM_FR_BYTES);
+ } else {
+ printf(" * input: (bad)\n");
+ memset(frame, 0x00, GSM_FR_BYTES);
+ osmo_ecu_frame_in(state, true, frame, 0);
+ rc = osmo_ecu_frame_out(state, frame);
+ OSMO_ASSERT(rc == GSM_FR_BYTES);
+ }
+
+ /* Print result */
+ printf(" * output: %s\n",
+ osmo_hexdump_nospc(frame, GSM_FR_BYTES));
+
+ /* Go to the next frame */
+ i++;
+ }
+
+ osmo_ecu_destroy(state);
+}
+
+
int main(int argc, char **argv)
{
/* Perform actual tests */
test_fr_concealment();
test_fr_concealment_realistic();
+ test_fr_concealment_realistic_core();
return 0;
}