2
0
Эх сурвалжийг харах

sdpops: New function sdp_with_active_media

- Return true of the SDP has 'media=type ...' line and the media is active.
- Active media means the port is non-zero and the direction is not "inactive"
Andrew Miller 11 жил өмнө
parent
commit
083f7c8e5d

+ 104 - 81
modules/sdpops/README

@@ -10,7 +10,7 @@ Daniel-Constantin Mierla
 
 
    <[email protected]>
    <[email protected]>
 
 
-   Copyright © 2011 asipto.com
+   Copyright © 2011 asipto.com
      __________________________________________________________________
      __________________________________________________________________
 
 
    Table of Contents
    Table of Contents
@@ -32,18 +32,19 @@ Daniel-Constantin Mierla
               4.4. sdp_keep_codecs_by_id(list [, mtype])
               4.4. sdp_keep_codecs_by_id(list [, mtype])
               4.5. sdp_keep_codecs_by_name(list [, mtype])
               4.5. sdp_keep_codecs_by_name(list [, mtype])
               4.6. sdp_with_media(type)
               4.6. sdp_with_media(type)
-              4.7. sdp_remove_media(type)
-              4.8. sdp_with_transport(type)
-              4.9. sdp_with_transport_like(string)
-              4.10. sdp_transport(pv)
-              4.11. sdp_remove_transport(type)
-              4.12. sdp_with_codecs_by_id(list)
-              4.13. sdp_with_codecs_by_name(list)
-              4.14. sdp_print(level)
-              4.15. sdp_get(avpvar)
-              4.16. sdp_content()
-              4.17. sdp_with_ice()
-              4.18. sdp_get_line_startswith(avpvar, string)
+              4.7. sdp_with_active_media(type)
+              4.8. sdp_remove_media(type)
+              4.9. sdp_with_transport(type)
+              4.10. sdp_with_transport_like(string)
+              4.11. sdp_transport(pv)
+              4.12. sdp_remove_transport(type)
+              4.13. sdp_with_codecs_by_id(list)
+              4.14. sdp_with_codecs_by_name(list)
+              4.15. sdp_print(level)
+              4.16. sdp_get(avpvar)
+              4.17. sdp_content()
+              4.18. sdp_with_ice()
+              4.19. sdp_get_line_startswith(avpvar, string)
 
 
    List of Examples
    List of Examples
 
 
@@ -53,18 +54,19 @@ Daniel-Constantin Mierla
    1.4. sdp_keep_codecs_by_id usage
    1.4. sdp_keep_codecs_by_id usage
    1.5. sdp_keep_codecs_by_name usage
    1.5. sdp_keep_codecs_by_name usage
    1.6. sdp_with_media usage
    1.6. sdp_with_media usage
-   1.7. sdp_remove_media usage
-   1.8. sdp_with_transport usage
-   1.9. sdp_with_transport_like usage
-   1.10. sdp_transport usage
-   1.11. sdp_remove_transport usage
-   1.12. sdp_with_codecs_by_id usage
-   1.13. sdp_with_codecs_by_name usage
-   1.14. sdp_print usage
-   1.15. sdp_get usage
-   1.16. sdp_content usage
-   1.17. sdp_with_ice usage
-   1.18. sdp_get_line_startswith usage
+   1.7. sdp_with_active_media usage
+   1.8. sdp_remove_media usage
+   1.9. sdp_with_transport usage
+   1.10. sdp_with_transport_like usage
+   1.11. sdp_transport usage
+   1.12. sdp_remove_transport usage
+   1.13. sdp_with_codecs_by_id usage
+   1.14. sdp_with_codecs_by_name usage
+   1.15. sdp_print usage
+   1.16. sdp_get usage
+   1.17. sdp_content usage
+   1.18. sdp_with_ice usage
+   1.19. sdp_get_line_startswith usage
 
 
 Chapter 1. Admin Guide
 Chapter 1. Admin Guide
 
 
