[Freeswitch-dev] Using a modem to connect ordinary phones
Hi, I found the same topic created 2 years back in Oct 2007 but it doesn't seem to have the answer yet. I am quite new to FS and having a hard time reading the documentation. Someone could tell me: how would I use a modem and develop an Endpoint in FS that I could bridge the call from VoIP to PSTN. I am a hardware engineer, I am developing this modem and would want to use it with FS. I know that I could simply buy a VoIP Gateway or a zaptel compatible card and use OpenZap. Could someone point me out the direction for the following matters: 1. I feel that I need to develop an Endpoint module, like mod_sofia, mod_iax... that controls my modem so I could bridge the call from VoIP to PSTN ? If that is correct, could someone point me the documentation to start reading about Endpoint interface .? 2. Is there any similar module developed before about controlling a modem using AT Command Pardon my bad English, I don't come from an English speaking country. Btw, this is the first time I participate in a mailing list so I still have no idea how to create a thread or reply to a posting like I normally do in forums. Thanks very much and any helps are highly appreciated. Regards Alex To ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
Re: [Freeswitch-dev] Using a modem to connect ordinary phones
Thank you very much for your prompt reply Mike The problem is I could simply get everything working by buying a zaptel compatible card or a VoIP Gateway. However I would like to use the modem that I am developing since it does provides some additional features. Does that mean I could start my way reading about Zaptel and develop a modified version of Zaptel to control my modem ? Thanks for pointing me the way. Regards Alex To From: freeswitch-dev-boun...@lists.freeswitch.org [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of Michael Jerris Sent: Wednesday, October 28, 2009 1:23 PM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] Using a modem to connect ordinary phones You are better off creating a zaptel driver than re-creating all that work that has already been done. Mike On Oct 28, 2009, at 1:05 AM, Alex To wrote: Hi, I found the same topic created 2 years back in Oct 2007 but it doesn't seem to have the answer yet. I am quite new to FS and having a hard time reading the documentation. Someone could tell me: how would I use a modem and develop an Endpoint in FS that I could bridge the call from VoIP to PSTN. I am a hardware engineer, I am developing this modem and would want to use it with FS. I know that I could simply buy a VoIP Gateway or a zaptel compatible card and use OpenZap. Could someone point me out the direction for the following matters: 1. I feel that I need to develop an Endpoint module, like mod_sofia, mod_iax... that controls my modem so I could bridge the call from VoIP to PSTN ? If that is correct, could someone point me the documentation to start reading about Endpoint interface .? 2. Is there any similar module developed before about controlling a modem using AT Command ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
Re: [Freeswitch-dev] Using a modem to connect ordinary phones
That is exactly what I am doing now. It's nice knowing somebody is doing the same thing. The only difference is I am developing for Windows platform. The modem that I am developing uses USB/Serial Port that accepts AT command. Still reading how should I control audio I/O as to be honest I just got to know FreeSwitch for less than a week. I will be very grateful if you could share your experience. Regards Alex To -Original Message- From: freeswitch-dev-boun...@lists.freeswitch.org [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of Giovanni Maruzzelli Sent: Thursday, October 29, 2009 1:06 AM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] Using a modem to connect ordinary phones On Wed, Oct 28, 2009 at 6:37 AM, Alex To wrote: > The problem is I could simply get everything working by buying a zaptel > compatible card or a VoIP Gateway. However I would like to use the modem > that I am developing since it does provides some additional features. > It depends on how your modem behave... Eg: in the past I developed a channel driver that was using voicemodems and ALSA to interface with PSTN: AT command for call control and ALSA for audio I/O. If you are in this situation (your modem accept AT commands, and has a way to do audio I/O through ALSA or some other interface), then maybe you would like to wait a little bit until I release a new endpoint for FreeSWITCH that do this for GSM, and just use that endpoint with little or no customization. -giovanni > > > Does that mean I could start my way reading about Zaptel and develop a > modified version of Zaptel to control my modem ? > > > > Thanks for pointing me the way. > > > > Regards > > > > Alex To > > > > From: freeswitch-dev-boun...@lists.freeswitch.org > [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of Michael > Jerris > Sent: Wednesday, October 28, 2009 1:23 PM > To: freeswitch-dev@lists.freeswitch.org > Subject: Re: [Freeswitch-dev] Using a modem to connect ordinary phones > > > > You are better off creating a zaptel driver than re-creating all that work > that has already been done. > > > > Mike > > > > On Oct 28, 2009, at 1:05 AM, Alex To wrote: > > Hi, > > > > I found the same topic created 2 years back in Oct 2007 but it doesnt seem > to have the answer yet. > > > > I am quite new to FS and having a hard time reading the documentation. > Someone could tell me: how would I use a modem and develop an Endpoint in FS > that I could bridge the call from VoIP to PSTN. I am a hardware engineer, I > am developing this modem and would want to use it with FS. I know that I > could simply buy a VoIP Gateway or a zaptel compatible card and use OpenZap. > > > > Could someone point me out the direction for the following matters: > > > > 1. I feel that I need to develop an Endpoint module, like mod_sofia, > mod_iax... that controls my modem so I could bridge the call from VoIP to > PSTN ? If that is correct, could someone point me the documentation to start > reading about Endpoint interface ? > > 2. Is there any similar module developed before about controlling a > modem using AT Command > > > > ___ > FreeSWITCH-dev mailing list > FreeSWITCH-dev@lists.freeswitch.org > http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev > UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev > http://www.freeswitch.org > > -- Sincerely, Giovanni Maruzzelli Cell : +39-347-2665618 ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
[Freeswitch-dev] Visual Studio 2008 Pro SP1: switch_loadable_module.c:871 Error Loading module .... **dll sym error [127l]
Hi, excuse me if this is already asked where else but I did browse through the mailing list and I couldn't find anything related. I tried to create a new end point module by copying the mod_skel to mod/endpoints/my_module folder. I modified "skel" to my module name and basically I leave no codes in the load function, just a few lines to test if the new module is working. These few lines are: *module_interface = switch_loadable_module_create_module_interface(pool, modname); modem_endpoint_interface = (switch_endpoint_interface_t*)switch_loadable_module_create_interface(*modul e_interface, SWITCH_ENDPOINT_INTERFACE); modem_endpoint_interface->interface_name = "modem"; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello World!\n"); // //do_config(SWITCH_FALSE); // SWITCH_ADD_API(api_interface, "modem", "Modem API", modem_function, "syntax"); /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; It compiles but the module can't load properly. I received the following error: 2009-11-01 19:18:10.551180 [CRIT] switch_loadable_module.c:871 Error Loading module D:\Projects\freeswitch\Debug\mod\mod_mymodule.dll **dll sym error [127l] ** I tried to load module normally at the FS console but "load mod_skel" and "load mod_mymodule" gives the same error. Would someone tell me what do I miss here. Btw, I looked at mod_sofia and mod_iax, this line of code could compile in those 2 modules. modem_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE); The same line of code couldn't compile in my module coz VS complains: cannot convert from void* to switch_endpoint_interface_t*. I know C++ require more type-safe conversion than C but anyone got the same error? And how would I search in the mailing list ? Sorry for this dumb question but I can't seem to find out how to search in the archives. For now, before posting anything, I need to try to browse through all the postings first, which is quite tedious to do. Regards Alex To ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
[Freeswitch-dev] FW: Visual Studio 2008 Pro SP1: switch_loadable_module.c:871 Error Loading module .... **dll sym error [127l]
Sorry, I figured it out by myself. It was because my code file is mod_mymodule.cpp. I changed it to mod_mymodule.c and the module loaded file. So I take it as FS accepts only C library but not C++ ? Regards Alex To From: Alex To [mailto:tonhud...@gmail.com] Sent: Sunday, November 01, 2009 7:35 PM To: 'freeswitch-dev@lists.freeswitch.org' Subject: Visual Studio 2008 Pro SP1: switch_loadable_module.c:871 Error Loading module **dll sym error [127l] Hi, excuse me if this is already asked where else but I did browse through the mailing list and I couldn't find anything related. I tried to create a new end point module by copying the mod_skel to mod/endpoints/my_module folder. I modified "skel" to my module name and basically I leave no codes in the load function, just a few lines to test if the new module is working. These few lines are: *module_interface = switch_loadable_module_create_module_interface(pool, modname); modem_endpoint_interface = (switch_endpoint_interface_t*)switch_loadable_module_create_interface(*modul e_interface, SWITCH_ENDPOINT_INTERFACE); modem_endpoint_interface->interface_name = "modem"; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello World!\n"); // //do_config(SWITCH_FALSE); // SWITCH_ADD_API(api_interface, "modem", "Modem API", modem_function, "syntax"); /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; It compiles but the module can't load properly. I received the following error: 2009-11-01 19:18:10.551180 [CRIT] switch_loadable_module.c:871 Error Loading module D:\Projects\freeswitch\Debug\mod\mod_mymodule.dll **dll sym error [127l] ** I tried to load module normally at the FS console but "load mod_skel" and "load mod_mymodule" gives the same error. Would someone tell me what do I miss here. Btw, I looked at mod_sofia and mod_iax, this line of code could compile in those 2 modules. modem_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE); The same line of code couldn't compile in my module coz VS complains: cannot convert from void* to switch_endpoint_interface_t*. I know C++ require more type-safe conversion than C but anyone got the same error? And how would I search in the mailing list ? Sorry for this dumb question but I can't seem to find out how to search in the archives. For now, before posting anything, I need to try to browse through all the postings first, which is quite tedious to do. Regards Alex To ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
Re: [Freeswitch-dev] FW: Visual Studio 2008 Pro SP1: switch_loadable_module.c:871 Error Loading module .... **dll sym error [127l]
Right I checked it again and I did miss some information. I am modifying my module to be written in C++. Thank you. -Original Message- From: freeswitch-dev-boun...@lists.freeswitch.org [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of Giovanni Maruzzelli Sent: Sunday, November 01, 2009 9:05 PM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] FW: Visual Studio 2008 Pro SP1: switch_loadable_module.c:871 Error Loading module **dll sym error [127l] On Sun, Nov 1, 2009 at 12:44 PM, Alex To wrote: > Sorry, I figured it out by myself. It was because my code file is > mod_mymodule.cpp. I changed it to mod_mymodule.c and the module loaded file. > So I take it as FS accepts only C library but not C++ ? Ciao Alex, no, you're on the wrong track. FS loads CPP modules. Your problems probably come because mod_skel is a C module, and the Makefile for it manages it as a C module. If you want to compile a CPP module, find one as an example, and adjust yourmodule and its Makefile to be compiled in a similar way. I've done it, and I can assure it works. In this moment I cannot tell you out of my memory which module is CPP, but just browse the sources looking for *.cc or *.cpp. -giovanni > > > > Regards > > > > Alex To > > > > From: Alex To [mailto:tonhud...@gmail.com] > Sent: Sunday, November 01, 2009 7:35 PM > To: 'freeswitch-dev@lists.freeswitch.org' > Subject: Visual Studio 2008 Pro SP1: switch_loadable_module.c:871 Error > Loading module **dll sym error [127l] > > > > Hi, excuse me if this is already asked where else but I did browse through > the mailing list and I couldnt find anything related. I tried to create a > new end point module by copying the mod_skel to mod/endpoints/my_module > folder. > > > > I modified skel to my module name and basically I leave no codes in the > load function, just a few lines to test if the new module is working. These > few lines are: > > > > *module_interface = switch_loadable_module_create_module_interface(pool, > modname); > > modem_endpoint_interface = > (switch_endpoint_interface_t*)switch_loadable_module_create_interface(*modul e_interface, > SWITCH_ENDPOINT_INTERFACE); > > modem_endpoint_interface->interface_name = "modem"; > > switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello > World!\n"); > > // > > //do_config(SWITCH_FALSE); > > // > > SWITCH_ADD_API(api_interface, "modem", "Modem API", modem_function, > "syntax"); > > > > /* indicate that the module should continue to be loaded */ > > return SWITCH_STATUS_SUCCESS; > > > > It compiles but the module cant load properly. I received the following > error: > > > > 2009-11-01 19:18:10.551180 [CRIT] switch_loadable_module.c:871 Error Loading > module D:\Projects\freeswitch\Debug\mod\mod_mymodule.dll > > **dll sym error [127l] > > ** > > I tried to load module normally at the FS console but load mod_skel and > load mod_mymodule gives the same error. > > > > Would someone tell me what do I miss here. > > > > Btw, I looked at mod_sofia and mod_iax, this line of code could compile in > those 2 modules. > > > > modem_endpoint_interface = > switch_loadable_module_create_interface(*module_interface, > SWITCH_ENDPOINT_INTERFACE); > > > > The same line of code couldnt compile in my module coz VS complains: cannot > convert from void* to switch_endpoint_interface_t*. I know C++ require more > type-safe conversion than C but anyone got the same error? > > > > And how would I search in the mailing list ? Sorry for this dumb question > but I cant seem to find out how to search in the archives. For now, before > posting anything, I need to try to browse through all the postings first, > which is > > > > quite tedious to do. > > > > Regards > > > > Alex To > > ___ > FreeSWITCH-dev mailing list > FreeSWITCH-dev@lists.freeswitch.org > http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev > UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev > http://www.freeswitch.org > > -- Sincerely, Giovanni Maruzzelli Cell : +39-347-2665618 ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
Re: [Freeswitch-dev] mod managed, cant receive events thru EventReceivedFunction callback
Hi, I would like to raise this question again since it doesn't seem to have an answer yet. I built a .NET module which implements IAppPlugin and IApiPlugin. I looked at the /contrib/verifier/eventsocket and it is actually the client to connect to FS through mod_event_socket (correct me if I'm wrong here). I believe Andrew's concern was how to receive events through EventReceivedFunctionCallback but not connect to FS and receive event via TCP/IP. I would want to implement a .NET module that acts like an endpoint. Could someone show me the direction of how to hook up handlers like it is done in native C++? How would I read the incoming audio data and how would I send audio as an outgoing stream. I setup the .NET module and dial plan so that the Run() method in my module is invoked whenever a call is bridged to my endpoint. The ParkingLot and Demo script sample does enlighten me a little but I still have no clue how would I go about the audio stream after I call session.Answer(). Any help would be greatly appreciated. Best Regards Alex To ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
Re: [Freeswitch-dev] mod managed, cant receive events thru EventReceivedFunction callback
Oh thank you Michael for answering all my dumb questions. :D I agree with you Interoperability between unmanaged and managed code is such a PITA. I think I am going back to C++ module for the moment since the unmanaged API isn't "made easy" in managed code yet. If I have the time later, I will go back and read the managed part, hopefully I could contribute to the managed part in FS. Regards Alex To From: freeswitch-dev-boun...@lists.freeswitch.org [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of Michael Giagnocavo Sent: Monday, November 02, 2009 8:34 PM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] mod managed, cant receive events thru EventReceivedFunction callback Basically, if you want to do something that's not "made easy" for language plugins, you just do it the C way, like any other FreeSWITCH C module. The mod_managed swig wrappers expose nearly every function. The difficult part is that some of the indirect types (pointers to types and function pointers) aren't swig'd very nicely, and just have a wrapper class such as "SWIGTYPE_p_foo_t". In this case, you're required to create the backing structure however required, then get a pointer to that structure and wrap it in the SWIGTYPE_p_xxx class. If your backing structure is a .NET type, you can use GCHandle to get an IntPtr to it. Or you can directly allocate memory via the Marshal class and use that IntPtr. This is likely to be annoying and a lot of work. It's only really easy for function pointers, as all you need to do is declare a delegate, attribute it [UnmanagedFunctionPointer(CallingConvention.Cdecl)], then call Marshal.GetFunctionPointerForDelegate. The runtime will emit unmanaged stubs that will handle unmanaged-managed transitioning and give you a nice C compatible function pointer you can wrap and pass around. You can see some examples in ManagedSession.cs. Additionally, the SWIGTYPE_p_xxx classes don't have public constructors, so the FSUtil class provides this extension method on IntPtr: public static T CreateSwigTypePointer(this IntPtr cPtr) That way you can create the wrapper classes as needed after you've created the structures and wrapped them up. In summary, it's possible to create an endpoint module from C#, but a major PITA. You should consider either using a mixed-mode language such as C++/CLI or write a helper library in C/C++ and export that via swig. We'd welcome contributions to mod_managed that simplify access to a set of the FS APIs. -Michael From: freeswitch-dev-boun...@lists.freeswitch.org [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of Alex To Sent: Monday, November 02, 2009 5:19 AM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] mod managed, cant receive events thru EventReceivedFunction callback Hi, I would like to raise this question again since it doesn't seem to have an answer yet. I built a .NET module which implements IAppPlugin and IApiPlugin. I looked at the /contrib/verifier/eventsocket and it is actually the client to connect to FS through mod_event_socket (correct me if I'm wrong here). I believe Andrew's concern was how to receive events through EventReceivedFunctionCallback but not connect to FS and receive event via TCP/IP. I would want to implement a .NET module that acts like an endpoint. Could someone show me the direction of how to hook up handlers like it is done in native C++? How would I read the incoming audio data and how would I send audio as an outgoing stream. I setup the .NET module and dial plan so that the Run() method in my module is invoked whenever a call is bridged to my endpoint. The ParkingLot and Demo script sample does enlighten me a little but I still have no clue how would I go about the audio stream after I call session.Answer(). Any help would be greatly appreciated. Best Regards Alex To ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
Re: [Freeswitch-dev] FW: Visual Studio 2008 Pro SP1: switch_loadable_module.c:871 Error Loading module .... **dll sym error [127l]
Hi, I copied mod_opal to mod_mymodule which is C++ module and remove all the codes. I copied mod_skel.c to my module and rename it to .cpp. Compiled fine in VS 2008 SP1 but still I couldn't load the module in FS. The FS console still complains "dll sym error.". If I rename mod_mymodule.cpp to .c, it loaded successfully. Hmm, what do I miss here ? any special trick to load a C++ module in FS ? Alex -Original Message- From: freeswitch-dev-boun...@lists.freeswitch.org [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of Giovanni Maruzzelli Sent: Sunday, November 01, 2009 9:05 PM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] FW: Visual Studio 2008 Pro SP1: switch_loadable_module.c:871 Error Loading module **dll sym error [127l] On Sun, Nov 1, 2009 at 12:44 PM, Alex To wrote: > Sorry, I figured it out by myself. It was because my code file is > mod_mymodule.cpp. I changed it to mod_mymodule.c and the module loaded file. > So I take it as FS accepts only C library but not C++ ? Ciao Alex, no, you're on the wrong track. FS loads CPP modules. Your problems probably come because mod_skel is a C module, and the Makefile for it manages it as a C module. If you want to compile a CPP module, find one as an example, and adjust yourmodule and its Makefile to be compiled in a similar way. I've done it, and I can assure it works. In this moment I cannot tell you out of my memory which module is CPP, but just browse the sources looking for *.cc or *.cpp. -giovanni > > > > Regards > > > > Alex To > > > > From: Alex To [mailto:tonhud...@gmail.com] > Sent: Sunday, November 01, 2009 7:35 PM > To: 'freeswitch-dev@lists.freeswitch.org' > Subject: Visual Studio 2008 Pro SP1: switch_loadable_module.c:871 Error > Loading module **dll sym error [127l] > > > > Hi, excuse me if this is already asked where else but I did browse through > the mailing list and I couldnt find anything related. I tried to create a > new end point module by copying the mod_skel to mod/endpoints/my_module > folder. > > > > I modified skel to my module name and basically I leave no codes in the > load function, just a few lines to test if the new module is working. These > few lines are: > > > > *module_interface = switch_loadable_module_create_module_interface(pool, > modname); > > modem_endpoint_interface = > (switch_endpoint_interface_t*)switch_loadable_module_create_interface(*modul e_interface, > SWITCH_ENDPOINT_INTERFACE); > > modem_endpoint_interface->interface_name = "modem"; > > switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello > World!\n"); > > // > > //do_config(SWITCH_FALSE); > > // > > SWITCH_ADD_API(api_interface, "modem", "Modem API", modem_function, > "syntax"); > > > > /* indicate that the module should continue to be loaded */ > > return SWITCH_STATUS_SUCCESS; > > > > It compiles but the module cant load properly. I received the following > error: > > > > 2009-11-01 19:18:10.551180 [CRIT] switch_loadable_module.c:871 Error Loading > module D:\Projects\freeswitch\Debug\mod\mod_mymodule.dll > > **dll sym error [127l] > > ** > > I tried to load module normally at the FS console but load mod_skel and > load mod_mymodule gives the same error. > > > > Would someone tell me what do I miss here. > > > > Btw, I looked at mod_sofia and mod_iax, this line of code could compile in > those 2 modules. > > > > modem_endpoint_interface = > switch_loadable_module_create_interface(*module_interface, > SWITCH_ENDPOINT_INTERFACE); > > > > The same line of code couldnt compile in my module coz VS complains: cannot > convert from void* to switch_endpoint_interface_t*. I know C++ require more > type-safe conversion than C but anyone got the same error? > > > > And how would I search in the mailing list ? Sorry for this dumb question > but I cant seem to find out how to search in the archives. For now, before > posting anything, I need to try to browse through all the postings first, > which is > > > > quite tedious to do. > > > > Regards > > > > Alex To > > ___ > FreeSWITCH-dev mailing list > FreeSWITCH-dev@lists.freeswitch.org > http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev > UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev > http://www.freeswitch.org > > -- Sincerely, Giovanni Maruzzelli Cell : +39-347-2665618 ___ F
Re: [Freeswitch-dev] FW: Visual Studio 2008 Pro SP1: switch_loadable_module.c:871 Error Loading module .... **dll sym error [127l]
Anyone out there have built and loaded successfully a C++ module using Visual Studio 2008 SP1 with FS? This error really got me frustrated these few days. I can't seem to load a C++ module in FS, the error is "dll sym error [1271]" If I rename the code file to .c or change the compile option to "Compile as C code", the module loads fine. If I compile using option "Compile as C++ code" then I got the error. Would really appreciate it if anyone could shed some lights. It must be a setting somewhere in VS or in FS ?? I build FS on Windows 7 x64, VS 2008 SP1, Windows SDK 7.0, build target win32. Regards Alex To -Original Message- From: freeswitch-dev-boun...@lists.freeswitch.org [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of Giovanni Maruzzelli Sent: Sunday, November 01, 2009 9:05 PM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] FW: Visual Studio 2008 Pro SP1: switch_loadable_module.c:871 Error Loading module **dll sym error [127l] On Sun, Nov 1, 2009 at 12:44 PM, Alex To wrote: > Sorry, I figured it out by myself. It was because my code file is > mod_mymodule.cpp. I changed it to mod_mymodule.c and the module loaded file. > So I take it as FS accepts only C library but not C++ ? Ciao Alex, no, you're on the wrong track. FS loads CPP modules. Your problems probably come because mod_skel is a C module, and the Makefile for it manages it as a C module. If you want to compile a CPP module, find one as an example, and adjust yourmodule and its Makefile to be compiled in a similar way. I've done it, and I can assure it works. In this moment I cannot tell you out of my memory which module is CPP, but just browse the sources looking for *.cc or *.cpp. -giovanni > > > > Regards > > > > Alex To > > > > From: Alex To [mailto:tonhud...@gmail.com] > Sent: Sunday, November 01, 2009 7:35 PM > To: 'freeswitch-dev@lists.freeswitch.org' > Subject: Visual Studio 2008 Pro SP1: switch_loadable_module.c:871 Error > Loading module **dll sym error [127l] > > > > Hi, excuse me if this is already asked where else but I did browse through > the mailing list and I couldnt find anything related. I tried to create a > new end point module by copying the mod_skel to mod/endpoints/my_module > folder. > > > > I modified skel to my module name and basically I leave no codes in the > load function, just a few lines to test if the new module is working. These > few lines are: > > > > *module_interface = switch_loadable_module_create_module_interface(pool, > modname); > > modem_endpoint_interface = > (switch_endpoint_interface_t*)switch_loadable_module_create_interface(*modul e_interface, > SWITCH_ENDPOINT_INTERFACE); > > modem_endpoint_interface->interface_name = "modem"; > > switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello > World!\n"); > > // > > //do_config(SWITCH_FALSE); > > // > > SWITCH_ADD_API(api_interface, "modem", "Modem API", modem_function, > "syntax"); > > > > /* indicate that the module should continue to be loaded */ > > return SWITCH_STATUS_SUCCESS; > > > > It compiles but the module cant load properly. I received the following > error: > > > > 2009-11-01 19:18:10.551180 [CRIT] switch_loadable_module.c:871 Error Loading > module D:\Projects\freeswitch\Debug\mod\mod_mymodule.dll > > **dll sym error [127l] > > ** > > I tried to load module normally at the FS console but load mod_skel and > load mod_mymodule gives the same error. > > > > Would someone tell me what do I miss here. > > > > Btw, I looked at mod_sofia and mod_iax, this line of code could compile in > those 2 modules. > > > > modem_endpoint_interface = > switch_loadable_module_create_interface(*module_interface, > SWITCH_ENDPOINT_INTERFACE); > > > > The same line of code couldnt compile in my module coz VS complains: cannot > convert from void* to switch_endpoint_interface_t*. I know C++ require more > type-safe conversion than C but anyone got the same error? > > > > And how would I search in the mailing list ? Sorry for this dumb question > but I cant seem to find out how to search in the archives. For now, before > posting anything, I need to try to browse through all the postings first, > which is > > > > quite tedious to do. > > > > Regards > > > > Alex To > > ___ > FreeSWITCH-dev mailing list > FreeSWITCH-dev@lists.freeswitch.org > http://lists.freesw
Re: [Freeswitch-dev] FW: Visual Studio 2008 Pro SP1: switch_loadable_module.c:871 Error Loading module .... **dll sym error [127l]
Thanks Mike for the hint. I figured it out. To avoid this error, I need to wrap the part where we define the SWITCH_MODULE_..._FUNCTION inside SWITCH_BEGIN_EXTERN_C AND SWITCH_END_EXTERN_C. It is now loaded fine. Regards Alex To -Original Message- From: freeswitch-dev-boun...@lists.freeswitch.org [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of Michael Giagnocavo Sent: Wednesday, November 04, 2009 8:30 PM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] FW: Visual Studio 2008 Pro SP1: switch_loadable_module.c:871 Error Loading module **dll sym error [127l] mod_managed is C++ and builds and loads fine. You could look at that and compare options and code. (Actually, all of the language plugins should be C++.) -Michael -Original Message- From: freeswitch-dev-boun...@lists.freeswitch.org [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of Alex To Sent: Wednesday, November 04, 2009 5:02 AM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] FW: Visual Studio 2008 Pro SP1: switch_loadable_module.c:871 Error Loading module **dll sym error [127l] Anyone out there have built and loaded successfully a C++ module using Visual Studio 2008 SP1 with FS? This error really got me frustrated these few days. I can't seem to load a C++ module in FS, the error is "dll sym error [1271]" If I rename the code file to .c or change the compile option to "Compile as C code", the module loads fine. If I compile using option "Compile as C++ code" then I got the error. Would really appreciate it if anyone could shed some lights. It must be a setting somewhere in VS or in FS ?? I build FS on Windows 7 x64, VS 2008 SP1, Windows SDK 7.0, build target win32. Regards Alex To -Original Message- From: freeswitch-dev-boun...@lists.freeswitch.org [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of Giovanni Maruzzelli Sent: Sunday, November 01, 2009 9:05 PM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] FW: Visual Studio 2008 Pro SP1: switch_loadable_module.c:871 Error Loading module **dll sym error [127l] On Sun, Nov 1, 2009 at 12:44 PM, Alex To wrote: > Sorry, I figured it out by myself. It was because my code file is > mod_mymodule.cpp. I changed it to mod_mymodule.c and the module loaded file. > So I take it as FS accepts only C library but not C++ ? Ciao Alex, no, you're on the wrong track. FS loads CPP modules. Your problems probably come because mod_skel is a C module, and the Makefile for it manages it as a C module. If you want to compile a CPP module, find one as an example, and adjust yourmodule and its Makefile to be compiled in a similar way. I've done it, and I can assure it works. In this moment I cannot tell you out of my memory which module is CPP, but just browse the sources looking for *.cc or *.cpp. -giovanni > > > > Regards > > > > Alex To > > > > From: Alex To [mailto:tonhud...@gmail.com] > Sent: Sunday, November 01, 2009 7:35 PM > To: 'freeswitch-dev@lists.freeswitch.org' > Subject: Visual Studio 2008 Pro SP1: switch_loadable_module.c:871 Error > Loading module **dll sym error [127l] > > > > Hi, excuse me if this is already asked where else but I did browse through > the mailing list and I couldn't find anything related. I tried to create a > new end point module by copying the mod_skel to mod/endpoints/my_module > folder. > > > > I modified "skel" to my module name and basically I leave no codes in the > load function, just a few lines to test if the new module is working. These > few lines are: > > > > *module_interface = switch_loadable_module_create_module_interface(pool, > modname); > > modem_endpoint_interface = > (switch_endpoint_interface_t*)switch_loadable_module_create_interface(*modul e_interface, > SWITCH_ENDPOINT_INTERFACE); > > modem_endpoint_interface->interface_name = "modem"; > > switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello > World!\n"); > > // > > //do_config(SWITCH_FALSE); > > // > > SWITCH_ADD_API(api_interface, "modem", "Modem API", modem_function, > "syntax"); > > > > /* indicate that the module should continue to be loaded */ > > return SWITCH_STATUS_SUCCESS; > > > > It compiles but the module can't load properly. I received the following > error: > > > > 2009-11-01 19:18:10.551180 [CRIT] switch_loadable_module.c:871 Error Loading > module D:\Projects\freeswitch\Debug\mod\mod_mymodule.dll > > **dll sym error [127l] > > ** > > I tried to load module normally at the FS console but "load mo
[Freeswitch-dev] Questions about read_frame and write_frame events
Hi, I am getting stuck on read_frame and write_frame in my custom endpoint. Would someone shed some lights on how it works? My questions about read_frame, write_frame after reading mod_iax, mod_portaudio and mod_skyiax are: 1. Is it correct that I need to check a flag (for e.g TFLAG_HUP) of the private object at the beginning of the event to determine whether I should continue reading audio or just return. The flag TFLAG_HUP is set when a hangup or kill channel event is detected. 2. Read_frame is called on an interval (how frequently is the interval ? how do I determine that?) to read audio from my endpoint. 3. What is TFLAG_IO normally used for ? 4. What is the label "cng" is all about ? May I know what "cng" stands for and how it is used? 5. What if read_frame is called while my end point is not ready to send any audio yet? 6. What is the tech_pvt->cng_frame is used for? I notice that the *frame is set to tech_pvt->cng_frame if the label "cng" is reached. Thank you very much for even reading my questions. I tried to look for documents that explains clearly the above questions but so far no luck. Until now I still don't have a clear understanding about these 2 events yet. Best Regards Alex To ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
Re: [Freeswitch-dev] Questions about read_frame and write_frame events
Thank you very much Mathieu So if TFLAG_IO is not set, read_frame will return immediately and *frame is NULL ? Is it a normal behavior if the call is terminated when a NULL frame is returned ? Coz when I return a NULL frame, the call is terminated. So now my understanding is that if my endpoint buffer is empty, I need to return a silence frame to the other end, right? Thank again Mathieu for your quick reply, that helps a lot J. Regards Alex To From: freeswitch-dev-boun...@lists.freeswitch.org [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of Mathieu Rene Sent: Monday, November 09, 2009 2:54 AM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] Questions about read_frame and write_frame events Hi, See answers inline. Mathieu Rene Avant-Garde Solutions Inc Office: + 1 (514) 664-1044 x100 Cell: +1 (514) 664-1044 x200 mr...@avgs.ca On 8-Nov-09, at 4:21 AM, Alex To wrote: Hi, I am getting stuck on read_frame and write_frame in my custom endpoint. Would someone shed some lights on how it works? My questions about read_frame, write_frame after reading mod_iax, mod_portaudio and mod_skyiax are: 1. Is it correct that I need to check a flag (for e.g TFLAG_HUP) of the private object at the beginning of the event to determine whether I should continue reading audio or just return. The flag TFLAG_HUP is set when a hangup or kill channel event is detected. Thats what TFLAG_IO is for, clear the flag the read_frame functions should return immediately. If you catch TFLAG_BREAK, on the other side, you should clear it and return a comfort noise frame ( cng ) 2. Read_frame is called on an interval (how frequently is the interval ? how do I determine that?) to read audio from my endpoint. It depends on the codec you are using, if you are using 20 packetization time, it'll be called every 20ms. 3. What is TFLAG_IO normally used for ? See point 1 4. What is the label "cng" is all about ? May I know what "cng" stands for and how it is used? CNG stands for Comfort Noise Generation, whenever read_frame jumps there, it returns a frame of silence. It it first initialized on private_t since its pointless to re-allocate empty frames. 5. What if read_frame is called while my end point is not ready to send any audio yet? That's why you set TFLAG_IO whenever you are ready. Also note that it wont be called until you either pre_answer (go in early media) or answer the channel. When a call is made, switch_ivr_originate() doesn't return until your endpoint is ready to exchange audio. 6. What is the tech_pvt->cng_frame is used for? I notice that the *frame is set to tech_pvt->cng_frame if the label "cng" is reached. See point 4. Thank you very much for even reading my questions. I tried to look for documents that explains clearly the above questions but so far no luck. Until now I still don't have a clear understanding about these 2 events yet. Best Regards Alex To ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
Re: [Freeswitch-dev] Questions about read_frame and write_frame events
Thanks very much Anthony. It is quite clear now but I wonder if anyone could suggest me the proper way to go about this problem My device has a buffer of 64 bytes equal to 8 ms of PCMA/PCMU so in the write_frame I need to write 64 bytes of PCMA to the device every 8 ms. Attempt to more at a time will cause frames lost. However, codecs in freeswitch only support ptime of multiple of 10 (10, 20, 30, 40.) so the work around that I go for is to take ptime = 40 ms since 40 can device by 8. It means, every 40 ms the write_frame event will be called right? And the frame->data will have 320 bytes so I try to write to the device 5 times, each time 64 bytes. Still trying different ways for this problem as I haven't achieved a good timing yet. Anybody has added support for ptime of multiple of 2, 4 or 8 for G711 before ? Regards Alex To From: freeswitch-dev-boun...@lists.freeswitch.org [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of Anthony Minessale Sent: Tuesday, November 10, 2009 2:00 AM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] Questions about read_frame and write_frame events yes you must return a frame marked SFF_CNG rather than a NULL frame. The TFLAG flags are all arbitrary, you can get rid of all of them if you wish they are just an example of how those modules communicate internally. Sometimes they were used for the host technology to have a way to mark the channel so the call should die but you may get the same effect by just hanging up the channel since the core now does a lot of this and may never let your read func even be called. On Mon, Nov 9, 2009 at 3:54 AM, Alex To wrote: Thank you very much Mathieu So if TFLAG_IO is not set, read_frame will return immediately and *frame is NULL ? Is it a normal behavior if the call is terminated when a NULL frame is returned ? Coz when I return a NULL frame, the call is terminated. So now my understanding is that if my endpoint buffer is empty, I need to return a silence frame to the other end, right? Thank again Mathieu for your quick reply, that helps a lot J. Regards Alex To From: freeswitch-dev-boun...@lists.freeswitch.org [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of Mathieu Rene Sent: Monday, November 09, 2009 2:54 AM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] Questions about read_frame and write_frame events Hi, See answers inline. Mathieu Rene Avant-Garde Solutions Inc Office: + 1 (514) 664-1044 x100 Cell: +1 (514) 664-1044 x200 mr...@avgs.ca On 8-Nov-09, at 4:21 AM, Alex To wrote: Hi, I am getting stuck on read_frame and write_frame in my custom endpoint. Would someone shed some lights on how it works? My questions about read_frame, write_frame after reading mod_iax, mod_portaudio and mod_skyiax are: 1. Is it correct that I need to check a flag (for e.g TFLAG_HUP) of the private object at the beginning of the event to determine whether I should continue reading audio or just return. The flag TFLAG_HUP is set when a hangup or kill channel event is detected. Thats what TFLAG_IO is for, clear the flag the read_frame functions should return immediately. If you catch TFLAG_BREAK, on the other side, you should clear it and return a comfort noise frame ( cng ) 2. Read_frame is called on an interval (how frequently is the interval ? how do I determine that?) to read audio from my endpoint. It depends on the codec you are using, if you are using 20 packetization time, it'll be called every 20ms. 3. What is TFLAG_IO normally used for ? See point 1 4. What is the label "cng" is all about ? May I know what "cng" stands for and how it is used? CNG stands for Comfort Noise Generation, whenever read_frame jumps there, it returns a frame of silence. It it first initialized on private_t since its pointless to re-allocate empty frames. 5. What if read_frame is called while my end point is not ready to send any audio yet? That's why you set TFLAG_IO whenever you are ready. Also note that it wont be called until you either pre_answer (go in early media) or answer the channel. When a call is made, switch_ivr_originate() doesn't return until your endpoint is ready to exchange audio. 6. What is the tech_pvt->cng_frame is used for? I notice that the *frame is set to tech_pvt->cng_frame if the label "cng" is reached. See point 4. Thank you very much for even reading my questions. I tried to look for documents that explains clearly the above questions but so far no luck. Until now I still don't have a clear understanding about these 2 events yet. Best Regards Alex To ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE
Re: [Freeswitch-dev] pls help
I have been with FreeSwitch for not so long but why don't you provide more details about exactly what you want to do? Maybe I will be able to share some thing. Regards Alex To From: freeswitch-dev-boun...@lists.freeswitch.org [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of miracle 2012 Sent: Monday, December 28, 2009 3:22 PM To: freeswitch-dev@lists.freeswitch.org Subject: [Freeswitch-dev] pls help Hi, please provide any example c programs , APIs info, reference as i want to write a dialer in c with freeswitch. i am a newbie for free switch... :| thanks. ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
[Freeswitch-dev] Need some explainations about method switch_core_session_run(switch_core_session_t *session) in switch_core_state_machine.c
Hi, First of all, pardon my English. English isnt my native language J. I am reading the method switch_core_session_run(switch_core_session_t *session) and I would be really appreciated if someone could shed some light on how the method works. Below is the logic according to my understanding: 1. LINE 303: while ((state = switch_channel_get_state(session->channel)) != CS_DESTROY) ð if state is CS_DESTROY return and do nothing ? 2. Inside if (state != switch_channel_get_running_state(session->channel) || state >= CS_HANGUP) { } a. LINE 308: state != switch_channel_get_running_state(session->channel) || state >= CS_HANGUP ð to check if channel->state and channel->running_state not equal. This is to avoid running the STATE_MACRO multiple times. However I dont understand why do we need (state >= CS_HANGUP) ?. b. Inside STATE_MACRO code block i. LINE 229: midstate = state ð to save the current state. ii. LINE 231: if (!driver_state_handler->on_##__STATE || (driver_state_handler->on_##__STATE(session) == SWITCH_STATUS_SUCCESS) ð to check either endpoint_interface->state_handler is NULL or return SWITCH_STATUS_SUCCESS so it will continue to execute handlers in session->channel, runtime.state_handlers and core standard state handlers. It means if the condition is not true, channel->state_handlers, runtime.state_handlers and core standard state handlers will NOT be executed at all ? iii. LINE 246: if (!proceed) global_proceed = 0; ð If something wrong in the previous while loop, do not run core standard state handlers ? iv. LINE 247: proceed = 1; LINE 248: while (do_extra_handlers && proceed && (application_state_handler = switch_core_get_state_handler(index++)) != 0) { } ð Since we set proceed = 1, do we still need (&& proceed) inside the condition in while loop ? v. LINE 260: if (!proceed || midstate != switch_channel_get_state(session->channel)) global_proceed = 0; ð If not proceed or the channel state has changed by some of the state handlers executed earlier, do not execute core standard state handler ? vi. LINE 266: while (silly) ð silly is never changed, does it mean we could go into an endless while loop ? Sorry for the long email and some questions are probably dumb but I am trying to understand about FreeSwitch, especially the core and the core state machine. If it is documented somewhere about the workflow happening inside FreeSwitch, please enlighten me as what I am doing now is to read the code line by line and figure out which may not be the most efficient . Thank you for reading this Regards Alex To ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
Re: [Freeswitch-dev] Need some explainations about method switch_core_session_run(switch_core_session_t *session) in switch_core_state_machine.c
Hi, Anthony I appreciate you spend your time answering my questions. I have no problem with FreeSwitch. Since you ask, I am digging into this code because I am trying to understand how FreeSwitch works inside the core, probably will take me a great deal of time but I am trying. I wrote a custom EndPoint in FreeSwitch before to run a modem created by the hardware engineer team. Basically it is similar to Zaptel compatible card. The Modem Endpoint runs in FreeSwitch to provide PSTN Connectivity that uses our specific modem. While working with FreeSwitch, I have this idea to implement something similar to FreeSwitch in 100% .NET managed code. Of course I am not expecting it to be as mature as FreeSwitch but something basic first. A core that allows me to write pluggable modules, basic dial plan and the the first supported endpoint would be XMMP since I had some experience working with this XMMP .Net library before. The ultimate aim is code readability, simplicity and maintainability. I have some other aims too but basically this is it, mostly. I am working on this as a personal hobby project only J. Cheers Alex To From: freeswitch-dev-boun...@lists.freeswitch.org [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of Anthony Minessale Sent: Thursday, January 07, 2010 12:16 AM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] Need some explainations about method switch_core_session_run(switch_core_session_t *session) in switch_core_state_machine.c On Wed, Jan 6, 2010 at 9:20 AM, Alex To wrote: Hi, First of all, pardon my English. English isnt my native language J. I am reading the method switch_core_session_run(switch_core_session_t *session) and I would be really appreciated if someone could shed some light on how the method works. Below is the logic according to my understanding: 1. LINE 303: while ((state = switch_channel_get_state(session->channel)) != CS_DESTROY) ð if state is CS_DESTROY return and do nothing ? state typically starts at CS_NEW the loop runs until state destroy is reached 2. Inside if (state != switch_channel_get_running_state(session->channel) || state >= CS_HANGUP) { } a. LINE 308: state != switch_channel_get_running_state(session->channel) || state >= CS_HANGUP ð to check if channel->state and channel->running_state not equal. This is to avoid running the STATE_MACRO multiple times. However I dont understand why do we need (state >= CS_HANGUP) ?. Once we are >= HANGUP we dont want to do that test anymore. b. Inside STATE_MACRO code block i. LINE 229: midstate = state ð to save the current state. ii. LINE 231: if (!driver_state_handler->on_##__STATE || (driver_state_handler->on_##__STATE(session) == SWITCH_STATUS_SUCCESS) ð to check either endpoint_interface->state_handler is NULL or return SWITCH_STATUS_SUCCESS so it will continue to execute handlers in session->channel, runtime.state_handlers and core standard state handlers. It means if the condition is not true, channel->state_handlers, runtime.state_handlers and core standard state handlers will NOT be executed at all ? iii. LINE 246: if (!proceed) global_proceed = 0; ð If something wrong in the previous while loop, do not run core standard state handlers ? yes the endpoints have the power to veto state handlers from being called iv. LINE 247: proceed = 1; LINE 248: while (do_extra_handlers && proceed && (application_state_handler = switch_core_get_state_handler(index++)) != 0) { } ð Since we set proceed = 1, do we still need (&& proceed) inside the condition in while loop ? yes because proceed can become 0 within that loop v. LINE 260: if (!proceed || midstate != switch_channel_get_state(session->channel)) global_proceed = 0; ð If not proceed or the channel state has changed by some of the state handlers executed earlier, do not execute core standard state handler ? Again, veto power. vi. LINE 266: while (silly) ð silly is never changed, does it mean we could go into an endless while loop ? Its to stop the compiler from getting mad, that's why it's called silly its specific to using a while loop inside a macro Sorry for the long email and some questions are probably dumb but I am trying to understand about FreeSwitch, especial
[Freeswitch-dev] Help on switch_channel_expand_variables(switch_channel_t *channel, const char *in)
Hi, Could somebody shed some lights on how the mentioned method works ? What does it do exactly ? My best guess is it takes in a channel, a string and does something to the string (escape the string ? split the string ? or something like that? But why need a channel parameter?) If there is already an explanation somewhere about this, please point it out for me or possibly just tell me what configuration should I make to trigger this method to be called. I can use debugger and figure it out by myself. Any help would be greatly appreciated. Thanks very much Regards Alex To ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
Re: [Freeswitch-dev] Help on switch_channel_expand_variables(switch_channel_t *channel, const char *in)
Thanks Anthony and Rupa, it's clear now. J Alex To From: freeswitch-dev-boun...@lists.freeswitch.org [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of Anthony Minessale Sent: Thursday, January 21, 2010 2:49 AM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] Help on switch_channel_expand_variables(switch_channel_t *channel, const char *in) say you had 2 vars test1=foo and test2=bar it would turn the string "${test1} ${test2}" into "foo bar" if the returned string does not return the exact pointer that was input, it must be freed. On Wed, Jan 20, 2010 at 12:04 AM, Alex To wrote: Hi, Could somebody shed some lights on how the mentioned method works ? What does it do exactly ? My best guess is it takes in a channel, a string and does something to the string (escape the string ? split the string ? or something like that? But why need a channel parameter?) If there is already an explanation somewhere about this, please point it out for me or possibly just tell me what configuration should I make to trigger this method to be called. I can use debugger and figure it out by myself. Any help would be greatly appreciated. Thanks very much Regards Alex To ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org -- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire AIM: anthm MSN:anthony_miness...@hotmail.com <mailto:msn%3aanthony_miness...@hotmail.com> GTALK/JABBER/PAYPAL:anthony.miness...@gmail.com <mailto:paypal%3aanthony.miness...@gmail.com> IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:8...@conference.freeswitch.org <mailto:sip%3a...@conference.freeswitch.org> iax:gu...@conference.freeswitch.org/888 googletalk:conf+...@conference.freeswitch.org <mailto:googletalk%3aconf%2b...@conference.freeswitch.org> pstn:+19193869900 ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
[Freeswitch-dev] Need help on switch_ivr_originate(...) in switch_ivr_originate.c
Hi, Would somebody enlighten me on this trunk of code in the mentioned file at line 2273: if (local_clobber) { if (var_event) { switch_event_t *event; switch_event_header_t *header; /* install the vars from the {} params */ for (header = var_event->headers; header; header = header->next) { switch_channel_set_variable(originate_status[i].peer_channel, header->name, header->value); } switch_event_create(&event, SWITCH_EVENT_CHANNEL_ORIGINATE); switch_assert(event); switch_channel_event_set_data(originate_status[i].peer_channel, event); switch_event_fire(&event); } } if (vdata) { char *var_array[1024] = { 0 }; int var_count = 0; if ((var_count = switch_separate_string(vdata, '|', var_array, (sizeof(var_array) / sizeof(var_array[0]) { int x = 0; for (x = 0; x < var_count; x++) { char *inner_var_array[2] = { 0 }; int inner_var_count; if ((inner_var_count = switch_separate_string(var_array[x], '=', inner_var_array, (sizeof(inner_var_array) / sizeof(inner_var_array[0] == 2) { switch_channel_set_variable(originate_status[i].peer_channel, inner_var_array[0], inner_var_array[1]); } } } } if (!local_clobber) { if (var_event) { switch_event_t *event; switch_event_header_t *header; /* install the vars from the {} params */ for (header = var_event->headers; header; header = header->next) { switch_channel_set_variable(originate_status[i].peer_channel, header->name, header->value); } switch_event_create(&event, SWITCH_EVENT_CHANNEL_ORIGINATE); switch_assert(event); switch_channel_event_set_data(originate_status[i].peer_channel, event); switch_event_fire(&event); } } The code block inside if (local_clobber) and if (!local_clobber) does exactly the same thing. May I know is it by design and how does it actually work ? I am not sure what does it mean by localClobber so if someone can spare sometime explaining, I would really appreciate it. Thank you Best Regards Alex To ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
Re: [Freeswitch-dev] Need help on switch_ivr_originate(...) in switch_ivr_originate.c
Oh thank you Mike. I overlook the if (vdata) code block in between if(local_clobber) and if (!local_clobber). So actually if (!local_clobber) it will override the local variables by setting the global ones inside the {.}. So it's clear now. Thanks again. Alex To From: freeswitch-dev-boun...@lists.freeswitch.org [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of Anthony Minessale Sent: Tuesday, January 26, 2010 11:27 PM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] Need help on switch_ivr_originate(...) in switch_ivr_originate.c local_clobber true|false (default false) whether or not to allow (per-leg) local variables inside [] to take precedence over originate global variables in {} {foo=value1,local_clobber=false}sofia/internal/1...@test.com,[foo=value2]sofi a/internal/1...@test.com foo will be value1 on both legs {foo=value1,local_clobber=true}sofia/internal/1...@test.com,[foo=value2]sofia /internal/1...@test.com foo will be value1 on all legs except the 101 who set it to value2 On Tue, Jan 26, 2010 at 5:53 AM, Alex To wrote: Hi, Would somebody enlighten me on this trunk of code in the mentioned file at line 2273: if (local_clobber) { if (var_event) { switch_event_t *event; switch_event_header_t *header; /* install the vars from the {} params */ for (header = var_event->headers; header; header = header->next) { switch_channel_set_variable(originate_status[i].peer_channel, header->name, header->value); } switch_event_create(&event, SWITCH_EVENT_CHANNEL_ORIGINATE); switch_assert(event); switch_channel_event_set_data(originate_status[i].peer_channel, event); switch_event_fire(&event); } } if (vdata) { char *var_array[1024] = { 0 }; int var_count = 0; if ((var_count = switch_separate_string(vdata, '|', var_array, (sizeof(var_array) / sizeof(var_array[0]) { int x = 0; for (x = 0; x < var_count; x++) { char *inner_var_array[2] = { 0 }; int inner_var_count; if ((inner_var_count = switch_separate_string(var_array[x], '=', inner_var_array, (sizeof(inner_var_array) / sizeof(inner_var_array[0] == 2) { switch_channel_set_variable(originate_status[i].peer_channel, inner_var_array[0], inner_var_array[1]); } } } } if (!local_clobber) { if (var_event) { switch_event_t *event; switch_event_header_t *header; /* install the vars from the {} params */ for (header = var_event->headers; header; header = header->next) { switch_channel_set_variable(originate_status[i].peer_channel, header->name, header->value); } switch_event_create(&event, SWITCH_EVENT_CHANNEL_ORIGINATE); switch_assert(event); switch_channel_event_set_data(originate_status[i].peer_channel, event); switch_event_fire(&event); } } The code block inside if (local_clobber) and if (!local_clobber) does exactly the same thing. May I know is it by design and how does it actually work ? I am not sure what does it mean by localClobber so if someone can spare sometime explaining, I would really appreciate it. Thank you Best Regards Alex To ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org -- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire AIM: anthm MSN:anthony_miness...@hotmail.com <mailto:msn%3aanthony_miness...@hotmail.com> GTALK/JABBER/PAYPAL:anthony.miness...@gmail.com <mailto:paypal%3aanthony.miness...@gmail.c
Re: [Freeswitch-dev] Need help on switch_ivr_originate(...) in switch_ivr_originate.c
Ignore my previous message. Wanted to say thanks Anthony but I wrote "Mike" . I think I wrote it in a hurry. Sorry for the mistake and thanks Anthony for your help. :D Regards Alex To From: freeswitch-dev-boun...@lists.freeswitch.org [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of Anthony Minessale Sent: Tuesday, January 26, 2010 11:27 PM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] Need help on switch_ivr_originate(...) in switch_ivr_originate.c local_clobber true|false (default false) whether or not to allow (per-leg) local variables inside [] to take precedence over originate global variables in {} {foo=value1,local_clobber=false}sofia/internal/1...@test.com,[foo=value2]sofi a/internal/1...@test.com foo will be value1 on both legs {foo=value1,local_clobber=true}sofia/internal/1...@test.com,[foo=value2]sofia /internal/1...@test.com foo will be value1 on all legs except the 101 who set it to value2 On Tue, Jan 26, 2010 at 5:53 AM, Alex To wrote: Hi, Would somebody enlighten me on this trunk of code in the mentioned file at line 2273: if (local_clobber) { if (var_event) { switch_event_t *event; switch_event_header_t *header; /* install the vars from the {} params */ for (header = var_event->headers; header; header = header->next) { switch_channel_set_variable(originate_status[i].peer_channel, header->name, header->value); } switch_event_create(&event, SWITCH_EVENT_CHANNEL_ORIGINATE); switch_assert(event); switch_channel_event_set_data(originate_status[i].peer_channel, event); switch_event_fire(&event); } } if (vdata) { char *var_array[1024] = { 0 }; int var_count = 0; if ((var_count = switch_separate_string(vdata, '|', var_array, (sizeof(var_array) / sizeof(var_array[0]) { int x = 0; for (x = 0; x < var_count; x++) { char *inner_var_array[2] = { 0 }; int inner_var_count; if ((inner_var_count = switch_separate_string(var_array[x], '=', inner_var_array, (sizeof(inner_var_array) / sizeof(inner_var_array[0] == 2) { switch_channel_set_variable(originate_status[i].peer_channel, inner_var_array[0], inner_var_array[1]); } } } } if (!local_clobber) { if (var_event) { switch_event_t *event; switch_event_header_t *header; /* install the vars from the {} params */ for (header = var_event->headers; header; header = header->next) { switch_channel_set_variable(originate_status[i].peer_channel, header->name, header->value); } switch_event_create(&event, SWITCH_EVENT_CHANNEL_ORIGINATE); switch_assert(event); switch_channel_event_set_data(originate_status[i].peer_channel, event); switch_event_fire(&event); } } The code block inside if (local_clobber) and if (!local_clobber) does exactly the same thing. May I know is it by design and how does it actually work ? I am not sure what does it mean by localClobber so if someone can spare sometime explaining, I would really appreciate it. Thank you Best Regards Alex To ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org -- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire AIM: anthm MSN:anthony_miness...@hotmail.com <mailto:msn%3aanthony_miness...@hotmail.com> GTALK/JABBER/PAYPAL:anthony.miness...@gmail.com <mailto:paypal%3aanthony.miness...@gmail.com> IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference si
[Freeswitch-dev] Question about switch_cond_next()
Hi, would someone clarify this for me please Is it right to say that switch_cond_next() does only one thing which is to put the current thread to sleep for a period of time (1 second) ? Is it equivalent to, let's say, Thread.Sleep(xxx); or it also does something else besides putting the current thead to sleep ? Is switch_cond_yield the same as switch_cond_next, except that switch_cond_yield accepts parameter as the input interval ? Thanks Regards Alex To ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
Re: [Freeswitch-dev] Question about switch_cond_next()
Thank you, Anthony Alex From: freeswitch-dev-boun...@lists.freeswitch.org [mailto:freeswitch-dev-boun...@lists.freeswitch.org] On Behalf Of Anthony Minessale Sent: Friday, January 29, 2010 12:33 AM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] Question about switch_cond_next() cond_next is equiv to cond_yield(1000) or 1 ms actual time will vary depending on OS and HW On Thu, Jan 28, 2010 at 8:10 AM, Alex To wrote: Hi, would someone clarify this for me please Is it right to say that switch_cond_next() does only one thing which is to put the current thread to sleep for a period of time (1 second) ? Is it equivalent to, let's say, Thread.Sleep(xxx); or it also does something else besides putting the current thead to sleep ? Is switch_cond_yield the same as switch_cond_next, except that switch_cond_yield accepts parameter as the input interval ? Thanks Regards Alex To ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org -- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire AIM: anthm MSN:anthony_miness...@hotmail.com <mailto:msn%3aanthony_miness...@hotmail.com> GTALK/JABBER/PAYPAL:anthony.miness...@gmail.com <mailto:paypal%3aanthony.miness...@gmail.com> IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:8...@conference.freeswitch.org <mailto:sip%3a...@conference.freeswitch.org> iax:gu...@conference.freeswitch.org/888 googletalk:conf+...@conference.freeswitch.org <mailto:googletalk%3aconf%2b...@conference.freeswitch.org> pstn:+19193869900 ___ FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org