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