annotate rvinterf/asyncshell/tchrec.c @ 1030:194967e11b2b

fc-shell: tch record and tch play reworked for libgsm-compatible file format
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 31 May 2016 18:39:06 +0000
parents 71bbddbcc6a1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1028
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * TCH downlink recording functionality
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdio.h>
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <string.h>
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <strings.h>
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "pktmux.h"
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "tch_feature.h"
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 extern u_char rvi_msg[];
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 extern int rvi_msg_len;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 static FILE *gsm_data_file;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 static u_long frame_count;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 void
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 tch_dlbits_handler()
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 {
1030
194967e11b2b fc-shell: tch record and tch play reworked for libgsm-compatible file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 1028
diff changeset
22 u_char writebytes[33];
194967e11b2b fc-shell: tch record and tch play reworked for libgsm-compatible file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 1028
diff changeset
23
1028
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 if (!gsm_data_file)
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 return;
1030
194967e11b2b fc-shell: tch record and tch play reworked for libgsm-compatible file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 1028
diff changeset
26 gsm0610_tidsp_to_libgsm(rvi_msg + 9, writebytes);
194967e11b2b fc-shell: tch record and tch play reworked for libgsm-compatible file format
Mychaela Falconia <falcon@freecalypso.org>
parents: 1028
diff changeset
27 fwrite(writebytes, 1, 33, gsm_data_file);
1028
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 frame_count++;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 }
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 static void
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 cmd_tch_record_start(filename)
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 char *filename;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 {
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 if (gsm_data_file) {
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 printf("error: tch record session already in progress\n");
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 return;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 }
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 gsm_data_file = fopen(filename, "w");
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 if (!gsm_data_file) {
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 perror(filename);
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 return;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 }
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 printf("Starting TCH DL recording\n");
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 tch_rx_control(1);
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 send_tch_config_req(1);
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 frame_count = 0;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 }
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 static void
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 cmd_tch_record_stop()
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 {
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 if (!gsm_data_file) {
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 printf("error: no tch record session in progress\n");
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 return;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 }
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 fclose(gsm_data_file);
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 gsm_data_file = 0;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 printf("TCH DL recording stopped, captured %lu speech frames\n",
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 frame_count);
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 send_tch_config_req(0);
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 }
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 void
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 cmd_tch_record(argc, argv)
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 char **argv;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 {
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 if (argc < 2) {
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 printf("error: too few arguments\n");
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 return;
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 }
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 if (strcmp(argv[1], "stop"))
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 cmd_tch_record_start(argv[1]);
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 else
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 cmd_tch_record_stop();
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 }
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 void
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 show_tch_record_status()
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 {
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 printf("TCH DL recording: %s\n",
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 gsm_data_file ? "RUNNING" : "not running");
71bbddbcc6a1 fc-shell: tch record implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 }