Hello,
We need to replace a=sendrecv with a=sendonly in the 200 OK reply to an INVITE. In theory it should be something straightforward, like in the onreply_route using:
replace_body_all( "a=sendrecv", "a=sendonly" );
or:
subst_body( '/^a=sendrecv/a=sendonly/' )
Our first problem is that these both are appending a=sendonly to the end of the SDP, not replacing values within it. Does anyone know why this might happen?
Our second problem is that we really only want to do this for video media, and not touch the audio media. Are there any text tools that allow you to work with specific media within the SDP?
Thanks in advance for any tips!
Hello David,
are you using another module or function that also works on the SDP? Then they probably interfere with each other.
Regarding the video topic, have a look to the sdpops module, sdp_with_media for example.
Cheers,
Henning
-- Henning Westerholt – https://skalatan.de/blog/ Kamailio services – https://gilawa.comhttps://gilawa.com/
From: David Cunningham via sr-users sr-users@lists.kamailio.org Sent: Mittwoch, 17. Dezember 2025 02:09 To: Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org Cc: David Cunningham dcunningham@voisonics.com Subject: [SR-Users] Replacing an attribute in the SDP
Hello,
We need to replace a=sendrecv with a=sendonly in the 200 OK reply to an INVITE. In theory it should be something straightforward, like in the onreply_route using:
replace_body_all( "a=sendrecv", "a=sendonly" );
or:
subst_body( '/^a=sendrecv/a=sendonly/' )
Our first problem is that these both are appending a=sendonly to the end of the SDP, not replacing values within it. Does anyone know why this might happen?
Our second problem is that we really only want to do this for video media, and not touch the audio media. Are there any text tools that allow you to work with specific media within the SDP?
Thanks in advance for any tips!
-- David Cunningham, Voisonics Limited http://voisonics.com/ USA: +1 213 221 1092 New Zealand: +64 (0)28 2558 3782
Hello,
On 17.12.25 02:08, David Cunningham via sr-users wrote:
Hello,
We need to replace a=sendrecv with a=sendonly in the 200 OK reply to an INVITE. In theory it should be something straightforward, like in the onreply_route using:
replace_body_all( "a=sendrecv", "a=sendonly" );
or:
subst_body( '/^a=sendrecv/a=sendonly/' )
Our first problem is that these both are appending a=sendonly to the end of the SDP, not replacing values within it. Does anyone know why this might happen?
it could be because of conflicting operations with rtpengine (or rtpproxy). You could try the replacement in the core reply_route() and then use msg_apply_changes.
Our second problem is that we really only want to do this for video media, and not touch the audio media. Are there any text tools that allow you to work with specific media within the SDP?
The sdpops has an sdp iterator that could help: once you match the video stream, look for the sendrecv attrbute and replace the line.
Cheers, Daniel
Hi Henning and Daniel,
Thank you very much for the replies. We moved the following configuration to reply_route{}, and now it inserts "a=sendonly" immediately before the "a=sendrecv" rather than appending it to the SDP as before. This configuration does use RTPengine as the call is from a WebRTC client. Have you any further idea why it's not actually replacing the "a=sendonly"?
replace_body_all( "a=sendrecv", "a=sendonly" ); msg_apply_changes();
Daniel, from reading the sdpops documentation it's not clear how to iterate through an SDP. Could you please give us a pointer on that?
Thanks again.
On Thu, 18 Dec 2025 at 00:23, Daniel-Constantin Mierla miconda@gmail.com wrote:
Hello,
On 17.12.25 02:08, David Cunningham via sr-users wrote:
Hello,
We need to replace a=sendrecv with a=sendonly in the 200 OK reply to an INVITE. In theory it should be something straightforward, like in the onreply_route using:
replace_body_all( "a=sendrecv", "a=sendonly" );
or:
subst_body( '/^a=sendrecv/a=sendonly/' )
Our first problem is that these both are appending a=sendonly to the end of the SDP, not replacing values within it. Does anyone know why this might happen?
it could be because of conflicting operations with rtpengine (or rtpproxy). You could try the replacement in the core reply_route() and then use msg_apply_changes.
Our second problem is that we really only want to do this for video media, and not touch the audio media. Are there any text tools that allow you to work with specific media within the SDP?
The sdpops has an sdp iterator that could help: once you match the video stream, look for the sendrecv attrbute and replace the line.
Cheers, Daniel
-- Daniel-Constantin Mierla (@ asipto.com)twitter.com/miconda -- linkedin.com/in/miconda Kamailio Consultancy, Training and Development Services -- asipto.com Kamailio World Conference, May 7-8, 2026 - Berlin, Germany -- kamailioworld.com
Hello,
On 17.12.25 23:35, David Cunningham wrote:
Hi Henning and Daniel,
Thank you very much for the replies. We moved the following configuration to reply_route{}, and now it inserts "a=sendonly" immediately before the "a=sendrecv" rather than appending it to the SDP as before. This configuration does use RTPengine as the call is from a WebRTC client. Have you any further idea why it's not actually replacing the "a=sendonly"?
replace_body_all( "a=sendrecv", "a=sendonly" ); msg_apply_changes();
Daniel, from reading the sdpops documentation it's not clear how to iterate through an SDP. Could you please give us a pointer on that?
the functions to remove/insert/append should show how to use the iterator, e.g.,:
- https://www.kamailio.org/docs/modules/stable/modules/sdpops.html#sdpops.f.sd...
For example, to replace for all media sessions:
sdp_iterator_start("s1"); while(sdp_iterator_next("s1")) { if($sdpitval(s1) =~ "^a=sendrecv") { sdp_iterator_rm("s1"); sdp_iterator_append("s1", "a=sendonly\r\n"); } } sdp_iterator_end("s1");
Cheers, Daniel
Thanks again.
On Thu, 18 Dec 2025 at 00:23, Daniel-Constantin Mierla miconda@gmail.com wrote:
Hello, On 17.12.25 02:08, David Cunningham via sr-users wrote:Hello, We need to replace a=sendrecv with a=sendonly in the 200 OK reply to an INVITE. In theory it should be something straightforward, like in the onreply_route using: replace_body_all( "a=sendrecv", "a=sendonly" ); or: subst_body( '/^a=sendrecv/a=sendonly/' ) Our first problem is that these both are appending a=sendonly to the end of the SDP, not replacing values within it. Does anyone know why this might happen?it could be because of conflicting operations with rtpengine (or rtpproxy). You could try the replacement in the core reply_route() and then use msg_apply_changes.Our second problem is that we really only want to do this for video media, and not touch the audio media. Are there any text tools that allow you to work with specific media within the SDP?The sdpops has an sdp iterator that could help: once you match the video stream, look for the sendrecv attrbute and replace the line. Cheers, Daniel -- Daniel-Constantin Mierla (@ asipto.com <http://asipto.com>) twitter.com/miconda <http://twitter.com/miconda> -- linkedin.com/in/miconda <http://linkedin.com/in/miconda> Kamailio Consultancy, Training and Development Services -- asipto.com <http://asipto.com> Kamailio World Conference, May 7-8, 2026 - Berlin, Germany -- kamailioworld.com <http://kamailioworld.com>-- David Cunningham, Voisonics Limited http://voisonics.com/ USA: +1 213 221 1092 New Zealand: +64 (0)28 2558 3782
Thanks Daniel. I had been looking at the documentation for 5.2 since that's what the customer uses, and it appears that those functions are new in 5.8. We'll upgrade and give it a try.
On Fri, 19 Dec 2025 at 05:39, Daniel-Constantin Mierla miconda@gmail.com wrote:
Hello, On 17.12.25 23:35, David Cunningham wrote:
Hi Henning and Daniel,
Thank you very much for the replies. We moved the following configuration to reply_route{}, and now it inserts "a=sendonly" immediately before the "a=sendrecv" rather than appending it to the SDP as before. This configuration does use RTPengine as the call is from a WebRTC client. Have you any further idea why it's not actually replacing the "a=sendonly"?
replace_body_all( "a=sendrecv","a=sendonly" ); msg_apply_changes();
Daniel, from reading the sdpops documentation it's not clear how to iterate through an SDP. Could you please give us a pointer on that?
the functions to remove/insert/append should show how to use the iterator, e.g.,:
https://www.kamailio.org/docs/modules/stable/modules/sdpops.html#sdpops.f.sd...
For example, to replace for all media sessions:
sdp_iterator_start("s1"); while(sdp_iterator_next("s1")) { if($sdpitval(s1) =~ "^a=sendrecv") { sdp_iterator_rm("s1"); sdp_iterator_append("s1", "a=sendonly\r\n"); } } sdp_iterator_end("s1");Cheers, Daniel
Thanks again.
On Thu, 18 Dec 2025 at 00:23, Daniel-Constantin Mierla miconda@gmail.com wrote:
Hello,
On 17.12.25 02:08, David Cunningham via sr-users wrote:
Hello,
We need to replace a=sendrecv with a=sendonly in the 200 OK reply to an INVITE. In theory it should be something straightforward, like in the onreply_route using:
replace_body_all( "a=sendrecv", "a=sendonly" );
or:
subst_body( '/^a=sendrecv/a=sendonly/' )
Our first problem is that these both are appending a=sendonly to the end of the SDP, not replacing values within it. Does anyone know why this might happen?
it could be because of conflicting operations with rtpengine (or rtpproxy). You could try the replacement in the core reply_route() and then use msg_apply_changes.
Our second problem is that we really only want to do this for video media, and not touch the audio media. Are there any text tools that allow you to work with specific media within the SDP?
The sdpops has an sdp iterator that could help: once you match the video stream, look for the sendrecv attrbute and replace the line.
Cheers, Daniel
-- Daniel-Constantin Mierla (@ asipto.com)twitter.com/miconda -- linkedin.com/in/miconda Kamailio Consultancy, Training and Development Services -- asipto.com Kamailio World Conference, May 7-8, 2026 - Berlin, Germany -- kamailioworld.com
-- David Cunningham, Voisonics Limited http://voisonics.com/ USA: +1 213 221 1092 New Zealand: +64 (0)28 2558 3782
-- Daniel-Constantin Mierla (@ asipto.com)twitter.com/miconda -- linkedin.com/in/miconda Kamailio Consultancy, Training and Development Services -- asipto.com Kamailio World Conference, May 7-8, 2026 - Berlin, Germany -- kamailioworld.com
The following works moderately well in only acting on the video media. However, it still appends "a=sendonly" to the end of the SDP rather than replacing the "a=sendrecv". Using "sdp_iterator_insert" instead of "sdp_iterator_append" makes no difference.
Does anyone have any further advice on the possible cause? Thanks in advance.
sdp_iterator_start( "s1" ); $var(media) = "other"; while ( sdp_iterator_next( "s1" ) ) { if ( $sdpitval(s1) =~ "^m=video" ) { $var(media) = "video"; } else if ( $sdpitval(s1) =~ "^m=" ) { $var(media) = "other"; } else if ( $var(media) == "video" && $sdpitval(s1) =~ "^a=sendrecv" ) { sdp_iterator_rm( "s1" ); sdp_iterator_append( "s1", "a=sendonly\r\n" ); } } sdp_iterator_end( "s1" );
On Fri, 19 Dec 2025 at 08:55, David Cunningham dcunningham@voisonics.com wrote:
Thanks Daniel. I had been looking at the documentation for 5.2 since that's what the customer uses, and it appears that those functions are new in 5.8. We'll upgrade and give it a try.
On Fri, 19 Dec 2025 at 05:39, Daniel-Constantin Mierla miconda@gmail.com wrote:
Hello, On 17.12.25 23:35, David Cunningham wrote:
Hi Henning and Daniel,
Thank you very much for the replies. We moved the following configuration to reply_route{}, and now it inserts "a=sendonly" immediately before the "a=sendrecv" rather than appending it to the SDP as before. This configuration does use RTPengine as the call is from a WebRTC client. Have you any further idea why it's not actually replacing the "a=sendonly"?
replace_body_all( "a=sendrecv","a=sendonly" ); msg_apply_changes();
Daniel, from reading the sdpops documentation it's not clear how to iterate through an SDP. Could you please give us a pointer on that?
the functions to remove/insert/append should show how to use the iterator, e.g.,:
https://www.kamailio.org/docs/modules/stable/modules/sdpops.html#sdpops.f.sd...
For example, to replace for all media sessions:
sdp_iterator_start("s1"); while(sdp_iterator_next("s1")) { if($sdpitval(s1) =~ "^a=sendrecv") { sdp_iterator_rm("s1"); sdp_iterator_append("s1", "a=sendonly\r\n"); } } sdp_iterator_end("s1");Cheers, Daniel
Thanks again.
On Thu, 18 Dec 2025 at 00:23, Daniel-Constantin Mierla miconda@gmail.com wrote:
Hello,
On 17.12.25 02:08, David Cunningham via sr-users wrote:
Hello,
We need to replace a=sendrecv with a=sendonly in the 200 OK reply to an INVITE. In theory it should be something straightforward, like in the onreply_route using:
replace_body_all( "a=sendrecv", "a=sendonly" );
or:
subst_body( '/^a=sendrecv/a=sendonly/' )
Our first problem is that these both are appending a=sendonly to the end of the SDP, not replacing values within it. Does anyone know why this might happen?
it could be because of conflicting operations with rtpengine (or rtpproxy). You could try the replacement in the core reply_route() and then use msg_apply_changes.
Our second problem is that we really only want to do this for video media, and not touch the audio media. Are there any text tools that allow you to work with specific media within the SDP?
The sdpops has an sdp iterator that could help: once you match the video stream, look for the sendrecv attrbute and replace the line.
Cheers, Daniel
-- Daniel-Constantin Mierla (@ asipto.com)twitter.com/miconda -- linkedin.com/in/miconda Kamailio Consultancy, Training and Development Services -- asipto.com Kamailio World Conference, May 7-8, 2026 - Berlin, Germany -- kamailioworld.com
-- David Cunningham, Voisonics Limited http://voisonics.com/ USA: +1 213 221 1092 New Zealand: +64 (0)28 2558 3782
-- Daniel-Constantin Mierla (@ asipto.com)twitter.com/miconda -- linkedin.com/in/miconda Kamailio Consultancy, Training and Development Services -- asipto.com Kamailio World Conference, May 7-8, 2026 - Berlin, Germany -- kamailioworld.com
-- David Cunningham, Voisonics Limited http://voisonics.com/ USA: +1 213 221 1092 New Zealand: +64 (0)28 2558 3782