annotate test-voice/pcmu_catcher.c @ 17:830af7de3403

sipout-test-voice: disallow empty files for play command
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 13 May 2024 22:31:24 -0800
parents 4f81b959a5f5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module implements the logic that scans received PCMU sample streams
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * for patterns that result from a GSM-FR or GSM-EFR decoder processing
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * uplink test frames constructed in vband-misc repository, ul-test
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * subdirectory.
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 */
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdio.h>
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdint.h>
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 static const uint8_t match_frame_fr[160] = {
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 0xFF,0x0F,0x0E,0x1B,0x8D,0x8A,0x9C,0x23,0x1D,0x38,0x1C,0x1B,0x26,0x8A,0x80,0x92,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 0x11,0x06,0x1E,0xA3,0x9B,0xBF,0x9B,0x91,0x9C,0x11,0x06,0x1C,0x98,0x87,0x8D,0xAF,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 0x1D,0x16,0x13,0x1F,0xBE,0x8D,0x88,0x99,0x1D,0x07,0x05,0x12,0xAC,0x8B,0x87,0x95,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 0x25,0x09,0x06,0x14,0xAA,0x8B,0x88,0x97,0x25,0x0A,0x09,0x1A,0xA4,0x8C,0x8A,0x99,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 0x28,0x0C,0x09,0x1B,0xA5,0x8C,0x8B,0x9D,0x23,0x0C,0x0A,0x19,0xA4,0x8C,0x8A,0x9D,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 0x1E,0x0A,0x0A,0x1C,0xA2,0x8C,0x8B,0x9B,0x25,0x0C,0x0A,0x19,0xA7,0x8C,0x8B,0x9B,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 0x26,0x0D,0x0B,0x1A,0xAA,0x8D,0x8A,0x99,0x2A,0x0D,0x0B,0x1A,0xAB,0x8E,0x8C,0x99,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 0x2F,0x0F,0x0B,0x19,0xAE,0x8E,0x8C,0x99,0x34,0x0F,0x0D,0x1A,0xB2,0x91,0x8D,0x99,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 0x3B,0x12,0x0D,0x19,0xBA,0x92,0x8E,0x9B,0x38,0x14,0x0F,0x1B,0xBB,0x94,0x8E,0x9A,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 0x3B,0x13,0x0E,0x1B,0xBA,0x95,0x90,0x9B,0x3F,0x16,0x0F,0x1B,0xBB,0x94,0x8F,0x9C,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 };
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 static const uint8_t match_frame_efr_classic[160] = {
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 0x6F,0x64,0x63,0x6B,0xE8,0xDA,0xDC,0xEF,0x60,0x5A,0x5D,0x6F,0xE2,0xD8,0xD9,0xEC,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 0x5F,0x58,0x5E,0x7E,0xE2,0xDF,0xE2,0xF0,0x63,0x58,0x59,0x67,0xE0,0xD4,0xD7,0xEC,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 0x5E,0x56,0x5A,0x6D,0xE1,0xD6,0xD7,0xEA,0x4D,0x37,0x2F,0x3A,0xC2,0xA7,0xA3,0xB5,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 0x2F,0x1C,0x1A,0x2D,0xA9,0x96,0x96,0xAE,0x22,0x12,0x14,0x31,0x9E,0x8F,0x94,0xB6,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 0x1B,0x0D,0x0F,0x2C,0x9B,0x8C,0x8E,0xAB,0x17,0x09,0x0C,0x28,0x97,0x88,0x8A,0xA7,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 0x15,0x07,0x0A,0x29,0x95,0x88,0x8B,0xAA,0x15,0x08,0x0B,0x2A,0x96,0x88,0x8B,0xAA,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 0x15,0x09,0x0C,0x2A,0x97,0x89,0x8C,0xAA,0x17,0x0A,0x0D,0x2B,0x98,0x8A,0x8D,0xAB,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 0x18,0x0A,0x0D,0x2A,0x99,0x8A,0x8D,0xAA,0x18,0x0A,0x0D,0x29,0x99,0x8A,0x8D,0xA9,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 0x19,0x0A,0x0D,0x29,0x99,0x8A,0x8D,0xA9,0x19,0x0A,0x0D,0x29,0x99,0x8A,0x8D,0xA9,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 0x19,0x0A,0x0D,0x28,0x99,0x8A,0x8C,0xA8,0x19,0x0A,0x0D,0x27,0x9A,0x8B,0x8D,0xA7,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 };
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 static const uint8_t match_frame_amrefr_dec[160] = {
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 0x6F,0x66,0x66,0x6E,0xE5,0xDA,0xDD,0xF2,0x5F,0x5A,0x5E,0x76,0xE0,0xD8,0xDA,0xEF,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 0x5E,0x59,0x5F,0xFC,0xE1,0xDF,0xE5,0xF5,0x61,0x59,0x5B,0x6B,0xDE,0xD4,0xD9,0xEF,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 0x5D,0x56,0x5B,0x71,0xDF,0xD6,0xD8,0xEE,0x4D,0x38,0x31,0x3E,0xBD,0xA7,0xA5,0xB9,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 0x2D,0x1C,0x1C,0x35,0xA5,0x96,0x98,0xB4,0x1F,0x12,0x17,0x3D,0x9C,0x90,0x96,0xC1,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 0x1A,0x0E,0x12,0x38,0x98,0x8C,0x8F,0xB4,0x16,0x0A,0x0D,0x32,0x94,0x88,0x8C,0xAE,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 0x13,0x08,0x0C,0x35,0x92,0x88,0x8C,0xB3,0x13,0x08,0x0D,0x35,0x93,0x88,0x8D,0xB3,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 0x13,0x09,0x0D,0x34,0x94,0x89,0x8D,0xB3,0x15,0x0A,0x0E,0x35,0x96,0x8B,0x8E,0xB5,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 0x16,0x0B,0x0E,0x32,0x97,0x8B,0x8E,0xB3,0x16,0x0A,0x0E,0x32,0x96,0x8A,0x8E,0xB1,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 0x16,0x0B,0x0E,0x31,0x96,0x8B,0x8E,0xB1,0x16,0x0B,0x0E,0x31,0x97,0x8B,0x8E,0xB1,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 0x16,0x0A,0x0E,0x30,0x97,0x8A,0x8E,0xAF,0x17,0x0B,0x0E,0x2F,0x97,0x8B,0x8E,0xAE,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 };
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 enum state {
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 STATE_GROUND,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 STATE_FE,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 STATE_EFR_PRELIM,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 STATE_EFR_CLASSIC,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 STATE_EFR_AMR,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 STATE_FR,
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 };
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 static enum state state;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 static unsigned fe_byte_count, match_pos;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 void
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 pcmu_catcher_reset()
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 {
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 state = STATE_GROUND;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 }
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 static void
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 report_match(name, offset)
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 char *name;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 unsigned offset;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 {
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 offset++;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 if (offset == 160)
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 offset = 0;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 printf("Caught output of %s decoder at offset %u\n", name, offset);
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 }
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 static void
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 process_sample(samp, offset)
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 unsigned samp, offset;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 {
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 if (samp == 0xFE) {
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 if (state != STATE_FE) {
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 state = STATE_FE;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 fe_byte_count = 1;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 } else if (fe_byte_count < 160)
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 fe_byte_count++;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 return;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 }
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 switch (state) {
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 case STATE_GROUND:
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 return;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 case STATE_FE:
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 if (fe_byte_count < 160) {
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 state = STATE_GROUND;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 return;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 }
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 switch (samp) {
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 case 0x6F:
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 state = STATE_EFR_PRELIM;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 return;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 case 0xFF:
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 state = STATE_FR;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 match_pos = 1;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 return;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 default:
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 state = STATE_GROUND;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 }
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 return;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 case STATE_EFR_PRELIM:
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 switch (samp) {
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 case 0x64:
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 state = STATE_EFR_CLASSIC;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 match_pos = 2;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 return;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 case 0x66:
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 state = STATE_EFR_AMR;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 match_pos = 2;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 return;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 default:
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 state = STATE_GROUND;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 }
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 return;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 case STATE_EFR_CLASSIC:
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 if (samp == match_frame_efr_classic[match_pos])
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 match_pos++;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 else {
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 state = STATE_GROUND;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 return;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 }
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 if (match_pos < 160)
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 return;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 report_match("classic EFR", offset);
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 state = STATE_GROUND;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 return;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 case STATE_EFR_AMR:
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 if (samp == match_frame_amrefr_dec[match_pos])
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 match_pos++;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 else {
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 state = STATE_GROUND;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 return;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 }
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 if (match_pos < 160)
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 return;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 report_match("AMR-EFR", offset);
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 state = STATE_GROUND;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 return;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 case STATE_FR:
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 if (samp == match_frame_fr[match_pos])
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 match_pos++;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 else {
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 state = STATE_GROUND;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 return;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 }
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 if (match_pos < 160)
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 return;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 report_match("GSM-FR", offset);
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 state = STATE_GROUND;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 return;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 default:
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 state = STATE_GROUND;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 }
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 }
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 void
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 pcmu_catcher_process(inbuf)
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 uint8_t *inbuf;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 {
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 unsigned n;
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 for (n = 0; n < 160; n++)
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 process_sample(inbuf[n], n);
4f81b959a5f5 sipout-test-voice: implement PCMU GSM uplink catcher
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 }