Module: kamailio Branch: master Commit: 3d002d561e82b8bb71b225da708bdfd9ce504335 URL: https://github.com/kamailio/kamailio/commit/3d002d561e82b8bb71b225da708bdfd9...
Author: Farzaneh Soltanzadeh fr.soltanzadeh@resaa.net Committer: Henning Westerholt hw@gilawa.com Date: 2024-08-19T12:30:29Z
rtpengine: export API for other modules (GH #3949)
---
Added: src/modules/rtpengine/api.h Modified: src/modules/rtpengine/rtpengine.c
---
Diff: https://github.com/kamailio/kamailio/commit/3d002d561e82b8bb71b225da708bdfd9... Patch: https://github.com/kamailio/kamailio/commit/3d002d561e82b8bb71b225da708bdfd9...
---
diff --git a/src/modules/rtpengine/api.h b/src/modules/rtpengine/api.h new file mode 100644 index 00000000000..fa499916238 --- /dev/null +++ b/src/modules/rtpengine/api.h @@ -0,0 +1,66 @@ +/* + * Rtpengine Module + * + * Copyright (C) 2003-2008 Sippy Software, Inc., http://www.sippysoft.com + * Copyright (C) 2014-2015 Sipwise GmbH, http://www.sipwise.com + * + * This file is part of Kamailio, a free SIP server. + * + * Kamailio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version + * + * Kamailio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _RTPENGINE_API_H_ +#define _RTPENGINE_API_H_ + +#include "../../core/parser/msg_parser.h" + +typedef int (*rtpengine_start_recording_f)( + struct sip_msg *msg, char *str1, char *str2); +typedef int (*rtpengine_answer_f)(struct sip_msg *msg, char *str1, char *str2); +typedef int (*rtpengine_offer_f)(struct sip_msg *msg, char *str1, char *str2); +typedef int (*rtpengine_delete_f)(struct sip_msg *msg, char *str1, char *str2); + +typedef struct rtpengine_api +{ + rtpengine_start_recording_f start_recording; + rtpengine_answer_f answer; + rtpengine_offer_f offer; + rtpengine_delete_f delete; +} rtpengine_api_t; + +typedef int (*bind_rtpengine_f)(rtpengine_api_t *api); + +/** + * @brief Load the RTPENGINE API + */ +static inline int rtpengine_load_api(rtpengine_api_t *api) +{ + bind_rtpengine_f bindrtpengine; + + bindrtpengine = (bind_rtpengine_f)find_export("bind_rtpengine", 0, 0); + if(bindrtpengine == 0) { + LM_ERR("cannot find bind_rtpengine\n"); + return -1; + } + if(bindrtpengine(api) < 0) { + LM_ERR("cannot bind rtpengine api\n"); + return -1; + } + + return 0; +} + + +#endif /* _RTPENGINE_API_H_ */ diff --git a/src/modules/rtpengine/rtpengine.c b/src/modules/rtpengine/rtpengine.c index aefdc7c7d6e..84bf5951752 100644 --- a/src/modules/rtpengine/rtpengine.c +++ b/src/modules/rtpengine/rtpengine.c @@ -89,6 +89,7 @@ #include "rtpengine_hash.h" #include "bencode.h" #include "config.h" +#include "api.h"
MODULE_VERSION
@@ -241,6 +242,8 @@ static int parse_viabranch(struct ng_flags_parse *ng_flags, struct sip_msg *msg, static int parse_from_to_tags(struct ng_flags_parse *ng_flags, enum rtpe_operation op, struct sip_msg *msg);
+static int bind_rtpengine(rtpengine_api_t *api); + static int rtpengine_offer_answer( struct sip_msg *msg, void *d, enum rtpe_operation op, int more); static int fixup_set_id(void **param, int param_no); @@ -468,6 +471,7 @@ static cmd_export_t cmds[] = { {"rtpengine_query_v", (cmd_function)w_rtpengine_query_v, 2, fixup_rtpengine_query_v, fixup_free_rtpengine_query_v, ANY_ROUTE}, + {"bind_rtpengine", (cmd_function)bind_rtpengine, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} };
@@ -5779,3 +5783,21 @@ int mod_register(char *path, int *dlflags, void *p1, void *p2) sr_kemi_modules_add(sr_kemi_rtpengine_exports); return 0; } + + +/** + * load rtpengine module API + */ +static int bind_rtpengine(rtpengine_api_t *api) +{ + if(!api) { + LM_ERR("Invalid parameter value\n"); + return -1; + } + api->start_recording = start_recording_f; + api->answer = rtpengine_answer1_f; + api->offer = rtpengine_offer1_f; + api->delete = rtpengine_delete1_f; + + return 0; +} \ No newline at end of file