diff --git a/modules/sipmsgops/codecs.c b/modules/sipmsgops/codecs.c index 344953db5ed..114ec1365eb 100644 --- a/modules/sipmsgops/codecs.c +++ b/modules/sipmsgops/codecs.c @@ -331,7 +331,7 @@ static int do_for_all_streams(struct sip_msg* msg, str* str1,str * str2, } cur_session = msg->sdp->sessions; - rez = 0; + rez = -1; while(cur_session) { @@ -339,7 +339,8 @@ static int do_for_all_streams(struct sip_msg* msg, str* str1,str * str2, while(cur_cell) { - rez |= stream_process(msg,cur_cell,str1,str2,re,op,desc); + if(stream_process(msg,cur_cell,str1,str2,re,op,desc)==1) + rez = 1; cur_cell = cur_cell->next; } @@ -347,8 +348,6 @@ static int do_for_all_streams(struct sip_msg* msg, str* str1,str * str2, } - if( rez <0 ) - rez = 0; return rez; } @@ -685,18 +684,15 @@ int codec_find (struct sip_msg* msg, char* str1 ) LM_DBG("searching for codec <%.*s> \n",res.len,res.s); - if( do_for_all_streams( msg, &res, NULL, NULL, - FIND, DESC_NAME) == 0) - return -1; - - return 1; - + return do_for_all_streams( msg, &res, NULL, NULL, + FIND, DESC_NAME); } int codec_find_re (struct sip_msg* msg, char* str1 ) { regex_t *re; int do_free; + int ret; re = fixup_get_regex(msg,(gparam_p)str1,&do_free); if (!re) { @@ -704,16 +700,12 @@ int codec_find_re (struct sip_msg* msg, char* str1 ) return -1; } - if( do_for_all_streams(msg, NULL, NULL, re, - FIND, DESC_REGEXP) == 0) { - if (do_free) - fixup_free_regexp((void **)&re); - return -1; - } - + ret = do_for_all_streams(msg, NULL, NULL, re, + FIND, DESC_REGEXP); + if (do_free) fixup_free_regexp((void **)&re); - return 1; + return ret; } @@ -736,11 +728,8 @@ int codec_find_clock (struct sip_msg* msg, char* str1,char * str2 ) LM_DBG("searching for codec <%.*s> with clock <%.*s> \n", codec.len,codec.s,clock.len,clock.s); - if( do_for_all_streams( msg, &codec, &clock, NULL, - FIND, DESC_NAME_AND_CLOCK) == 0) - return -1; - - return 1; + return do_for_all_streams( msg, &codec, &clock, NULL, + FIND, DESC_NAME_AND_CLOCK); } @@ -756,10 +745,8 @@ int codec_delete (struct sip_msg* msg, char* str1 ) LM_DBG("deleting codec <%.*s> \n",res.len,res.s); - if( do_for_all_streams( msg, &res, NULL, NULL, - DELETE, DESC_NAME) == 0) - return -1; - return 1; + return do_for_all_streams( msg, &res, NULL, NULL, + DELETE, DESC_NAME); } @@ -767,6 +754,7 @@ int codec_delete_re (struct sip_msg* msg, char* str1 ) { regex_t *re; int do_free; + int ret; re = fixup_get_regex(msg,(gparam_p)str1,&do_free); if (!re) { @@ -774,16 +762,12 @@ int codec_delete_re (struct sip_msg* msg, char* str1 ) return -1; } - if( do_for_all_streams( msg, NULL, NULL, re, - DELETE, DESC_REGEXP) == 0) { - if (do_free) - fixup_free_regexp((void **)&re); - return -1; - } + ret = do_for_all_streams( msg, NULL, NULL, re, + DELETE, DESC_REGEXP); if (do_free) fixup_free_regexp((void **)&re); - return 1; + return ret; } @@ -791,6 +775,7 @@ int codec_delete_except_re (struct sip_msg* msg, char* str1 ) { regex_t *re; int do_free; + int ret; re = fixup_get_regex(msg,(gparam_p)str1,&do_free); if (!re) { @@ -798,16 +783,12 @@ int codec_delete_except_re (struct sip_msg* msg, char* str1 ) return -1; } - if( do_for_all_streams( msg, NULL, NULL, re, - DELETE, DESC_REGEXP_COMPLEMENT) == 0) { - if (do_free) - fixup_free_regexp((void **)&re); - return -1; - } + ret = do_for_all_streams( msg, NULL, NULL, re, + DELETE, DESC_REGEXP_COMPLEMENT); if (do_free) fixup_free_regexp((void **)&re); - return 1; + return ret; } @@ -830,10 +811,8 @@ int codec_delete_clock (struct sip_msg* msg, char* str1 ,char * str2) LM_DBG("deleting codec <%.*s> with clock <%.*s> \n", codec.len,codec.s,clock.len,clock.s); - if( do_for_all_streams( msg, &codec, &clock, NULL, - DELETE, DESC_NAME_AND_CLOCK) == 0) - return -1; - return 1; + return do_for_all_streams( msg, &codec, &clock, NULL, + DELETE, DESC_NAME_AND_CLOCK); } @@ -849,10 +828,8 @@ int codec_move_up (struct sip_msg* msg, char* str1) LM_DBG("moving up codec <%.*s> \n",res.len,res.s); - if( do_for_all_streams( msg, &res, NULL, NULL, - ADD_TO_FRONT, DESC_NAME) == 0) - return -1; - return 1; + return do_for_all_streams( msg, &res, NULL, NULL, + ADD_TO_FRONT, DESC_NAME); } @@ -860,6 +837,7 @@ int codec_move_up_re (struct sip_msg* msg, char* str1) { regex_t *re; int do_free; + int ret; re = fixup_get_regex(msg,(gparam_p)str1,&do_free); if (!re) { @@ -867,16 +845,12 @@ int codec_move_up_re (struct sip_msg* msg, char* str1) return -1; } - if( do_for_all_streams( msg, NULL, NULL, re, - ADD_TO_FRONT, DESC_REGEXP) == 0) { - if (do_free) - fixup_free_regexp((void **)&re); - return -1; - } + ret = do_for_all_streams( msg, NULL, NULL, re, + ADD_TO_FRONT, DESC_REGEXP); if (do_free) fixup_free_regexp((void **)&re); - return 1; + return ret; } @@ -899,10 +873,8 @@ int codec_move_up_clock (struct sip_msg* msg, char* str1 ,char * str2) LM_DBG("moving up codec <%.*s> with clock <%.*s> \n", codec.len,codec.s,clock.len,clock.s); - if( do_for_all_streams( msg, &codec, &clock, NULL, - ADD_TO_FRONT, DESC_NAME_AND_CLOCK) == 0) - return -1; - return 1; + return do_for_all_streams( msg, &codec, &clock, NULL, + ADD_TO_FRONT, DESC_NAME_AND_CLOCK); } @@ -918,10 +890,8 @@ int codec_move_down (struct sip_msg* msg, char* str1) LM_DBG("moving down codec <%.*s> \n",res.len,res.s); - if( do_for_all_streams( msg, &res, NULL, NULL, - ADD_TO_BACK, DESC_NAME) == 0) - return -1; - return 1; + return do_for_all_streams( msg, &res, NULL, NULL, + ADD_TO_BACK, DESC_NAME); } @@ -929,6 +899,7 @@ int codec_move_down_re (struct sip_msg* msg, char* str1) { regex_t *re; int do_free; + int ret; re = fixup_get_regex(msg,(gparam_p)str1,&do_free); if (!re) { @@ -936,16 +907,12 @@ int codec_move_down_re (struct sip_msg* msg, char* str1) return -1; } - if( do_for_all_streams( msg, NULL, NULL, re, - ADD_TO_BACK, DESC_REGEXP) == 0) { - if (do_free) - fixup_free_regexp((void **)&re); - return -1; - } + ret = do_for_all_streams( msg, NULL, NULL, re, + ADD_TO_BACK, DESC_REGEXP); if (do_free) fixup_free_regexp((void **)&re); - return 1; + return ret; } @@ -968,10 +935,8 @@ int codec_move_down_clock (struct sip_msg* msg, char* str1 ,char * str2) LM_DBG("moving down codec <%.*s> with clock <%.*s> \n", codec.len,codec.s,clock.len,clock.s); - if( do_for_all_streams( msg, &codec, &clock, NULL, - ADD_TO_BACK, DESC_NAME_AND_CLOCK) == 0) - return -1; - return 1; + return do_for_all_streams( msg, &codec, &clock, NULL, + ADD_TO_BACK, DESC_NAME_AND_CLOCK); }