@@ -85,18 +87,19 @@ Chapter 1. Admin Guide
         4.4. sdp_keep_codecs_by_id(list [, mtype])
         4.4. sdp_keep_codecs_by_id(list [, mtype])
         4.5. sdp_keep_codecs_by_name(list [, mtype])
         4.5. sdp_keep_codecs_by_name(list [, mtype])
         4.6. sdp_with_media(type)
         4.6. sdp_with_media(type)
-        4.7. sdp_remove_media(type)
-        4.8. sdp_with_transport(type)
-        4.9. sdp_with_transport_like(string)
-        4.10. sdp_transport(pv)
-        4.11. sdp_remove_transport(type)
-        4.12. sdp_with_codecs_by_id(list)
-        4.13. sdp_with_codecs_by_name(list)
-        4.14. sdp_print(level)
-        4.15. sdp_get(avpvar)
-        4.16. sdp_content()
-        4.17. sdp_with_ice()
-        4.18. sdp_get_line_startswith(avpvar, string)
+        4.7. sdp_with_active_media(type)
+        4.8. sdp_remove_media(type)
+        4.9. sdp_with_transport(type)
+        4.10. sdp_with_transport_like(string)
+        4.11. sdp_transport(pv)
+        4.12. sdp_remove_transport(type)
+        4.13. sdp_with_codecs_by_id(list)
+        4.14. sdp_with_codecs_by_name(list)
+        4.15. sdp_print(level)
+        4.16. sdp_get(avpvar)
+        4.17. sdp_content()
+        4.18. sdp_with_ice()
+        4.19. sdp_get_line_startswith(avpvar, string)
 
 
 1. Overview
 1. Overview
 
 
@@ -126,7 +129,7 @@ Chapter 1. Admin Guide
 
 
 3. Parameters
 3. Parameters
 
 
-   The module does not export any config parameter yet.
+   The module does not export any config parameters yet.
 
 
 4. Functions
 4. Functions
 
 
@@ -136,20 +139,21 @@ Chapter 1. Admin Guide
    4.4. sdp_keep_codecs_by_id(list [, mtype])
    4.4. sdp_keep_codecs_by_id(list [, mtype])
    4.5. sdp_keep_codecs_by_name(list [, mtype])
    4.5. sdp_keep_codecs_by_name(list [, mtype])
    4.6. sdp_with_media(type)
    4.6. sdp_with_media(type)
-   4.7. sdp_remove_media(type)
-   4.8. sdp_with_transport(type)
-   4.9. sdp_with_transport_like(string)
-   4.10. sdp_transport(pv)
-   4.11. sdp_remove_transport(type)
-   4.12. sdp_with_codecs_by_id(list)
-   4.13. sdp_with_codecs_by_name(list)
-   4.14. sdp_print(level)
-   4.15. sdp_get(avpvar)
-   4.16. sdp_content()
-   4.17. sdp_with_ice()
-   4.18. sdp_get_line_startswith(avpvar, string)
-
-4.1. sdp_remove_codecs_by_id(list)
+   4.7. sdp_with_active_media(type)
+   4.8. sdp_remove_media(type)
+   4.9. sdp_with_transport(type)
+   4.10. sdp_with_transport_like(string)
+   4.11. sdp_transport(pv)
+   4.12. sdp_remove_transport(type)
+   4.13. sdp_with_codecs_by_id(list)
+   4.14. sdp_with_codecs_by_name(list)
+   4.15. sdp_print(level)
+   4.16. sdp_get(avpvar)
+   4.17. sdp_content()
+   4.18. sdp_with_ice()
+   4.19. sdp_get_line_startswith(avpvar, string)
+
+4.1.  sdp_remove_codecs_by_id(list)
 
 
    Remove the codecs provided in the parameter 'list' from all media
    Remove the codecs provided in the parameter 'list' from all media
    streams found in SDP payload. The parameter 'list' must be one item or
    streams found in SDP payload. The parameter 'list' must be one item or
@@ -166,7 +170,7 @@ sdp_remove_codecs_by_id("0");
 sdp_remove_codecs_by_id("0,8,3");
 sdp_remove_codecs_by_id("0,8,3");
 ...
 ...
 
 
