| 908 | } |
| 909 | |
| 910 | static mi_response_t *mi_enable_rtp_proxy(const mi_params_t *params, |
| 911 | unsigned int set_id) |
| 912 | { |
| 913 | str rtpp_url; |
| 914 | int enable; |
| 915 | struct rtpp_set * rtpp_list; |
| 916 | struct rtpp_node * crt_rtpp; |
| 917 | int found, disabled, prev_disabled, recheck_ticks; |
| 918 | |
| 919 | found = 0; |
| 920 | |
| 921 | if(*rtpp_set_list ==NULL) |
| 922 | goto end; |
| 923 | |
| 924 | if (get_mi_string_param(params, "url", &rtpp_url.s, &rtpp_url.len) < 0) |
| 925 | return init_mi_param_error(); |
| 926 | if(rtpp_url.s == NULL || rtpp_url.len ==0) |
| 927 | return init_mi_error(400, MI_SSTR("Empty url")); |
| 928 | |
| 929 | if (get_mi_int_param(params, "enable", &enable) < 0) |
| 930 | return init_mi_param_error(); |
| 931 | |
| 932 | for(rtpp_list = (*rtpp_set_list)->rset_first; rtpp_list != NULL; |
| 933 | rtpp_list = rtpp_list->rset_next){ |
| 934 | |
| 935 | /* if set_id given, check only the list with the matching set_id */ |
| 936 | if ( (set_id!=(unsigned int)(-1)) && set_id!=rtpp_list->id_set ) |
| 937 | continue; |
| 938 | |
| 939 | for(crt_rtpp = rtpp_list->rn_first; crt_rtpp != NULL; |
| 940 | crt_rtpp = crt_rtpp->rn_next){ |
| 941 | /*found a matching rtpp*/ |
| 942 | |
| 943 | if(crt_rtpp->rn_url.len == rtpp_url.len){ |
| 944 | |
| 945 | if(strncmp(crt_rtpp->rn_url.s, rtpp_url.s, rtpp_url.len) == 0){ |
| 946 | /*set the enabled/disabled status*/ |
| 947 | found = 1; |
| 948 | prev_disabled = crt_rtpp->rn_disabled; |
| 949 | switch (enable) { |
| 950 | case 0: /* disable */ |
| 951 | recheck_ticks = MI_MAX_RECHECK_TICKS; |
| 952 | disabled = 1; |
| 953 | break; |
| 954 | case 2: /* pending */ |
| 955 | recheck_ticks = get_ticks() + rtpproxy_disable_tout; |
| 956 | disabled = 1; |
| 957 | break; |
| 958 | default: /* enable */ |
| 959 | recheck_ticks = MI_MIN_RECHECK_TICKS; |
| 960 | disabled = 0; |
| 961 | break; |
| 962 | } |
| 963 | crt_rtpp->rn_recheck_ticks = recheck_ticks; |
| 964 | crt_rtpp->rn_disabled = disabled; |
| 965 | if (prev_disabled != crt_rtpp->rn_disabled) |
| 966 | raise_rtpproxy_event(crt_rtpp, crt_rtpp->rn_disabled); |
| 967 | } |
no test coverage detected