FreeCalypso > hg > freecalypso-tools
view 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 |
line wrap: on
line source
/* * TCH downlink recording functionality */ #include <sys/types.h> #include <stdio.h> #include <string.h> #include <strings.h> #include <stdlib.h> #include "pktmux.h" #include "tch_feature.h" extern u_char rvi_msg[]; extern int rvi_msg_len; static FILE *gsm_data_file; static u_long frame_count; void tch_dlbits_handler() { u_char writebytes[33]; if (!gsm_data_file) return; gsm0610_tidsp_to_libgsm(rvi_msg + 9, writebytes); fwrite(writebytes, 1, 33, gsm_data_file); frame_count++; } static void cmd_tch_record_start(filename) char *filename; { if (gsm_data_file) { printf("error: tch record session already in progress\n"); return; } gsm_data_file = fopen(filename, "w"); if (!gsm_data_file) { perror(filename); return; } printf("Starting TCH DL recording\n"); tch_rx_control(1); send_tch_config_req(1); frame_count = 0; } static void cmd_tch_record_stop() { if (!gsm_data_file) { printf("error: no tch record session in progress\n"); return; } fclose(gsm_data_file); gsm_data_file = 0; printf("TCH DL recording stopped, captured %lu speech frames\n", frame_count); send_tch_config_req(0); } void cmd_tch_record(argc, argv) char **argv; { if (argc < 2) { printf("error: too few arguments\n"); return; } if (strcmp(argv[1], "stop")) cmd_tch_record_start(argv[1]); else cmd_tch_record_stop(); } void show_tch_record_status() { printf("TCH DL recording: %s\n", gsm_data_file ? "RUNNING" : "not running"); }