diff --git a/README.md b/README.md index baf55493e..575123352 100644 --- a/README.md +++ b/README.md @@ -861,11 +861,18 @@ Optionally included keys are: Replace the address found in the *session-level connection* (c=) line of the SDP body. Corresponds to *rtpproxy* `c` flag. - - `SDP version` + - `SDP version` or `SDP-version` Take control of the version field in the SDP and make sure it's increased every time the SDP changes, and left unchanged if the SDP is the same. + - `username` + + Take control of the origin username field in the SDP. With this + option in use, *rtpengine* will make sure the username field in + the `o=` line always remains the same in all SDPs going to a + particular RTP endpoint. + - `zero address` Using a zero endpoint address is an obsolete way to signal a diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 5556e67c5..34ac9c14c 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -719,6 +719,9 @@ static void call_ng_flags_replace(struct sdp_ng_flags *out, str *s, void *dummy) case CSH_LOOKUP("SDP-version"): out->replace_sdp_version = 1; break; + case CSH_LOOKUP("username"): + out->replace_username = 1; + break; case CSH_LOOKUP("zero-address"): out->replace_zero_address = 1; break; diff --git a/daemon/sdp.c b/daemon/sdp.c index e8c165c2f..0017f4780 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -2455,8 +2455,21 @@ int sdp_replace(struct sdp_chopper *chop, GQueue *sessions, struct call_monologu goto error; ps = j->data; + err = "error while processing o= line"; + if (!monologue->sdp_username) + monologue->sdp_username = call_strdup_len(monologue->call, session->origin.username.s, + session->origin.username.len); + else if (flags->replace_username) { + if (copy_up_to(chop, &session->origin.username)) + goto error; + chopper_append_c(chop, monologue->sdp_username); + if (skip_over(chop, &session->origin.username)) + goto error; + } + // record position of o= line and init SDP version - copy_up_to(chop, &session->origin.version_str); + if (copy_up_to(chop, &session->origin.version_str)) + goto error; session->origin.version_output_pos = chop->output->len; if (!monologue->sdp_version) { monologue->sdp_version = session->origin.version_num; diff --git a/include/call.h b/include/call.h index 8a2e24ca6..58d075951 100644 --- a/include/call.h +++ b/include/call.h @@ -374,6 +374,7 @@ struct call_monologue { struct media_player *player; unsigned long long sdp_version; GString *last_sdp; + char *sdp_username; unsigned int block_dtmf:1; unsigned int block_media:1; diff --git a/include/call_interfaces.h b/include/call_interfaces.h index 4ffdc3f7a..4baecfa2d 100644 --- a/include/call_interfaces.h +++ b/include/call_interfaces.h @@ -74,6 +74,7 @@ struct sdp_ng_flags { replace_origin:1, replace_sess_conn:1, replace_sdp_version:1, + replace_username:1, replace_zero_address:1, rtcp_mux_offer:1, rtcp_mux_require:1, diff --git a/utils/rtpengine-ng-client b/utils/rtpengine-ng-client index 8aa56f0df..073b03be6 100755 --- a/utils/rtpengine-ng-client +++ b/utils/rtpengine-ng-client @@ -29,6 +29,7 @@ GetOptions( 'replace-origin' => \$options{'replace-origin'}, 'replace-session-connection' => \$options{'replace-session connection'}, 'replace-sdp-version' => \$options{'replace-sdp version'}, + 'replace-username' => \$options{'replace-username'}, 'client-address=s' => \$options{'client-address'}, 'sdp=s' => \$options{'sdp'}, 'sdp-file=s' => \$options{'sdp-file'}, @@ -101,7 +102,7 @@ for my $x (split(/,/, 'TOS,delete-delay')) { for my $x (split(/,/, 'trust address,symmetric,asymmetric,unidirectional,force,strict source,media handover,sip source address,reset,port latching,no rtcp attribute,full rtcp attribute,loop protect,record call,always transcode,all,pad crypto,generate mid,fragment,original sendrecv,symmetric codecs,asymmetric codecs,inject DTMF,generate RTCP,single codec,reorder codecs')) { defined($options{$x}) and push(@{$packet{flags}}, $x); } -for my $x (split(/,/, 'origin,session connection,sdp version')) { +for my $x (split(/,/, 'origin,session connection,sdp version,username')) { defined($options{'replace-' . $x}) and push(@{$packet{replace}}, $x); } for my $x (split(/,/, 'rtcp-mux,SDES,supports,T.38,OSRTP')) {