actually trigger start + stop of B-channel recordings

This commit is contained in:
Harald Welte 2022-10-16 17:31:47 +02:00
parent 219ca5a323
commit db63cdd38b
1 changed files with 40 additions and 1 deletions

View File

@ -153,6 +153,34 @@ static void calltbl_delete_callref_on_chan_id(struct isdntap_line *line, const s
* Q.931 processing
***********************************************************************/
/* Resolve the B-channel data structure based on a decoded Q.931 Channel ID */
static struct isdntap_ts *get_bchan_ts(struct isdntap_line *line, const struct q931_channel_id *chan_id)
{
if (!chan_id->exclusive) {
return NULL;
}
if (chan_id->d_channel) {
return NULL;
}
if (chan_id->b_channel < 1) {
return NULL;
}
if (chan_id->b_channel >= ARRAY_SIZE(line->ts)) {
return NULL;
}
return &line->ts[chan_id->b_channel];
}
static void gen_chan_label(char *out, size_t out_len, const struct q931_call_state *cstate)
{
char tmbuf[64];
/* convert starting time to a string */
strftime(tmbuf, sizeof(tmbuf), "%Y%m%d-%H%M%s", localtime(&cstate->create_time));
snprintf(out, out_len, "%s-%s-%s", cstate->calling_party.digits, cstate->called_party.digits,
tmbuf);
}
/* append additional digits received (overlap dialling) to called party number */
static void append_called_digits(struct q931_party_number *out, const uint8_t *buf, size_t len)
{
@ -204,6 +232,7 @@ static int isdntap_q931_rx(struct isdntap_line *line, bool net2user, const uint8
{
struct q931_msg_parsed parsed;
struct q931_call_state *cstate;
struct isdntap_ts *ts_b = NULL;
int rc;
rc = q931_msg_parse(&parsed, buf, len);
@ -280,7 +309,13 @@ static int isdntap_q931_rx(struct isdntap_line *line, bool net2user, const uint8
return rc;
if (cstate->chan_id.exclusive && !cstate->chan_id.d_channel) {
/* now we know the exact B channel used */
/* TODO: start capturing */
/* start B-channel capturing */
ts_b = get_bchan_ts(line, &cstate->chan_id);
if (!ts_b)
break;
char strbuf[256];
gen_chan_label(strbuf, sizeof(strbuf), cstate);
isdntap_ts_start_bchan(ts_b, strbuf);
}
}
break;
@ -289,6 +324,10 @@ static int isdntap_q931_rx(struct isdntap_line *line, bool net2user, const uint8
/* forget about the call */
calltbl_delete_callref(cstate);
cstate = NULL;
/* stop B channel capture */
ts_b = get_bchan_ts(line, &cstate->chan_id);
if (ts_b)
isdntap_ts_stop_bchan(ts_b);
break;
default:
break;