mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-15 16:39:14 +00:00
a little cleanup
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9644 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
0f0efa6719
commit
d52e65a88a
@ -33,12 +33,28 @@
|
|||||||
* The native code just handles getting the Mono runtime up and down
|
* The native code just handles getting the Mono runtime up and down
|
||||||
* and passing pointers into managed code.
|
* and passing pointers into managed code.
|
||||||
*/
|
*/
|
||||||
#ifndef _MANAGED
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
|
SWITCH_BEGIN_EXTERN_C
|
||||||
|
#include "freeswitch_managed.h"
|
||||||
|
|
||||||
|
SWITCH_MODULE_LOAD_FUNCTION(mod_managed_load);
|
||||||
|
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_managed_shutdown);
|
||||||
|
SWITCH_MODULE_DEFINITION(mod_managed, mod_managed_load, mod_managed_shutdown, NULL);
|
||||||
|
|
||||||
|
SWITCH_STANDARD_API(managedrun_api_function); /* ExecuteBackground */
|
||||||
|
SWITCH_STANDARD_API(managed_api_function); /* Execute */
|
||||||
|
SWITCH_STANDARD_APP(managed_app_function); /* Run */
|
||||||
|
|
||||||
|
SWITCH_END_EXTERN_C
|
||||||
|
|
||||||
|
#define MOD_MANAGED_DLL "mod_managed_lib.dll"
|
||||||
|
|
||||||
|
#ifndef _MANAGED
|
||||||
|
|
||||||
SWITCH_BEGIN_EXTERN_C
|
SWITCH_BEGIN_EXTERN_C
|
||||||
|
|
||||||
#include "freeswitch_managed.h"
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <mono/jit/jit.h>
|
#include <mono/jit/jit.h>
|
||||||
#include <mono/metadata/assembly.h>
|
#include <mono/metadata/assembly.h>
|
||||||
@ -53,8 +69,6 @@ SWITCH_BEGIN_EXTERN_C
|
|||||||
#define EXPORT
|
#define EXPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MOD_MONO_MANAGED_DLL "mod_managed_lib.dll"
|
|
||||||
|
|
||||||
#define MOD_MONO_MANAGED_ASM_NAME "mod_managed_lib"
|
#define MOD_MONO_MANAGED_ASM_NAME "mod_managed_lib"
|
||||||
#define MOD_MONO_MANAGED_ASM_V1 1
|
#define MOD_MONO_MANAGED_ASM_V1 1
|
||||||
#define MOD_MONO_MANAGED_ASM_V2 0
|
#define MOD_MONO_MANAGED_ASM_V2 0
|
||||||
@ -64,15 +78,6 @@ SWITCH_BEGIN_EXTERN_C
|
|||||||
mod_mono_globals globals =
|
mod_mono_globals globals =
|
||||||
{ 0 };
|
{ 0 };
|
||||||
|
|
||||||
SWITCH_MODULE_LOAD_FUNCTION(mod_managed_load);
|
|
||||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_managed_shutdown);
|
|
||||||
SWITCH_MODULE_DEFINITION(mod_managed, mod_managed_load, mod_managed_shutdown, NULL);
|
|
||||||
|
|
||||||
SWITCH_STANDARD_API(monorun_api_function); /* ExecuteBackground */
|
|
||||||
SWITCH_STANDARD_API(mono_api_function); /* Execute */
|
|
||||||
SWITCH_STANDARD_APP(mono_app_function); /* Run */
|
|
||||||
|
|
||||||
|
|
||||||
// Sets up delegates (and anything else needed) on the ManagedSession object
|
// Sets up delegates (and anything else needed) on the ManagedSession object
|
||||||
// Called via internalcall
|
// Called via internalcall
|
||||||
SWITCH_MOD_DECLARE(void) InitManagedSession(ManagedSession * session, MonoObject * dtmfDelegate, MonoObject * hangupDelegate)
|
SWITCH_MOD_DECLARE(void) InitManagedSession(ManagedSession * session, MonoObject * dtmfDelegate, MonoObject * hangupDelegate)
|
||||||
@ -158,8 +163,7 @@ switch_status_t setMonoDirs()
|
|||||||
mono_set_dirs(NULL, NULL);
|
mono_set_dirs(NULL, NULL);
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
#endif /*
|
#endif
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_status_t loadModMonoManaged()
|
switch_status_t loadModMonoManaged()
|
||||||
@ -167,7 +171,7 @@ switch_status_t loadModMonoManaged()
|
|||||||
/* Find and load mod_mono_managed.exe */
|
/* Find and load mod_mono_managed.exe */
|
||||||
char filename[256];
|
char filename[256];
|
||||||
|
|
||||||
switch_snprintf(filename, 256, "%s%s%s", SWITCH_GLOBAL_dirs.mod_dir, SWITCH_PATH_SEPARATOR, MOD_MONO_MANAGED_DLL);
|
switch_snprintf(filename, 256, "%s%s%s", SWITCH_GLOBAL_dirs.mod_dir, SWITCH_PATH_SEPARATOR, MOD_MANAGED_DLL);
|
||||||
globals.domain = mono_jit_init(filename);
|
globals.domain = mono_jit_init(filename);
|
||||||
|
|
||||||
/* Already got a Mono domain? */
|
/* Already got a Mono domain? */
|
||||||
@ -204,7 +208,6 @@ switch_status_t loadModMonoManaged()
|
|||||||
}
|
}
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MonoMethod * getMethod(const char *name, MonoClass * klass)
|
MonoMethod * getMethod(const char *name, MonoClass * klass)
|
||||||
@ -305,14 +308,14 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_managed_load)
|
|||||||
switch_api_interface_t *api_interface;
|
switch_api_interface_t *api_interface;
|
||||||
switch_application_interface_t *app_interface;
|
switch_application_interface_t *app_interface;
|
||||||
|
|
||||||
SWITCH_ADD_API(api_interface, "managedrun", "Run a module (ExecuteBackground)", monorun_api_function, "<module> [<args>]");
|
SWITCH_ADD_API(api_interface, "managedrun", "Run a module (ExecuteBackground)", managedrun_api_function, "<module> [<args>]");
|
||||||
SWITCH_ADD_API(api_interface, "managed", "Run a module as an API function (Execute)", mono_api_function, "<module> [<args>]");
|
SWITCH_ADD_API(api_interface, "managed", "Run a module as an API function (Execute)", managed_api_function, "<module> [<args>]");
|
||||||
SWITCH_ADD_APP(app_interface, "managed", "Run Mono IVR", "Run a Mono IVR on a channel", mono_app_function, "<modulename> [<args>]", SAF_NONE);
|
SWITCH_ADD_APP(app_interface, "managed", "Run Mono IVR", "Run a Mono IVR on a channel", managed_app_function, "<modulename> [<args>]", SAF_NONE);
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_STANDARD_API(monorun_api_function)
|
SWITCH_STANDARD_API(managedrun_api_function)
|
||||||
{
|
{
|
||||||
// TODO: Should we be detaching after all this?
|
// TODO: Should we be detaching after all this?
|
||||||
mono_thread_attach(globals.domain);
|
mono_thread_attach(globals.domain);
|
||||||
@ -344,7 +347,7 @@ SWITCH_STANDARD_API(monorun_api_function)
|
|||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_STANDARD_API(mono_api_function)
|
SWITCH_STANDARD_API(managed_api_function)
|
||||||
{
|
{
|
||||||
mono_thread_attach(globals.domain);
|
mono_thread_attach(globals.domain);
|
||||||
|
|
||||||
@ -375,7 +378,7 @@ SWITCH_STANDARD_API(mono_api_function)
|
|||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_STANDARD_APP(mono_app_function)
|
SWITCH_STANDARD_APP(managed_app_function)
|
||||||
{
|
{
|
||||||
mono_thread_attach(globals.domain);
|
mono_thread_attach(globals.domain);
|
||||||
|
|
||||||
@ -430,7 +433,6 @@ SWITCH_END_EXTERN_C
|
|||||||
|
|
||||||
#ifdef _MANAGED
|
#ifdef _MANAGED
|
||||||
|
|
||||||
#include <switch.h>
|
|
||||||
#include <mscoree.h>
|
#include <mscoree.h>
|
||||||
|
|
||||||
using namespace System;
|
using namespace System;
|
||||||
@ -438,10 +440,6 @@ using namespace System::Runtime::InteropServices;
|
|||||||
|
|
||||||
SWITCH_BEGIN_EXTERN_C
|
SWITCH_BEGIN_EXTERN_C
|
||||||
|
|
||||||
#include "freeswitch_managed.h"
|
|
||||||
|
|
||||||
#define MOD_DOTNET_MANAGED_DLL "mod_managed_lib.dll"
|
|
||||||
|
|
||||||
struct dotnet_conf_t {
|
struct dotnet_conf_t {
|
||||||
switch_memory_pool_t *pool;
|
switch_memory_pool_t *pool;
|
||||||
//ICLRRuntimeHost *pCorRuntime;
|
//ICLRRuntimeHost *pCorRuntime;
|
||||||
@ -450,13 +448,6 @@ struct dotnet_conf_t {
|
|||||||
//char *cor_version;
|
//char *cor_version;
|
||||||
} globals;
|
} globals;
|
||||||
|
|
||||||
SWITCH_MODULE_LOAD_FUNCTION(mod_managed_load);
|
|
||||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_managed_shutdown);
|
|
||||||
SWITCH_MODULE_DEFINITION(mod_managed, mod_managed_load, mod_managed_shutdown, NULL);
|
|
||||||
SWITCH_STANDARD_API(dotnetrun_api_function); /* ExecuteBackground */
|
|
||||||
SWITCH_STANDARD_API(dotnet_api_function); /* Execute */
|
|
||||||
SWITCH_STANDARD_APP(dotnet_app_function); /* Run */
|
|
||||||
|
|
||||||
// Sets up delegates (and anything else needed) on the ManagedSession object
|
// Sets up delegates (and anything else needed) on the ManagedSession object
|
||||||
// Called from ManagedSession.Initialize Managed -> this is Unmanaged code so all pointers are marshalled and prevented from GC
|
// Called from ManagedSession.Initialize Managed -> this is Unmanaged code so all pointers are marshalled and prevented from GC
|
||||||
// Exported method.
|
// Exported method.
|
||||||
@ -476,7 +467,7 @@ switch_status_t loadModDotnetManaged()
|
|||||||
{
|
{
|
||||||
/* Find and load mod_dotnet_managed.dll */
|
/* Find and load mod_dotnet_managed.dll */
|
||||||
char filename[256];
|
char filename[256];
|
||||||
switch_snprintf(filename, 256, "%s%s%s", SWITCH_GLOBAL_dirs.mod_dir, SWITCH_PATH_SEPARATOR, MOD_DOTNET_MANAGED_DLL);
|
switch_snprintf(filename, 256, "%s%s%s", SWITCH_GLOBAL_dirs.mod_dir, SWITCH_PATH_SEPARATOR, MOD_MANAGED_DLL);
|
||||||
|
|
||||||
//HRESULT hr;
|
//HRESULT hr;
|
||||||
//wchar_t wCORVersion[256];
|
//wchar_t wCORVersion[256];
|
||||||
@ -592,14 +583,14 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_managed_load)
|
|||||||
switch_api_interface_t *api_interface;
|
switch_api_interface_t *api_interface;
|
||||||
switch_application_interface_t *app_interface;
|
switch_application_interface_t *app_interface;
|
||||||
|
|
||||||
SWITCH_ADD_API(api_interface, "managedrun", "Run a module (ExecuteBackground)", dotnetrun_api_function, "<module> [<args>]");
|
SWITCH_ADD_API(api_interface, "managedrun", "Run a module (ExecuteBackground)", managedrun_api_function, "<module> [<args>]");
|
||||||
SWITCH_ADD_API(api_interface, "managed", "Run a module as an API function (Execute)", dotnet_api_function, "<module> [<args>]");
|
SWITCH_ADD_API(api_interface, "managed", "Run a module as an API function (Execute)", managed_api_function, "<module> [<args>]");
|
||||||
SWITCH_ADD_APP(app_interface, "managed", "Run CLI App", "Run an App on a channel", dotnet_app_function, "<modulename> [<args>]", SAF_NONE);
|
SWITCH_ADD_APP(app_interface, "managed", "Run CLI App", "Run an App on a channel", managed_app_function, "<modulename> [<args>]", SAF_NONE);
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SWITCH_STANDARD_API(dotnetrun_api_function)
|
SWITCH_STANDARD_API(managedrun_api_function)
|
||||||
{
|
{
|
||||||
if (switch_strlen_zero(cmd)) {
|
if (switch_strlen_zero(cmd)) {
|
||||||
stream->write_function(stream, "-ERR no args specified!\n");
|
stream->write_function(stream, "-ERR no args specified!\n");
|
||||||
@ -626,7 +617,7 @@ SWITCH_STANDARD_API(dotnetrun_api_function)
|
|||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_STANDARD_API(dotnet_api_function)
|
SWITCH_STANDARD_API(managed_api_function)
|
||||||
{
|
{
|
||||||
if (switch_strlen_zero(cmd)) {
|
if (switch_strlen_zero(cmd)) {
|
||||||
stream->write_function(stream, "-ERR no args specified!\n");
|
stream->write_function(stream, "-ERR no args specified!\n");
|
||||||
@ -651,7 +642,7 @@ SWITCH_STANDARD_API(dotnet_api_function)
|
|||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_STANDARD_APP(dotnet_app_function)
|
SWITCH_STANDARD_APP(managed_app_function)
|
||||||
{
|
{
|
||||||
if (switch_strlen_zero(data)) {
|
if (switch_strlen_zero(data)) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No args specified!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No args specified!\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user