-4.2. sdp_remove_codecs_by_name(list)
+4.2.  sdp_remove_codecs_by_name(list)
 
 
    Remove the codecs provided in the parameter 'list' from all media
    Remove the codecs provided in the parameter 'list' from all media
    streams found in SDP payload. The parameter 'list' must be one item or
    streams found in SDP payload. The parameter 'list' must be one item or
@@ -183,7 +187,7 @@ sdp_remove_codecs_by_name("PCMU");
 sdp_remove_codecs_by_name("PCMU,PCMA,GSM");
 sdp_remove_codecs_by_name("PCMU,PCMA,GSM");
 ...
 ...
 
 
-4.3. sdp_remove_line_by_prefix(string)
+4.3.  sdp_remove_line_by_prefix(string)
 
 
    Remove all SDP attribute lines beginning with 'string' in all media
    Remove all SDP attribute lines beginning with 'string' in all media
    streams.
    streams.
@@ -202,7 +206,7 @@ if ($si == "2001:DB8::8:800:200C:417A"
 
 
 ...
 ...
 
 
-4.4. sdp_keep_codecs_by_id(list [, mtype])
+4.4.  sdp_keep_codecs_by_id(list [, mtype])
 
 
    Keep only the codecs provided in the parameter 'list' from all media
    Keep only the codecs provided in the parameter 'list' from all media
    streams found in SDP payload. The parameter 'list' must be one item or
    streams found in SDP payload. The parameter 'list' must be one item or
@@ -222,7 +226,7 @@ sdp_keep_codecs_by_id("0");
 sdp_keep_codecs_by_id("0,8,3", "audio");
 sdp_keep_codecs_by_id("0,8,3", "audio");
 ...
 ...
 
 
-4.5. sdp_keep_codecs_by_name(list [, mtype])
+4.5.  sdp_keep_codecs_by_name(list [, mtype])
 
 
    Keep only the codecs provided in the parameter 'list' from all media
    Keep only the codecs provided in the parameter 'list' from all media
    streams found in SDP payload. The parameter 'list' must be one or a
    streams found in SDP payload. The parameter 'list' must be one or a
@@ -245,7 +249,7 @@ sdp_keep_codecs_by_name("PCMU");
 sdp_keep_codecs_by_name("PCMU,PCMA,GSM");
 sdp_keep_codecs_by_name("PCMU,PCMA,GSM");
 ...
 ...
 
 
-4.6. sdp_with_media(type)
+4.6.  sdp_with_media(type)
 
 
    Return true of the SDP has 'media=type ...' line. Useful to check the
    Return true of the SDP has 'media=type ...' line. Useful to check the
    content of the RTP sessions, such as 'audio' or 'video'. The parameter
    content of the RTP sessions, such as 'audio' or 'video'. The parameter
@@ -262,20 +266,39 @@ if(sdp_with_media("video"))
 }
 }
 ...
 ...
 
 
-4.7. sdp_remove_media(type)
+4.7.  sdp_with_active_media(type)
+
+   Return true of the SDP has 'media=type ...' line and the media is
+   active. Useful to check the content of the RTP sessions, such as
+   'audio' or 'video'. Active media means the port is non-zero and the
+   direction is not "inactive" The parameter can be static string or
+   variable holding the media type.
+
+   This function can be used from ANY_ROUTE.
+
+   Example 1.7. sdp_with_active_media usage
+...
+# check for active video stream
+if(sdp_with_active_media("video"))
+{
+    # the session has an active video stream
+}
+...
+
+4.8.  sdp_remove_media(type)
 
 
    Remove the streams that match on 'm=type ...' line. The parameter can
    Remove the streams that match on 'm=type ...' line. The parameter can
    be static string or variable holding the media type.
    be static string or variable holding the media type.
 
 
    This function can be used from ANY_ROUTE.
    This function can be used from ANY_ROUTE.
 
 
-   Example 1.7. sdp_remove_media usage
+   Example 1.8. sdp_remove_media usage
 ...
 ...
 # remove video stream
 # remove video stream
 sdp_remove_media("video");
 sdp_remove_media("video");
 ...
 ...
 
 
