Module: sip-router
Branch: master
Commit: bd18d55dc1a5225a58483132b578723a155958e9
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=bd18d55…
Author: Ovidiu Sas <osas(a)voipembedded.com>
Committer: Ovidiu Sas <osas(a)voipembedded.com>
Date: Thu Dec 2 14:56:11 2010 -0500
modules_k/textops: new function is_audio_on_hold()
- returns true if at least one 'audio' stream is on hold
- only 'audio' streams are checked
---
modules_k/textops/textops.c | 35 ++++++++++++++++++++++++++++++++++-
1 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/modules_k/textops/textops.c b/modules_k/textops/textops.c
index cb3907d..5b0e3b5 100644
--- a/modules_k/textops/textops.c
+++ b/modules_k/textops/textops.c
@@ -64,6 +64,7 @@
#include "../../parser/parse_methods.h"
#include "../../parser/parse_content.h"
#include "../../parser/parse_param.h"
+#include "../../parser/sdp/sdp.h"
#include "../../lib/kcore/parse_privacy.h"
#include "../../msg_translator.h"
#include "../../ut.h"
@@ -93,6 +94,9 @@ MODULE_VERSION
#define TIME_FORMAT "Date: %a, %d %b %Y %H:%M:%S GMT"
#define MAX_TIME 64
+#define AUDIO_STR "audio"
+#define AUDIO_STR_LEN 5
+
static int search_body_f(struct sip_msg*, char*, char*);
static int replace_f(struct sip_msg*, char*, char*);
@@ -124,7 +128,7 @@ static int cmp_istr_f(struct sip_msg *msg, char *str1, char *str2 );
static int starts_with_f(struct sip_msg *msg, char *str1, char *str2 );
static int remove_hf_re_f(struct sip_msg* msg, char* key, char* foo);
static int is_present_hf_re_f(struct sip_msg* msg, char* key, char* foo);
-
+static int is_audio_on_hold_f(struct sip_msg *msg, char *str1, char *str2 );
static int fixup_substre(void**, int);
static int hname_fixup(void** param, int param_no);
static int free_hname_fixup(void** param, int param_no);
@@ -246,6 +250,9 @@ static cmd_export_t cmds[]={
{"starts_with", (cmd_function)starts_with_f, 2,
fixup_spve_spve, 0,
REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE},
+ {"is_audio_on_hold", (cmd_function)is_audio_on_hold_f, 0,
+ 0, 0,
+ REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE},
{0,0,0,0,0,0}
};
@@ -1874,6 +1881,32 @@ static int starts_with_f(struct sip_msg *msg, char *str1, char
*str2 )
return -2;
}
+static int is_audio_on_hold_f(struct sip_msg *msg, char *str1, char *str2 )
+{
+ int sdp_session_num = 0, sdp_stream_num;
+ sdp_session_cell_t* sdp_session;
+ sdp_stream_cell_t* sdp_stream;
+
+ if (0 == parse_sdp(msg)) {
+ for(;;) {
+ sdp_session = get_sdp_session(msg, sdp_session_num);
+ if(!sdp_session) break;
+ sdp_stream_num = 0;
+ for(;;) {
+ sdp_stream = get_sdp_stream(msg, sdp_session_num, sdp_stream_num);
+ if(!sdp_stream) break;
+ if(sdp_stream->media.len==AUDIO_STR_LEN &&
+ strncmp(sdp_stream->media.s,AUDIO_STR,AUDIO_STR_LEN)==0 &&
+ sdp_stream->is_on_hold)
+ return 1;
+ sdp_stream_num++;
+ }
+ sdp_session_num++;
+ }
+ }
+ return -1;
+}
+
int fixup_regexpNL_none(void** param, int param_no)
{
regex_t* re;