Module: kamailio
Branch: master
Commit: 5ee6747368751c9d428314c92791314c02e601a5
URL: 
https://github.com/kamailio/kamailio/commit/5ee6747368751c9d428314c92791314c02e601a5

Author: Camille Oudot <[email protected]>
Committer: Camille Oudot <[email protected]>
Date: 2015-08-11T15:49:55+02:00

rtpengine: new read_sdp_pv parameter

this parameter allows to specify a script var or AVP for rtpengine to
get the SDP from, instead of the SIP message body.

---

Modified: modules/rtpengine/doc/rtpengine_admin.xml
Modified: modules/rtpengine/rtpengine.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/5ee6747368751c9d428314c92791314c02e601a5.diff
Patch: 
https://github.com/kamailio/kamailio/commit/5ee6747368751c9d428314c92791314c02e601a5.patch

---

diff --git a/modules/rtpengine/doc/rtpengine_admin.xml 
b/modules/rtpengine/doc/rtpengine_admin.xml
index f0029eb..de8bb63 100644
--- a/modules/rtpengine/doc/rtpengine_admin.xml
+++ b/modules/rtpengine/doc/rtpengine_admin.xml
@@ -286,6 +286,31 @@ modparam("rtpengine", "force_send_interface", 
"2001:8d8:1ff:10c0:9a90:96ff:fea8:
 </programlisting>
                </example>
        </section>
+
+       <section id="rtpengine.p.read_sdp_pv">
+               <title><varname>read_sdp_pv</varname> (string)</title>
+               <para>
+                       If this parameter is set to a valid AVP or script var 
specifier, rtpengine
+                       will take the input SDP from this pv instead of the 
message body.
+               </para>
+               <para>
+                       There is no default value.
+               </para>
+               <example>
+               <title>Set <varname>read_sdp_pv</varname> parameter</title>
+<programlisting format="linespecific">
+...
+modparam("rtpengine", "read_sdp_pv", "$var(sdp)")
+...
+route {
+       ...
+       $var(sdp) = $rb + "a=foo:bar\r\n";
+       rtpproxy_manage();
+}
+</programlisting>
+               </example>
+       </section>
+
        <section id="rtpengine.p.write_sdp_pv">
                <title><varname>write_sdp_pv</varname> (string)</title>
                <para>
diff --git a/modules/rtpengine/rtpengine.c b/modules/rtpengine/rtpengine.c
index c67ac5a..eb25232 100644
--- a/modules/rtpengine/rtpengine.c
+++ b/modules/rtpengine/rtpengine.c
@@ -255,6 +255,9 @@ static int_str setid_avp;
 static str            write_sdp_pvar_str = {NULL, 0};
 static pv_spec_t*     write_sdp_pvar = NULL;
 
+static str            read_sdp_pvar_str = {NULL, 0};
+static pv_spec_t*     read_sdp_pvar = NULL;
+
 #define RTPENGINE_SESS_LIMIT_MSG "Parallel session limit reached"
 #define RTPENGINE_SESS_LIMIT_MSG_LEN (sizeof(RTPENGINE_SESS_LIMIT_MSG)-1)
 
@@ -332,6 +335,7 @@ static param_export_t params[] = {
        {"force_send_interface",  PARAM_STRING, &force_send_ip_str      },
        {"rtp_inst_pvar",         PARAM_STR, &rtp_inst_pv_param },
        {"write_sdp_pv",          PARAM_STR, &write_sdp_pvar_str          },
+       {"read_sdp_pv",           PARAM_STR, &read_sdp_pvar_str          },
        {0, 0, 0}
 };
 
@@ -1403,6 +1407,16 @@ mod_init(void)
                }
        }
 
+       if (read_sdp_pvar_str.len > 0) {
+               read_sdp_pvar = pv_cache_get(&read_sdp_pvar_str);
+               if (read_sdp_pvar == NULL
+                   || (read_sdp_pvar->type != PVT_AVP &&  read_sdp_pvar->type 
!= PVT_SCRIPTVAR) ) {
+                       LM_ERR("read_sdp_pv: not a valid AVP or VAR definition 
<%.*s>\n",
+                      read_sdp_pvar_str.len, read_sdp_pvar_str.s);
+                       return -1;
+               }
+       }
+
        if (rtpp_strings)
                pkg_free(rtpp_strings);
 
@@ -1780,6 +1794,7 @@ static bencode_item_t 
*rtpp_function_call(bencode_buffer_t *bencbuf, struct sip_
        int ret, queried_nodes;
        struct rtpp_node *node;
        char *cp;
+       pv_value_t pv_val;
 
        /*** get & init basic stuff needed ***/
 
@@ -1810,7 +1825,16 @@ static bencode_item_t 
*rtpp_function_call(bencode_buffer_t *bencbuf, struct sip_
                ng_flags.replace = bencode_list(bencbuf);
                ng_flags.rtcp_mux = bencode_list(bencbuf);
 
-               if (extract_body(msg, &body) == -1) {
+               if (read_sdp_pvar!= NULL) {
+                       if (read_sdp_pvar->getf(msg,&read_sdp_pvar->pvp, 
&pv_val) < 0)
+                       {
+                               LM_ERR("error getting pvar value <%.*s>\n", 
read_sdp_pvar_str.len, read_sdp_pvar_str.s);
+                               goto error;
+                       } else {
+                               body = pv_val.rs;
+                       }
+
+               } else if (extract_body(msg, &body) == -1) {
                        LM_ERR("can't extract body from the message\n");
                        goto error;
                }


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to