diff --git a/src/dotnet/Common.cs b/src/dotnet/Common.cs index aa3849ea66..411b4189f9 100755 --- a/src/dotnet/Common.cs +++ b/src/dotnet/Common.cs @@ -32,7 +32,7 @@ using System; using System.Reflection; -namespace FreeSwitch.NET +namespace FreeSwitch { public class Common { diff --git a/src/dotnet/FreeSwitch.NET.csproj b/src/dotnet/FreeSwitch.NET.csproj index 872a79a498..0f33694513 100755 --- a/src/dotnet/FreeSwitch.NET.csproj +++ b/src/dotnet/FreeSwitch.NET.csproj @@ -7,8 +7,8 @@ {251CAABC-16C3-4593-A491-603B908094E0} Library Properties - FreeSwitch.NET - Freeswitch + FreeSwitch + FreeSwitch.NET true @@ -42,11 +42,17 @@ + + + + + + @@ -65,6 +71,9 @@ + + + @@ -79,6 +88,8 @@ + + @@ -96,6 +107,13 @@ + + + + + + + diff --git a/src/dotnet/Ivr.cs b/src/dotnet/Ivr.cs new file mode 100644 index 0000000000..49fffb3142 --- /dev/null +++ b/src/dotnet/Ivr.cs @@ -0,0 +1,44 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; +using FreeSwitch.Types; +using FreeSwitch.Marshaling.Types; + +namespace FreeSwitch +{ + public class Ivr + { + public static Status MultiThreadedBridge(CoreSession session, CoreSession peerSession, InputCallbackFunction dtmfCallback) + { + return Switch.switch_ivr_multi_threaded_bridge(session, peerSession, dtmfCallback, IntPtr.Zero, IntPtr.Zero); + } + + public static Status Originate(CoreSession session, CoreSession peerSession, CallCause callCause, string data, uint timelimit) + { + IntPtr callCausePtr = Marshal.AllocHGlobal(4); + IntPtr dataPtr = Marshal.StringToHGlobalAnsi(data); + + Marshal.StructureToPtr(callCause, callCausePtr, true); + + return Switch.switch_ivr_originate(session, ref peerSession, callCausePtr, dataPtr, timelimit, null, null, null, null); + } + + public static Status RecordFile(CoreSession coreSession, FileHandle fileHandle, string file, DtmfCallbackFunction dtmfCallbackFunction) + { + Byte[] filename = Encoding.Default.GetBytes(file); + + Console.WriteLine("File: {0}", file); + + dtmfCallbackFunction(coreSession, "1"); + dtmfCallbackFunction(coreSession, "2"); + dtmfCallbackFunction(coreSession, "3"); + + Encoding ansiEncoding = Encoding.GetEncoding(1252); + //filename = Encoding.Convert(Encoding.Default, ansiEncoding, filename); + + Console.WriteLine("Filename: {0}", file); + //Console.WriteLine("Status record: {0}", status.ToString()); + return Status.Success; + } + } +} \ No newline at end of file diff --git a/src/dotnet/Log.cs b/src/dotnet/Log.cs new file mode 100644 index 0000000000..7991df64f1 --- /dev/null +++ b/src/dotnet/Log.cs @@ -0,0 +1,16 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; +using FreeSwitch.Types; +using FreeSwitch.Marshaling.Types; + +namespace FreeSwitch +{ + public class Log + { + public static void Printf(LogLevel level, string message) + { + Switch.switch_log_printf(null, "File", "Func.NET", 123, level, message); + } + } +} \ No newline at end of file diff --git a/src/dotnet/Makefile b/src/dotnet/Makefile index a3d06096e1..53670e7f59 100644 --- a/src/dotnet/Makefile +++ b/src/dotnet/Makefile @@ -2,7 +2,7 @@ all: $(MODNAME).so $(MODNAME).so: /usr/local/freeswitch/bin/gmcs -debug -unsafe -t:library -keyfile:public.snk \ - -out:FreeSwitch.dll -reference:Mono.Posix.dll \ + -out:FreeSwitch.NET.dll -reference:Mono.Posix.dll \ Properties/AssemblyInfo.cs \ Marshaling/Types/ApiInterfaceMarshal.cs \ Marshaling/Types/ApplicationInterfaceMarshal.cs \ @@ -24,26 +24,35 @@ $(MODNAME).so: Marshaling/Types/IOEventHooksMarshal.cs \ Marshaling/Types/LoadableModuleInterfaceMarshal.cs \ Marshaling/Types/LoadableModuleMarshal.cs \ + Marshaling/Types/SpeechHandleMarshal.cs \ + Marshaling/Types/StateHandlerTableMarshal.cs \ Marshaling/Types/StreamHandleMarshal.cs \ Marshaling/Types/TypesMarshal.cs \ + Marshaling/Types/TimerMarshal.cs \ Marshaling/BufferMarshaler.cs \ Marshaling/CallerExtensionMarshaler.cs \ Marshaling/CallerProfileMarshaler.cs \ Marshaling/ChannelMarshaler.cs \ Marshaling/ChannelTimetableMarshaler.cs \ + Marshaling/CodecMarshaler.cs \ Marshaling/CoreSessionMarshaler.cs \ Marshaling/EventMarshaler.cs \ Marshaling/FileHandleMarshaler.cs \ Marshaling/MemoryPoolMarshaler.cs \ + Marshaling/SpeechHandleMarshaler.cs \ + Marshaling/StateHandlerTableMarshaler.cs \ Marshaling/StreamHandleMarshaler.cs \ + Marshaling/TimerMarshaler.cs \ Modules/Api.cs \ Modules/Application.cs \ Switch/CallerProfile.cs \ Switch/Channel.cs \ Switch/Console.cs \ Switch/CoreSession.cs \ + Switch/Event.cs \ Switch/Ivr.cs \ Switch/LoadableModule.cs \ + Switch/Log.cs \ Switch/StreamHandle.cs \ Types/ApiFunction.cs \ Types/ApplicationFunction.cs \ @@ -56,24 +65,33 @@ $(MODNAME).so: Types/ChannelFlag.cs \ Types/ChannelState.cs \ Types/ChannelTimetable.cs \ + Types/Codec.cs \ Types/CoreSession.cs \ Types/DtmfCallbackFunction.cs \ Types/InputCallbackFunction.cs \ Types/InputType.cs \ Types/Event.cs \ + Types/EventCallback.cs \ + Types/EventType.cs \ Types/FileHandle.cs \ Types/LoadableModule.cs \ Types/LoadableModuleInterface.cs \ + Types/LogLevel.cs \ Types/MemoryPool.cs \ Types/Module.cs \ Types/Status.cs \ + Types/SpeechHandle.cs \ + Types/StateHandlerTable.cs \ Types/StreamHandle.cs \ Types/TextChannel.cs \ + Types/Timer.cs \ Common.cs \ Module.cs \ + Ivr.cs \ + Log.cs \ clean: rm -fr *.dll install: - cp -f FreeSwitch.dll /usr/local/freeswitch/lib/ + cp -f FreeSwitch.NET.dll /usr/local/freeswitch/lib/ diff --git a/src/dotnet/Marshaling/CodecMarshaler.cs b/src/dotnet/Marshaling/CodecMarshaler.cs new file mode 100644 index 0000000000..7313c3810a --- /dev/null +++ b/src/dotnet/Marshaling/CodecMarshaler.cs @@ -0,0 +1,82 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2006, James Martelletti + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * James Martelletti + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * James Martelletti + * + * + * CodecMarshaler.cs -- + * + */ +using System; +using System.Collections; +using FreeSwitch.Marshaling.Types; +using FreeSwitch.Types; +using System.Runtime.InteropServices; + +namespace FreeSwitch.Marshaling +{ + class CodecMarshaler : ICustomMarshaler + { + private static CodecMarshaler Instance = new CodecMarshaler(); + + public static ICustomMarshaler GetInstance(string s) + { + return Instance; + } + + public void CleanUpManagedData(object o) + { + } + + public void CleanUpNativeData(IntPtr pNativeData) + { + } + + public int GetNativeDataSize() + { + return IntPtr.Size; + } + + public IntPtr MarshalManagedToNative(object obj) + { + Codec streamHandleObj = (Codec)obj; + + return streamHandleObj.marshaledObject.Handle; + } + + public object MarshalNativeToManaged(IntPtr codecPtr) + { + CodecMarshal codecMarshal = new CodecMarshal(); + Codec codecObj = new Codec(); + + + Marshal.PtrToStructure(codecPtr, codecMarshal); + + codecObj.marshaledObject = new HandleRef(codecMarshal, codecPtr); + + return codecObj; + } + } +} \ No newline at end of file diff --git a/src/dotnet/Marshaling/CoreSessionMarshaler.cs b/src/dotnet/Marshaling/CoreSessionMarshaler.cs index 981b15a1ff..11c537928d 100755 --- a/src/dotnet/Marshaling/CoreSessionMarshaler.cs +++ b/src/dotnet/Marshaling/CoreSessionMarshaler.cs @@ -61,8 +61,28 @@ namespace FreeSwitch.Marshaling public IntPtr MarshalManagedToNative(object obj) { CoreSession coreSession = (CoreSession)obj; - - return coreSession.marshaledObject.Handle; + + Console.WriteLine("CoreSession: Marshalling Managed to Native"); + + if (coreSession.marshaledObject.Handle != IntPtr.Zero) + { + + Console.WriteLine("Returning: 0x{0:x}", coreSession.marshaledObject.Handle.ToInt32()); + return coreSession.marshaledObject.Handle; + } + else + { + CoreSessionMarshal coreSessionMarshal = new CoreSessionMarshal(); + IntPtr coreSessionPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CoreSessionMarshal))); + + Marshal.StructureToPtr(coreSessionMarshal, coreSessionPtr, true); + + coreSession.marshaledObject = new HandleRef(coreSessionMarshal, coreSessionPtr); + + Console.WriteLine("CoreSession: NO OBJECT EXISTS OMG"); + Console.WriteLine("Returning: 0x{0:x}", coreSession.marshaledObject.Handle.ToInt32()); + return coreSession.marshaledObject.Handle; + } } public object MarshalNativeToManaged(IntPtr coreSessionPtr) @@ -70,6 +90,8 @@ namespace FreeSwitch.Marshaling CoreSessionMarshal coreSessionMarshal = new CoreSessionMarshal(); CoreSession coreSession = new CoreSession(); + Console.WriteLine("CoreSession: Marshalling Native to Managed"); + Marshal.PtrToStructure(coreSessionPtr, coreSessionMarshal); coreSession.marshaledObject = new HandleRef(coreSessionMarshal, coreSessionPtr); diff --git a/src/dotnet/Marshaling/SpeechHandleMarshaler.cs b/src/dotnet/Marshaling/SpeechHandleMarshaler.cs new file mode 100644 index 0000000000..9c25384c3c --- /dev/null +++ b/src/dotnet/Marshaling/SpeechHandleMarshaler.cs @@ -0,0 +1,81 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2006, James Martelletti + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * James Martelletti + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * James Martelletti + * + * + * SpeechHandleMarshaler.cs -- + * + */ +using System; +using System.Collections; +using FreeSwitch.Marshaling.Types; +using FreeSwitch.Types; +using System.Runtime.InteropServices; + +namespace FreeSwitch.Marshaling +{ + class SpeechHandleMarshaler : ICustomMarshaler + { + private static SpeechHandleMarshaler Instance = new SpeechHandleMarshaler(); + + public static ICustomMarshaler GetInstance(string s) + { + return Instance; + } + + public void CleanUpManagedData(object o) + { + } + + public void CleanUpNativeData(IntPtr pNativeData) + { + } + + public int GetNativeDataSize() + { + return IntPtr.Size; + } + + public IntPtr MarshalManagedToNative(object obj) + { + SpeechHandle speechHandleObj = (SpeechHandle)obj; + + return speechHandleObj.marshaledObject.Handle; + } + + public object MarshalNativeToManaged(IntPtr speechHandlePtr) + { + SpeechHandleMarshal speechHandleMarshal = new SpeechHandleMarshal(); + SpeechHandle speechHandleObj = new SpeechHandle(); + + Marshal.PtrToStructure(speechHandlePtr, speechHandleMarshal); + + speechHandleObj.marshaledObject = new HandleRef(speechHandleMarshal, speechHandlePtr); + + return speechHandleObj; + } + } +} diff --git a/src/dotnet/Marshaling/StateHandlerTableMarshaler.cs b/src/dotnet/Marshaling/StateHandlerTableMarshaler.cs new file mode 100644 index 0000000000..db4fe3f704 --- /dev/null +++ b/src/dotnet/Marshaling/StateHandlerTableMarshaler.cs @@ -0,0 +1,81 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2006, James Martelletti + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * James Martelletti + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * James Martelletti + * + * + * StateHandlerTableMarshaler.cs -- + * + */ +using System; +using System.Collections; +using FreeSwitch.Marshaling.Types; +using FreeSwitch.Types; +using System.Runtime.InteropServices; + +namespace FreeSwitch.Marshaling +{ + class StateHandlerTableMarshaler : ICustomMarshaler + { + private static StateHandlerTableMarshaler Instance = new StateHandlerTableMarshaler(); + + public static ICustomMarshaler GetInstance(string s) + { + return Instance; + } + + public void CleanUpManagedData(object o) + { + } + + public void CleanUpNativeData(IntPtr pNativeData) + { + } + + public int GetNativeDataSize() + { + return IntPtr.Size; + } + + public IntPtr MarshalManagedToNative(object obj) + { + StateHandlerTable stateHandlerTableObj = (StateHandlerTable)obj; + + return stateHandlerTableObj.marshaledObject.Handle; + } + + public object MarshalNativeToManaged(IntPtr stateHandlerTablePtr) + { + StateHandlerTableMarshal stateHandlerTableMarshal = new StateHandlerTableMarshal(); + StateHandlerTable stateHandlerTableObj = new StateHandlerTable(); + + Marshal.PtrToStructure(stateHandlerTablePtr, stateHandlerTableMarshal); + + stateHandlerTableObj.marshaledObject = new HandleRef(stateHandlerTableMarshal, stateHandlerTablePtr); + + return stateHandlerTableObj; + } + } +} diff --git a/src/dotnet/Marshaling/TimerMarshaler.cs b/src/dotnet/Marshaling/TimerMarshaler.cs new file mode 100644 index 0000000000..0b85deac6a --- /dev/null +++ b/src/dotnet/Marshaling/TimerMarshaler.cs @@ -0,0 +1,81 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2006, James Martelletti + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * James Martelletti + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * James Martelletti + * + * + * TimerMarshaler.cs -- + * + */ +using System; +using System.Collections; +using FreeSwitch.Marshaling.Types; +using FreeSwitch.Types; +using System.Runtime.InteropServices; + +namespace FreeSwitch.Marshaling +{ + class TimerMarshaler : ICustomMarshaler + { + private static TimerMarshaler Instance = new TimerMarshaler(); + + public static ICustomMarshaler GetInstance(string s) + { + return Instance; + } + + public void CleanUpManagedData(object o) + { + } + + public void CleanUpNativeData(IntPtr pNativeData) + { + } + + public int GetNativeDataSize() + { + return IntPtr.Size; + } + + public IntPtr MarshalManagedToNative(object obj) + { + Timer timerObj = (Timer)obj; + + return timerObj.marshaledObject.Handle; + } + + public object MarshalNativeToManaged(IntPtr timerPtr) + { + TimerMarshal timerMarshal = new TimerMarshal(); + Timer timerObj = new Timer(); + + Marshal.PtrToStructure(timerPtr, timerMarshal); + + timerObj.marshaledObject = new HandleRef(timerMarshal, timerPtr); + + return timerObj; + } + } +} diff --git a/src/dotnet/Marshaling/Types/CodecMarshal.cs b/src/dotnet/Marshaling/Types/CodecMarshal.cs index 065a9fb744..7035c5a842 100755 --- a/src/dotnet/Marshaling/Types/CodecMarshal.cs +++ b/src/dotnet/Marshaling/Types/CodecMarshal.cs @@ -38,9 +38,9 @@ namespace FreeSwitch.Marshaling.Types { internal IntPtr codec_interface; internal IntPtr implementation; - //internal CodecSettingsMarshal codec_settings; + internal IntPtr codec_settings; internal UInt32 flags; - //internal MemoryPoolMarshal memory_pool; + internal IntPtr memory_pool; internal IntPtr private_info; } } diff --git a/src/dotnet/Marshaling/Types/SpeechHandleMarshal.cs b/src/dotnet/Marshaling/Types/SpeechHandleMarshal.cs new file mode 100644 index 0000000000..937cbd653b --- /dev/null +++ b/src/dotnet/Marshaling/Types/SpeechHandleMarshal.cs @@ -0,0 +1,53 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2006, James Martelletti + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * James Martelletti + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * James Martelletti + * + * + * SpeechHandleMarshal.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.Types; + +namespace FreeSwitch.Marshaling.Types +{ + [StructLayout(LayoutKind.Sequential)] + internal class SpeechHandleMarshal + { + internal IntPtr speech_interface; + internal UInt32 flags; + internal IntPtr name; + internal UInt32 rate; + internal UInt32 speed; + [MarshalAs(UnmanagedType.ByValArray, SizeConst=80)] + internal byte[] voice; + [MarshalAs(UnmanagedType.ByValArray, SizeConst=80)] + internal byte[] engine; + internal IntPtr memory_pool; + internal IntPtr private_info; + } +} diff --git a/src/dotnet/Marshaling/Types/StateHandlerTableMarshal.cs b/src/dotnet/Marshaling/Types/StateHandlerTableMarshal.cs new file mode 100644 index 0000000000..1e7f68c755 --- /dev/null +++ b/src/dotnet/Marshaling/Types/StateHandlerTableMarshal.cs @@ -0,0 +1,49 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2006, James Martelletti + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * James Martelletti + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * James Martelletti + * + * + * StateHandlerTableMarshal.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.Types; + +namespace FreeSwitch.Marshaling.Types +{ + [StructLayout(LayoutKind.Sequential)] + internal class StateHandlerTableMarshal + { + internal IntPtr on_init; + internal IntPtr on_ring; + internal IntPtr on_execute; + internal IntPtr on_hangup; + internal IntPtr on_loopback; + internal IntPtr on_transmit; + internal IntPtr on_hold; + } +} \ No newline at end of file diff --git a/src/dotnet/Marshaling/Types/StreamHandleMarshal.cs b/src/dotnet/Marshaling/Types/StreamHandleMarshal.cs index 33878cc8f7..e50e747b70 100755 --- a/src/dotnet/Marshaling/Types/StreamHandleMarshal.cs +++ b/src/dotnet/Marshaling/Types/StreamHandleMarshal.cs @@ -43,6 +43,8 @@ namespace FreeSwitch.Marshaling.Types internal IntPtr end; internal int data_size; internal int data_len; + internal int alloc_len; + internal int alloc_chunk; internal IntPtr _event; } } diff --git a/src/dotnet/Marshaling/Types/TimerMarshal.cs b/src/dotnet/Marshaling/Types/TimerMarshal.cs new file mode 100644 index 0000000000..39d70c2dfe --- /dev/null +++ b/src/dotnet/Marshaling/Types/TimerMarshal.cs @@ -0,0 +1,49 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2006, James Martelletti + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * James Martelletti + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * James Martelletti + * + * + * TimerMarshal.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.Types; + +namespace FreeSwitch.Marshaling.Types +{ + [StructLayout(LayoutKind.Sequential)] + internal class TimerMarshal + { + int interval; + UInt32 flags; + uint samples; + uint samplecount; + IntPtr timer_interface; + IntPtr memory_pool; + IntPtr private_info; + } +} diff --git a/src/dotnet/Module.cs b/src/dotnet/Module.cs index 4c649bfa65..59078ecedd 100644 --- a/src/dotnet/Module.cs +++ b/src/dotnet/Module.cs @@ -34,12 +34,11 @@ using System.Collections; using System.Reflection; using System.Runtime.InteropServices; using System.Text; -using FreeSwitch.NET; using FreeSwitch.Types; using FreeSwitch.Modules; using FreeSwitch.Marshaling.Types; -namespace FreeSwitch.NET +namespace FreeSwitch { /// /// Base class for all Freeswitch.NET modules @@ -92,19 +91,25 @@ namespace FreeSwitch.NET /* Set the module_name field of the LoadableModuleInterface */ module_interface.module_name = Marshal.StringToHGlobalAnsi(filename); - /* Grab the first ApiInterface in our array and add a pointer to this in our ModuleInterface*/ - Api apiIndex = (Api)apiInterfaces[0]; - - module_interface.api_interface = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ApiInterfaceMarshal))); - - Marshal.StructureToPtr(apiIndex.handle.Wrapper, module_interface.api_interface, true); - - /* For each Application interface */ - Application applicationIndex = (Application)applicationInterfaces[0]; - - module_interface.application_interface = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ApplicationInterfaceMarshal))); - - Marshal.StructureToPtr(applicationIndex.handle.Wrapper, module_interface.application_interface, true); + if (apiInterfaces.Count > 0) + { + /* Grab the first ApiInterface in our array and add a pointer to this in our ModuleInterface*/ + Api apiIndex = (Api)apiInterfaces[0]; + + module_interface.api_interface = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ApiInterfaceMarshal))); + + Marshal.StructureToPtr(apiIndex.handle.Wrapper, module_interface.api_interface, true); + } + + if (applicationInterfaces.Count > 0) + { + /* For each Application interface */ + Application applicationIndex = (Application)applicationInterfaces[0]; + + module_interface.application_interface = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ApplicationInterfaceMarshal))); + + Marshal.StructureToPtr(applicationIndex.handle.Wrapper, module_interface.application_interface, true); + } /* Finally, marshal the moduleinterface class and return */ Marshal.StructureToPtr(module_interface, module, true); @@ -200,6 +205,10 @@ namespace FreeSwitch.NET module.module_shutdown); } - + public string Name + { + set { name = value; } + get { return name; } + } } } diff --git a/src/dotnet/Switch/Channel.cs b/src/dotnet/Switch/Channel.cs index 124ef36907..04711ccb53 100755 --- a/src/dotnet/Switch/Channel.cs +++ b/src/dotnet/Switch/Channel.cs @@ -84,6 +84,15 @@ namespace FreeSwitch [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(ChannelMarshaler))] Channel channel); + [DllImport("freeswitch")] + [return: MarshalAs(UnmanagedType.LPStr)] + public extern static + string switch_channel_get_variable( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(ChannelMarshaler))] + Channel channel, + [MarshalAs(UnmanagedType.LPStr)] + string varname); + [DllImport("freeswitch")] [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))] public extern static diff --git a/src/dotnet/Switch/Event.cs b/src/dotnet/Switch/Event.cs new file mode 100644 index 0000000000..1e70efad3e --- /dev/null +++ b/src/dotnet/Switch/Event.cs @@ -0,0 +1,52 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2006, James Martelletti + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * James Martelletti + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * James Martelletti + * + * + * Channel.cs -- + * + */ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using FreeSwitch.Types; +using FreeSwitch.Marshaling; + +namespace FreeSwitch +{ + public partial class Switch + { + [DllImport("freeswitch")] + public extern static + Status switch_event_bind( + [MarshalAs(UnmanagedType.LPStr)] + string id, + EventType eventType, + string subClassName, + EventCallback callback, + IntPtr userData); + } +} diff --git a/src/dotnet/Switch/Ivr.cs b/src/dotnet/Switch/Ivr.cs index 62aaf67129..f370445819 100755 --- a/src/dotnet/Switch/Ivr.cs +++ b/src/dotnet/Switch/Ivr.cs @@ -40,12 +40,67 @@ namespace FreeSwitch { public partial class Switch { + [DllImport("freeswitch")] + public extern static + Status switch_ivr_sleep( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] + CoreSession session, + UInt32 ms); + + [DllImport("freeswitch")] + public extern static + Status switch_ivr_park( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] + CoreSession session); + + [DllImport("freeswitch")] + public extern static + Status switch_ivr_collect_digits_callback( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] + CoreSession session, + InputCallbackFunction dtmfCallback, + IntPtr buf, + uint buflen); + + [DllImport("freeswitch")] + public extern static + Status switch_ivr_collect_digits_count( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] + CoreSession session, + [MarshalAs(UnmanagedType.LPStr)] + string buffer, + uint buflen, + uint maxdigits, + [MarshalAs(UnmanagedType.LPStr)] + string terminators, + [MarshalAs(UnmanagedType.LPStr)] + string terminator, + uint timeout); + + [DllImport("freeswitch")] + public extern static + Status switch_ivr_record_session( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] + CoreSession session, + [MarshalAs(UnmanagedType.LPStr)] + string file, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileHandleMarshaler))] + FileHandle fh); + + [DllImport("freeswitch")] + public extern static + Status switch_ivr_stop_record_session( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] + CoreSession session, + [MarshalAs(UnmanagedType.LPStr)] + string file); + [DllImport("freeswitch")] extern public static Status switch_ivr_play_file( - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoreSessionMarshaler))] + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] CoreSession session, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FileHandleMarshaler))] + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileHandleMarshaler))] FileHandle fh, [MarshalAs(UnmanagedType.LPStr)] string file, @@ -55,18 +110,6 @@ namespace FreeSwitch IntPtr buf, uint buflen); - [DllImport("freeswitch")] - public extern static - Status switch_ivr_multi_threaded_bridge( - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] - CoreSession session, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] - CoreSession peer_session, - uint timelimit, - IntPtr dtmf_callback, - IntPtr session_data, - IntPtr peer_session_data); - [DllImport("freeswitch")] public extern static Status switch_ivr_record_file( @@ -78,5 +121,82 @@ namespace FreeSwitch InputCallbackFunction input_callback, IntPtr buf, uint buflen); + + [DllImport("freeswitch")] + public extern static + Status switch_ivr_speak_text_handle( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] + CoreSession session, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(SpeechHandleMarshaler))] + SpeechHandle sh, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CodecMarshaler))] + Codec codec, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(TimerMarshaler))] + Timer timer, + InputCallbackFunction dtmfCallback, + [MarshalAs(UnmanagedType.LPStr)] + string text, + IntPtr buf, + uint buflen); + + [DllImport("freeswitch")] + public extern static + Status switch_ivr_speak_text( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] + CoreSession session, + [MarshalAs(UnmanagedType.LPStr)] + string tts_name, + [MarshalAs(UnmanagedType.LPStr)] + string voice_name, + [MarshalAs(UnmanagedType.LPStr)] + string timer_name, + uint rate, + InputCallbackFunction dtmfCallback, + [MarshalAs(UnmanagedType.LPStr)] + string text, + IntPtr buf, + uint buflen); + + [DllImport("freeswitch")] + public extern static + Status switch_ivr_originate( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] + CoreSession session, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] + ref CoreSession bleg, + IntPtr cause, + IntPtr bridgeto, + UInt32 timelimit_sec, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(StateHandlerTableMarshaler))] + StateHandlerTable table, + [MarshalAs(UnmanagedType.LPStr)] + string cid_name_override, + [MarshalAs(UnmanagedType.LPStr)] + string cid_num_override, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))] + CallerProfile caller_profile_override); + + [DllImport("freeswitch")] + public extern static + Status switch_ivr_multi_threaded_bridge( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] + CoreSession session, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] + CoreSession peer_session, + InputCallbackFunction dtmfCallback, + IntPtr session_data, + IntPtr peer_session_data); + + [DllImport("freeswitch")] + public extern static + Status switch_ivr_session_transfer( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] + CoreSession session, + [MarshalAs(UnmanagedType.LPStr)] + string extension, + [MarshalAs(UnmanagedType.LPStr)] + string dialplan, + [MarshalAs(UnmanagedType.LPStr)] + string context); } } diff --git a/src/dotnet/Switch/Log.cs b/src/dotnet/Switch/Log.cs new file mode 100644 index 0000000000..4c14ef4ea0 --- /dev/null +++ b/src/dotnet/Switch/Log.cs @@ -0,0 +1,62 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2006, James Martelletti + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * James Martelletti + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * James Martelletti + * + * + * Log.cs -- + * + */ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using FreeSwitch.Types; +using FreeSwitch.Marshaling; +using FreeSwitch.Marshaling.Types; + +namespace FreeSwitch +{ + /* + src/switch_log.c:SWITCH_DECLARE(const char *) switch_log_level2str(switch_log_level_t level) + src/switch_log.c:SWITCH_DECLARE(switch_log_level_t) switch_log_str2level(const char *str) + src/switch_log.c:SWITCH_DECLARE(switch_status_t) switch_log_bind_logger(switch_log_function_t function, switch_log_level_t level) + src/switch_log.c:SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, char *file, const char *func, int line, switch_log_level_t level, char *fmt, ...) + src/switch_log.c:SWITCH_DECLARE(switch_status_t) switch_log_init(switch_memory_pool_t *pool) + src/switch_log.c:SWITCH_DECLARE(switch_status_t) switch_log_shutdown(void) + */ + public partial class Switch + { + [DllImport("freeswitch")] + public extern static + void switch_log_printf( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))] + Channel channel, + string file, + string func, + int line, + LogLevel level, + string format); + } +} diff --git a/src/dotnet/Types/Channel.cs b/src/dotnet/Types/Channel.cs index ac9a9032d7..acdd3d3e4e 100755 --- a/src/dotnet/Types/Channel.cs +++ b/src/dotnet/Types/Channel.cs @@ -219,5 +219,15 @@ namespace FreeSwitch.Types { return Switch.switch_channel_answer(this); } + + public ChannelState Hangup(CallCause cause) + { + return Switch.switch_channel_perform_hangup(this, "file", "func", 666, cause); + } + + public string GetVariable(string varname) + { + return Switch.switch_channel_get_variable(this, varname); + } } } diff --git a/src/dotnet/Types/Codec.cs b/src/dotnet/Types/Codec.cs new file mode 100644 index 0000000000..97506611eb --- /dev/null +++ b/src/dotnet/Types/Codec.cs @@ -0,0 +1,44 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2006, James Martelletti + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * James Martelletti + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * James Martelletti + * + * + * Codec.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.Marshaling; +using FreeSwitch.Marshaling.Types; + +namespace FreeSwitch.Types +{ + public class Codec + { + internal HandleRef marshaledObject; + + } +} \ No newline at end of file diff --git a/src/dotnet/Types/CoreSession.cs b/src/dotnet/Types/CoreSession.cs index b8083ed009..59ca061bb6 100755 --- a/src/dotnet/Types/CoreSession.cs +++ b/src/dotnet/Types/CoreSession.cs @@ -109,7 +109,7 @@ namespace FreeSwitch.Types get { CoreSessionMarshal coreSessionMarshal = (CoreSessionMarshal)marshaledObject.Wrapper; - + if (coreSessionMarshal.thread_running <= 0) return false; else diff --git a/src/dotnet/Types/Event.cs b/src/dotnet/Types/Event.cs index d2800e992c..3f726bbb81 100755 --- a/src/dotnet/Types/Event.cs +++ b/src/dotnet/Types/Event.cs @@ -101,20 +101,4 @@ namespace FreeSwitch.Types public string Name; public string Value; } - - public enum EventType - { - SWITCH_EVENT_CUSTOM, - SWITCH_EVENT_CHANNEL_STATE, - SWITCH_EVENT_CHANNEL_ANSWER, - SWITCH_EVENT_CHANNEL_HANGUP, - SWITCH_EVENT_API, - SWITCH_EVENT_LOG, - SWITCH_EVENT_INBOUND_CHAN, - SWITCH_EVENT_OUTBOUND_CHAN, - SWITCH_EVENT_STARTUP, - SWITCH_EVENT_SHUTDOWN, - SWITCH_EVENT_ALL - } - } diff --git a/src/dotnet/Types/EventCallback.cs b/src/dotnet/Types/EventCallback.cs new file mode 100644 index 0000000000..719964bcff --- /dev/null +++ b/src/dotnet/Types/EventCallback.cs @@ -0,0 +1,41 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2006, James Martelletti + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * James Martelletti + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * James Martelletti + * + * + * EventCallback.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.Marshaling; + +namespace FreeSwitch.Types +{ + public delegate void EventCallback( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(EventMarshaler))] + Event _event); +} \ No newline at end of file diff --git a/src/dotnet/Types/EventType.cs b/src/dotnet/Types/EventType.cs new file mode 100644 index 0000000000..16cade1706 --- /dev/null +++ b/src/dotnet/Types/EventType.cs @@ -0,0 +1,72 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2006, James Martelletti + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * James Martelletti + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * James Martelletti + * + * + * EventType.cs -- + * + */ +using System; +using System.Collections; +using System.Text; +using System.Runtime.InteropServices; + +namespace FreeSwitch.Types +{ + public enum EventType + { + Custom, + Create, + Destroy, + State, + Answer, + Hangup, + Execute, + Bridge, + UnBridge, + Progress, + Outgoing, + Park, + UnPark, + Api, + Log, + InboundChan, + OutboundChan, + Startup, + Shutdown, + Publish, + UnPublish, + Talk, + NoTalk, + SessionCrash, + ModuleLoad, + Dtmf, + Message, + Codec, + BackgroundJob, + All + } +} \ No newline at end of file diff --git a/src/dotnet/Types/InputCallbackFunction.cs b/src/dotnet/Types/InputCallbackFunction.cs index c4d8aa50af..e16ecfd5a2 100755 --- a/src/dotnet/Types/InputCallbackFunction.cs +++ b/src/dotnet/Types/InputCallbackFunction.cs @@ -36,7 +36,7 @@ using FreeSwitch.Marshaling; namespace FreeSwitch.Types { public delegate Status InputCallbackFunction( - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StreamHandleMarshaler))] + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoreSessionMarshaler))] CoreSession session, [MarshalAs(UnmanagedType.LPStr)] string input, diff --git a/src/dotnet/Types/LoadableModuleInterface.cs b/src/dotnet/Types/LoadableModuleInterface.cs index 8bb5bbc5fd..89cdb154a5 100755 --- a/src/dotnet/Types/LoadableModuleInterface.cs +++ b/src/dotnet/Types/LoadableModuleInterface.cs @@ -37,11 +37,7 @@ using FreeSwitch.Marshaling; namespace FreeSwitch.Types { - public delegate Status WriteFunction( - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StreamHandleMarshaler))] - StreamHandle streamHandle, - [MarshalAs(UnmanagedType.LPStr)] - string fmt); + //public delegate void ModuleLoad(); diff --git a/src/dotnet/Types/LogLevel.cs b/src/dotnet/Types/LogLevel.cs new file mode 100644 index 0000000000..9224adcb7b --- /dev/null +++ b/src/dotnet/Types/LogLevel.cs @@ -0,0 +1,51 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2006, James Martelletti + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * James Martelletti + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * James Martelletti + * + * + * LogLevel.cs -- + * + */ +using System; +using System.Collections; +using System.Text; +using System.Runtime.InteropServices; + +namespace FreeSwitch.Types +{ + public enum LogLevel + { + Console, + Debug, + Info, + Notice, + Warning, + Error, + Crit, + Alert, + Emerg + } +} \ No newline at end of file diff --git a/src/dotnet/Types/Module.cs b/src/dotnet/Types/Module.cs index a8cd2060dd..760244b046 100755 --- a/src/dotnet/Types/Module.cs +++ b/src/dotnet/Types/Module.cs @@ -49,11 +49,13 @@ namespace FreeSwitch.Types CoreSession session, [MarshalAs(UnmanagedType.LPStr)] string data); - + public delegate Status ApiFunction( [MarshalAs(UnmanagedType.LPStr)] - string command, + string input, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] + CoreSession session, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(StreamHandleMarshaler))] StreamHandle streamHandle); } diff --git a/src/dotnet/Types/SpeechHandle.cs b/src/dotnet/Types/SpeechHandle.cs new file mode 100644 index 0000000000..b4d64af6e8 --- /dev/null +++ b/src/dotnet/Types/SpeechHandle.cs @@ -0,0 +1,66 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2006, James Martelletti + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * James Martelletti + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * James Martelletti + * + * + * SpeechHandle.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.Marshaling; +using FreeSwitch.Marshaling.Types; + +namespace FreeSwitch.Types +{ + /* + internal IntPtr speech_interface; + internal UInt32 flags; + internal IntPtr name; + internal UInt32 rate; + internal UInt32 speed; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 80)] + internal byte[] voice; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 80)] + internal byte[] engine; + internal IntPtr memory_pool; + internal IntPtr private_info; + */ + public class SpeechHandle + { + internal HandleRef marshaledObject; + + public UInt32 flags + { + get + { + SpeechHandleMarshal speechHandleMarshal = (SpeechHandleMarshal)marshaledObject.Wrapper; + + return speechHandleMarshal.flags; + } + } + } +} diff --git a/src/dotnet/Types/StateHandlerTable.cs b/src/dotnet/Types/StateHandlerTable.cs new file mode 100644 index 0000000000..66c99aa4a0 --- /dev/null +++ b/src/dotnet/Types/StateHandlerTable.cs @@ -0,0 +1,44 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2006, James Martelletti + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * James Martelletti + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * James Martelletti + * + * + * StateHandlerTable.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.Marshaling; +using FreeSwitch.Marshaling.Types; + +namespace FreeSwitch.Types +{ + public class StateHandlerTable + { + internal HandleRef marshaledObject; + + } +} diff --git a/src/dotnet/Types/StreamHandle.cs b/src/dotnet/Types/StreamHandle.cs index 72306d607b..dacd11664a 100755 --- a/src/dotnet/Types/StreamHandle.cs +++ b/src/dotnet/Types/StreamHandle.cs @@ -30,20 +30,26 @@ * */ using System; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; +using FreeSwitch.Marshaling; using FreeSwitch.Marshaling.Types; namespace FreeSwitch.Types -{ +{ + public delegate Status StreamHandleWriteFunction( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(StreamHandleMarshaler))] + StreamHandle streamHandle, + [MarshalAs(UnmanagedType.LPStr)] + string fmt); + public class StreamHandle { internal HandleRef marshaledObject; - internal WriteFunction writeFunction; public void Write(string data) { StreamHandleMarshal streamHandleMarshal = (StreamHandleMarshal)marshaledObject.Wrapper; - WriteFunction writeFunction = (WriteFunction)Marshal.GetDelegateForFunctionPointer(streamHandleMarshal.write_function, typeof(WriteFunction)); + StreamHandleWriteFunction writeFunction = (StreamHandleWriteFunction)Marshal.GetDelegateForFunctionPointer(streamHandleMarshal.write_function, typeof(StreamHandleWriteFunction)); writeFunction(this, data); } diff --git a/src/dotnet/Types/Timer.cs b/src/dotnet/Types/Timer.cs new file mode 100644 index 0000000000..8e199e4b73 --- /dev/null +++ b/src/dotnet/Types/Timer.cs @@ -0,0 +1,44 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2006, James Martelletti + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * James Martelletti + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * James Martelletti + * + * + * Timer.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.Marshaling; +using FreeSwitch.Marshaling.Types; + +namespace FreeSwitch.Types +{ + public class Timer + { + internal HandleRef marshaledObject; + + } +}