@@ -331,24 +331,23 @@ static int do_for_all_streams(struct sip_msg* msg, str* str1,str * str2,
331
331
}
332
332
333
333
cur_session = msg -> sdp -> sessions ;
334
- rez = 0 ;
334
+ rez = -1 ;
335
335
336
336
while (cur_session )
337
337
{
338
338
struct sdp_stream_cell * cur_cell = cur_session -> streams ;
339
339
340
340
while (cur_cell )
341
341
{
342
- rez |= stream_process (msg ,cur_cell ,str1 ,str2 ,re ,op ,desc );
342
+ if (stream_process (msg ,cur_cell ,str1 ,str2 ,re ,op ,desc )== 1 )
343
+ rez = 1 ;
343
344
cur_cell = cur_cell -> next ;
344
345
}
345
346
346
347
cur_session = cur_session -> next ;
347
348
348
349
}
349
350
350
- if ( rez < 0 )
351
- rez = 0 ;
352
351
return rez ;
353
352
}
354
353
@@ -685,35 +684,28 @@ int codec_find (struct sip_msg* msg, char* str1 )
685
684
686
685
LM_DBG ("searching for codec <%.*s> \n" ,res .len ,res .s );
687
686
688
- if ( do_for_all_streams ( msg , & res , NULL , NULL ,
689
- FIND , DESC_NAME ) == 0 )
690
- return -1 ;
691
-
692
- return 1 ;
693
-
687
+ return do_for_all_streams ( msg , & res , NULL , NULL ,
688
+ FIND , DESC_NAME );
694
689
}
695
690
696
691
int codec_find_re (struct sip_msg * msg , char * str1 )
697
692
{
698
693
regex_t * re ;
699
694
int do_free ;
695
+ int ret ;
700
696
701
697
re = fixup_get_regex (msg ,(gparam_p )str1 ,& do_free );
702
698
if (!re ) {
703
699
LM_ERR ("Failed to get regular expression \n" );
704
700
return -1 ;
705
701
}
706
702
707
- if ( do_for_all_streams (msg , NULL , NULL , re ,
708
- FIND , DESC_REGEXP ) == 0 ) {
709
- if (do_free )
710
- fixup_free_regexp ((void * * )& re );
711
- return -1 ;
712
- }
713
-
703
+ ret = do_for_all_streams (msg , NULL , NULL , re ,
704
+ FIND , DESC_REGEXP );
705
+
714
706
if (do_free )
715
707
fixup_free_regexp ((void * * )& re );
716
- return 1 ;
708
+ return ret ;
717
709
}
718
710
719
711
@@ -736,11 +728,8 @@ int codec_find_clock (struct sip_msg* msg, char* str1,char * str2 )
736
728
LM_DBG ("searching for codec <%.*s> with clock <%.*s> \n" ,
737
729
codec .len ,codec .s ,clock .len ,clock .s );
738
730
739
- if ( do_for_all_streams ( msg , & codec , & clock , NULL ,
740
- FIND , DESC_NAME_AND_CLOCK ) == 0 )
741
- return -1 ;
742
-
743
- return 1 ;
731
+ return do_for_all_streams ( msg , & codec , & clock , NULL ,
732
+ FIND , DESC_NAME_AND_CLOCK );
744
733
}
745
734
746
735
@@ -756,58 +745,50 @@ int codec_delete (struct sip_msg* msg, char* str1 )
756
745
757
746
LM_DBG ("deleting codec <%.*s> \n" ,res .len ,res .s );
758
747
759
- if ( do_for_all_streams ( msg , & res , NULL , NULL ,
760
- DELETE , DESC_NAME ) == 0 )
761
- return -1 ;
762
- return 1 ;
748
+ return do_for_all_streams ( msg , & res , NULL , NULL ,
749
+ DELETE , DESC_NAME );
763
750
}
764
751
765
752
766
753
int codec_delete_re (struct sip_msg * msg , char * str1 )
767
754
{
768
755
regex_t * re ;
769
756
int do_free ;
757
+ int ret ;
770
758
771
759
re = fixup_get_regex (msg ,(gparam_p )str1 ,& do_free );
772
760
if (!re ) {
773
761
LM_ERR ("Failed to get regular expression \n" );
774
762
return -1 ;
775
763
}
776
764
777
- if ( do_for_all_streams ( msg , NULL , NULL , re ,
778
- DELETE , DESC_REGEXP ) == 0 ) {
779
- if (do_free )
780
- fixup_free_regexp ((void * * )& re );
781
- return -1 ;
782
- }
765
+ ret = do_for_all_streams ( msg , NULL , NULL , re ,
766
+ DELETE , DESC_REGEXP );
783
767
784
768
if (do_free )
785
769
fixup_free_regexp ((void * * )& re );
786
- return 1 ;
770
+ return ret ;
787
771
}
788
772
789
773
790
774
int codec_delete_except_re (struct sip_msg * msg , char * str1 )
791
775
{
792
776
regex_t * re ;
793
777
int do_free ;
778
+ int ret ;
794
779
795
780
re = fixup_get_regex (msg ,(gparam_p )str1 ,& do_free );
796
781
if (!re ) {
797
782
LM_ERR ("Failed to get regular expression \n" );
798
783
return -1 ;
799
784
}
800
785
801
- if ( do_for_all_streams ( msg , NULL , NULL , re ,
802
- DELETE , DESC_REGEXP_COMPLEMENT ) == 0 ) {
803
- if (do_free )
804
- fixup_free_regexp ((void * * )& re );
805
- return -1 ;
806
- }
786
+ ret = do_for_all_streams ( msg , NULL , NULL , re ,
787
+ DELETE , DESC_REGEXP_COMPLEMENT );
807
788
808
789
if (do_free )
809
790
fixup_free_regexp ((void * * )& re );
810
- return 1 ;
791
+ return ret ;
811
792
}
812
793
813
794
@@ -830,10 +811,8 @@ int codec_delete_clock (struct sip_msg* msg, char* str1 ,char * str2)
830
811
LM_DBG ("deleting codec <%.*s> with clock <%.*s> \n" ,
831
812
codec .len ,codec .s ,clock .len ,clock .s );
832
813
833
- if ( do_for_all_streams ( msg , & codec , & clock , NULL ,
834
- DELETE , DESC_NAME_AND_CLOCK ) == 0 )
835
- return -1 ;
836
- return 1 ;
814
+ return do_for_all_streams ( msg , & codec , & clock , NULL ,
815
+ DELETE , DESC_NAME_AND_CLOCK );
837
816
}
838
817
839
818
@@ -849,34 +828,29 @@ int codec_move_up (struct sip_msg* msg, char* str1)
849
828
850
829
LM_DBG ("moving up codec <%.*s> \n" ,res .len ,res .s );
851
830
852
- if ( do_for_all_streams ( msg , & res , NULL , NULL ,
853
- ADD_TO_FRONT , DESC_NAME ) == 0 )
854
- return -1 ;
855
- return 1 ;
831
+ return do_for_all_streams ( msg , & res , NULL , NULL ,
832
+ ADD_TO_FRONT , DESC_NAME );
856
833
}
857
834
858
835
859
836
int codec_move_up_re (struct sip_msg * msg , char * str1 )
860
837
{
861
838
regex_t * re ;
862
839
int do_free ;
840
+ int ret ;
863
841
864
842
re = fixup_get_regex (msg ,(gparam_p )str1 ,& do_free );
865
843
if (!re ) {
866
844
LM_ERR ("Failed to get regular expression \n" );
867
845
return -1 ;
868
846
}
869
847
870
- if ( do_for_all_streams ( msg , NULL , NULL , re ,
871
- ADD_TO_FRONT , DESC_REGEXP ) == 0 ) {
872
- if (do_free )
873
- fixup_free_regexp ((void * * )& re );
874
- return -1 ;
875
- }
848
+ ret = do_for_all_streams ( msg , NULL , NULL , re ,
849
+ ADD_TO_FRONT , DESC_REGEXP );
876
850
877
851
if (do_free )
878
852
fixup_free_regexp ((void * * )& re );
879
- return 1 ;
853
+ return ret ;
880
854
}
881
855
882
856
@@ -899,10 +873,8 @@ int codec_move_up_clock (struct sip_msg* msg, char* str1 ,char * str2)
899
873
LM_DBG ("moving up codec <%.*s> with clock <%.*s> \n" ,
900
874
codec .len ,codec .s ,clock .len ,clock .s );
901
875
902
- if ( do_for_all_streams ( msg , & codec , & clock , NULL ,
903
- ADD_TO_FRONT , DESC_NAME_AND_CLOCK ) == 0 )
904
- return -1 ;
905
- return 1 ;
876
+ return do_for_all_streams ( msg , & codec , & clock , NULL ,
877
+ ADD_TO_FRONT , DESC_NAME_AND_CLOCK );
906
878
}
907
879
908
880
@@ -918,34 +890,29 @@ int codec_move_down (struct sip_msg* msg, char* str1)
918
890
919
891
LM_DBG ("moving down codec <%.*s> \n" ,res .len ,res .s );
920
892
921
- if ( do_for_all_streams ( msg , & res , NULL , NULL ,
922
- ADD_TO_BACK , DESC_NAME ) == 0 )
923
- return -1 ;
924
- return 1 ;
893
+ return do_for_all_streams ( msg , & res , NULL , NULL ,
894
+ ADD_TO_BACK , DESC_NAME );
925
895
}
926
896
927
897
928
898
int codec_move_down_re (struct sip_msg * msg , char * str1 )
929
899
{
930
900
regex_t * re ;
931
901
int do_free ;
902
+ int ret ;
932
903
933
904
re = fixup_get_regex (msg ,(gparam_p )str1 ,& do_free );
934
905
if (!re ) {
935
906
LM_ERR ("Failed to get regular expression \n" );
936
907
return -1 ;
937
908
}
938
909
939
- if ( do_for_all_streams ( msg , NULL , NULL , re ,
940
- ADD_TO_BACK , DESC_REGEXP ) == 0 ) {
941
- if (do_free )
942
- fixup_free_regexp ((void * * )& re );
943
- return -1 ;
944
- }
910
+ ret = do_for_all_streams ( msg , NULL , NULL , re ,
911
+ ADD_TO_BACK , DESC_REGEXP );
945
912
946
913
if (do_free )
947
914
fixup_free_regexp ((void * * )& re );
948
- return 1 ;
915
+ return ret ;
949
916
}
950
917
951
918
@@ -968,10 +935,8 @@ int codec_move_down_clock (struct sip_msg* msg, char* str1 ,char * str2)
968
935
LM_DBG ("moving down codec <%.*s> with clock <%.*s> \n" ,
969
936
codec .len ,codec .s ,clock .len ,clock .s );
970
937
971
- if ( do_for_all_streams ( msg , & codec , & clock , NULL ,
972
- ADD_TO_BACK , DESC_NAME_AND_CLOCK ) == 0 )
973
- return -1 ;
974
- return 1 ;
938
+ return do_for_all_streams ( msg , & codec , & clock , NULL ,
939
+ ADD_TO_BACK , DESC_NAME_AND_CLOCK );
975
940
}
976
941
977
942
0 commit comments