Module: sip-router
Branch: master
Commit: 550a879a50258557084da59787f13f3f6eb285f1
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=550a879…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Wed Sep 28 16:02:02 2011 +0200
core: parser/sdp - optimized a= lines parsing
- search for next a= line from the last parsed position in previous a=
line
---
parser/sdp/sdp.c | 8 +++++---
parser/sdp/sdp_helpr_funcs.c | 12 ++++++++++++
parser/sdp/sdp_helpr_funcs.h | 2 ++
3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/parser/sdp/sdp.c b/parser/sdp/sdp.c
index 687d466..6d53ab9 100644
--- a/parser/sdp/sdp.c
+++ b/parser/sdp/sdp.c
@@ -553,11 +553,13 @@ static int parse_sdp_session(str *sdp_body, int session_num, str
*cnt_disp, sdp_
a1p = stream->max_size.s + stream->max_size.len;
} else if (extract_path(&tmpstr1, &stream->path) == 0) {
a1p = stream->path.s + stream->path.len;
- /*} else { */
- /* LM_DBG("else: `%.*s'\n", tmpstr1.len, tmpstr1.s); */
+ } else {
+ /* unknown a= line, ignore -- jump over it */
+ LM_DBG("ignoring unknown type in a= line: `%.*s'\n", tmpstr1.len,
tmpstr1.s);
+ a1p += 2;
}
- a2p = find_next_sdp_line(a2p, m2p, 'a', m2p);
+ a2p = find_first_sdp_line(a1p, m2p, 'a', m2p);
}
/* Let's detect if the media is on hold by checking
* the good old "0.0.0.0" connection address */
diff --git a/parser/sdp/sdp_helpr_funcs.c b/parser/sdp/sdp_helpr_funcs.c
index 6dde0d4..466dc8c 100644
--- a/parser/sdp/sdp_helpr_funcs.c
+++ b/parser/sdp/sdp_helpr_funcs.c
@@ -606,6 +606,18 @@ char * find_next_sdp_line(char* p, char* plimit, char linechar, char*
defptr)
}
+/* Find first SDP line starting with linechar. Return defptr if not found */
+char * find_first_sdp_line(char* pstart, char* plimit, char linechar,
+ char* defptr)
+{
+ char *t;
+ if (pstart >= plimit || plimit - pstart < 3)
+ return defptr;
+ t = find_sdp_line(pstart, plimit, linechar);
+ return t ? t : defptr;
+}
+
+
/* returns pointer to next header line, and fill hdr_f ;
* if at end of header returns pointer to the last crlf (always buf)*/
char* get_sdp_hdr_field(char* buf, char* end, struct hdr_field* hdr)
diff --git a/parser/sdp/sdp_helpr_funcs.h b/parser/sdp/sdp_helpr_funcs.h
index c815845..0ec10e2 100644
--- a/parser/sdp/sdp_helpr_funcs.h
+++ b/parser/sdp/sdp_helpr_funcs.h
@@ -68,4 +68,6 @@ char* get_sdp_hdr_field(char* , char* , struct hdr_field* );
char *find_sdp_line_delimiter(char *p, char *plimit, str delimiter);
char *find_next_sdp_line_delimiter(char *p, char *plimit, str delimiter, char *defptr);
+char * find_first_sdp_line(char* pstart, char* plimit, char linechar,
+ char* defptr);
#endif