-4.8. sdp_with_transport(type)
+4.9.  sdp_with_transport(type)
 
 
    Return true of the SDP has 'media=media port type ...' line. Useful to
    Return true of the SDP has 'media=media port type ...' line. Useful to
    check the transport of the RTP sessions, such as 'RTP/AVP', 'RTP/SAVP'
    check the transport of the RTP sessions, such as 'RTP/AVP', 'RTP/SAVP'
@@ -284,7 +307,7 @@ sdp_remove_media("video");
 
 
    This function can be used from ANY_ROUTE.
    This function can be used from ANY_ROUTE.
 
 
-   Example 1.8. sdp_with_transport usage
+   Example 1.9. sdp_with_transport usage
 ...
 ...
 # check for RTP/SAVP stream
 # check for RTP/SAVP stream
 if(sdp_with_transport("RTP/SAVP"))
 if(sdp_with_transport("RTP/SAVP"))
@@ -293,7 +316,7 @@ if(sdp_with_transport("RTP/SAVP"))
 }
 }
 ...
 ...
 
 
-4.9. sdp_with_transport_like(string)
+4.10.  sdp_with_transport_like(string)
 
 
    Returns true if the SDP has 'media=media port type ...' line, where
    Returns true if the SDP has 'media=media port type ...' line, where
    type contains string. The parameter can be static string or variable
    type contains string. The parameter can be static string or variable
@@ -301,7 +324,7 @@ if(sdp_with_transport("RTP/SAVP"))
 
 
    This function can be used from ANY_ROUTE.
    This function can be used from ANY_ROUTE.
 
 
-   Example 1.9. sdp_with_transport_like usage
+   Example 1.10. sdp_with_transport_like usage
 ...
 ...
 # check for SAVPF stream
 # check for SAVPF stream
 if(sdp_with_transport_like("SAVPF"))
 if(sdp_with_transport_like("SAVPF"))
@@ -310,7 +333,7 @@ if(sdp_with_transport_like("SAVPF"))
 }
 }
 ...
 ...
 
 
-4.10. sdp_transport(pv)
+4.11.  sdp_transport(pv)
 
 
    Assigns common media transport (if any) of 'm' lines to pv argument.
    Assigns common media transport (if any) of 'm' lines to pv argument.
    Returns 1 if common media transport was found, -2 if there was no
    Returns 1 if common media transport was found, -2 if there was no
@@ -318,25 +341,25 @@ if(sdp_with_transport_like("SAVPF"))
 
 
    This function can be used from ANY_ROUTE.
    This function can be used from ANY_ROUTE.
 
 
-   Example 1.10. sdp_transport usage
+   Example 1.11. sdp_transport usage
 ...
 ...
 sdp_transport("$avp(caller_rtp_transport)");
 sdp_transport("$avp(caller_rtp_transport)");
 ...
 ...
 
 
-4.11. sdp_remove_transport(type)
+4.12.  sdp_remove_transport(type)
 
 
    Remove the streams that match on 'm=media port type ...' line. The
    Remove the streams that match on 'm=media port type ...' line. The
    parameter can be static string or variable holding the transport type.
    parameter can be static string or variable holding the transport type.
 
 
    This function can be used from ANY_ROUTE.
    This function can be used from ANY_ROUTE.
 
 
-   Example 1.11. sdp_remove_transport usage
+   Example 1.12. sdp_remove_transport usage
 ...
 ...
 # remove stream with transport RTP/AVP
 # remove stream with transport RTP/AVP
 sdp_remove_transport("RTP/AVP");
 sdp_remove_transport("RTP/AVP");
 ...
 ...
 
 
-4.12. sdp_with_codecs_by_id(list)
+4.13.  sdp_with_codecs_by_id(list)
 
 
    Returns true if any of the codecs provided in the parameter 'list' from
    Returns true if any of the codecs provided in the parameter 'list' from
    all media streams is found in SDP payload. The parameter 'list' must be
    all media streams is found in SDP payload. The parameter 'list' must be
@@ -345,7 +368,7 @@ sdp_remove_transport("RTP/AVP");
 
 
    This function can be used from ANY_ROUTE.
    This function can be used from ANY_ROUTE.
 
 
