FreeCalypso > hg > freecalypso-tools
comparison rvinterf/asyncshell/tchrec.c @ 0:e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 11 Jun 2016 00:13:35 +0000 |
parents | |
children | 971906d7763d |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e7502631a0f9 |
---|---|
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 u_char writebytes[33]; | |
23 | |
24 if (!gsm_data_file) | |
25 return; | |
26 gsm0610_tidsp_to_libgsm(rvi_msg + 9, writebytes); | |
27 fwrite(writebytes, 1, 33, gsm_data_file); | |
28 frame_count++; | |
29 } | |
30 | |
31 static void | |
32 cmd_tch_record_start(filename) | |
33 char *filename; | |
34 { | |
35 if (gsm_data_file) { | |
36 printf("error: tch record session already in progress\n"); | |
37 return; | |
38 } | |
39 gsm_data_file = fopen(filename, "w"); | |
40 if (!gsm_data_file) { | |
41 perror(filename); | |
42 return; | |
43 } | |
44 printf("Starting TCH DL recording\n"); | |
45 tch_rx_control(1); | |
46 send_tch_config_req(1); | |
47 frame_count = 0; | |
48 } | |
49 | |
50 static void | |
51 cmd_tch_record_stop() | |
52 { | |
53 if (!gsm_data_file) { | |
54 printf("error: no tch record session in progress\n"); | |
55 return; | |
56 } | |
57 fclose(gsm_data_file); | |
58 gsm_data_file = 0; | |
59 printf("TCH DL recording stopped, captured %lu speech frames\n", | |
60 frame_count); | |
61 send_tch_config_req(0); | |
62 } | |
63 | |
64 void | |
65 cmd_tch_record(argc, argv) | |
66 char **argv; | |
67 { | |
68 if (argc < 2) { | |
69 printf("error: too few arguments\n"); | |
70 return; | |
71 } | |
72 if (strcmp(argv[1], "stop")) | |
73 cmd_tch_record_start(argv[1]); | |
74 else | |
75 cmd_tch_record_stop(); | |
76 } | |
77 | |
78 void | |
79 show_tch_record_status() | |
80 { | |
81 printf("TCH DL recording: %s\n", | |
82 gsm_data_file ? "RUNNING" : "not running"); | |
83 } |