MT#61352 support default signalling templates

Change-Id: Ifad2d5958defc8c7995be8bb6569885ae6749dc9
pull/1884/head
Richard Fuchs 7 months ago
parent 643547377f
commit 352465fc6a

@ -37,6 +37,7 @@ static pcre2_code *streams_re;
bool trust_address_def;
bool dtls_passive_def;
str_case_value_ht rtpe_signalling_templates;
str rtpe_default_signalling_templates[OP_COUNT + 1];
enum basic_errors {
NG_ERROR_NO_SDP_BODY = 1,
@ -2090,6 +2091,14 @@ static void call_ng_process_flags(sdp_ng_flags *out, ng_command_ctx_t *ctx, enum
call_ng_flags_init(out, opmode);
ctx->opmode = opmode;
ctx->flags = out;
// check for default templates, "default" first
if (rtpe_default_signalling_templates[OP_OTHER].len)
parse_rtpp_flags(&rtpe_default_signalling_templates[OP_OTHER], out);
// and then one matching the current command
if (opmode != OP_OTHER && rtpe_default_signalling_templates[opmode].len)
parse_rtpp_flags(&rtpe_default_signalling_templates[opmode], out);
parser->dict_iter(parser, ctx->req, call_ng_main_flags, out);
}
@ -4028,6 +4037,19 @@ static void parse_templates(GHashTable *templates) {
char *value = valuep;
t_hash_table_insert(rtpe_signalling_templates, str_dup(STR_PTR(key)), str_dup(STR_PTR(value)));
}
// look for templates matching known commands
for (unsigned int i = 0; i < OP_COUNT; i++) {
const char *cmd = ng_command_strings[i];
str *tmpl = t_hash_table_lookup(rtpe_signalling_templates, STR_PTR(cmd));
if (tmpl)
rtpe_default_signalling_templates[i] = *tmpl;
}
// finally look for "default" and store it in the OTHER slot
str *tmpl = t_hash_table_lookup(rtpe_signalling_templates, STR_PTR("default"));
if (tmpl)
rtpe_default_signalling_templates[OP_OTHER] = *tmpl;
}
int call_interfaces_init(GHashTable *templates) {

@ -1576,6 +1576,14 @@ The __offer__ command in Kamailio or OpenSIPS can then simply be turned into:
rtpengine_offer("template=WebRTC");
In addition to named signalling templates, *rtpengine* supports default
signalling templates that are automatically applied. Default signalling
templates are templates using a name that matches a signalling command (e.g.
__offer__ or __start recording__), or the special name __default__ which is a
template that is applied to all signalling messages. These templates are
automatically applied without needing to refer to them by name using
__template=...__ from within the signalling message.
## EXIT STATUS
- __0__

@ -264,6 +264,7 @@ RTPE_NG_FLAGS_STR_CASE_HT_PARAMS
extern bool trust_address_def;
extern bool dtls_passive_def;
extern str_case_value_ht rtpe_signalling_templates;
extern str rtpe_default_signalling_templates[OP_COUNT + 1];
str *call_request_tcp(char **);
str *call_lookup_tcp(char **);

@ -101,7 +101,8 @@ include ../lib/common.Makefile
daemon-tests-main daemon-tests-jb daemon-tests-dtx daemon-tests-dtx-cn daemon-tests-pubsub \
daemon-tests-intfs daemon-tests-stats daemon-tests-delay-buffer daemon-tests-delay-timing \
daemon-tests-evs daemon-tests-player-cache daemon-tests-redis daemon-tests-redis-json \
daemon-tests-measure-rtp daemon-tests-mos-legacy daemon-tests-mos-fullband daemon-tests-config-file
daemon-tests-measure-rtp daemon-tests-mos-legacy daemon-tests-mos-fullband daemon-tests-config-file \
daemon-tests-templ-def daemon-tests-templ-def-offer
TESTS= test-bitstr aes-crypt aead-aes-crypt test-const_str_hash.strhash
ifeq ($(with_transcoding),yes)
@ -140,7 +141,8 @@ daemon-tests: daemon-tests-main daemon-tests-jb daemon-tests-pubsub daemon-tests
daemon-tests-audio-player daemon-tests-audio-player-play-media \
daemon-tests-intfs daemon-tests-stats daemon-tests-player-cache daemon-tests-redis \
daemon-tests-rtpp-flags daemon-tests-redis-json daemon-tests-measure-rtp daemon-tests-mos-legacy \
daemon-tests-mos-fullband daemon-tests-config-file
daemon-tests-mos-fullband daemon-tests-config-file \
daemon-tests-templ-def daemon-tests-templ-def-offer
daemon-test-deps: tests-preload.so
$(MAKE) -C ../daemon
@ -211,6 +213,12 @@ daemon-tests-mos-fullband: daemon-test-deps
daemon-tests-config-file: daemon-test-deps
./auto-test-helper "$@" perl -I../perl auto-daemon-tests-config-file.pl
daemon-tests-templ-def-offer: daemon-test-deps
./auto-test-helper "$@" perl -I../perl auto-daemon-tests-templ-def-offer.pl
daemon-tests-templ-def: daemon-test-deps
./auto-test-helper "$@" perl -I../perl auto-daemon-tests-templ-def.pl
test-bitstr: test-bitstr.o
test-mix-buffer: test-mix-buffer.o $(COMMONOBJS) mix_buffer.o ssrc.o rtp.o crypto.o helpers.o \

@ -0,0 +1,64 @@
#!/usr/bin/perl
use strict;
use warnings;
use NGCP::Rtpengine::Test;
use NGCP::Rtpclient::SRTP;
use NGCP::Rtpengine::AutoTest;
use Test::More;
use Test2::Tools::Compare qw();
use NGCP::Rtpclient::ICE;
use POSIX;
autotest_start(qw(--config-file=test3.conf)) or die;
my ($sock_a, $sock_b, $sock_c, $sock_d, $port_a, $port_b, $ssrc, $ssrc_b, $resp,
$sock_ax, $sock_bx, $port_ax, $port_bx,
$srtp_ctx_a, $srtp_ctx_b, $srtp_ctx_a_rev, $srtp_ctx_b_rev, $ufrag_a, $ufrag_b,
@ret1, @ret2, @ret3, @ret4, $srtp_key_a, $srtp_key_b, $ts, $seq, $has_recv);
new_call;
offer('template', { }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 172.17.0.2
s=tester
c=IN IP4 198.51.100.19
t=0 0
m=audio 6000 RTP/AVP 0 8
----------------------------------
v=0
o=- 1545997027 1 IN IP4 172.17.0.2
s=tester
t=0 0
m=audio PORT UDP/TLS/RTP/SAVPF 0 8
c=IN IP4 203.0.113.1
a=mid:1
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=sendrecv
a=rtcp-mux
a=setup:actpass
a=fingerprint:sha-256 FINGERPRINT256
a=tls-id:TLS_ID
a=ice-ufrag:ICEUFRAG
a=ice-pwd:ICEPWD
a=ice-options:trickle
a=candidate:ICEBASE 1 UDP 2130706431 203.0.113.1 PORT typ host
a=candidate:ICEBASE 1 UDP 2130706175 203.0.113.2 PORT typ host
a=candidate:ICEBASE 1 UDP 2130705919 2001:db8:4321::1 PORT typ host
a=candidate:ICEBASE 1 UDP 2130705663 2001:db8:4321::2 PORT typ host
a=end-of-candidates
SDP
#done_testing;NGCP::Rtpengine::AutoTest::terminate('f00');exit;
done_testing();

@ -0,0 +1,64 @@
#!/usr/bin/perl
use strict;
use warnings;
use NGCP::Rtpengine::Test;
use NGCP::Rtpclient::SRTP;
use NGCP::Rtpengine::AutoTest;
use Test::More;
use Test2::Tools::Compare qw();
use NGCP::Rtpclient::ICE;
use POSIX;
autotest_start(qw(--config-file=test2.conf)) or die;
my ($sock_a, $sock_b, $sock_c, $sock_d, $port_a, $port_b, $ssrc, $ssrc_b, $resp,
$sock_ax, $sock_bx, $port_ax, $port_bx,
$srtp_ctx_a, $srtp_ctx_b, $srtp_ctx_a_rev, $srtp_ctx_b_rev, $ufrag_a, $ufrag_b,
@ret1, @ret2, @ret3, @ret4, $srtp_key_a, $srtp_key_b, $ts, $seq, $has_recv);
new_call;
offer('template', { }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 172.17.0.2
s=tester
c=IN IP4 198.51.100.19
t=0 0
m=audio 6000 RTP/AVP 0 8
----------------------------------
v=0
o=- 1545997027 1 IN IP4 172.17.0.2
s=tester
t=0 0
m=audio PORT UDP/TLS/RTP/SAVPF 0 8
c=IN IP4 203.0.113.1
a=mid:1
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=sendrecv
a=rtcp-mux
a=setup:actpass
a=fingerprint:sha-256 FINGERPRINT256
a=tls-id:TLS_ID
a=ice-ufrag:ICEUFRAG
a=ice-pwd:ICEPWD
a=ice-options:trickle
a=candidate:ICEBASE 1 UDP 2130706431 203.0.113.1 PORT typ host
a=candidate:ICEBASE 1 UDP 2130706175 203.0.113.2 PORT typ host
a=candidate:ICEBASE 1 UDP 2130705919 2001:db8:4321::1 PORT typ host
a=candidate:ICEBASE 1 UDP 2130705663 2001:db8:4321::2 PORT typ host
a=end-of-candidates
SDP
#done_testing;NGCP::Rtpengine::AutoTest::terminate('f00');exit;
done_testing();

@ -0,0 +1,11 @@
[rtpengine]
table = -1
interface = 203.0.113.1 ; 2001:db8:4321::1 ; 203.0.113.2 ; 2001:db8:4321::2 ; foobar/203.0.113.3 ; quux/203.0.113.4
listen-ng = 2223
foreground = true
log-level = 7
log-stderr = true
templates = templates
[templates]
default = transport-protocol=UDP/TLS/RTP/SAVPF ICE=force trickle-ICE rtcp-mux=[offer require] no-rtcp-attribute SDES=off generate-mid

@ -0,0 +1,11 @@
[rtpengine]
table = -1
interface = 203.0.113.1 ; 2001:db8:4321::1 ; 203.0.113.2 ; 2001:db8:4321::2 ; foobar/203.0.113.3 ; quux/203.0.113.4
listen-ng = 2223
foreground = true
log-level = 7
log-stderr = true
templates = templates
[templates]
offer = transport-protocol=UDP/TLS/RTP/SAVPF ICE=force trickle-ICE rtcp-mux=[offer require] no-rtcp-attribute SDES=off generate-mid
Loading…
Cancel
Save