-   Example 1.12. sdp_with_codecs_by_id usage
+   Example 1.13. sdp_with_codecs_by_id usage
 ...
 ...
 # test for PCMU
 # test for PCMU
 if(sdp_with_codecs_by_id("0")) { ... }
 if(sdp_with_codecs_by_id("0")) { ... }
@@ -353,7 +376,7 @@ if(sdp_with_codecs_by_id("0")) { ... }
 if(sdp_with_codecs_by_id("0,8,3")) { ... }
 if(sdp_with_codecs_by_id("0,8,3")) { ... }
 ...
 ...
 
 
-4.13. sdp_with_codecs_by_name(list)
+4.14.  sdp_with_codecs_by_name(list)
 
 
    Returns true if any of the codecs provided in the parameter 'list' from
    Returns true if any of the codecs provided in the parameter 'list' from
    all media streams is found in SDP payload. The parameter 'list' must be
    all media streams is found in SDP payload. The parameter 'list' must be
@@ -362,7 +385,7 @@ if(sdp_with_codecs_by_id("0,8,3")) { ... }
 
 
    This function can be used from ANY_ROUTE.
    This function can be used from ANY_ROUTE.
 
 
-   Example 1.13. sdp_with_codecs_by_name usage
+   Example 1.14. sdp_with_codecs_by_name usage
 ...
 ...
 # test for PCMU
 # test for PCMU
 if(sdp_with_codecs_by_name("PCMU")) { ... }
 if(sdp_with_codecs_by_name("PCMU")) { ... }
@@ -370,59 +393,59 @@ if(sdp_with_codecs_by_name("PCMU")) { ... }
 if(sdp_with_codecs_by_name("PCMU,PCMA,GSM")) { ... }
 if(sdp_with_codecs_by_name("PCMU,PCMA,GSM")) { ... }
 ...
 ...
 
 
-4.14. sdp_print(level)
+4.15.  sdp_print(level)
 
 
    Print the SDP internal structure to log 'level'. The parameter can be
    Print the SDP internal structure to log 'level'. The parameter can be
    static integer or variable holding the integer value of the log level.
    static integer or variable holding the integer value of the log level.
 
 
    This function can be used from ANY_ROUTE.
    This function can be used from ANY_ROUTE.
 
 
-   Example 1.14. sdp_print usage
+   Example 1.15. sdp_print usage
 ...
 ...
 # print the SDP
 # print the SDP
 sdp_print("1");
 sdp_print("1");
 ...
 ...
 
 
-4.15. sdp_get(avpvar)
+4.16.  sdp_get(avpvar)
 
 
    Store the SDP part of message body in an AVP. Return 1 if SDP is found,
    Store the SDP part of message body in an AVP. Return 1 if SDP is found,
    -1 on error and -2 if there is no SDP part in the message body.
    -1 on error and -2 if there is no SDP part in the message body.
 
 
    This function can be used from ANY_ROUTE.
    This function can be used from ANY_ROUTE.
 
 
-   Example 1.15. sdp_get usage
+   Example 1.16. sdp_get usage
 ...
 ...
 sdp_get("$avp(sdp)");
 sdp_get("$avp(sdp)");
 ...
 ...
 
 
-4.16. sdp_content()
+4.17.  sdp_content()
 
 
    Return true if the SIP message has SDP body or a SDP part in body.
    Return true if the SIP message has SDP body or a SDP part in body.
 
 
    This function can be used from ANY_ROUTE.
    This function can be used from ANY_ROUTE.
 
 
-   Example 1.16. sdp_content usage
+   Example 1.17. sdp_content usage
 ...
 ...
 if(sdp_content()) {
 if(sdp_content()) {
     ...
     ...
 }
 }
 ...
 ...
 
 
-4.17. sdp_with_ice()
+4.18.  sdp_with_ice()
 
 
    Return true if the SIP message has SDP body that contains ICE candidate
    Return true if the SIP message has SDP body that contains ICE candidate
    attribute(s).
    attribute(s).
 
 
    This function can be used from ANY_ROUTE.
    This function can be used from ANY_ROUTE.
 
 
