Module: sip-router
Branch: master
Commit: c90ff4d4861fcd33c376122a0b0daf1ce7ca7522
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c90ff4d…
Author: Ovidiu Sas <osas(a)voipembedded.com>
Committer: Ovidiu Sas <osas(a)voipembedded.com>
Date: Mon Jun 28 09:54:01 2010 -0400
core: sdp parser: making 'sendrecv_mode' and 'ptime' session attributes
---
parser/sdp/sdp.c | 97 +++++++++++++++---------------------------------------
parser/sdp/sdp.h | 4 +-
2 files changed, 29 insertions(+), 72 deletions(-)
diff --git a/parser/sdp/sdp.c b/parser/sdp/sdp.c
index 0b6d3e9..f0e490f 100644
--- a/parser/sdp/sdp.c
+++ b/parser/sdp/sdp.c
@@ -216,47 +216,6 @@ void set_sdp_payload_attr(sdp_payload_attr_t *payload_attr, str
*rtp_enc, str *r
return;
}
-void set_sdp_ptime_attr(sdp_stream_cell_t *stream, sdp_payload_attr_t *payload_attr, str
*ptime)
-{
- sdp_payload_attr_t *payload;
- int i;
-
- if (payload_attr == 0) {
- /* This is a generic attribute
- * Let's update all payloads */
- for (i=0;i<stream->payloads_num;i++) {
- payload = stream->p_payload_attr[i];
- payload->ptime.s = ptime->s;
- payload->ptime.len = ptime->len;
- }
- } else {
- payload_attr->ptime.s = ptime->s;
- payload_attr->ptime.len = ptime->len;
- }
- return;
-}
-
-void set_sdp_sendrecv_mode_attr(sdp_stream_cell_t *stream, sdp_payload_attr_t
*payload_attr, str *sendrecv_mode)
-{
- sdp_payload_attr_t *payload;
- int i;
-
- if (payload_attr == 0) {
- /* This is a generic attribute
- * Let's update all payloads */
- for (i=0;i<stream->payloads_num;i++) {
- payload = stream->p_payload_attr[i];
- payload->sendrecv_mode.s = sendrecv_mode->s;
- payload->sendrecv_mode.len = sendrecv_mode->len;
- }
- } else {
- payload_attr->sendrecv_mode.s = sendrecv_mode->s;
- payload_attr->sendrecv_mode.len = sendrecv_mode->len;
- }
-
- return;
-}
-
/*
* Getters ....
*/
@@ -380,7 +339,7 @@ static int parse_sdp_session(str *sdp_body, int session_num, str
*cnt_disp, sdp_
str body = *sdp_body;
str sdp_ip, sdp_media, sdp_port, sdp_transport, sdp_payload;
str payload;
- str rtp_payload, rtp_enc, rtp_clock, rtp_params, ptime, sendrecv_mode;
+ str rtp_payload, rtp_enc, rtp_clock, rtp_params;
char *bodylimit;
char *v1p, *o1p, *m1p, *m2p, *c1p, *c2p, *a1p, *a2p, *b1p;
str tmpstr1;
@@ -543,12 +502,10 @@ static int parse_sdp_session(str *sdp_body, int session_num, str
*cnt_disp, sdp_
tmpstr1.s = a2p;
tmpstr1.len = m2p - a2p;
- if (parse_payload_attr && extract_ptime(&tmpstr1, &ptime) == 0) {
- a1p = ptime.s + ptime.len;
- set_sdp_ptime_attr(stream, payload_attr, &ptime);
- } else if (parse_payload_attr && extract_sendrecv_mode(&tmpstr1,
&sendrecv_mode) == 0) {
- a1p = sendrecv_mode.s + sendrecv_mode.len;
- set_sdp_sendrecv_mode_attr(stream, payload_attr, &sendrecv_mode);
+ if (parse_payload_attr && extract_ptime(&tmpstr1, &stream->ptime)
== 0) {
+ a1p = stream->ptime.s + stream->ptime.len;
+ } else if (parse_payload_attr && extract_sendrecv_mode(&tmpstr1,
&stream->sendrecv_mode) == 0) {
+ a1p = stream->sendrecv_mode.s + stream->sendrecv_mode.len;
} else if (parse_payload_attr && extract_rtpmap(&tmpstr1,
&rtp_payload, &rtp_enc, &rtp_clock, &rtp_params) == 0) {
if (rtp_params.len != 0 && rtp_params.s != NULL) {
a1p = rtp_params.s + rtp_params.len;
@@ -801,7 +758,7 @@ 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:%.*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' '%.*s' '%.*s'\n",
stream->stream_num, stream, stream->next,
stream->p_payload_attr,
stream->media.len, stream->media.s,
@@ -811,21 +768,21 @@ void print_sdp_stream(sdp_stream_cell_t *stream)
stream->payloads.len, stream->payloads.s,
stream->bw_type.len, stream->bw_type.s, stream->bw_width.len,
stream->bw_width.s,
stream->payloads_num, stream->payload_attr,
+ stream->sendrecv_mode.len, stream->sendrecv_mode.s,
+ stream->ptime.len, stream->ptime.s,
stream->path.len, stream->path.s,
stream->max_size.len, stream->max_size.s,
stream->accept_types.len, stream->accept_types.s,
stream->accept_wrapped_types.len, stream->accept_wrapped_types.s);
payload = stream->payload_attr;
while (payload) {
- LM_DBG("......payload[%d]:%p=>%p p_payload_attr[%d]:%p '%.*s'
'%.*s' '%.*s' '%.*s' '%.*s' '%.*s'\n",
+ LM_DBG("......payload[%d]:%p=>%p p_payload_attr[%d]:%p '%.*s'
'%.*s' '%.*s' '%.*s'\n",
payload->payload_num, payload, payload->next,
payload->payload_num, stream->p_payload_attr[payload->payload_num],
payload->rtp_payload.len, payload->rtp_payload.s,
payload->rtp_enc.len, payload->rtp_enc.s,
payload->rtp_clock.len, payload->rtp_clock.s,
- payload->rtp_params.len, payload->rtp_params.s,
- payload->sendrecv_mode.len, payload->sendrecv_mode.s,
- payload->ptime.len, payload->ptime.s);
+ payload->rtp_params.len, payload->rtp_params.s);
payload=payload->next;
}
}
@@ -925,9 +882,7 @@ sdp_payload_attr_t * clone_sdp_payload_attr(sdp_payload_attr_t *attr)
attr->rtp_payload.len +
attr->rtp_enc.len +
attr->rtp_clock.len +
- attr->rtp_params.len +
- attr->sendrecv_mode.len +
- attr->ptime.len;
+ attr->rtp_params.len;
clone_attr = (sdp_payload_attr_t*)shm_malloc(len);
if (clone_attr == NULL) {
LM_ERR("no more shm mem (%d)\n",len);
@@ -966,20 +921,6 @@ sdp_payload_attr_t * clone_sdp_payload_attr(sdp_payload_attr_t
*attr)
p += attr->rtp_params.len;
}
- if (attr->sendrecv_mode.len) {
- clone_attr->sendrecv_mode.s = p;
- clone_attr->sendrecv_mode.len = attr->sendrecv_mode.len;
- memcpy( p, attr->sendrecv_mode.s, attr->sendrecv_mode.len);
- p += attr->sendrecv_mode.len;
- }
-
- if (attr->ptime.len) {
- clone_attr->ptime.s = p;
- clone_attr->ptime.len = attr->ptime.len;
- memcpy( p, attr->ptime.s, attr->ptime.len);
- p += attr->ptime.len;
- }
-
return clone_attr;
}
@@ -1001,6 +942,8 @@ sdp_stream_cell_t * clone_sdp_stream_cell(sdp_stream_cell_t *stream)
stream->media.len +
stream->port.len +
stream->transport.len +
+ stream->sendrecv_mode.len +
+ stream->ptime.len +
stream->payloads.len +
stream->bw_type.len +
stream->bw_width.len +
@@ -1063,6 +1006,20 @@ sdp_stream_cell_t * clone_sdp_stream_cell(sdp_stream_cell_t
*stream)
p += stream->transport.len;
}
+ if (stream->sendrecv_mode.len) {
+ clone_stream->sendrecv_mode.s = p;
+ clone_stream->sendrecv_mode.len = stream->sendrecv_mode.len;
+ memcpy( p, stream->sendrecv_mode.s, stream->sendrecv_mode.len);
+ p += stream->sendrecv_mode.len;
+ }
+
+ if (stream->ptime.len) {
+ clone_stream->ptime.s = p;
+ clone_stream->ptime.len = stream->ptime.len;
+ memcpy( p, stream->ptime.s, stream->ptime.len);
+ p += stream->ptime.len;
+ }
+
if (stream->payloads.len) {
clone_stream->payloads.s = p;
clone_stream->payloads.len = stream->payloads.len;
diff --git a/parser/sdp/sdp.h b/parser/sdp/sdp.h
index 73c334f..0e9f19c 100644
--- a/parser/sdp/sdp.h
+++ b/parser/sdp/sdp.h
@@ -40,8 +40,6 @@ typedef struct sdp_payload_attr {
str rtp_enc;
str rtp_clock;
str rtp_params;
- str sendrecv_mode;
- str ptime;
} sdp_payload_attr_t;
typedef struct sdp_stream_cell {
@@ -54,6 +52,8 @@ typedef struct sdp_stream_cell {
str media;
str port;
str transport;
+ str sendrecv_mode;
+ str ptime;
str payloads;
int payloads_num; /**< number of payloads inside a stream */
/* b=<bwtype>:<bandwidth> */