summaryrefslogtreecommitdiffstats
path: root/src/router/audio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/router/audio.c')
-rw-r--r--src/router/audio.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/router/audio.c b/src/router/audio.c
index 0c4b6c3..16e83c0 100644
--- a/src/router/audio.c
+++ b/src/router/audio.c
@@ -127,6 +127,12 @@ void receive_originator(struct osmo_cc_session_codec *codec, uint16_t __attribut
len = len / 2;
sample_t samples[len];
+ if (codec->decoder == decode_te) {
+ struct telephone_event *te = (struct telephone_event *)data;
+ telephone_event(relation, te);
+ return;
+ }
+
/* convert int16 to samples */
int16_to_samples(samples, (int16_t *)data, len);
@@ -169,6 +175,11 @@ void receive_terminator(struct osmo_cc_session_codec *codec, uint16_t __attribut
len = len / 2;
sample_t samples[len];
+ if (codec->decoder == decode_te) {
+ PDEBUG(DROUTER, DEBUG_NOTICE, "Ignoring received telephony-events from terminator.\n");
+ return;
+ }
+
int16_to_samples(samples, (int16_t *)data, len);
/* forward to originator, if not a forking call */
@@ -284,3 +295,29 @@ void decode_l16(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len
*dst_len = len * 2;
}
+void encode_te(uint8_t __attribute__((unused)) *src_data, int __attribute__((unused)) src_len, uint8_t **dst_data, int *dst_len)
+{
+ /* FIXME: TBD... */
+ *dst_data = NULL;
+ *dst_len = 0;
+}
+
+void decode_te(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len)
+{
+ uint8_t *src = src_data;
+ struct telephone_event *te;
+
+ if (src_len < 4)
+ return;
+
+ te = calloc(1, sizeof(*te));
+ if (!te)
+ return;
+ te->event = src[0];
+ te->e = src[1] >> 7;
+ te->r = (src[1] >> 6) & 0x1;
+ te->volume = src[1] & 0x3f;
+ te->duration = (src[2] << 16) | src[3];
+ *dst_data = (uint8_t *)te;
+ *dst_len = sizeof(*te);
+}