-   Example 1.17. sdp_with_ice usage
+   Example 1.18. sdp_with_ice usage
 ...
 ...
 if(sdp_with_ice()) {
 if(sdp_with_ice()) {
     ...
     ...
 }
 }
 ...
 ...
 
 
-4.18. sdp_get_line_startswith(avpvar, string)
+4.19.  sdp_get_line_startswith(avpvar, string)
 
 
    Store the search part of SDP body message with line beginning with
    Store the search part of SDP body message with line beginning with
    'string' in an AVP. Return 1 if 'string' is found in SDP, -1 on error
    'string' in an AVP. Return 1 if 'string' is found in SDP, -1 on error
@@ -430,7 +453,7 @@ if(sdp_with_ice()) {
 
 
    This function can be used from ANY_ROUTE.
    This function can be used from ANY_ROUTE.
 
 
-   Example 1.18. sdp_get_line_startswith usage
+   Example 1.19. sdp_get_line_startswith usage
 ...
 ...
 if(sdp_get_line_startswith("$avp(mline)", "m=")) {
 if(sdp_get_line_startswith("$avp(mline)", "m=")) {
         xlog("m-line: $avp(mline)\n");
         xlog("m-line: $avp(mline)\n");

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

@@ -231,6 +231,32 @@ if(sdp_with_media("video"))
     # the session has a video stream
     # the session has a video stream
 }
 }
 ...
 ...
+</programlisting>
+	    </example>
+	</section>
+	<section id="sdpops.f.sdp_with_active_media">
+	    <title>
+		<function moreinfo="none">sdp_with_active_media(type)</function>
+	    </title>
+	    <para>
+		Return true of the SDP has 'media=type ...' line and the media is active.
+		Useful to check	the content of the RTP sessions, such as 'audio' or 'video'.
+		Active media means the port is non-zero and the direction is not "inactive"
+		The parameter can be static string or variable holding the media type.
+	    </para>
+		<para>
+			This function can be used from ANY_ROUTE.
+	    </para>
+		<example>
+		<title><function>sdp_with_active_media</function> usage</title>
+		<programlisting format="linespecific">
+...
+# check for active video stream
+if(sdp_with_active_media("video"))
+{
+    # the session has an active video stream
+}
+...
 </programlisting>
 </programlisting>
 	    </example>
 	    </example>
 	</section>
 	</section>

+ 83 - 0
modules/sdpops/sdpops_mod.c

@@ -48,6 +48,7 @@ static int w_sdp_remove_codecs_by_name(sip_msg_t* msg, char* codecs, char *bar);
 static int w_sdp_keep_codecs_by_id(sip_msg_t* msg, char* codecs, char *bar);
 static int w_sdp_keep_codecs_by_id(sip_msg_t* msg, char* codecs, char *bar);
 static int w_sdp_keep_codecs_by_name(sip_msg_t* msg, char* codecs, char *bar);
 static int w_sdp_keep_codecs_by_name(sip_msg_t* msg, char* codecs, char *bar);
 static int w_sdp_with_media(sip_msg_t* msg, char* media, char *bar);
 static int w_sdp_with_media(sip_msg_t* msg, char* media, char *bar);
+static int w_sdp_with_active_media(sip_msg_t* msg, char* media, char *bar);
 static int w_sdp_with_transport(sip_msg_t* msg, char* transport, char *bar);
 static int w_sdp_with_transport(sip_msg_t* msg, char* transport, char *bar);
 static int w_sdp_with_transport_like(sip_msg_t* msg, char* transport, char *bar);
 static int w_sdp_with_transport_like(sip_msg_t* msg, char* transport, char *bar);
 static int w_sdp_transport(sip_msg_t* msg, char *bar);
 static int w_sdp_transport(sip_msg_t* msg, char *bar);
@@ -81,6 +82,8 @@ static cmd_export_t cmds[] = {
 		2, fixup_spve_spve,  0, ANY_ROUTE},
 		2, fixup_spve_spve,  0, ANY_ROUTE},
 	{"sdp_with_media",             (cmd_function)w_sdp_with_media,
 	{"sdp_with_media",             (cmd_function)w_sdp_with_media,
 		1, fixup_spve_null,  0, ANY_ROUTE},
 		1, fixup_spve_null,  0, ANY_ROUTE},
