Embedding FreeSWITCH

From FreeSWITCH Wiki

Jump to: navigation, search

Just as FreeSWITCH™ can run embedded languages you can also embed FreeSWITCH™ into other programs in a variety of languages. FreeSWITCH™ is designed in a way to be extended from both sides of the equation, not only does it support modules but it also supports being embedded itself. Some examples of how this is done follow.

Contents

Extensibility

You can control the running process any way you want, which includes call data, or any other functionality within the application. You could, for example, write code to control a call path, and embed FreeSWITCH™ into that application.

Language Examples

C/C++

#include <switch.h>
int main(int argc, char** argv)
{
	switch_core_flag_t flags = SCF_USE_SQL;
	bool console = true;
	const char *err = NULL; 	
	switch_core_set_globals();	
	switch_core_init_and_modload(flags, console ? SWITCH_TRUE : SWITCH_FALSE, &err);
	switch_core_runtime_loop(!console);	
	return 0;
}

Compile and link against libfreeswitch. On Windows, this library is called FreeSwitchCore.lib and can be found in <freeswitch source>\w32\Library\Debug(or Release)\ after building the Visual Studio solution.

Launch compiled application in FreeSWITCH root directory and you will see FreeSWITCH console.

PHP

<?php
 include("freeswitch.php");
 fs_core_set_globals();
 fs_core_init("");
 fs_loadable_module_init();
 fs_console_loop();
 fs_core_destroy();
?>

Perl

Similar method to PHP - need example.

See Also

Personal tools
Community
Support FreeSWITCH