[sr-dev] git:master: core: sdp parser - adding two new getters
Ovidiu Sas
osas at voipembedded.com
Sun Jun 27 22:56:25 CEST 2010
Module: sip-router
Branch: master
Commit: 5a1d36d4fc94df11c1ff148ccd873f2fb2e82859
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5a1d36d4fc94df11c1ff148ccd873f2fb2e82859
Author: Ovidiu Sas <osas at voipembedded.com>
Committer: Ovidiu Sas <osas at voipembedded.com>
Date: Sun Jun 27 17:00:28 2010 -0400
core: sdp parser - adding two new getters
- get_sdp_session_num: get the total number of sessions
- get_sdp_stream_num: get the total number of streams
---
parser/sdp/sdp.c | 19 ++++++++++++++++++-
parser/sdp/sdp.h | 9 +++++++++
2 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/parser/sdp/sdp.c b/parser/sdp/sdp.c
index 11aa8f1..0b6d3e9 100644
--- a/parser/sdp/sdp.c
+++ b/parser/sdp/sdp.c
@@ -260,6 +260,19 @@ void set_sdp_sendrecv_mode_attr(sdp_stream_cell_t *stream, sdp_payload_attr_t *p
/*
* Getters ....
*/
+int get_sdp_session_num(struct sip_msg* _m)
+{
+ if (_m->body == NULL) return 0;
+ if (_m->body->type != MSG_BODY_SDP) return 0;
+ return ((sdp_info_t*)_m->body)->sessions_num;
+}
+
+int get_sdp_stream_num(struct sip_msg* _m)
+{
+ if (_m->body == NULL) return 0;
+ if (_m->body->type != MSG_BODY_SDP) return 0;
+ return ((sdp_info_t*)_m->body)->streams_num;
+}
sdp_session_cell_t* get_sdp_session_sdp(struct sdp_info* sdp, int session_num)
{
@@ -478,6 +491,9 @@ static int parse_sdp_session(str *sdp_body, int session_num, str *cnt_disp, sdp_
stream = add_sdp_stream(session, stream_num, &sdp_media, &sdp_port, &sdp_transport, &sdp_payload, pf, &sdp_ip);
if (stream == 0) return -1;
+ /* increment total number of streams */
+ _sdp->streams_num++;
+
/* b1p will point to per-media "b=" */
b1p = find_sdp_line(m1p, m2p, 'b');
if (b1p) {
@@ -839,7 +855,7 @@ void print_sdp(sdp_info_t* sdp)
{
sdp_session_cell_t *session;
- LM_DBG("sdp:%p=>%p (%d)\n", sdp, sdp->sessions, sdp->sessions_num);
+ LM_DBG("sdp:%p=>%p (%d:%d)\n", sdp, sdp->sessions, sdp->sessions_num, sdp->streams_num);
session = sdp->sessions;
while (session) {
print_sdp_session(session);
@@ -1207,6 +1223,7 @@ sdp_info_t * clone_sdp_info(struct sip_msg* _m)
memset( clone_sdp_info, 0, len);
LM_DBG("we have %d sessions\n", sdp_info->sessions_num);
clone_sdp_info->sessions_num = sdp_info->sessions_num;
+ clone_sdp_info->streams_num = sdp_info->streams_num;
session=sdp_info->sessions;
clone_session=clone_sdp_session_cell(session);
diff --git a/parser/sdp/sdp.h b/parser/sdp/sdp.h
index c26a568..73c334f 100644
--- a/parser/sdp/sdp.h
+++ b/parser/sdp/sdp.h
@@ -98,6 +98,7 @@ typedef struct sdp_info {
msg_body_type_t type;
free_msg_body_f free;
int sessions_num; /**< number of SDP sessions */
+ int streams_num; /**< total number of streams for all SDP sessions */
struct sdp_session_cell *sessions;
} sdp_info_t;
@@ -108,6 +109,14 @@ typedef struct sdp_info {
int parse_sdp(struct sip_msg* _m);
/**
+ * Get number of sessions in existing SDP.
+ */
+int get_sdp_session_num(struct sip_msg* _m);
+/**
+ * Get number of streams in existing SDP.
+ */
+int get_sdp_stream_num(struct sip_msg* _m);
+/**
* Get a session for the current sip msg based on position inside SDP.
*/
sdp_session_cell_t* get_sdp_session(struct sip_msg* _m, int session_num);
More information about the sr-dev
mailing list