Ver código fonte

sdpops: added sdp_content()

- return true of there is a sdp part in the body of sip message
Daniel-Constantin Mierla 12 anos atrás
pai
commit
61472e0470

+ 17 - 0
modules/sdpops/README

@@ -37,6 +37,7 @@ Daniel-Constantin Mierla
               4.9. sdp_with_codecs_by_name(list)
               4.10. sdp_print(level)
               4.11. sdp_get(avpvar)
+              4.12. sdp_content()
 
    List of Examples
 
@@ -51,6 +52,7 @@ Daniel-Constantin Mierla
    1.9. sdp_with_codecs_by_name usage
    1.10. sdp_print usage
    1.11. sdp_get usage
+   1.12. sdp_content usage
 
 Chapter 1. Admin Guide
 
@@ -76,6 +78,7 @@ Chapter 1. Admin Guide
         4.9. sdp_with_codecs_by_name(list)
         4.10. sdp_print(level)
         4.11. sdp_get(avpvar)
+        4.12. sdp_content()
 
 1. Overview
 
@@ -120,6 +123,7 @@ Chapter 1. Admin Guide
    4.9. sdp_with_codecs_by_name(list)
    4.10. sdp_print(level)
    4.11. sdp_get(avpvar)
+   4.12. sdp_content()
 
 4.1. sdp_remove_codecs_by_id(list)
 
@@ -301,3 +305,16 @@ sdp_print("1");
 ...
 sdp_get("$avp(sdp)");
 ...
+
+4.12. sdp_content()
+
+   Return true if the SIP message has SDP body or a SDP part in body.
+
+   This function can be used from ANY_ROUTE.
+
+   Example 1.12. sdp_content usage
+...
+if(sdp_content()) {
+    ...
+}
+...

+ 21 - 0
modules/sdpops/doc/sdpops_admin.xml

@@ -341,6 +341,27 @@ sdp_print("1");
 ...
 sdp_get("$avp(sdp)");
 ...
+</programlisting>
+	    </example>
+	</section>
+	<section>
+	    <title>
+		<function moreinfo="none">sdp_content()</function>
+	    </title>
+	    <para>
+		Return true if the SIP message has SDP body or a SDP part in body.
+	    </para>
+		<para>
+			This function can be used from ANY_ROUTE.
+	    </para>
+		<example>
+		<title><function>sdp_content</function> usage</title>
+		<programlisting format="linespecific">
+...
+if(sdp_content()) {
+    ...
+}
+...
 </programlisting>
 	    </example>
 	</section>

+ 13 - 0
modules/sdpops/sdpops_mod.c

@@ -51,6 +51,7 @@ static int w_sdp_with_codecs_by_name(sip_msg_t* msg, char* codec, char *bar);
 static int w_sdp_remove_media(sip_msg_t* msg, char* media, char *bar);
 static int w_sdp_print(sip_msg_t* msg, char* level, char *bar);
 static int w_sdp_get(sip_msg_t* msg, char *bar);
+static int w_sdp_content(sip_msg_t* msg, char* foo, char *bar);
 
 static int mod_init(void);
 
@@ -81,6 +82,8 @@ static cmd_export_t cmds[] = {
 		1, fixup_igp_null,  0, ANY_ROUTE},
 	{"sdp_get",                  (cmd_function)w_sdp_get,
 		1, 0,  0, ANY_ROUTE},
+	{"sdp_content",                (cmd_function)w_sdp_content,
+		0, 0,  0, ANY_ROUTE},
 	{"bind_sdpops",                (cmd_function)bind_sdpops,
 		1, 0, 0, 0},
 	{0, 0, 0, 0, 0, 0}
@@ -1106,6 +1109,16 @@ static int w_sdp_get(sip_msg_t* msg, char *avp)
 	return 1;
 }
 
+/**
+ *
+ */
+static int w_sdp_content(sip_msg_t* msg, char* foo, char *bar)
+{
+	if(parse_sdp(msg)==0 && msg->body!=NULL)
+		return 1;
+	return -1;
+}
+
 /**
  *
  */