+	{"sdp_with_active_media",       (cmd_function)w_sdp_with_active_media,
+		1, fixup_spve_null,  0, ANY_ROUTE},
 	{"sdp_remove_media",             (cmd_function)w_sdp_remove_media,
 	{"sdp_remove_media",             (cmd_function)w_sdp_remove_media,
 		1, fixup_spve_null,  0, ANY_ROUTE},
 		1, fixup_spve_null,  0, ANY_ROUTE},
 	{"sdp_with_transport",         (cmd_function)w_sdp_with_transport,
 	{"sdp_with_transport",         (cmd_function)w_sdp_with_transport,
@@ -809,6 +812,86 @@ static int w_sdp_with_media(sip_msg_t* msg, char* media, char *bar)
 	return 1;
 	return 1;
 }
 }
 
 
+/**
+ * @brief check 'media' matches the value of any 'm=value ...' lines, and that line is active
+ * @return -1 - error; 0 - not found or inactive; 1 - at least one sendrecv, recvonly or sendonly stream
+ */
+static int sdp_with_active_media(sip_msg_t *msg, str *media)
+{
+	int sdp_session_num;
+	int sdp_stream_num;
+	int port_num;
+	sdp_session_cell_t* sdp_session;
+	sdp_stream_cell_t* sdp_stream;
+
+	if(parse_sdp(msg) < 0) {
+		LM_ERR("Unable to parse sdp\n");
+		return -1;
+	}
+
+	LM_DBG("attempting to search for media type: [%.*s]\n",
+			media->len, media->s);
+
+	sdp_session_num = 0;
+	for(;;)
+	{
+		sdp_session = get_sdp_session(msg, sdp_session_num);
+		if(!sdp_session) break;
+		sdp_stream_num = 0;
+		for(;;)
+		{
+			sdp_stream = get_sdp_stream(msg, sdp_session_num, sdp_stream_num);
+			if(!sdp_stream) break;
+
+			LM_DBG("stream %d of %d - media [%.*s]\n",
+					sdp_stream_num, sdp_session_num,
+					sdp_stream->media.len, sdp_stream->media.s);
+			if(media->len==sdp_stream->media.len
+					&& strncasecmp(sdp_stream->media.s, media->s,
+						media->len)==0) {
+				port_num = atoi(sdp_stream->port.s);
+				LM_DBG("Port number is %d\n", port_num);
+				if (port_num != 0) {  /* Zero port number => inactive */
+					LM_DBG("sendrecv_mode %.*s\n", sdp_stream->sendrecv_mode.len, sdp_stream->sendrecv_mode.s);
+					if ((sdp_stream->sendrecv_mode.len == 0) || /* No send/recv mode given => sendrecv */
+						(strncasecmp(sdp_stream->sendrecv_mode.s, "inactive", 8) != 0)) { /* Explicit mode is not inactive */
+						/* Found an active stream for the correct media type */
+						return 1;
+					}
+				}
+			}
+			sdp_stream_num++;
+		}
+		sdp_session_num++;
+	}
+
+	return 0;
+}
+
+/**
+ *
+ */
+static int w_sdp_with_active_media(sip_msg_t* msg, char* media, char *bar)
+{
+	str lmedia = {0, 0};
+
+	if(media==0)
+	{
+		LM_ERR("invalid parameters\n");
+		return -1;
+	}
+
+	if(fixup_get_svalue(msg, (gparam_p)media, &lmedia)!=0)
+	{
+		LM_ERR("unable to get the media value\n");
+		return -1;
+	}
+
+	if(sdp_with_active_media(msg, &lmedia)<=0)
+		return -1;
+	return 1;
+}
+
 /**
 /**
  * @brief remove streams matching the m='media'
  * @brief remove streams matching the m='media'
  * @return -1 - error; 0 - not found; >=1 - found
  * @return -1 - error; 0 - not found; >=1 - found