Fixes for telephone event messages

master
Andreas Eversberg 1 month ago
parent bbc4af49e9
commit 20621011be
  1. 20
      src/router/audio.c
  2. 4
      src/router/audio.h
  3. 20
      src/router/call.c
  4. 2
      src/router/call.h

@ -115,7 +115,7 @@ static void gain_samples(sample_t *samples, int length, double gain)
*samples++ *= level;
}
static void send_terminator(call_relation_t *relation, sample_t *samples, int len)
static void send_terminator(call_relation_t *relation, sample_t *samples, int len, uint8_t marker)
{
int16_t spl[len];
@ -123,10 +123,10 @@ static void send_terminator(call_relation_t *relation, sample_t *samples, int le
samples_to_int16_speech(spl, samples, len);
/* encode and send via RTP */
osmo_cc_rtp_send(relation->codec, (uint8_t *)spl, len * sizeof(*spl), 1, len);
osmo_cc_rtp_send(relation->codec, (uint8_t *)spl, len * sizeof(*spl), marker, 1, len);
}
void receive_originator(struct osmo_cc_session_codec *codec, uint16_t sequence, uint32_t timestamp, uint32_t ssrc, uint8_t *data, int len)
void receive_originator(struct osmo_cc_session_codec *codec, uint8_t marker, uint16_t sequence, uint32_t timestamp, uint32_t ssrc, uint8_t *data, int len)
{
call_relation_t *relation = codec->media->session->priv;
call_t *call = relation->call;
@ -135,7 +135,7 @@ void receive_originator(struct osmo_cc_session_codec *codec, uint16_t sequence,
if (codec->decoder == decode_te) {
struct telephone_event *te = (struct telephone_event *)data;
telephone_event(relation, te);
telephone_event(relation, marker, te);
return;
}
@ -154,7 +154,7 @@ void receive_originator(struct osmo_cc_session_codec *codec, uint16_t sequence,
jitter_save(&call->orig_dejitter, samples, len, 1, sequence, timestamp, ssrc);
}
static void send_originator(call_relation_t *relation, sample_t *samples, int len)
static void send_originator(call_relation_t *relation, sample_t *samples, int len, uint8_t marker)
{
int16_t spl[len];
call_t *call = relation->call;
@ -166,10 +166,10 @@ static void send_originator(call_relation_t *relation, sample_t *samples, int le
/* convert samples to int16 */
samples_to_int16_speech(spl, samples, len);
osmo_cc_rtp_send(relation->codec, (uint8_t *)spl, len * sizeof(*spl), 1, len);
osmo_cc_rtp_send(relation->codec, (uint8_t *)spl, len * sizeof(*spl), marker, 1, len);
}
void receive_terminator(struct osmo_cc_session_codec *codec, uint16_t sequence, uint32_t timestamp, uint32_t ssrc, uint8_t *data, int len)
void receive_terminator(struct osmo_cc_session_codec *codec, uint8_t __attribute__((unused)) marker, uint16_t sequence, uint32_t timestamp, uint32_t ssrc, uint8_t *data, int len)
{
call_relation_t *relation = codec->media->session->priv;
call_t *call = relation->call;
@ -267,10 +267,10 @@ void call_clock(int len)
/* record */
if (call->rec.fp)
wave_write(&call->rec, samples, len);
/* forward audio */
send_originator(relation, sbuffer2, len);
/* forward audio (no marker set) */
send_originator(relation, sbuffer2, len, 0);
if (!call->forking && relation->next)
send_terminator(relation->next, sbuffer, len);
send_terminator(relation->next, sbuffer, len, 0);
}
}

@ -1,6 +1,6 @@
void receive_originator(struct osmo_cc_session_codec *codec, uint16_t sequence_number, uint32_t timestamp, uint32_t ssrc, uint8_t *data, int len);
void receive_terminator(struct osmo_cc_session_codec *codec, uint16_t sequence_number, uint32_t timestamp, uint32_t ssrc, uint8_t *data, int len);
void receive_originator(struct osmo_cc_session_codec *codec, uint8_t marker, uint16_t sequence_number, uint32_t timestamp, uint32_t ssrc, uint8_t *data, int len);
void receive_terminator(struct osmo_cc_session_codec *codec, uint8_t marker, uint16_t sequence_number, uint32_t timestamp, uint32_t ssrc, uint8_t *data, int len);
void call_media_handle(void);
void call_clock(int len);
void encode_l16(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len);

@ -2055,19 +2055,29 @@ void routing_close(routing_t *routing)
call_destroy(call);
}
void telephone_event(call_relation_t *relation, struct telephone_event *te)
void telephone_event(call_relation_t *relation, uint8_t marker, struct telephone_event *te)
{
char digit_string[7] = "dtmf x";
if (te->event < 16) {
if (!relation->te_started && !te->e && te->volume <= 36) {
PDEBUG(DROUTER, DEBUG_INFO, "Received start of Telephone-Event '%d'\n", te->event);
if (marker && te->volume <= 36) {
if (!te->e) {
PDEBUG(DROUTER, DEBUG_INFO, "Received start of Telephone-Event '%d' duration=%d ms (marker set)\n", te->event, te->duration / 8);
relation->te_started = 1;
} else
PDEBUG(DROUTER, DEBUG_INFO, "Received start and end of Telephone-Event '%d' duration=%d ms (marker set)\n", te->event, te->duration / 8);
digit_string[5] = "0123456789*#ABCD"[te->event];
} else if (!relation->te_started && !te->e && te->volume <= 36) {
PDEBUG(DROUTER, DEBUG_INFO, "Received start of Telephone-Event '%d' duration=%d ms (marker not set, this is wrong!)\n", te->event, te->duration / 8);
relation->te_started = 1;
digit_string[5] = "0123456789*#ABCD"[te->event];
}
if (relation->te_started && te->e) {
} else if (relation->te_started && !te->e && te->volume <= 36) {
PDEBUG(DROUTER, DEBUG_DEBUG, "Received subsequent Telephone-Event '%d' duration=%d ms\n", te->event, te->duration / 8);
} else if (relation->te_started && te->e) {
PDEBUG(DROUTER, DEBUG_INFO, "Received end of Telephone-Event '%d'\n", te->event);
relation->te_started = 0;
} else if (!relation->te_started && te->e) {
PDEBUG(DROUTER, DEBUG_DEBUG, "Received subsequent end of Telephone-Event '%d'\n", te->event);
}
} else
PDEBUG(DROUTER, DEBUG_INFO, "Received unsupported Telephone-Event '%d'\n", te->event);

@ -96,7 +96,7 @@ int call_init(osmo_cc_endpoint_t *cc_ep1, osmo_cc_endpoint_t *cc_ep2, const char
void call_exit(void);
int call_handle(void);
void cc_message(osmo_cc_endpoint_t *ep, uint32_t callref, osmo_cc_msg_t *msg);
void telephone_event(call_relation_t *relation, struct telephone_event *te);
void telephone_event(call_relation_t *relation, uint8_t marker, struct telephone_event *te);
void routing_help(void);

Loading…
Cancel
Save