mirror of https://github.com/sipwise/kamailio.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
465 lines
13 KiB
465 lines
13 KiB
SDPOPS Module
|
|
|
|
Daniel-Constantin Mierla
|
|
|
|
<miconda@gmail.com>
|
|
|
|
Edited by
|
|
|
|
Daniel-Constantin Mierla
|
|
|
|
<miconda@gmail.com>
|
|
|
|
Copyright © 2011 asipto.com
|
|
__________________________________________________________________
|
|
|
|
Table of Contents
|
|
|
|
1. Admin Guide
|
|
|
|
1. Overview
|
|
2. Dependencies
|
|
|
|
2.1. Kamailio Modules
|
|
2.2. External Libraries or Applications
|
|
|
|
3. Parameters
|
|
4. Functions
|
|
|
|
4.1. sdp_remove_codecs_by_id(list)
|
|
4.2. sdp_remove_codecs_by_name(list)
|
|
4.3. sdp_remove_line_by_prefix(string)
|
|
4.4. sdp_keep_codecs_by_id(list [, mtype])
|
|
4.5. sdp_keep_codecs_by_name(list [, mtype])
|
|
4.6. sdp_with_media(type)
|
|
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([sloppy])
|
|
4.18. sdp_with_ice()
|
|
4.19. sdp_get_line_startswith(avpvar, string)
|
|
|
|
List of Examples
|
|
|
|
1.1. sdp_remove_codecs_by_id usage
|
|
1.2. sdp_remove_codecs_by_name usage
|
|
1.3. sdp_remove_line_by_prefix usage
|
|
1.4. sdp_keep_codecs_by_id usage
|
|
1.5. sdp_keep_codecs_by_name usage
|
|
1.6. sdp_with_media 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
|
|
|
|
Table of Contents
|
|
|
|
1. Overview
|
|
2. Dependencies
|
|
|
|
2.1. Kamailio Modules
|
|
2.2. External Libraries or Applications
|
|
|
|
3. Parameters
|
|
4. Functions
|
|
|
|
4.1. sdp_remove_codecs_by_id(list)
|
|
4.2. sdp_remove_codecs_by_name(list)
|
|
4.3. sdp_remove_line_by_prefix(string)
|
|
4.4. sdp_keep_codecs_by_id(list [, mtype])
|
|
4.5. sdp_keep_codecs_by_name(list [, mtype])
|
|
4.6. sdp_with_media(type)
|
|
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([sloppy])
|
|
4.18. sdp_with_ice()
|
|
4.19. sdp_get_line_startswith(avpvar, string)
|
|
|
|
1. Overview
|
|
|
|
This module provides functions for checking and managing the SDP
|
|
payloads of SIP messages.
|
|
|
|
Examples of functions this module offers: remove codecs from SDP, check
|
|
the media stream types and return attributes of SDP document. For the
|
|
full list of the features provided by this module and the
|
|
implementation state, please read the list of exported functions.
|
|
|
|
2. Dependencies
|
|
|
|
2.1. Kamailio Modules
|
|
2.2. External Libraries or Applications
|
|
|
|
2.1. Kamailio Modules
|
|
|
|
The following modules must be loaded before this module:
|
|
* none.
|
|
|
|
2.2. External Libraries or Applications
|
|
|
|
The following libraries or applications must be installed before
|
|
running Kamailio with this module loaded:
|
|
* None
|
|
|
|
3. Parameters
|
|
|
|
The module does not export any config parameters yet.
|
|
|
|
4. Functions
|
|
|
|
4.1. sdp_remove_codecs_by_id(list)
|
|
4.2. sdp_remove_codecs_by_name(list)
|
|
4.3. sdp_remove_line_by_prefix(string)
|
|
4.4. sdp_keep_codecs_by_id(list [, mtype])
|
|
4.5. sdp_keep_codecs_by_name(list [, mtype])
|
|
4.6. sdp_with_media(type)
|
|
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([sloppy])
|
|
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
|
|
streams found in SDP payload. The parameter 'list' must be one item or
|
|
a comma separated list of numeric codec IDs. The parameter can be a
|
|
static string or a variable holding the list of numeric codec IDs.
|
|
|
|
This function can be used from ANY_ROUTE.
|
|
|
|
Example 1.1. sdp_remove_codecs_by_id usage
|
|
...
|
|
# remove PCMU
|
|
sdp_remove_codecs_by_id("0");
|
|
# remove PCMU, PCMA and GSM
|
|
sdp_remove_codecs_by_id("0,8,3");
|
|
...
|
|
|
|
4.2. sdp_remove_codecs_by_name(list)
|
|
|
|
Remove the codecs provided in the parameter 'list' from all media
|
|
streams found in SDP payload. The parameter 'list' must be one item or
|
|
a comma separated list of codec names. The parameter can be a static
|
|
string or a variable holding the list of codec names.
|
|
|
|
This function can be used from ANY_ROUTE.
|
|
|
|
Example 1.2. sdp_remove_codecs_by_name usage
|
|
...
|
|
# remove PCMU
|
|
sdp_remove_codecs_by_name("PCMU");
|
|
# remove PCMU, PCMA and GSM
|
|
sdp_remove_codecs_by_name("PCMU,PCMA,GSM");
|
|
...
|
|
|
|
4.3. sdp_remove_line_by_prefix(string)
|
|
|
|
Remove all SDP attribute lines beginning with 'string' in all media
|
|
streams.
|
|
|
|
This function can be used from ANY_ROUTE.
|
|
|
|
Example 1.3. sdp_remove_line_by_prefix usage
|
|
...
|
|
if ($si == "2001:DB8::8:800:200C:417A"
|
|
and ( has_body("application/sdp") or has_body("multipart/mixed")))
|
|
{
|
|
xlog("L_INFO", "Cleaning ugly SDP from $si\n");
|
|
sdp_remove_codecs_by_name("X-NSE");
|
|
sdp_remove_line_by_prefix("a=X-");
|
|
}
|
|
|
|
...
|
|
|
|
4.4. sdp_keep_codecs_by_id(list [, mtype])
|
|
|
|
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
|
|
a comma separated list of numeric codec IDs. The parameter can be a
|
|
static string or a variable holding the list of numeric codec IDs.
|
|
|
|
Optional parameter mtype can be provided to apply the operations only
|
|
to the streams matching m=mtype.
|
|
|
|
This function can be used from ANY_ROUTE.
|
|
|
|
Example 1.4. sdp_keep_codecs_by_id usage
|
|
...
|
|
# keep only PCMU
|
|
sdp_keep_codecs_by_id("0");
|
|
# keep PCMU, PCMA and GSM in audio stream
|
|
sdp_keep_codecs_by_id("0,8,3", "audio");
|
|
...
|
|
|
|
4.5. sdp_keep_codecs_by_name(list [, mtype])
|
|
|
|
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
|
|
comma separated list of codec names. The parameter can be a static
|
|
string or a variable holding the list of codec names.
|
|
|
|
Note that you have to explicitely keep 'telephone-event' in the list of
|
|
names if you want to keep DTMF attributes.
|
|
|
|
Optional parameter mtype can be provided to apply the operations only
|
|
to the streams matching m=mtype.
|
|
|
|
This function can be used from ANY_ROUTE.
|
|
|
|
Example 1.5. sdp_keep_codecs_by_name usage
|
|
...
|
|
# keep only PCMU
|
|
sdp_keep_codecs_by_name("PCMU");
|
|
# keep PCMU, PCMA and GSM
|
|
sdp_keep_codecs_by_name("PCMU,PCMA,GSM");
|
|
...
|
|
|
|
4.6. sdp_with_media(type)
|
|
|
|
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
|
|
can be static string or variable holding the media type.
|
|
|
|
This function can be used from ANY_ROUTE.
|
|
|
|
Example 1.6. sdp_with_media usage
|
|
...
|
|
# check for video stream
|
|
if(sdp_with_media("video"))
|
|
{
|
|
# the session has a video stream
|
|
}
|
|
...
|
|
|
|
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
|
|
be static string or variable holding the media type.
|
|
|
|
This function can be used from ANY_ROUTE.
|
|
|
|
Example 1.8. sdp_remove_media usage
|
|
...
|
|
# remove video stream
|
|
sdp_remove_media("video");
|
|
...
|
|
|
|
4.9. sdp_with_transport(type)
|
|
|
|
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'
|
|
or 'RTP/SAVPF'. The parameter can be static string or variable holding
|
|
the transport type.
|
|
|
|
This function can be used from ANY_ROUTE.
|
|
|
|
Example 1.9. sdp_with_transport usage
|
|
...
|
|
# check for RTP/SAVP stream
|
|
if(sdp_with_transport("RTP/SAVP"))
|
|
{
|
|
# the session has a SRTP/SAVP stream
|
|
}
|
|
...
|
|
|
|
4.10. sdp_with_transport_like(string)
|
|
|
|
Returns true if the SDP has 'media=media port type ...' line, where
|
|
type contains string. The parameter can be static string or variable
|
|
holding a string.
|
|
|
|
This function can be used from ANY_ROUTE.
|
|
|
|
Example 1.10. sdp_with_transport_like usage
|
|
...
|
|
# check for SAVPF stream
|
|
if(sdp_with_transport_like("SAVPF"))
|
|
{
|
|
# the session has a SAVPF stream, e.g., RTP/SAVPF or UDP/TLS/RTP/SAVPF
|
|
}
|
|
...
|
|
|
|
4.11. sdp_transport(pv)
|
|
|
|
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
|
|
common media transport, and -1 in case of error.
|
|
|
|
This function can be used from ANY_ROUTE.
|
|
|
|
Example 1.11. sdp_transport usage
|
|
...
|
|
sdp_transport("$avp(caller_rtp_transport)");
|
|
...
|
|
|
|
4.12. sdp_remove_transport(type)
|
|
|
|
Remove the streams that match on 'm=media port type ...' line. The
|
|
parameter can be static string or variable holding the transport type.
|
|
|
|
This function can be used from ANY_ROUTE.
|
|
|
|
Example 1.12. sdp_remove_transport usage
|
|
...
|
|
# remove stream with transport RTP/AVP
|
|
sdp_remove_transport("RTP/AVP");
|
|
...
|
|
|
|
4.13. sdp_with_codecs_by_id(list)
|
|
|
|
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
|
|
one or a comma separated list of numeric codec IDs. The parameter can
|
|
be a static string or a variable holding the list of numeric codec IDs.
|
|
|
|
This function can be used from ANY_ROUTE.
|
|
|
|
Example 1.13. sdp_with_codecs_by_id usage
|
|
...
|
|
# test for PCMU
|
|
if(sdp_with_codecs_by_id("0")) { ... }
|
|
# test for PCMU, PCMA or GSM
|
|
if(sdp_with_codecs_by_id("0,8,3")) { ... }
|
|
...
|
|
|
|
4.14. sdp_with_codecs_by_name(list)
|
|
|
|
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
|
|
one item or a comma separated list of codec names. The parameter can be
|
|
a static string or a variable holding the list of codec names.
|
|
|
|
This function can be used from ANY_ROUTE.
|
|
|
|
Example 1.14. sdp_with_codecs_by_name usage
|
|
...
|
|
# test for PCMU
|
|
if(sdp_with_codecs_by_name("PCMU")) { ... }
|
|
# test for PCMU, PCMA or GSM
|
|
if(sdp_with_codecs_by_name("PCMU,PCMA,GSM")) { ... }
|
|
...
|
|
|
|
4.15. sdp_print(level)
|
|
|
|
Print the SDP internal structure to log 'level'. The parameter can be
|
|
static integer or variable holding the integer value of the log level.
|
|
|
|
This function can be used from ANY_ROUTE.
|
|
|
|
Example 1.15. sdp_print usage
|
|
...
|
|
# print the SDP
|
|
sdp_print("1");
|
|
...
|
|
|
|
4.16. sdp_get(avpvar)
|
|
|
|
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.
|
|
|
|
This function can be used from ANY_ROUTE.
|
|
|
|
Example 1.16. sdp_get usage
|
|
...
|
|
sdp_get("$avp(sdp)");
|
|
...
|
|
|
|
4.17. sdp_content([sloppy])
|
|
|
|
Return true if the SIP message has SDP body or a SDP part in body. If
|
|
an argument is given, the function does not parse message body, but
|
|
returns true if Content-Type is "application/sdp" or if that string
|
|
exists in "multipart/mixed" body.
|
|
|
|
This function can be used from ANY_ROUTE.
|
|
|
|
Example 1.17. sdp_content usage
|
|
...
|
|
if(sdp_content()) {
|
|
...
|
|
}
|
|
...
|
|
|
|
4.18. sdp_with_ice()
|
|
|
|
Return true if the SIP message has SDP body that contains ICE candidate
|
|
attribute(s).
|
|
|
|
This function can be used from ANY_ROUTE.
|
|
|
|
Example 1.18. sdp_with_ice usage
|
|
...
|
|
if(sdp_with_ice()) {
|
|
...
|
|
}
|
|
...
|
|
|
|
4.19. sdp_get_line_startswith(avpvar, string)
|
|
|
|
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
|
|
and -2 if there is no SDP part in the message body.
|
|
|
|
This function can be used from ANY_ROUTE.
|
|
|
|
Example 1.19. sdp_get_line_startswith usage
|
|
...
|
|
if(sdp_get_line_startswith("$avp(mline)", "m=")) {
|
|
xlog("m-line: $avp(mline)\n");
|
|
}
|
|
...
|