MT#55283 directly print T.38 attributes

Make sure sdp_attributes is only used for _received_ SDP attributes, and
not ones that we want to send out. The only places where self-generated
attributes are being used is the T.38 gateway.

Change-Id: I1f035cd42a35fa250ea477700a1a88ad59efcc38
pull/1786/head
Richard Fuchs 1 year ago
parent 0a20da45ed
commit 8c99588550

@ -425,6 +425,17 @@ static void append_tagged_attr_to_gstring(GString *s, const char * name, const s
static void append_int_tagged_attr_to_gstring(GString *s, const char * name, unsigned int tag, const str * value,
const sdp_ng_flags *flags, enum media_type media_type);
void sdp_append_str_attr(GString *s, const sdp_ng_flags *flags, enum media_type media_type,
const str *name, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
g_autoptr(GString) gs = g_string_new("");
g_string_vprintf(gs, fmt, ap);
va_end(ap);
append_str_attr_to_gstring(s, name, &STR_INIT_GS(gs), flags, media_type);
}
INLINE void append_attr_to_gstring(GString *s, const char * name, const str * value,
const sdp_ng_flags *flags, enum media_type media_type)
{

@ -332,6 +332,28 @@ static int span_log_level_map(int level) {
return level;
}
void t38_insert_media_attributes(GString *gs, union sdp_attr_print_arg a, const sdp_ng_flags *flags) {
struct t38_gateway *tg = a.cm->t38_gateway;
if (!tg)
return;
sdp_append_attr(gs, flags, MT_IMAGE, "T38FaxVersion", "%i", tg->options.version);
sdp_append_attr(gs, flags, MT_IMAGE, "T38MaxBitRate", "14400");
sdp_append_attr(gs, flags, MT_IMAGE, "T38FaxRateManagement", "%s",
tg->options.local_tcf ? "localTFC" : "transferredTCF");
sdp_append_attr(gs, flags, MT_IMAGE, "T38FaxMaxBuffer", "1800");
sdp_append_attr(gs, flags, MT_IMAGE, "T38FaxMaxDatagram", "512");
if (tg->options.max_ec_entries == 0)
sdp_append_attr(gs, flags, MT_IMAGE, "T38FaxUdpEC", "t38UDPNoEC");
else if (tg->options.fec_span > 1)
sdp_append_attr(gs, flags, MT_IMAGE, "T38FaxUdpEC", "t38UDPFEC");
else
sdp_append_attr(gs, flags, MT_IMAGE, "T38FaxUdpEC", "t38UDPRedundancy");
// XXX more options possible here
}
// call is locked in W
int t38_gateway_pair(struct call_media *t38_media, struct call_media *pcm_media,
const struct t38_options *options)
@ -423,22 +445,7 @@ int t38_gateway_pair(struct call_media *t38_media, struct call_media *pcm_media,
pcm_media->t38_gateway = obj_get(tg);
// add SDP options for T38
t_queue_clear_full(&t38_media->sdp_attributes, str_free);
t_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxVersion:%i", tg->options.version));
t_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38MaxBitRate:14400"));
t_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxRateManagement:%s",
tg->options.local_tcf ? "localTFC" : "transferredTCF"));
t_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxMaxBuffer:1800"));
t_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxMaxDatagram:512"));
if (tg->options.max_ec_entries == 0)
t_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxUdpEC:t38UDPNoEC"));
else if (tg->options.fec_span > 1)
t_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxUdpEC:t38UDPFEC"));
else
t_queue_push_tail(&t38_media->sdp_attributes, str_sprintf("T38FaxUdpEC:t38UDPRedundancy"));
// XXX more options possible here
t38_media->sdp_attr_print = t38_insert_media_attributes;
return 0;
@ -771,7 +778,7 @@ void t38_gateway_stop(struct t38_gateway *tg) {
if (tg->pcm_player)
media_player_stop(tg->pcm_player);
if (tg->t38_media)
t_queue_clear_full(&tg->t38_media->sdp_attributes, str_free);
tg->t38_media->sdp_attr_print = sdp_insert_media_attributes;
}

@ -42,6 +42,11 @@ void sdp_init(void);
sdp_attr_print_f sdp_insert_media_attributes;
sdp_attr_print_f sdp_insert_monologue_attributes;
void sdp_append_str_attr(GString *s, const sdp_ng_flags *flags, enum media_type media_type,
const str *name, const char *fmt, ...)
__attribute__ ((format (printf, 5, 6)));
#define sdp_append_attr(s, g, t, n, f, ...) sdp_append_str_attr(s, g, t, &STR_INIT(n), f, ##__VA_ARGS__)
int sdp_parse(str *body, sdp_sessions_q *sessions, const sdp_ng_flags *);
int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_flags *);
void sdp_streams_clear(sdp_streams_q *);

Loading…
Cancel
Save