Browse code

rtpengine: exported more functions to kemi framework

Daniel-Constantin Mierla authored on 18/04/2017 12:06:58
Showing 1 changed files
... ...
@@ -3005,6 +3005,101 @@ static int ki_rtpengine_manage(sip_msg_t *msg, str *flags) {
3005 3005
     return rtpengine_rtpp_set_wrap(msg, rtpengine_manage_wrap, ((flags && flags->len > 0) ? flags->s : NULL), 1);
3006 3006
 }
3007 3007
 
3008
+static int ki_rtpengine_offer0(sip_msg_t *msg)
3009
+{
3010
+	return rtpengine_rtpp_set_wrap(msg, rtpengine_offer_wrap, 0, 1);
3011
+}
3012
+
3013
+static int ki_rtpengine_offer(sip_msg_t *msg, str *flags)
3014
+{
3015
+	return rtpengine_rtpp_set_wrap(msg, rtpengine_offer_wrap, flags->s, 1);
3016
+}
3017
+
3018
+static int ki_rtpengine_answer0(sip_msg_t *msg)
3019
+{
3020
+	return rtpengine_rtpp_set_wrap(msg, rtpengine_answer_wrap, NULL, 2);
3021
+}
3022
+
3023
+static int ki_rtpengine_answer(sip_msg_t *msg, str *flags)
3024
+{
3025
+	return rtpengine_rtpp_set_wrap(msg, rtpengine_answer_wrap, flags->s, 2);
3026
+}
3027
+
3028
+static int ki_rtpengine_delete0(sip_msg_t *msg)
3029
+{
3030
+	return rtpengine_rtpp_set_wrap(msg, rtpengine_delete_wrap, NULL, 1);
3031
+}
3032
+
3033
+static int ki_rtpengine_delete(sip_msg_t *msg, str *flags)
3034
+{
3035
+	return rtpengine_rtpp_set_wrap(msg, rtpengine_delete_wrap, flags->s, 1);
3036
+}
3037
+
3038
+static int ki_start_recording(sip_msg_t *msg)
3039
+{
3040
+	return rtpengine_rtpp_set_wrap(msg, rtpengine_start_recording_wrap, NULL, 1);
3041
+}
3042
+
3043
+static int ki_set_rtpengine_set(sip_msg_t *msg, int r1)
3044
+{
3045
+	rtpp_set_link_t rtpl1;
3046
+	rtpp_set_link_t rtpl2;
3047
+	int ret;
3048
+
3049
+	memset(&rtpl1, 0, sizeof(rtpp_set_link_t));
3050
+	memset(&rtpl2, 0, sizeof(rtpp_set_link_t));
3051
+
3052
+	if((rtpl1.rset = select_rtpp_set((unsigned int)r1)) ==0){
3053
+		LM_ERR("rtpp_proxy set %d not configured\n", r1);
3054
+		return -1;
3055
+	}
3056
+
3057
+	current_msg_id = 0;
3058
+	active_rtpp_set = 0;
3059
+	selected_rtpp_set_1 = 0;
3060
+	selected_rtpp_set_2 = 0;
3061
+
3062
+	ret = set_rtpengine_set_n(msg, &rtpl1, &selected_rtpp_set_1);
3063
+	if (ret < 0)
3064
+		return ret;
3065
+
3066
+	return 1;
3067
+}
3068
+
3069
+static int ki_set_rtpengine_set2(sip_msg_t *msg, int r1, int r2)
3070
+{
3071
+	rtpp_set_link_t rtpl1;
3072
+	rtpp_set_link_t rtpl2;
3073
+	int ret;
3074
+
3075
+	memset(&rtpl1, 0, sizeof(rtpp_set_link_t));
3076
+	memset(&rtpl2, 0, sizeof(rtpp_set_link_t));
3077
+
3078
+	if((rtpl1.rset = select_rtpp_set((unsigned int)r1)) ==0){
3079
+		LM_ERR("rtpp_proxy set %d not configured\n", r1);
3080
+		return -1;
3081
+	}
3082
+	if((rtpl2.rset = select_rtpp_set((unsigned int)r2)) ==0){
3083
+		LM_ERR("rtpp_proxy set %d not configured\n", r2);
3084
+		return -1;
3085
+	}
3086
+
3087
+	current_msg_id = 0;
3088
+	active_rtpp_set = 0;
3089
+	selected_rtpp_set_1 = 0;
3090
+	selected_rtpp_set_2 = 0;
3091
+
3092
+	ret = set_rtpengine_set_n(msg, &rtpl1, &selected_rtpp_set_1);
3093
+	if (ret < 0)
3094
+		return ret;
3095
+
3096
+	ret = set_rtpengine_set_n(msg, &rtpl2, &selected_rtpp_set_2);
3097
+	if (ret < 0)
3098
+		return ret;
3099
+
3100
+	return 1;
3101
+}
3102
+
3008 3103
 /**
3009 3104
  *
3010 3105
  */
... ...
@@ -3019,6 +3114,51 @@ static sr_kemi_t sr_kemi_rtpengine_exports[] = {
3019 3114
         { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
3020 3115
             SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
3021 3116
     },
3117
+    { str_init("rtpengine"), str_init("rtpengine_offer0"),
3118
+        SR_KEMIP_INT, ki_rtpengine_offer0,
3119
+        { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
3120
+            SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
3121
+    },
3122
+    { str_init("rtpengine"), str_init("rtpengine_offer"),
3123
+        SR_KEMIP_INT, ki_rtpengine_offer,
3124
+        { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
3125
+            SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
3126
+    },
3127
+    { str_init("rtpengine"), str_init("rtpengine_answer0"),
3128
+        SR_KEMIP_INT, ki_rtpengine_answer0,
3129
+        { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
3130
+            SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
3131
+    },
3132
+    { str_init("rtpengine"), str_init("rtpengine_answer"),
3133
+        SR_KEMIP_INT, ki_rtpengine_answer,
3134
+        { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
3135
+            SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
3136
+    },
3137
+    { str_init("rtpengine"), str_init("rtpengine_delete0"),
3138
+        SR_KEMIP_INT, ki_rtpengine_delete0,
3139
+        { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
3140
+            SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
3141
+    },
3142
+    { str_init("rtpengine"), str_init("rtpengine_delete"),
3143
+        SR_KEMIP_INT, ki_rtpengine_delete,
3144
+        { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
3145
+            SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
3146
+    },
3147
+    { str_init("rtpengine"), str_init("start_recording"),
3148
+        SR_KEMIP_INT, ki_start_recording,
3149
+        { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
3150
+            SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
3151
+    },
3152
+    { str_init("rtpengine"), str_init("set_rtpengine_set"),
3153
+        SR_KEMIP_INT, ki_set_rtpengine_set,
3154
+        { SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE,
3155
+            SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
3156
+    },
3157
+    { str_init("rtpengine"), str_init("set_rtpengine_set2"),
3158
+        SR_KEMIP_INT, ki_set_rtpengine_set2,
3159
+        { SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE,
3160
+            SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
3161
+    },
3022 3162
 
3023 3163
     { {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
3024 3164
 };
... ...
@@ -3026,4 +3166,4 @@ static sr_kemi_t sr_kemi_rtpengine_exports[] = {
3026 3166
 int mod_register(char *path, int *dlflags, void *p1, void *p2) {
3027 3167
     sr_kemi_modules_add(sr_kemi_rtpengine_exports);
3028 3168
     return 0;
3029
-}
3169
+}
3030 3170
\ No newline at end of file