Module: sip-router
Branch: master
Commit: 0e608506687a171529d2d60f22aade8a72a7f7c4
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=0e60850…
Author: Ovidiu Sas <osas(a)voipembedded.com>
Committer: Ovidiu Sas <osas(a)voipembedded.com>
Date: Fri Jun 25 13:06:12 2010 -0400
core: sdp parser
- added support for rtcp attribute (RFC3605)
---
parser/sdp/sdp.c | 27 +++++++++++++++++++--------
parser/sdp/sdp.h | 3 +++
parser/sdp/sdp_helpr_funcs.c | 5 +++++
parser/sdp/sdp_helpr_funcs.h | 3 +++
4 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/parser/sdp/sdp.c b/parser/sdp/sdp.c
index fa1394d..367651b 100644
--- a/parser/sdp/sdp.c
+++ b/parser/sdp/sdp.c
@@ -524,6 +524,8 @@ static int parse_sdp_session(str *sdp_body, int session_num, str
*cnt_disp, sdp_
}
payload_attr = (sdp_payload_attr_t*)get_sdp_payload4payload(stream,
&rtp_payload);
set_sdp_payload_attr(payload_attr, &rtp_enc, &rtp_clock, &rtp_params);
+ } else if (extract_rtcp(&tmpstr1, &stream->rtcp_port) == 0) {
+ a1p = stream->rtcp_port.s + stream->rtcp_port.len;
} else if (extract_accept_types(&tmpstr1, &stream->accept_types) == 0) {
a1p = stream->accept_types.s + stream->accept_types.len;
} else if (extract_accept_wrapped_types(&tmpstr1,
&stream->accept_wrapped_types) == 0) {
@@ -766,11 +768,12 @@ void print_sdp_stream(sdp_stream_cell_t *stream)
{
sdp_payload_attr_t *payload;
- LM_DBG("....stream[%d]:%p=>%p {%p} '%.*s' '%.*s:%.*s'
'%.*s' '%.*s' '%.*s:%.*s' (%d)=>%p '%.*s'
'%.*s' '%.*s' '%.*s'\n",
+ LM_DBG("....stream[%d]:%p=>%p {%p} '%.*s' '%.*s:%.*s' [%.*s]
'%.*s' '%.*s' '%.*s:%.*s' (%d)=>%p '%.*s'
'%.*s' '%.*s' '%.*s'\n",
stream->stream_num, stream, stream->next,
stream->p_payload_attr,
stream->media.len, stream->media.s,
stream->ip_addr.len, stream->ip_addr.s, stream->port.len, stream->port.s,
+ stream->rtcp_port.len, stream->rtcp_port.s,
stream->transport.len, stream->transport.s,
stream->payloads.len, stream->payloads.s,
stream->bw_type.len, stream->bw_type.s, stream->bw_width.len,
stream->bw_width.s,
@@ -961,13 +964,14 @@ sdp_stream_cell_t * clone_sdp_stream_cell(sdp_stream_cell_t
*stream)
/* NOTE: we are not cloning RFC4975 attributes */
len = sizeof(sdp_stream_cell_t) +
+ stream->ip_addr.len +
stream->media.len +
stream->port.len +
stream->transport.len +
stream->payloads.len +
stream->bw_type.len +
stream->bw_width.len +
- stream->ip_addr.len;
+ stream->rtcp_port.len;
clone_stream = (sdp_stream_cell_t*)shm_malloc(len);
if (clone_stream == NULL) {
LM_ERR("no more shm mem (%d)\n",len);
@@ -998,6 +1002,13 @@ sdp_stream_cell_t * clone_sdp_stream_cell(sdp_stream_cell_t
*stream)
clone_stream->stream_num = stream->stream_num;
clone_stream->pf = stream->pf;
+ if (stream->ip_addr.len) {
+ clone_stream->ip_addr.s = p;
+ clone_stream->ip_addr.len = stream->ip_addr.len;
+ memcpy( p, stream->ip_addr.s, stream->ip_addr.len);
+ p += stream->ip_addr.len;
+ }
+
if (stream->media.len) {
clone_stream->media.s = p;
clone_stream->media.len = stream->media.len;
@@ -1038,11 +1049,11 @@ sdp_stream_cell_t * clone_sdp_stream_cell(sdp_stream_cell_t
*stream)
p += stream->bw_width.len;
}
- if (stream->ip_addr.len) {
- clone_stream->ip_addr.s = p;
- clone_stream->ip_addr.len = stream->ip_addr.len;
- memcpy( p, stream->ip_addr.s, stream->ip_addr.len);
- //p += stream->payloads.len;
+ if (stream->rtcp_port.len) {
+ clone_stream->rtcp_port.s = p;
+ clone_stream->rtcp_port.len = stream->rtcp_port.len;
+ memcpy( p, stream->rtcp_port.s, stream->rtcp_port.len);
+ p += stream->rtcp_port.len;
}
/* NOTE: we are not cloning RFC4975 attributes:
@@ -1120,7 +1131,7 @@ sdp_session_cell_t * clone_sdp_session_cell(sdp_session_cell_t
*session)
clone_session->bw_width.s = p;
clone_session->bw_width.len = session->bw_width.len;
memcpy( p, session->bw_width.s, session->bw_width.len);
- //p += session->bw_type.len;
+ p += session->bw_width.len;
}
return clone_session;
diff --git a/parser/sdp/sdp.h b/parser/sdp/sdp.h
index 9c9b9c7..481afec 100644
--- a/parser/sdp/sdp.h
+++ b/parser/sdp/sdp.h
@@ -61,6 +61,9 @@ typedef struct sdp_stream_cell {
CT - conference total;
AS - application specific */
str bw_width; /**< The <bandwidth> is interpreted as
kilobits per second by default */
+ /* RFC3605: Real Time Control Protocol (RTCP) attribute in Session Description Protocol
(SDP) */
+ /* a=rtcp: port [nettype space addrtype space connection-address] CRLF */
+ str rtcp_port; /**< RFC3605: rtcp attribute */
str path; /**< RFC4975: path attribute */
str max_size; /**< RFC4975: max-size attribute */
str accept_types; /**< RFC4975: accept-types attribute */
diff --git a/parser/sdp/sdp_helpr_funcs.c b/parser/sdp/sdp_helpr_funcs.c
index d6270a6..681dd23 100644
--- a/parser/sdp/sdp_helpr_funcs.c
+++ b/parser/sdp/sdp_helpr_funcs.c
@@ -267,6 +267,11 @@ int extract_path(str *body, str *path)
return extract_field(body, path, field);
}
+int extract_rtcp(str *body, str *rtcp)
+{
+ static const str field = str_init("a=rtcp:");
+ return extract_field(body, rtcp, field);
+}
int extract_sendrecv_mode(str *body, str *sendrecv_mode)
{
diff --git a/parser/sdp/sdp_helpr_funcs.h b/parser/sdp/sdp_helpr_funcs.h
index de845ea..d7b02ee 100644
--- a/parser/sdp/sdp_helpr_funcs.h
+++ b/parser/sdp/sdp_helpr_funcs.h
@@ -50,6 +50,9 @@ int extract_mediaip(str *body, str *mediaip, int *pf, char *line);
int extract_media_attr(str *body, str *mediamedia, str *mediaport, str *mediatransport,
str *mediapayload);
int extract_bwidth(str *body, str *bwtype, str *bwwitdth);
+/* RFC3605 attributes */
+int extract_rtcp(str *body, str *rtcp);
+
/* RFC4975 attributes */
int extract_accept_types(str *body, str *accept_types);
int extract_accept_wrapped_types(str *body, str *accept_wrapped_types);