diff --git a/src/dotnet/dotnet/Common.cs b/src/dotnet/dotnet/Common.cs new file mode 100755 index 0000000000..aa3849ea66 --- /dev/null +++ b/src/dotnet/dotnet/Common.cs @@ -0,0 +1,75 @@ +/* + * 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 + * + * + * Common.cs -- + * + */ +using System; +using System.Reflection; + +namespace FreeSwitch.NET +{ + public class Common + { + public static void DumpHex(string label, IntPtr pointer, int length) + { + Console.WriteLine("DUMP-{0}:", label); + + DumpHex(pointer, length); + } + + public static void DumpProperties(string label, object dumpObject) + { + Type type = dumpObject.GetType(); + PropertyInfo[] properties = type.GetProperties(); + + foreach (PropertyInfo p in properties) + { + Console.WriteLine("%%% - {0}: {1}:{2}", label, p.Name, p.GetValue(dumpObject, null)); + } + } + + public static void DumpHex(IntPtr pointer, int length) + { + if (pointer == IntPtr.Zero) + throw new NullReferenceException(); + + for (int i = 0; i < length; i++) + { + IntPtr offset = new IntPtr(pointer.ToInt32() + i); + + if (i % 20 == 0) + Console.Write("\n0x{0:x}: ", offset.ToInt32()); + + Console.Write("{0:x2} ", System.Runtime.InteropServices.Marshal.ReadByte(offset)); + } + + Console.WriteLine("\n"); + } + } +} diff --git a/src/dotnet/dotnet/FreeSwitch.NET.csproj b/src/dotnet/dotnet/FreeSwitch.NET.csproj new file mode 100755 index 0000000000..872a79a498 --- /dev/null +++ b/src/dotnet/dotnet/FreeSwitch.NET.csproj @@ -0,0 +1,126 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {251CAABC-16C3-4593-A491-603B908094E0} + Library + Properties + FreeSwitch.NET + Freeswitch + + + true + public.snk + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/dotnet/dotnet/Makefile b/src/dotnet/dotnet/Makefile new file mode 100644 index 0000000000..07b0b92c6b --- /dev/null +++ b/src/dotnet/dotnet/Makefile @@ -0,0 +1,78 @@ +all: $(MODNAME).so + +$(MODNAME).so: + gmcs -debug -unsafe -t:library -keyfile:public.snk \ + -out:Freeswitch.dll -reference:Mono.Posix.dll \ + Properties/AssemblyInfo.cs \ + Marshaling/Types/ApiInterfaceMarshal.cs \ + Marshaling/Types/ApplicationInterfaceMarshal.cs \ + Marshaling/Types/BufferMarshal.cs \ + Marshaling/Types/CallerExtensionMarshal.cs \ + Marshaling/Types/CallerProfileMarshal.cs \ + Marshaling/Types/ChannelFlagMarshal.cs \ + Marshaling/Types/ChannelMarshal.cs \ + Marshaling/Types/ChannelStateMarshal.cs \ + Marshaling/Types/ChannelTimetableMarshal.cs \ + Marshaling/Types/CodecImplementationMarshal.cs \ + Marshaling/Types/CodecInterfaceMarshal.cs \ + Marshaling/Types/CodecMarshal.cs \ + Marshaling/Types/CodecTypeMarshal.cs \ + Marshaling/Types/CoreSessionMarshal.cs \ + Marshaling/Types/EventMarshal.cs \ + Marshaling/Types/FileHandleMarshal.cs \ + Marshaling/Types/FrameMarshal.cs \ + Marshaling/Types/IOEventHooksMarshal.cs \ + Marshaling/Types/LoadableModuleInterfaceMarshal.cs \ + Marshaling/Types/LoadableModuleMarshal.cs \ + Marshaling/Types/TypesMarshal.cs \ + Marshaling/BufferMarshaler.cs \ + Marshaling/CallerExtensionMarshaler.cs \ + Marshaling/CallerProfileMarshaler.cs \ + Marshaling/ChannelMarshaler.cs \ + Marshaling/ChannelTimetableMarshaler.cs \ + Marshaling/CoreSessionMarshaler.cs \ + Marshaling/EventMarshaler.cs \ + Marshaling/FileHandleMarshaler.cs \ + Marshaling/MemoryPoolMarshaler.cs \ + Marshaling/StreamHandleMarshaler.cs \ + Modules/Api.cs \ + Modules/Application.cs \ + Switch/CallerProfile.cs \ + Switch/Channel.cs \ + Switch/Console.cs \ + Switch/CoreSession.cs \ + Switch/Ivr.cs \ + Switch/LoadableModule.cs \ + Switch/StreamHandle.cs \ + Types/ApiFunction.cs \ + Types/ApplicationFunction.cs \ + Types/ApplicationInterface.cs \ + Types/Buffer.cs \ + Types/CallCause.cs \ + Types/CallerExtension.cs \ + Types/CallerProfile.cs \ + Types/Channel.cs \ + Types/ChannelFlag.cs \ + Types/ChannelState.cs \ + Types/ChannelTimetable.cs \ + Types/CoreSession.cs \ + Types/DtmfCallbackFunction.cs \ + Types/Event.cs \ + Types/FileHandle.cs \ + Types/LoadableModule.cs \ + Types/LoadableModuleInterface.cs \ + Types/MemoryPool.cs \ + Types/Module.cs \ + Types/Status.cs \ + Types/StreamHandle.cs \ + Types/TextChannel.cs \ + Common.cs \ + Core.cs \ + Ivr.cs \ + Module.cs \ + +clean: + rm -fr *.dll + +install: + cp -f Freeswitch.dll /usr/local/freeswitch/lib/ diff --git a/src/dotnet/dotnet/Marshaling/BufferMarshaler.cs b/src/dotnet/dotnet/Marshaling/BufferMarshaler.cs new file mode 100755 index 0000000000..4cde49d9f9 --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/BufferMarshaler.cs @@ -0,0 +1,80 @@ +/* + * 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 + * + * + * BufferMarshaler.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Marshaling.Types; +using FreeSwitch.NET.Types; + +namespace FreeSwitch.NET.Marshaling +{ + class BufferMarshaler : ICustomMarshaler + { + private static BufferMarshaler Instance = new BufferMarshaler(); + + 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) + { + FreeSwitch.NET.Types.Buffer buffer = (FreeSwitch.NET.Types.Buffer)obj; + + return buffer.marshaledObject.Handle; + } + + public object MarshalNativeToManaged(IntPtr bufferPtr) + { + FreeSwitch.NET.Types.Buffer buffer = new FreeSwitch.NET.Types.Buffer(); + BufferMarshal bufferMarshal = new BufferMarshal(); + + Marshal.PtrToStructure(bufferPtr, bufferMarshal); + + buffer.marshaledObject = new HandleRef(bufferMarshal, bufferPtr); + + return buffer; + } + } +} diff --git a/src/dotnet/dotnet/Marshaling/CallerExtensionMarshaler.cs b/src/dotnet/dotnet/Marshaling/CallerExtensionMarshaler.cs new file mode 100755 index 0000000000..e3d9c28dad --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/CallerExtensionMarshaler.cs @@ -0,0 +1,80 @@ +/* + * 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 + * + * + * CallerExtensionMarshaler.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; +using FreeSwitch.NET.Marshaling.Types; + +namespace FreeSwitch.NET.Marshaling +{ + class CallerExtensionMarshaler : ICustomMarshaler + { + private static CallerExtensionMarshaler Instance = new CallerExtensionMarshaler(); + + 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) + { + CallerExtension callerExtension = (CallerExtension)obj; + + return callerExtension.marshaledObject.Handle; + } + + public object MarshalNativeToManaged(IntPtr callerExtensionPtr) + { + CallerExtensionMarshal callerExtensionMarshal = new CallerExtensionMarshal(); + CallerExtension callerExtension = new CallerExtension(); + + Marshal.PtrToStructure(callerExtensionPtr, callerExtensionMarshal); + + callerExtension.marshaledObject = new HandleRef(callerExtensionMarshal, callerExtensionPtr); + + return callerExtension; + } + } +} diff --git a/src/dotnet/dotnet/Marshaling/CallerProfileMarshaler.cs b/src/dotnet/dotnet/Marshaling/CallerProfileMarshaler.cs new file mode 100755 index 0000000000..a8eadedca2 --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/CallerProfileMarshaler.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 + * + * + * CallerProfileMarshaler.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; +using FreeSwitch.NET.Marshaling.Types; + +namespace FreeSwitch.NET.Marshaling +{ + class CallerProfileMarshaler : ICustomMarshaler + { + + private static CallerProfileMarshaler Instance = new CallerProfileMarshaler(); + + 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) + { + CallerProfile callerProfile = (CallerProfile) obj; + + return callerProfile.marshaledObject.Handle; + } + + public object MarshalNativeToManaged(IntPtr callerProfilePtr) + { + CallerProfileMarshal callerProfileMarshal = new CallerProfileMarshal(); + CallerProfile callerProfile = new CallerProfile(); + + Marshal.PtrToStructure(callerProfilePtr, callerProfileMarshal); + + callerProfile.marshaledObject = new HandleRef(callerProfileMarshal, callerProfilePtr); + + return callerProfile; + } + } +} diff --git a/src/dotnet/dotnet/Marshaling/ChannelMarshaler.cs b/src/dotnet/dotnet/Marshaling/ChannelMarshaler.cs new file mode 100755 index 0000000000..f72e59ef26 --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/ChannelMarshaler.cs @@ -0,0 +1,80 @@ +/* + * 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 + * + * + * ChannelMarshaler.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; +using FreeSwitch.NET.Marshaling.Types; + +namespace FreeSwitch.NET.Marshaling +{ + class ChannelMarshaler : ICustomMarshaler + { + private static ChannelMarshaler Instance = new ChannelMarshaler(); + + 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) + { + Channel channel = (Channel) obj; + + return channel.marshaledObject.Handle; + } + + public object MarshalNativeToManaged(IntPtr ptr) + { + ChannelMarshal channelMarshal = new ChannelMarshal(); + Channel channel = new Channel(); + + Marshal.PtrToStructure(ptr, channelMarshal); + + channel.marshaledObject = new HandleRef(channelMarshal, ptr); + + return channel; + } + } +} diff --git a/src/dotnet/dotnet/Marshaling/ChannelTimetableMarshaler.cs b/src/dotnet/dotnet/Marshaling/ChannelTimetableMarshaler.cs new file mode 100755 index 0000000000..a05456d05e --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/ChannelTimetableMarshaler.cs @@ -0,0 +1,80 @@ +/* + * 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 + * + * + * ChannelTimetableMarshaler.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; +using FreeSwitch.NET.Marshaling.Types; + +namespace FreeSwitch.NET.Marshaling +{ + class ChannelTimetableMarshaler : ICustomMarshaler + { + private static ChannelTimetableMarshaler Instance = new ChannelTimetableMarshaler(); + + 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) + { + ChannelTimetable channelTimetable = (ChannelTimetable)obj; + + return channelTimetable.marshaledObject.Handle; + } + + public object MarshalNativeToManaged(IntPtr channelTimetablePtr) + { + ChannelTimetableMarshal channelTimetableMarshal = new ChannelTimetableMarshal(); + ChannelTimetable channelTimetable = new ChannelTimetable(); + + Marshal.PtrToStructure(channelTimetablePtr, channelTimetableMarshal); + + channelTimetable.marshaledObject = new HandleRef(channelTimetableMarshal, channelTimetablePtr); + + return channelTimetable; + } + } +} diff --git a/src/dotnet/dotnet/Marshaling/CoreSessionMarshaler.cs b/src/dotnet/dotnet/Marshaling/CoreSessionMarshaler.cs new file mode 100755 index 0000000000..29e1fd8dae --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/CoreSessionMarshaler.cs @@ -0,0 +1,80 @@ +/* + * 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 + * + * + * CoreSessionMarshaler.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; +using FreeSwitch.NET.Marshaling.Types; + +namespace FreeSwitch.NET.Marshaling +{ + class CoreSessionMarshaler : ICustomMarshaler + { + private static CoreSessionMarshaler Instance = new CoreSessionMarshaler(); + + 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) + { + CoreSession coreSession = (CoreSession)obj; + + return coreSession.marshaledObject.Handle; + } + + public object MarshalNativeToManaged(IntPtr coreSessionPtr) + { + CoreSessionMarshal coreSessionMarshal = new CoreSessionMarshal(); + CoreSession coreSession = new CoreSession(); + + Marshal.PtrToStructure(coreSessionPtr, coreSessionMarshal); + + coreSession.marshaledObject = new HandleRef(coreSessionMarshal, coreSessionPtr); + + return coreSession; + } + } +} diff --git a/src/dotnet/dotnet/Marshaling/EventMarshaler.cs b/src/dotnet/dotnet/Marshaling/EventMarshaler.cs new file mode 100755 index 0000000000..c23f7a56d3 --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/EventMarshaler.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 + * + * + * EventMarshaler.cs -- + * + */ +using System; +using System.Collections; +using FreeSwitch.NET.Marshaling.Types; +using FreeSwitch.NET.Types; +using System.Runtime.InteropServices; + +namespace FreeSwitch.NET.Marshaling +{ + class EventMarshaler : ICustomMarshaler + { + private static EventMarshaler Instance = new EventMarshaler(); + + 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) + { + Event eventObj = (Event)obj; + + return eventObj.marshaledObject.Handle; + } + + public object MarshalNativeToManaged(IntPtr eventPtr) + { + EventMarshal eventMarshal = new EventMarshal(); + Event eventObj = new Event(); + + Marshal.PtrToStructure(eventPtr, eventMarshal); + + eventObj.marshaledObject = new HandleRef(eventMarshal, eventPtr); + + return eventObj; + } + } +} diff --git a/src/dotnet/dotnet/Marshaling/FileHandleMarshaler.cs b/src/dotnet/dotnet/Marshaling/FileHandleMarshaler.cs new file mode 100755 index 0000000000..1c432aa7ce --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/FileHandleMarshaler.cs @@ -0,0 +1,78 @@ +/* + * 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 + * + * + * FileHandleMarshaler.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; +using FreeSwitch.NET.Marshaling.Types; + +namespace FreeSwitch.NET.Marshaling +{ + class FileHandleMarshaler : ICustomMarshaler + { + private static FileHandleMarshaler Instance = new FileHandleMarshaler(); + + 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) + { + FileHandle fileHandle = (FileHandle)obj; + + return fileHandle.marshaledObject.Handle; + } + + public object MarshalNativeToManaged(IntPtr file_handle) + { + FileHandleMarshal fileHandleMarshal = new FileHandleMarshal(); + FileHandle fileHandle = new FileHandle(); + + fileHandle.marshaledObject = new HandleRef(fileHandleMarshal, file_handle); + + return fileHandle; + } + } +} diff --git a/src/dotnet/dotnet/Marshaling/MemoryPoolMarshaler.cs b/src/dotnet/dotnet/Marshaling/MemoryPoolMarshaler.cs new file mode 100755 index 0000000000..c71e72d036 --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/MemoryPoolMarshaler.cs @@ -0,0 +1,77 @@ +/* + * 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 + * + * + * MemoryPoolMarshaler.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; +using FreeSwitch.NET.Marshaling.Types; + +namespace FreeSwitch.NET.Marshaling +{ + class MemoryPoolMarshaler : ICustomMarshaler + { + private static MemoryPoolMarshaler Instance = new MemoryPoolMarshaler(); + + 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) + { + MemoryPool memoryPool = (MemoryPool) obj; + + return memoryPool.marshaledObject.Handle; + } + + public object MarshalNativeToManaged(IntPtr pool) + { + MemoryPool memoryPool = new MemoryPool(); + + memoryPool.marshaledObject = new HandleRef(new IntPtr(), pool); + + return memoryPool; + } + } +} diff --git a/src/dotnet/dotnet/Marshaling/StreamHandleMarshaler.cs b/src/dotnet/dotnet/Marshaling/StreamHandleMarshaler.cs new file mode 100755 index 0000000000..cd44856315 --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/StreamHandleMarshaler.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 + * + * + * StreamHandleMarshaler.cs -- + * + */ +using System; +using System.Collections; +using FreeSwitch.NET.Marshaling.Types; +using FreeSwitch.NET.Types; +using System.Runtime.InteropServices; + +namespace FreeSwitch.NET.Marshaling +{ + class StreamHandleMarshaler : ICustomMarshaler + { + private static StreamHandleMarshaler Instance = new StreamHandleMarshaler(); + + 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) + { + StreamHandle streamHandleObj = (StreamHandle)obj; + + return streamHandleObj.marshaledObject.Handle; + } + + public object MarshalNativeToManaged(IntPtr streamHandlePtr) + { + StreamHandleMarshal streamHandleMarshal = new StreamHandleMarshal(); + StreamHandle streamHandleObj = new StreamHandle(); + + Marshal.PtrToStructure(streamHandlePtr, streamHandleMarshal); + + streamHandleObj.marshaledObject = new HandleRef(streamHandleMarshal, streamHandlePtr); + + return streamHandleObj; + } + } +} diff --git a/src/dotnet/dotnet/Marshaling/Types/ApiInterfaceMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/ApiInterfaceMarshal.cs new file mode 100755 index 0000000000..33bad12fe5 --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/ApiInterfaceMarshal.cs @@ -0,0 +1,48 @@ +/* + * 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 + * + * + * ApiInterfaceMarshal.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; + +namespace FreeSwitch.NET.Marshaling.Types +{ + [StructLayout(LayoutKind.Sequential)] + internal class ApiInterfaceMarshal + { + //[MarshalAs(UnmanagedType.LPStr)] + internal IntPtr interface_name; + //[MarshalAs(UnmanagedType.LPStr)] + internal IntPtr desc; + internal ApiFunction function; + internal IntPtr next; + } +} diff --git a/src/dotnet/dotnet/Marshaling/Types/ApplicationInterfaceMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/ApplicationInterfaceMarshal.cs new file mode 100755 index 0000000000..4c09cc3acf --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/ApplicationInterfaceMarshal.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 + * + * + * ApplicationInterfaceMarshal.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; + +namespace FreeSwitch.NET.Marshaling.Types +{ + [StructLayout(LayoutKind.Sequential)] + internal class ApplicationInterfaceMarshal + { + // [MarshalAs(UnmanagedType.LPStr)] + internal IntPtr interface_name; + internal ApplicationFunction application_function; + // [MarshalAs(UnmanagedType.LPStr)] + internal IntPtr long_desc; + //[MarshalAs(UnmanagedType.LPStr)] + internal IntPtr short_desc; + //[MarshalAs(UnmanagedType.LPStr)] + internal IntPtr syntax; + internal IntPtr next; + } +} \ No newline at end of file diff --git a/src/dotnet/dotnet/Marshaling/Types/BufferMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/BufferMarshal.cs new file mode 100755 index 0000000000..4b91216b08 --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/BufferMarshal.cs @@ -0,0 +1,46 @@ +/* + * 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 + * + * + * BufferMarshal.cs -- + * + */ +using System; +using System.Runtime.InteropServices; + +namespace FreeSwitch.NET.Marshaling.Types +{ + [StructLayout(LayoutKind.Sequential)] + internal class BufferMarshal + { + [MarshalAs(UnmanagedType.LPStr)] + internal string data; + internal int used; + internal int datalen; + internal UInt32 id; + } +} diff --git a/src/dotnet/dotnet/Marshaling/Types/CallerExtensionMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/CallerExtensionMarshal.cs new file mode 100755 index 0000000000..1d1fb6fc1e --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/CallerExtensionMarshal.cs @@ -0,0 +1,46 @@ +/* + * 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 + * + * + * CallerExtensionMarshal.cs -- + * + */ +using System; +using System.Runtime.InteropServices; + +namespace FreeSwitch.NET.Marshaling.Types +{ + [StructLayout(LayoutKind.Sequential)] + internal class CallerExtensionMarshal + { + internal IntPtr extension_name; + internal IntPtr extension_number; + internal IntPtr current_application; + internal IntPtr last_application; + internal IntPtr applications; + } +} diff --git a/src/dotnet/dotnet/Marshaling/Types/CallerProfileMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/CallerProfileMarshal.cs new file mode 100755 index 0000000000..829c2cffc7 --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/CallerProfileMarshal.cs @@ -0,0 +1,68 @@ +/* + * 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 + * + * + * CallerProfileMarshal.cs -- + * + */ +using System; +using System.Runtime.InteropServices; + +namespace FreeSwitch.NET.Marshaling.Types +{ + [StructLayout(LayoutKind.Sequential)] + internal class CallerProfileMarshal + { + [MarshalAs(UnmanagedType.LPStr)] + internal string username; + [MarshalAs(UnmanagedType.LPStr)] + internal string dialplan; + [MarshalAs(UnmanagedType.LPStr)] + internal string caller_id_name; + [MarshalAs(UnmanagedType.LPStr)] + internal string caller_id_number; + [MarshalAs(UnmanagedType.LPStr)] + internal string network_addr; + [MarshalAs(UnmanagedType.LPStr)] + internal string ani; + [MarshalAs(UnmanagedType.LPStr)] + internal string ani2; + [MarshalAs(UnmanagedType.LPStr)] + internal string rdnis; + [MarshalAs(UnmanagedType.LPStr)] + internal string destination_number; + [MarshalAs(UnmanagedType.LPStr)] + internal string source; + [MarshalAs(UnmanagedType.LPStr)] + internal string chan_name; + [MarshalAs(UnmanagedType.LPStr)] + internal string uuid; + [MarshalAs(UnmanagedType.LPStr)] + internal string context; + internal IntPtr next; + } +} diff --git a/src/dotnet/dotnet/Marshaling/Types/ChannelFlagMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/ChannelFlagMarshal.cs new file mode 100755 index 0000000000..eeb6c79b8b --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/ChannelFlagMarshal.cs @@ -0,0 +1,46 @@ +/* + * 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 + * + * + * ChannelFlagMarshal.cs -- + * + */ +using System; + +namespace FreeSwitch.NET.Marshaling.Types +{ + internal enum ChannelFlagMarshal + { + CF_SEND_AUDIO, + CF_RECV_AUDIO, + CF_ANSWERED, + CF_OUTBOUND, + CF_EARLY_MEDIA, + CF_ORIGINATOR, + CF_TRANSFER + } +} diff --git a/src/dotnet/dotnet/Marshaling/Types/ChannelMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/ChannelMarshal.cs new file mode 100755 index 0000000000..43d7db61d9 --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/ChannelMarshal.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 + * + * + * ChannelMarshal.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; + +namespace FreeSwitch.NET.Marshaling.Types +{ + [StructLayout(LayoutKind.Sequential)] + internal class ChannelMarshal + { + internal IntPtr name; + internal IntPtr dtmf_buffer; + internal IntPtr dtmf_mutex; + internal IntPtr flag_mutex; + internal IntPtr profile_mutex; + internal IntPtr session; + internal ChannelState state; + internal UInt32 flags; + internal IntPtr caller_profile; + internal IntPtr originator_caller_profile; + internal IntPtr originatee_caller_profile; + internal IntPtr caller_extension; + [MarshalAs(UnmanagedType.ByValArray, SizeConst=120)] + internal byte[] state_handlers; + internal int state_handler_index; + internal IntPtr variables; + internal IntPtr times; + internal IntPtr private_info; + internal IntPtr hangup_cause; + internal int freq; + internal int bits; + internal int channels; + internal int ms; + internal int kbps; + } +} diff --git a/src/dotnet/dotnet/Marshaling/Types/ChannelStateMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/ChannelStateMarshal.cs new file mode 100755 index 0000000000..543f16cd5d --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/ChannelStateMarshal.cs @@ -0,0 +1,47 @@ +/* + * 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 + * + * + * ChannelStateMarshal.cs -- + * + */ +using System; + +namespace FreeSwitch.NET.Marshaling.Types +{ + internal enum ChannelStateMarshal + { + CS_NEW, + CS_INIT, + CS_RING, + CS_TRANSMIT, + CS_EXECUTE, + CS_LOOPBACK, + CS_HANGUP, + CS_DONE + } +} diff --git a/src/dotnet/dotnet/Marshaling/Types/ChannelTimetableMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/ChannelTimetableMarshal.cs new file mode 100755 index 0000000000..088c7d75a8 --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/ChannelTimetableMarshal.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 + * + * + * ChannelTimetableMarshal.cs -- + * + */ +using System; +using System.Runtime.InteropServices; + +namespace FreeSwitch.NET.Marshaling.Types +{ + [StructLayout(LayoutKind.Sequential)] + internal class ChannelTimetableMarshal + { + internal Int64 created; + internal Int64 answered; + internal Int64 hungup; + } +} diff --git a/src/dotnet/dotnet/Marshaling/Types/CodecImplementationMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/CodecImplementationMarshal.cs new file mode 100755 index 0000000000..f8cce868e3 --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/CodecImplementationMarshal.cs @@ -0,0 +1,54 @@ +/* + * 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 + * + * + * CodecImplementationMarshal.cs -- + * + */ +using System; +using FreeSwitch.NET.Types; + +namespace FreeSwitch.NET.Marshaling.Types +{ + internal class CodecImplementationMarshal + { + internal UInt32 samples_per_seconds; + internal int bits_per_second; + internal int microseconds_per_frame; + internal UInt32 samples_per_frame; + internal UInt32 bytes_per_frame; + internal UInt32 encoded_bytes_per_frame; + internal Byte number_of_channels; + internal int pref_frames_per_packet; + internal int max_frames_per_packet; + //internal CodecInitMarshal init; + //internal CodecEncodeMarshal encode; + //internal CodecDecode decode; + //internal CodecDestroy destroy; + internal IntPtr next; + } +} diff --git a/src/dotnet/dotnet/Marshaling/Types/CodecInterfaceMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/CodecInterfaceMarshal.cs new file mode 100755 index 0000000000..9494c4ddfe --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/CodecInterfaceMarshal.cs @@ -0,0 +1,63 @@ +/* + * 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 + * + * + * CodecInterfaceMarshal.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; + +namespace FreeSwitch.NET.Marshaling.Types +{ + [StructLayout(LayoutKind.Sequential)] + internal class CodecInterfaceMarshal + { + [MarshalAs(UnmanagedType.LPStr)] + internal string interface_name; + /* + internal CodecImplementation application_function; + [MarshalAs(UnmanagedType.LPStr)] + internal string long_desc; + [MarshalAs(UnmanagedType.LPStr)] + internal string short_desc; + [MarshalAs(UnmanagedType.LPStr)] + internal string syntax; + internal IntPtr next; +} + + +struct switch_codec_interface { + ! the name of the interface + const char *interface_name; + ! a list of codec implementations related to the codec + const switch_codec_implementation_t *implementations; + const struct switch_codec_interface *next; +};*/ + } +} \ No newline at end of file diff --git a/src/dotnet/dotnet/Marshaling/Types/CodecMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/CodecMarshal.cs new file mode 100755 index 0000000000..9c1e62a402 --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/CodecMarshal.cs @@ -0,0 +1,46 @@ +/* + * 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 + * + * + * CodecMarshal.cs -- + * + */ +using System; +using System.Text; + +namespace FreeSwitch.NET.Marshaling.Types +{ + internal class CodecMarshal + { + internal IntPtr codec_interface; + internal IntPtr implementation; + //internal CodecSettingsMarshal codec_settings; + internal UInt32 flags; + //internal MemoryPoolMarshal memory_pool; + internal IntPtr private_info; + } +} diff --git a/src/dotnet/dotnet/Marshaling/Types/CodecTypeMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/CodecTypeMarshal.cs new file mode 100755 index 0000000000..e8df17012e --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/CodecTypeMarshal.cs @@ -0,0 +1,43 @@ +/* + * 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 + * + * + * CodecTypeMarshal.cs -- + * + */ +using System; + +namespace FreeSwitch.NET.Marshaling.Types +{ + internal enum CodecTypesMarshal + { + SWITCH_CODEC_TYPE_AUDIO, + SWITCH_CODEC_TYPE_VIDEO, + SWITCH_CODEC_TYPE_T38, + SWITCH_CODEC_TYPE_APP + } +} diff --git a/src/dotnet/dotnet/Marshaling/Types/CoreSessionMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/CoreSessionMarshal.cs new file mode 100755 index 0000000000..0011c801a1 --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/CoreSessionMarshal.cs @@ -0,0 +1,80 @@ +/* + * 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 + * + * + * CoreSessionMarshal.cs -- + * + */ +using System; +using System.Text; +using System.Runtime.InteropServices; + +namespace FreeSwitch.NET.Marshaling.Types +{ + [StructLayout(LayoutKind.Sequential, Pack=1)] + internal class CoreSessionMarshal + { + internal UInt32 id; + [MarshalAs(UnmanagedType.ByValArray, SizeConst=80)] + internal byte[] name; + internal int thread_running; + internal IntPtr pool; + internal IntPtr channel; + internal IntPtr thread; + internal IntPtr endpoint_interface; + internal IOEventHooksMarshal event_hooks; + internal IntPtr read_codec; + internal IntPtr write_codec; + internal IntPtr raw_write_buffer; + internal FrameMarshal raw_write_frame; + internal FrameMarshal enc_write_frame; + [MarshalAs(UnmanagedType.ByValArray, SizeConst=2048)] + internal byte[] raw_write_buf; + [MarshalAs(UnmanagedType.ByValArray, SizeConst=2048)] + internal byte[] enc_write_buf; + internal IntPtr raw_read_buffer; + internal FrameMarshal raw_read_frame; + internal FrameMarshal enc_read_frame; + [MarshalAs(UnmanagedType.ByValArray, SizeConst=2048)] + internal byte[] raw_read_buf; + [MarshalAs(UnmanagedType.ByValArray, SizeConst=2048)] + internal byte[] enc_read_buf; + internal IntPtr read_resampler; + internal IntPtr write_resampler; + internal IntPtr mutex; + internal IntPtr cond; + internal IntPtr rwlock; + [MarshalAs(UnmanagedType.ByValArray, SizeConst=128)] + internal IntPtr[] streams; + internal int stream_count; + /* 36 + 1 char string, but need to grab 40 bytes */ + [MarshalAs(UnmanagedType.ByValArray, SizeConst=40)] + internal byte[] uuid_str; + internal IntPtr private_info; + internal IntPtr event_queue; + } +} diff --git a/src/dotnet/dotnet/Marshaling/Types/EventMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/EventMarshal.cs new file mode 100755 index 0000000000..e8d8b1db40 --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/EventMarshal.cs @@ -0,0 +1,59 @@ +/* + * 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 + * + * + * EventMarshal.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; + +namespace FreeSwitch.NET.Marshaling.Types +{ + [StructLayout(LayoutKind.Sequential)] + internal class EventMarshal + { + internal EventType event_id; + internal Priority priority; + internal IntPtr owner; + internal IntPtr subclass; + internal IntPtr headers; + internal IntPtr body; + internal IntPtr bind_user_data; + internal IntPtr event_user_data; + internal IntPtr next; + } + + [StructLayout(LayoutKind.Sequential)] + internal class EventHeaderMarshal + { + internal string name; + internal string value; + internal IntPtr next; + } +} diff --git a/src/dotnet/dotnet/Marshaling/Types/FileHandleMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/FileHandleMarshal.cs new file mode 100755 index 0000000000..2a0e5a78de --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/FileHandleMarshal.cs @@ -0,0 +1,57 @@ +/* + * 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 + * + * + * FileHandleMarshal.cs -- + * + */ +using System; +using System.Runtime.InteropServices; + +namespace FreeSwitch.NET.Marshaling.Types +{ + [StructLayout(LayoutKind.Sequential)] + internal class FileHandleMarshal + { + internal IntPtr file_interface; + internal UInt32 flags; + internal IntPtr fd; + internal uint samples; + internal UInt32 samplerate; + internal Byte channels; + internal uint format; + internal uint sections; + internal int seekable; + internal uint sample_count; + internal int speed; + internal IntPtr memory_pool; + internal IntPtr private_info; + internal Int64 pos; + internal IntPtr audio_buffer; + } + +} diff --git a/src/dotnet/dotnet/Marshaling/Types/FrameMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/FrameMarshal.cs new file mode 100755 index 0000000000..37cd6696a1 --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/FrameMarshal.cs @@ -0,0 +1,54 @@ +/* + * 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 + * + * + * FrameMarshal.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; + +namespace FreeSwitch.NET.Marshaling.Types +{ + [StructLayout(LayoutKind.Sequential)] + internal class FrameMarshal + { + internal IntPtr codec; + internal IntPtr source; + internal IntPtr packet; + internal UInt32 packetlen; + internal IntPtr data; + internal UInt32 datalen; + internal UInt32 buflen; + internal UInt32 samples; + internal UInt32 rate; + internal byte payload; + internal UInt32 timestamp; + internal byte flags; + } +} diff --git a/src/dotnet/dotnet/Marshaling/Types/IOEventHooksMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/IOEventHooksMarshal.cs new file mode 100755 index 0000000000..8e23640c51 --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/IOEventHooksMarshal.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 + * + * + * IOEventHooksMarshal.cs -- + * + */ +using System; +using System.Runtime.InteropServices; + +namespace FreeSwitch.NET.Marshaling.Types +{ + [StructLayout(LayoutKind.Sequential)] + internal class IOEventHooksMarshal + { + internal IntPtr outgoing_channel; + internal IntPtr answer_channel; + internal IntPtr receive_message; + internal IntPtr receive_event; + internal IntPtr read_frame; + internal IntPtr write_frame; + internal IntPtr kill_channel; + internal IntPtr waitfor_read; + internal IntPtr waitfor_write; + internal IntPtr send_dtmf; + } +} diff --git a/src/dotnet/dotnet/Marshaling/Types/LoadableModuleInterfaceMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/LoadableModuleInterfaceMarshal.cs new file mode 100755 index 0000000000..4a3949f9cd --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/LoadableModuleInterfaceMarshal.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 + * + * + * LoadableModuleInterfaceMarshal.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; + +namespace FreeSwitch.NET.Marshaling.Types +{ + [StructLayout(LayoutKind.Sequential)] + internal class LoadableModuleInterfaceMarshal + { + internal IntPtr module_name; + internal IntPtr endpoint_interface; + internal IntPtr timer_interface; + internal IntPtr dialplan_interface; + internal IntPtr codec_interface; + internal IntPtr application_interface; + internal IntPtr api_interface; + internal IntPtr file_interface; + internal IntPtr speech_interface; + internal IntPtr directory_interface; + } +} diff --git a/src/dotnet/dotnet/Marshaling/Types/LoadableModuleMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/LoadableModuleMarshal.cs new file mode 100755 index 0000000000..14e848fb1d --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/LoadableModuleMarshal.cs @@ -0,0 +1,54 @@ +/* + * 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 + * + * + * LoadableModuleMarshal.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; + +namespace FreeSwitch.NET.Marshaling.Types +{ + + + [StructLayout(LayoutKind.Sequential)] + public class LoadableModuleMarshal + { + public IntPtr filename; + public IntPtr module_interface; + public IntPtr lib; + public ModuleLoad module_load; + public ModuleReload module_reload; + public ModulePause module_pause; + public ModuleResume module_resume; + public ModuleStatus module_status; + public ModuleRuntime module_runtime; + public ModuleShutdown module_shutdown; + } +} diff --git a/src/dotnet/dotnet/Marshaling/Types/StreamHandleMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/StreamHandleMarshal.cs new file mode 100755 index 0000000000..29f73e17e1 --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/StreamHandleMarshal.cs @@ -0,0 +1,48 @@ +/* + * 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 + * + * + * StreamHandleMarshal.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; + +namespace FreeSwitch.NET.Marshaling.Types +{ + [StructLayout(LayoutKind.Sequential)] + internal class StreamHandleMarshal + { + internal IntPtr write_function; + internal IntPtr data; + internal IntPtr end; + internal int data_size; + internal int data_len; + internal IntPtr _event; + } +} diff --git a/src/dotnet/dotnet/Marshaling/Types/TypesMarshal.cs b/src/dotnet/dotnet/Marshaling/Types/TypesMarshal.cs new file mode 100755 index 0000000000..8aadcbcd5f --- /dev/null +++ b/src/dotnet/dotnet/Marshaling/Types/TypesMarshal.cs @@ -0,0 +1,45 @@ +/* + * 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 + * + * + * TypesMarshal.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; + +namespace FreeSwitch.NET.Marshaling.Types +{ + public delegate + Status DtmfCallbackFunctionMarshal( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoreSessionMarshaler))] + CoreSession session, + string dtmf, + IntPtr buf, + uint buflen); +} diff --git a/src/dotnet/dotnet/Module.cs b/src/dotnet/dotnet/Module.cs new file mode 100644 index 0000000000..c195c7e279 --- /dev/null +++ b/src/dotnet/dotnet/Module.cs @@ -0,0 +1,205 @@ +/* + * 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 + * + * + * Module.cs -- + * + */ +using System; +using System.Collections; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Text; +using FreeSwitch.NET; +using FreeSwitch.NET.Types; +using FreeSwitch.NET.Modules; +using FreeSwitch.NET.Marshaling.Types; + +namespace FreeSwitch.NET +{ + /// + /// Base class for all Freeswitch.NET modules + /// + /// + /// public class Example : Module + /// { + /// public Example() + /// { + /// AddApiInterface(new ExampleApi()); + /// AddApplicationInterface(new ExampleApplication()); + /// + /// Register(); + /// } + /// } + /// + public class Module + { + private LoadableModuleInterfaceMarshal module_interface = new LoadableModuleInterfaceMarshal(); + private LoadableModuleMarshal module = new LoadableModuleMarshal(); + + private ArrayList applicationInterfaces = new ArrayList(); + private ArrayList apiInterfaces = new ArrayList(); + + private ModuleLoad load; + private string name; + private string filename = Assembly.GetCallingAssembly().GetName().Name; + + /// + /// Module constructor + /// + public Module() + { + Console.WriteLine("*** Creating new module object"); + + load = new ModuleLoad(Load); + } + + /// + /// Implementation of ModuleLoad Delegate + /// + /// + /// + /// + public Status Load(ref IntPtr module, string name) + { + /* Allocate some unmanaged mem for the ModuleInterface */ + module = Marshal.AllocHGlobal(Marshal.SizeOf(module_interface)); + + /* 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); + + /* Finally, marshal the moduleinterface class and return */ + Marshal.StructureToPtr(module_interface, module, true); + + return Status.Success; + } + + /// + /// AddApiInterface + /// + /// + public void AddApiInterface(Api apiInterface) + { + /* Create a new ApiInterface type and allocate unmanaged mem */ + ApiInterfaceMarshal apiInterfaceMarshal = new ApiInterfaceMarshal(); + IntPtr apiInterfacePtr = Marshal.AllocHGlobal(Marshal.SizeOf(apiInterfaceMarshal)); + + /* Allocate umanaged mem to to interface fields so GC doesn't disturb them */ + apiInterfaceMarshal.interface_name = Marshal.StringToHGlobalAnsi(apiInterface.Name); + apiInterfaceMarshal.desc = Marshal.StringToHGlobalAnsi(apiInterface.Description); + apiInterfaceMarshal.function = new ApiFunction(apiInterface.ApiFunction); + + /* Set the handle of the managed object */ + apiInterface.handle = new HandleRef(apiInterfaceMarshal, apiInterfacePtr); + + Marshal.StructureToPtr(apiInterfaceMarshal, apiInterface.handle.Handle, true); + + /* Check to see whether there is already an interface defined, if there is then + * we want to set the *next pointer of the last element before adding the new + * interface to the array + */ + if (apiInterfaces.Count > 0) + { + Api apiInterfaceElement = (Api)apiInterfaces[apiInterfaces.Count - 1]; + ApiInterfaceMarshal apiInterfacePrev = (ApiInterfaceMarshal)apiInterfaceElement.handle.Wrapper; + + apiInterfacePrev.next = apiInterface.handle.Handle; + } + + /* Finally, add our new interface to the array */ + apiInterfaces.Add(apiInterface); + } + + /// + /// AddApplicationInterface + /// + /// + public void AddApplicationInterface(Application applicationInterface) + { + /* Create a new ApplicationInterface type and allocate unmanaged mem */ + ApplicationInterfaceMarshal applicationInterfaceMarshal = new ApplicationInterfaceMarshal(); + IntPtr applicationInterfacePtr = Marshal.AllocHGlobal(Marshal.SizeOf(applicationInterfaceMarshal)); + + /* Allocate umanaged mem to to interface fields so GC doesn't disturb them */ + applicationInterfaceMarshal.interface_name = Marshal.StringToHGlobalAnsi(applicationInterface.Name); + applicationInterfaceMarshal.syntax = Marshal.StringToHGlobalAnsi(applicationInterface.Syntax); + applicationInterfaceMarshal.long_desc = Marshal.StringToHGlobalAnsi(applicationInterface.LongDescription); + applicationInterfaceMarshal.short_desc = Marshal.StringToHGlobalAnsi(applicationInterface.ShortDescription); + + applicationInterfaceMarshal.application_function = new ApplicationFunction(applicationInterface.ApplicationFunction); + + /* Set the handle of the managed object */ + applicationInterface.handle = new HandleRef(applicationInterfaceMarshal, applicationInterfacePtr); + + Marshal.StructureToPtr(applicationInterfaceMarshal, applicationInterface.handle.Handle, true); + + /* Check to see whether there is already an interface defined, if there is then + * we want to set the *next pointer of the last element before adding the new + * interface to the array + */ + if (applicationInterfaces.Count > 0) + { + Application applicationInterfaceElement = (Application)applicationInterfaces[applicationInterfaces.Count - 1]; + ApplicationInterfaceMarshal applicationInterfacePrev = (ApplicationInterfaceMarshal)applicationInterfaceElement.handle.Wrapper; + + applicationInterfacePrev.next = applicationInterface.handle.Handle; + } + + /* Finally, add our new interface to the array */ + applicationInterfaces.Add(applicationInterface); + } + + /// + /// Register + /// + public void Register() + { + module.module_load = new ModuleLoad(Load); + + Switch.switch_loadable_module_build_dynamic(filename, + module.module_load, + module.module_runtime, + module.module_shutdown); + } + + + } +} diff --git a/src/dotnet/dotnet/Modules/Api.cs b/src/dotnet/dotnet/Modules/Api.cs new file mode 100755 index 0000000000..36aea931b6 --- /dev/null +++ b/src/dotnet/dotnet/Modules/Api.cs @@ -0,0 +1,65 @@ +/* + * 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 + * + * + * Api.cs -- + * + */ +using System; +using System.Collections; +using System.Text; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; + +namespace FreeSwitch.NET.Modules +{ + public class Api + { + private string name; + private string description; + private ApiFunction apiFunction; + public HandleRef handle; + + public string Name + { + set { name = value; } + get { return name; } + } + + public string Description + { + set { description = value; } + get { return description; } + } + + public ApiFunction ApiFunction + { + set { apiFunction = value; } + get { return apiFunction; } + } + } +} \ No newline at end of file diff --git a/src/dotnet/dotnet/Modules/Application.cs b/src/dotnet/dotnet/Modules/Application.cs new file mode 100755 index 0000000000..045e10c8ed --- /dev/null +++ b/src/dotnet/dotnet/Modules/Application.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 + * + * + * Application.cs -- + * + */ +using System; +using System.Collections; +using System.Text; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Marshaling; +using FreeSwitch.NET.Types; +using FreeSwitch.NET.Marshaling.Types; + +namespace FreeSwitch.NET.Modules +{ + public class Application + { + private string name; + private string longDescription; + private string shortDescription; + private string syntax; + private ApplicationFunction applicationFunction; + public HandleRef handle; + + public string Name + { + set { name = value; } + get { return name; } + } + + public string ShortDescription + { + set { shortDescription = value; } + get { return shortDescription; } + } + + public string LongDescription + { + set { longDescription = value; } + get { return longDescription; } + } + + public string Syntax + { + set { syntax = value; } + get { return syntax; } + } + + public ApplicationFunction ApplicationFunction + { + set { applicationFunction = value; } + get { return applicationFunction; } + } + } +} \ No newline at end of file diff --git a/src/dotnet/dotnet/Properties/AssemblyInfo.cs b/src/dotnet/dotnet/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..895c50f78e --- /dev/null +++ b/src/dotnet/dotnet/Properties/AssemblyInfo.cs @@ -0,0 +1,5 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("Freeswitch API")] +[assembly: AssemblyDescription("mod_mono allows you to load .NET assemblies that can interact with Freeswitch's module system.")] \ No newline at end of file diff --git a/src/dotnet/dotnet/Switch/CallerProfile.cs b/src/dotnet/dotnet/Switch/CallerProfile.cs new file mode 100755 index 0000000000..6003d34ed2 --- /dev/null +++ b/src/dotnet/dotnet/Switch/CallerProfile.cs @@ -0,0 +1,92 @@ +/* + * 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 + * + * + * CallerProfile.cs -- + * + */ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; +using FreeSwitch.NET.Marshaling; +using FreeSwitch.NET.Marshaling.Types; + +namespace FreeSwitch.NET +{ + public partial class Switch + { + /* + * TODO: Figure out how to stop mono from trying to free the returned string. + */ + [DllImport("freeswitch")] + //[return: MarshalAs(UnmanagedType.LPStr)] + public extern static + IntPtr switch_caller_get_field_by_name( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))] + CallerProfile caller_profile, + [MarshalAs(UnmanagedType.LPStr)] + string name); + /* + [DllImport("freeswitch")] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))] + public extern static + CallerProfile switch_caller_profile_clone( + [MarshalAs + switch_core_session_t *session, switch_caller_profile_t *tocopy) + */ + + [DllImport("freeswitch")] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))] + public extern static + CallerProfile switch_caller_profile_new( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(MemoryPoolMarshaler))] + MemoryPool pool, + [MarshalAs(UnmanagedType.LPStr)] + string username, + [MarshalAs(UnmanagedType.LPStr)] + string dialplan, + [MarshalAs(UnmanagedType.LPStr)] + string callerIdName, + [MarshalAs(UnmanagedType.LPStr)] + string callerIdNumber, + [MarshalAs(UnmanagedType.LPStr)] + string networkAddress, + [MarshalAs(UnmanagedType.LPStr)] + string ani, + [MarshalAs(UnmanagedType.LPStr)] + string ani2, + [MarshalAs(UnmanagedType.LPStr)] + string rdnis, + [MarshalAs(UnmanagedType.LPStr)] + string source, + [MarshalAs(UnmanagedType.LPStr)] + string context, + [MarshalAs(UnmanagedType.LPStr)] + string destinationNumber); + } +} diff --git a/src/dotnet/dotnet/Switch/Channel.cs b/src/dotnet/dotnet/Switch/Channel.cs new file mode 100755 index 0000000000..7b695c89e1 --- /dev/null +++ b/src/dotnet/dotnet/Switch/Channel.cs @@ -0,0 +1,114 @@ +/* + * 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.NET.Types; +using FreeSwitch.NET.Marshaling; + +namespace FreeSwitch.NET +{ + public partial class Switch + { + [DllImport("freeswitch")] + public extern static + ChannelState switch_channel_set_state( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))] + Channel channel, + ChannelState channelState); + + [DllImport("freeswitch")] + public extern static + ChannelState switch_channel_get_state( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))] + Channel channel); + + [DllImport("freeswitch")] + public extern static + Status switch_channel_answer( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))] + Channel channel); + + [DllImport("freeswitch")] + public extern static + ChannelState switch_channel_perform_hangup( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))] + Channel channel, + [MarshalAs(UnmanagedType.LPStr)] + string file, + [MarshalAs(UnmanagedType.LPStr)] + string func, + int line, + CallCause hangup_cause); + + [DllImport("freeswitch")] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerExtensionMarshaler))] + public extern static + CallerExtension switch_channel_get_caller_extension( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))] + Channel channel); + + [DllImport("freeswitch")] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CallerProfileMarshaler))] + public extern static + CallerProfile switch_channel_get_caller_profile( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(ChannelMarshaler))] + Channel channel); + + [DllImport("freeswitch")] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))] + public extern static + CallerProfile switch_channel_get_originator_caller_profile( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))] + Channel channel); + + [DllImport("freeswitch")] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CallerProfileMarshaler))] + public extern static + CallerProfile switch_channel_get_originatee_caller_profile( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(ChannelMarshaler))] + Channel channel); + + [DllImport("freeswitch")] + public extern static + ChannelState switch_channel_hangup( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))] + Channel channel, + CallCause hangup_cause); + + [DllImport("freeswitch")] + public extern static + uint switch_channel_ready( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))] + Channel channel); + } +} diff --git a/src/dotnet/dotnet/Switch/Console.cs b/src/dotnet/dotnet/Switch/Console.cs new file mode 100644 index 0000000000..58d40fbc15 --- /dev/null +++ b/src/dotnet/dotnet/Switch/Console.cs @@ -0,0 +1,42 @@ +/* + * 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 + * + * + * Console.cs -- + * + */ +using System; +using System.Runtime.CompilerServices; +using System.Diagnostics; +using System.Text; + +namespace FreeSwitch.NET +{ + public partial class Switch + { + } +} diff --git a/src/dotnet/dotnet/Switch/CoreSession.cs b/src/dotnet/dotnet/Switch/CoreSession.cs new file mode 100755 index 0000000000..6130cafc47 --- /dev/null +++ b/src/dotnet/dotnet/Switch/CoreSession.cs @@ -0,0 +1,70 @@ +/* + * 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 + * + * + * CoreSession.cs -- + * + */ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; +using FreeSwitch.NET.Marshaling; + +namespace FreeSwitch.NET +{ + public partial class Switch + { + [DllImport("freeswitch")] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))] + public extern static + Channel switch_core_session_get_channel( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] + CoreSession session); + + [DllImport("freeswitch")] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(MemoryPoolMarshaler))] + public extern static + MemoryPool switch_core_session_get_pool( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] + CoreSession session); + + [DllImport("freeswitch")] + public extern static + Status switch_core_session_outgoing_channel( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] + CoreSession session, + [MarshalAs(UnmanagedType.LPStr)] + string endpointName, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))] + CallerProfile caller_profile, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] + ref CoreSession new_session, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(MemoryPoolMarshaler))] + MemoryPool pool); + } +} \ No newline at end of file diff --git a/src/dotnet/dotnet/Switch/Ivr.cs b/src/dotnet/dotnet/Switch/Ivr.cs new file mode 100755 index 0000000000..33219b5871 --- /dev/null +++ b/src/dotnet/dotnet/Switch/Ivr.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 + * + * + * Ivr.cs -- + * + */ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; +using FreeSwitch.NET.Marshaling; +using FreeSwitch.NET.Marshaling.Types; + +namespace FreeSwitch.NET +{ + public partial class Switch + { + [DllImport("freeswitch")] + extern public static + Status switch_ivr_play_file( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoreSessionMarshaler))] + CoreSession session, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FileHandleMarshaler))] + FileHandle fh, + [MarshalAs(UnmanagedType.LPStr)] + string file, + [MarshalAs(UnmanagedType.LPStr)] + string timer_name, + InputCallbackFunction input_callback, + 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( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))] + CoreSession session, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileHandleMarshaler))] + FileHandle fh, + IntPtr file, + InputCallbackFunction input_callback, + IntPtr buf, + uint buflen); + } +} diff --git a/src/dotnet/dotnet/Switch/LoadableModule.cs b/src/dotnet/dotnet/Switch/LoadableModule.cs new file mode 100755 index 0000000000..60bcbda57d --- /dev/null +++ b/src/dotnet/dotnet/Switch/LoadableModule.cs @@ -0,0 +1,71 @@ +/* + * 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 + * + * + * LoadableModule.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; +using FreeSwitch.NET.Marshaling.Types; + +namespace FreeSwitch.NET +{ + /* + * SWITCH_DECLARE(switch_status_t) switch_loadable_module_load_module(char *dir, char *fname) + * SWITCH_DECLARE(switch_status_t) switch_loadable_module_build_dynamic(char *filename, + * SWITCH_DECLARE(switch_status_t) switch_loadable_module_init() + * SWITCH_DECLARE(void) switch_loadable_module_shutdown(void) + * SWITCH_DECLARE(switch_endpoint_interface_t *) switch_loadable_module_get_endpoint_interface(char *name) + * SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_interface(char *name) + * SWITCH_DECLARE(switch_dialplan_interface_t *) switch_loadable_module_get_dialplan_interface(char *name) + * SWITCH_DECLARE(switch_timer_interface_t *) switch_loadable_module_get_timer_interface(char *name) + * SWITCH_DECLARE(switch_application_interface_t *) switch_loadable_module_get_application_interface(char *name) + * SWITCH_DECLARE(switch_api_interface_t *) switch_loadable_module_get_api_interface(char *name) + * SWITCH_DECLARE(switch_file_interface_t *) switch_loadable_module_get_file_interface(char *name) + * SWITCH_DECLARE(switch_speech_interface_t *) switch_loadable_module_get_speech_interface(char *name) + * SWITCH_DECLARE(switch_directory_interface_t *) switch_loadable_module_get_directory_interface(char *name) + * SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool_t *pool, switch_codec_interface_t **array, + * SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(switch_codec_interface_t **array, + * SWITCH_DECLARE(switch_status_t) switch_api_execute(char *cmd, char *arg, char *retbuf, switch_size_t len) + */ + public partial class Switch + { + [DllImport("__Internal")] + public static extern + Status + switch_loadable_module_build_dynamic( + string filename, + [MarshalAs(UnmanagedType.FunctionPtr)] + ModuleLoad switch_module_load, + [MarshalAs(UnmanagedType.FunctionPtr)] + ModuleRuntime switch_module_runtime, + [MarshalAs(UnmanagedType.FunctionPtr)] + ModuleShutdown switch_module_shutdown); + } +} diff --git a/src/dotnet/dotnet/Switch/StreamHandle.cs b/src/dotnet/dotnet/Switch/StreamHandle.cs new file mode 100755 index 0000000000..fa1315a245 --- /dev/null +++ b/src/dotnet/dotnet/Switch/StreamHandle.cs @@ -0,0 +1,61 @@ +/* + * 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 + * + * + * LoadableModule.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Types; +using FreeSwitch.NET.Marshaling.Types; + +namespace FreeSwitch.NET +{ + /* + * SWITCH_DECLARE(switch_status_t) switch_loadable_module_load_module(char *dir, char *fname) + * SWITCH_DECLARE(switch_status_t) switch_loadable_module_build_dynamic(char *filename, + * SWITCH_DECLARE(switch_status_t) switch_loadable_module_init() + * SWITCH_DECLARE(void) switch_loadable_module_shutdown(void) + * SWITCH_DECLARE(switch_endpoint_interface_t *) switch_loadable_module_get_endpoint_interface(char *name) + * SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_interface(char *name) + * SWITCH_DECLARE(switch_dialplan_interface_t *) switch_loadable_module_get_dialplan_interface(char *name) + * SWITCH_DECLARE(switch_timer_interface_t *) switch_loadable_module_get_timer_interface(char *name) + * SWITCH_DECLARE(switch_application_interface_t *) switch_loadable_module_get_application_interface(char *name) + * SWITCH_DECLARE(switch_api_interface_t *) switch_loadable_module_get_api_interface(char *name) + * SWITCH_DECLARE(switch_file_interface_t *) switch_loadable_module_get_file_interface(char *name) + * SWITCH_DECLARE(switch_speech_interface_t *) switch_loadable_module_get_speech_interface(char *name) + * SWITCH_DECLARE(switch_directory_interface_t *) switch_loadable_module_get_directory_interface(char *name) + * SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool_t *pool, switch_codec_interface_t **array, + * SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(switch_codec_interface_t **array, + * SWITCH_DECLARE(switch_status_t) switch_api_execute(char *cmd, char *arg, char *retbuf, switch_size_t len) + */ + public partial class Switch + { + + } +} diff --git a/src/dotnet/dotnet/Types/ApiFunction.cs b/src/dotnet/dotnet/Types/ApiFunction.cs new file mode 100755 index 0000000000..e91251889d --- /dev/null +++ b/src/dotnet/dotnet/Types/ApiFunction.cs @@ -0,0 +1,31 @@ +/* + * 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 + * + * + * ApiFunction.cs -- + * + */ \ No newline at end of file diff --git a/src/dotnet/dotnet/Types/ApplicationFunction.cs b/src/dotnet/dotnet/Types/ApplicationFunction.cs new file mode 100755 index 0000000000..c3f7fd5b67 --- /dev/null +++ b/src/dotnet/dotnet/Types/ApplicationFunction.cs @@ -0,0 +1,37 @@ +/* + * 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 + * + * + * ApplicationFunction.cs -- + * + */ +using System; + +namespace FreeSwitch.NET.Types +{ + +} diff --git a/src/dotnet/dotnet/Types/ApplicationInterface.cs b/src/dotnet/dotnet/Types/ApplicationInterface.cs new file mode 100755 index 0000000000..91a49a6f4b --- /dev/null +++ b/src/dotnet/dotnet/Types/ApplicationInterface.cs @@ -0,0 +1,50 @@ +/* + * 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 + * + * + * ApplicationInterface.cs -- + * + */ +using System; +using System.Collections; +using System.Runtime.InteropServices; +using System.Text; + +namespace FreeSwitch.NET.Types +{ + /* + public class ApplicationInterface + { + private string interface_name; + private IntPtr application_function; + private string long_desc; + private string short_desc; + private string syntax; + //const struct switch_application_interface *next; + } + * */ +} diff --git a/src/dotnet/dotnet/Types/Buffer.cs b/src/dotnet/dotnet/Types/Buffer.cs new file mode 100755 index 0000000000..cd7a755531 --- /dev/null +++ b/src/dotnet/dotnet/Types/Buffer.cs @@ -0,0 +1,56 @@ +/* + * 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 + * + * + * Buffer.cs -- + * + */ +using System; +using System.Runtime.InteropServices; + +namespace FreeSwitch.NET.Types +{ + public class Buffer + { + internal HandleRef marshaledObject; + + public string Data + { + get { throw new NotImplementedException(); } + } + + public int Used + { + get { throw new NotImplementedException(); } + } + + public int Length + { + get { throw new NotImplementedException(); } + } + } +} diff --git a/src/dotnet/dotnet/Types/CallCause.cs b/src/dotnet/dotnet/Types/CallCause.cs new file mode 100755 index 0000000000..274b92a0c1 --- /dev/null +++ b/src/dotnet/dotnet/Types/CallCause.cs @@ -0,0 +1,83 @@ +/* + * 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 + * + * + * CallCause.cs -- + * + */ +using System; + +namespace FreeSwitch.NET.Types +{ + public enum CallCause + { + Unallocated, + NoRouteTransitNet, + NoRouteDestination, + ChannelUnacceptable, + CallAwardedDelivered, + NormalClearing, + UserBusy, + NoUserResponse, + NoAnswer, + CallRejected, + NumberChanged, + DestinationOutOfOrder, + InvalidNumberFormat, + FacilityRejected, + ResponseToStatusEnquiry, + NormalUnspecified, + NormalCircuitCongestion, + NetworkOutOfOrder, + NormalTemporaryFailure, + SwitchCongestion, + AccessInfoDescarded, + RequestedChannelUnavailable, + PreEmpted, + FacilityNotSubscribed, + OutgoingCallBarred, + IncomingCallBarred, + BearerCapabilityNotAuth, + BearerCapabilityNotAvail, + BearerCapabilityNotImpl, + ChanNotImplemented, + FacilityNotImplemented, + InvalidCallReference, + IncompatibleDestination, + InvalidMsgUnspecified, + MandatoryIeMissing, + MessageTypeNonExistant, + WrongMessage, + IoNonExistant, + InvalidIeContents, + WrongCallState, + RecoveryOnTimeExpire, + MandatoryIeLengthError, + ProtocolError, + Internetworking + } +} diff --git a/src/dotnet/dotnet/Types/CallerExtension.cs b/src/dotnet/dotnet/Types/CallerExtension.cs new file mode 100755 index 0000000000..79f07c8cb8 --- /dev/null +++ b/src/dotnet/dotnet/Types/CallerExtension.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 + * + * + * CallerExtension.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Marshaling.Types; + +namespace FreeSwitch.NET.Types +{ + public class CallerExtension + { + internal HandleRef marshaledObject; + + public string ExtensionName + { + get + { + CallerExtensionMarshal callerExtension = (CallerExtensionMarshal)marshaledObject.Wrapper; + + return Marshal.PtrToStringAnsi(callerExtension.extension_name); + } + } + + public string ExtensionNumber + { + get + { + CallerExtensionMarshal callerExtension = (CallerExtensionMarshal)marshaledObject.Wrapper; + + return Marshal.PtrToStringAnsi(callerExtension.extension_number); + } + } + } +} diff --git a/src/dotnet/dotnet/Types/CallerProfile.cs b/src/dotnet/dotnet/Types/CallerProfile.cs new file mode 100755 index 0000000000..bd114fccc0 --- /dev/null +++ b/src/dotnet/dotnet/Types/CallerProfile.cs @@ -0,0 +1,139 @@ +/* + * 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 + * + * + * CallerProfile.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Marshaling.Types; + +namespace FreeSwitch.NET.Types +{ + public class CallerProfile + { + internal HandleRef marshaledObject; + + public static CallerProfile New(MemoryPool pool, + string username, + string dialplan, + string callerIdName, + string callerIdNumber, + string networkAddress, + string ani, + string ani2, + string rdnis, + string source, + string context, + string destinationNumber) + { + return Switch.switch_caller_profile_new(pool, username, dialplan, callerIdName, callerIdNumber, networkAddress, ani, ani2, rdnis, source, context, destinationNumber); + } + + public string GetFieldByName(string field) + { + IntPtr ptr; + + ptr = Switch.switch_caller_get_field_by_name(this, field); + + if (ptr != IntPtr.Zero) + return Marshal.PtrToStringAnsi(ptr); + else + return ""; + } + + + /* + * Properties + */ + public string Dialplan + { + get { return GetFieldByName("dialplan"); } + } + + public string CallerIdName + { + get { return GetFieldByName("caller_id_name"); } + } + + public string CallerIdNumber + { + get { return GetFieldByName("caller_id_number"); } + } + + public string NetworkAddress + { + get { return GetFieldByName("network_addr"); } + } + + public string Ani + { + get { return GetFieldByName("ani"); } + } + + public string Ani2 + { + get { return GetFieldByName("ani2"); } + } + + public string Rdnis + { + get { return GetFieldByName("rdnis"); } + } + + public string Source + { + get { return GetFieldByName("source"); } + } + + public string Context + { + get { return GetFieldByName("context"); } + } + + public string DestinationNumber + { + get { return GetFieldByName("destination_number"); } + } + + public string ChannelName + { + get { return GetFieldByName("chan_name"); } + } + + public string Uuid + { + get{ return GetFieldByName("uuid"); } + } + + public string Username + { + get { return GetFieldByName("username"); } + } + } +} diff --git a/src/dotnet/dotnet/Types/Channel.cs b/src/dotnet/dotnet/Types/Channel.cs new file mode 100755 index 0000000000..4f6baaebf3 --- /dev/null +++ b/src/dotnet/dotnet/Types/Channel.cs @@ -0,0 +1,223 @@ +/* + * 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.InteropServices; +using FreeSwitch.NET.Marshaling.Types; + +namespace FreeSwitch.NET.Types +{ + /* + * char *name; + switch_buffer_t *dtmf_buffer; + switch_mutex_t *dtmf_mutex; + switch_mutex_t *flag_mutex; + switch_mutex_t *profile_mutex; + switch_core_session_t *session; + switch_channel_state_t state; + uint32_t flags; + switch_caller_profile_t *caller_profile; + switch_caller_profile_t *originator_caller_profile; + switch_caller_profile_t *originatee_caller_profile; + switch_caller_extension_t *caller_extension; + const switch_state_handler_table_t *state_handlers[SWITCH_MAX_STATE_HANDLERS]; + int state_handler_index; + switch_hash_t *variables; + switch_channel_timetable_t *times; + void *private_info; + switch_call_cause_t hangup_cause; + int freq; + int bits; + int channels; + int ms; + int kbps; + */ + public class Channel + { + internal HandleRef marshaledObject; + + public string Name + { + get + { + ChannelMarshal channel = (ChannelMarshal) marshaledObject.Wrapper; + + return Marshal.PtrToStringAnsi(channel.name); + } + } + + public Buffer DtmfBuffer + { + get + { + Console.WriteLine("Buffer"); + return new Buffer(); + //throw new NotImplementedException(); + } + } + + public ChannelState State + { + set + { + Switch.switch_channel_set_state(this, value); + } + get + { + return Switch.switch_channel_get_state(this); + } + } + + public bool IsReady + { + get + { + uint isReady = Switch.switch_channel_ready(this); + + if (isReady != 0) + return true; + else + return false; + } + } + + public ChannelFlag Flags + { + get + { + Console.WriteLine("ChannelFlag"); + return new ChannelFlag(); + //throw new NotImplementedException(); + } + } + + public CallerProfile CallerProfile + { + get + { + return Switch.switch_channel_get_caller_profile(this); + } + } + + public CallerProfile OriginatorCallerProfile + { + get + { + return Switch.switch_channel_get_originator_caller_profile(this); + } + } + + public CallerProfile OriginateeCallerProfile + { + get + { + return Switch.switch_channel_get_originatee_caller_profile(this); + } + } + + public CallerExtension CallerExtension + { + get + { + return Switch.switch_channel_get_caller_extension(this); + } + } + + public ChannelTimetable Times + { + get + { + Console.WriteLine("Channel Timetable"); + return new ChannelTimetable(); + // throw new NotImplementedException(); + } + } + + public int Freq + { + get + { + ChannelMarshal channel = (ChannelMarshal) marshaledObject.Wrapper; + + return channel.freq; + } + } + + public int Bits + { + get + { + ChannelMarshal channel = (ChannelMarshal) marshaledObject.Wrapper; + + return channel.bits; + } + } + + public int Channels + { + get + { + ChannelMarshal channel = (ChannelMarshal) marshaledObject.Wrapper; + + return channel.channels; + } + } + + public int Ms + { + get + { + ChannelMarshal channel = (ChannelMarshal) marshaledObject.Wrapper; + + return channel.ms; + } + } + + public int Kbps + { + get { + ChannelMarshal channel = (ChannelMarshal) marshaledObject.Wrapper; + + return channel.kbps; + } + } + + public void PerformHangup() + { + Switch.switch_channel_perform_hangup(this, "file", "func", 100, CallCause.OutgoingCallBarred); + } + + public Status Answer() + { + return Switch.switch_channel_answer(this); + } + } +} diff --git a/src/dotnet/dotnet/Types/ChannelFlag.cs b/src/dotnet/dotnet/Types/ChannelFlag.cs new file mode 100755 index 0000000000..78c9e64328 --- /dev/null +++ b/src/dotnet/dotnet/Types/ChannelFlag.cs @@ -0,0 +1,46 @@ +/* + * 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 + * + * + * ChannelFlag.cs -- + * + */ +using System; + +namespace FreeSwitch.NET.Types +{ + public enum ChannelFlag + { + CF_SEND_AUDIO, + CF_RECV_AUDIO, + CF_ANSWERED, + CF_OUTBOUND, + CF_EARLY_MEDIA, + CF_ORIGINATOR, + CF_TRANSFER + } +} diff --git a/src/dotnet/dotnet/Types/ChannelState.cs b/src/dotnet/dotnet/Types/ChannelState.cs new file mode 100755 index 0000000000..52e688707e --- /dev/null +++ b/src/dotnet/dotnet/Types/ChannelState.cs @@ -0,0 +1,47 @@ +/* + * 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 + * + * + * ChannelState.cs -- + * + */ +using System; + +namespace FreeSwitch.NET.Types +{ + public enum ChannelState + { + CS_NEW, + CS_INIT, + CS_RING, + CS_TRANSMIT, + CS_EXECUTE, + CS_LOOPBACK, + CS_HANGUP, + CS_DONE + } +} diff --git a/src/dotnet/dotnet/Types/ChannelTimetable.cs b/src/dotnet/dotnet/Types/ChannelTimetable.cs new file mode 100755 index 0000000000..1e3cdcb0c7 --- /dev/null +++ b/src/dotnet/dotnet/Types/ChannelTimetable.cs @@ -0,0 +1,56 @@ +/* + * 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 + * + * + * ChannelTimetable.cs -- + * + */ +using System; +using System.Runtime.InteropServices; + +namespace FreeSwitch.NET.Types +{ + public class ChannelTimetable + { + internal HandleRef marshaledObject; + + public Int64 Created + { + get { throw new NotImplementedException(); } + } + + public Int64 Answered + { + get { throw new NotImplementedException(); } + } + + public Int64 Hungup + { + get { throw new NotImplementedException(); } + } + } +} diff --git a/src/dotnet/dotnet/Types/CoreSession.cs b/src/dotnet/dotnet/Types/CoreSession.cs new file mode 100755 index 0000000000..6c9165fe32 --- /dev/null +++ b/src/dotnet/dotnet/Types/CoreSession.cs @@ -0,0 +1,175 @@ +/* + * 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 + * + * + * CoreSession.cs -- + * + */ +using System; +using System.Collections; +using System.Runtime.InteropServices; +using System.Text; +using FreeSwitch.NET.Marshaling.Types; + +namespace FreeSwitch.NET.Types +{ + /* + * uint32_t id; + char name[80]; + int thread_running; + switch_memory_pool_t *pool; + switch_channel_t *channel; + switch_thread_t *thread; + const switch_endpoint_interface_t *endpoint_interface; + switch_io_event_hooks_t event_hooks; + switch_codec_t *read_codec; + switch_codec_t *write_codec; + + switch_buffer_t *raw_write_buffer; + switch_frame_t raw_write_frame; + switch_frame_t enc_write_frame; + uint8_t raw_write_buf[SWITCH_RECCOMMENDED_BUFFER_SIZE]; + uint8_t enc_write_buf[SWITCH_RECCOMMENDED_BUFFER_SIZE]; + + switch_buffer_t *raw_read_buffer; + switch_frame_t raw_read_frame; + switch_frame_t enc_read_frame; + uint8_t raw_read_buf[SWITCH_RECCOMMENDED_BUFFER_SIZE]; + uint8_t enc_read_buf[SWITCH_RECCOMMENDED_BUFFER_SIZE]; + + + switch_audio_resampler_t *read_resampler; + switch_audio_resampler_t *write_resampler; + + switch_mutex_t *mutex; + switch_thread_cond_t *cond; + + switch_thread_rwlock_t *rwlock; + + void *streams[SWITCH_MAX_STREAMS]; + int stream_count; + + char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1]; + void *private_info; + switch_queue_t *event_queue; + */ + public class CoreSession + { + public HandleRef marshaledObject; + + /* + * Properties + */ + public UInt32 Id + { + get + { + CoreSessionMarshal coreSessionMarshal = (CoreSessionMarshal)marshaledObject.Wrapper; + + return coreSessionMarshal.id; + } + } + + public string Name + { + get + { + CoreSessionMarshal coreSessionMarshal = (CoreSessionMarshal) marshaledObject.Wrapper; + + return Encoding.ASCII.GetString(coreSessionMarshal.name); + } + } + + public bool IsThreadRunning + { + get + { + CoreSessionMarshal coreSessionMarshal = (CoreSessionMarshal)marshaledObject.Wrapper; + + if (coreSessionMarshal.thread_running <= 0) + return false; + else + return true; + } + } + + public MemoryPool Pool + { + get + { + return Switch.switch_core_session_get_pool(this); + } + } + + + public Channel Channel + { + get + { + return Switch.switch_core_session_get_channel(this); + } + } + + public string Uuid + { + get + { + CoreSessionMarshal coreSessionMarshal = (CoreSessionMarshal)marshaledObject.Wrapper; + + return Encoding.ASCII.GetString(coreSessionMarshal.uuid_str); + } + } + + + public CoreSession OutgoingChannel(string endpointName, CallerProfile callerProfile) + { + CoreSession newSession = new CoreSession(); + MemoryPool pool = new MemoryPool(); + + Status status = Switch.switch_core_session_outgoing_channel(this, endpointName, callerProfile, ref newSession, pool); + + if (status != Status.Success) + throw new Exception("Unsuccessful"); + + + return newSession; + } + + public CoreSession() + { + //CoreSessionMarshal coreSessionMarshal = new CoreSessionMarshal(); + //IntPtr coreSessionPtr = Marshal.AllocHGlobal(Marshal.SizeOf(coreSessionMarshal)); + + //marshaledObject = new HandleRef(coreSessionMarshal, coreSessionPtr); + } + + public Status DtmfCallbackFunctionWrapper(CoreSession session, string dtmf, IntPtr buf, uint buflen) + { + return Status.Success; + } + } +} \ No newline at end of file diff --git a/src/dotnet/dotnet/Types/DtmfCallbackFunction.cs b/src/dotnet/dotnet/Types/DtmfCallbackFunction.cs new file mode 100755 index 0000000000..53c41eb3df --- /dev/null +++ b/src/dotnet/dotnet/Types/DtmfCallbackFunction.cs @@ -0,0 +1,37 @@ +/* + * 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 + * + * + * DtmfCallbackFunction.cs -- + * + */ +using System; + +namespace FreeSwitch.NET.Types +{ + public delegate Status DtmfCallbackFunction(CoreSession session, string dtmf); +} diff --git a/src/dotnet/dotnet/Types/Event.cs b/src/dotnet/dotnet/Types/Event.cs new file mode 100755 index 0000000000..de064fbb49 --- /dev/null +++ b/src/dotnet/dotnet/Types/Event.cs @@ -0,0 +1,120 @@ +/* + * 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 + * + * + * Event.cs -- + * + */ +using System; +using System.Collections; +using System.Text; +using System.Runtime.InteropServices; + +namespace FreeSwitch.NET.Types +{ + public enum Priority + { + SWITCH_PRIORITY_NORMAL, + SWITCH_PRIORITY_LOW, + SWITCH_PRIORITY_HIGH + } + + public class Event + { + internal HandleRef marshaledObject; + + public EventType EventId + { + get { throw new NotImplementedException(); } + } + + public Priority Priority + { + get { throw new NotImplementedException(); } + } + + public string Owner + { + get { throw new NotImplementedException(); } + } + + public IntPtr Subclass + { + get { throw new NotImplementedException(); } + } + + public ArrayList Headers + { + get { throw new NotImplementedException(); } + } + + public string Body + { + get { throw new NotImplementedException(); } + } + + public IntPtr BindUserData + { + get { throw new NotImplementedException(); } + } + + public IntPtr EventUserData + { + get { throw new NotImplementedException(); } + } + } + + [StructLayout(LayoutKind.Sequential)] + public class EventSubclass + { + private string owner; + private string name; + } + + [StructLayout(LayoutKind.Sequential)] + public class EventHeader + { + 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/dotnet/Types/FileHandle.cs b/src/dotnet/dotnet/Types/FileHandle.cs new file mode 100755 index 0000000000..707e496aad --- /dev/null +++ b/src/dotnet/dotnet/Types/FileHandle.cs @@ -0,0 +1,42 @@ +/* + * 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 + * + * + * FileHandle.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Marshaling.Types; + +namespace FreeSwitch.NET.Types +{ + public class FileHandle + { + internal HandleRef marshaledObject; + } +} diff --git a/src/dotnet/dotnet/Types/InputCallbackFunction.cs b/src/dotnet/dotnet/Types/InputCallbackFunction.cs new file mode 100755 index 0000000000..e233eef07c --- /dev/null +++ b/src/dotnet/dotnet/Types/InputCallbackFunction.cs @@ -0,0 +1,47 @@ +/* + * 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 + * + * + * DtmfCallbackFunction.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Marshaling; + +namespace FreeSwitch.NET.Types +{ + public delegate Status InputCallbackFunction( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StreamHandleMarshaler))] + CoreSession session, + [MarshalAs(UnmanagedType.LPStr)] + string input, + InputType inputType, + [MarshalAs(UnmanagedType.LPStr)] + string buffer, + int bufferLength); +} diff --git a/src/dotnet/dotnet/Types/InputType.cs b/src/dotnet/dotnet/Types/InputType.cs new file mode 100755 index 0000000000..170aaabd00 --- /dev/null +++ b/src/dotnet/dotnet/Types/InputType.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 + * + * + * ChannelState.cs -- + * + */ +using System; + +namespace FreeSwitch.NET.Types +{ + public enum InputType + { + INPUT_TYPE_DTMF, + INPUT_TYPE_EVENT + } +} diff --git a/src/dotnet/dotnet/Types/LoadableModule.cs b/src/dotnet/dotnet/Types/LoadableModule.cs new file mode 100755 index 0000000000..72535777e3 --- /dev/null +++ b/src/dotnet/dotnet/Types/LoadableModule.cs @@ -0,0 +1,146 @@ +/* + * 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.InteropServices; + +namespace FreeSwitch.NET.Types +{ + public class LoadableModule + { + internal IntPtr address; + + private string name; + private Buffer dtmfBuffer; + internal IntPtr dtmf_mutex; + internal IntPtr session; + private ChannelState state; + private ChannelFlag flags; + private CallerProfile callerProfile; + private CallerProfile originatorCallerProfile; + private CallerProfile originateeCallerProfile; + private CallerExtension callerExtension; + internal byte[] state_handlers; + internal int state_handler_index; + internal IntPtr variables; + private ChannelTimetable times; + internal IntPtr privateInfo; + private int freq; + private int bits; + private int channels; + private int ms; + private int kbps; + + public string Name + { + set { name = value; } + get { return name; } + } + + public Buffer DtmfBuffer + { + set { dtmfBuffer = value; } + get { return dtmfBuffer; } + } + + public ChannelState State + { + set { state = value; } + get { return state; } + } + + public ChannelFlag Flags + { + set { flags = value; } + get { return flags; } + } + + public CallerProfile CallerProfile + { + set { callerProfile = value; } + get { return callerProfile; } + } + + public CallerProfile OriginatorCallerProfile + { + set { originatorCallerProfile = value; } + get { return originatorCallerProfile; } + } + + public CallerProfile OriginateeCallerProfile + { + set { originateeCallerProfile = value; } + get { return originateeCallerProfile; } + } + + public CallerExtension CallerExtension + { + set { callerExtension = value; } + get { return callerExtension; } + } + + public ChannelTimetable Times + { + set { times = value; } + get { return times; } + } + + public int Freq + { + set { freq = value; } + get { return freq; } + } + + public int Bits + { + set { bits = value; } + get { return bits; } + } + + public int Channels + { + set { channels = value; } + get { return channels; } + } + + public int Ms + { + set { ms = value; } + get { return ms; } + } + + public int Kbps + { + set { kbps = value; } + get { return kbps; } + } + } +} diff --git a/src/dotnet/dotnet/Types/LoadableModuleInterface.cs b/src/dotnet/dotnet/Types/LoadableModuleInterface.cs new file mode 100755 index 0000000000..f0832f11bf --- /dev/null +++ b/src/dotnet/dotnet/Types/LoadableModuleInterface.cs @@ -0,0 +1,61 @@ +/* + * 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 + * + * + * LoadableModuleInterfaces.cs -- + * + */ +using System; +using System.Collections; +using System.Runtime.InteropServices; +using System.Text; +using FreeSwitch.NET.Marshaling; + +namespace FreeSwitch.NET.Types +{ + public delegate Status WriteFunction( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StreamHandleMarshaler))] + StreamHandle streamHandle, + [MarshalAs(UnmanagedType.LPStr)] + string fmt); + + //public delegate void ModuleLoad(); + + public class LoadableModuleInterface + { + private string module_name; + //private EndpointInterface endpoint_interface; + //private TimerInterface timer_interface; + //private DialplanInterface dialplan_interface; + //private CodecInterface codec_interface; + //private ApplicationInterface application_interface; + //private ApiInterface api_interface; + //private FileInterface file_interface; + //private SpeechInterface speech_interface; + //private DirectoryInterface directory_interface; + } +} diff --git a/src/dotnet/dotnet/Types/MemoryPool.cs b/src/dotnet/dotnet/Types/MemoryPool.cs new file mode 100755 index 0000000000..5b0aad3ff8 --- /dev/null +++ b/src/dotnet/dotnet/Types/MemoryPool.cs @@ -0,0 +1,10 @@ +using System; +using System.Runtime.InteropServices; + +namespace FreeSwitch.NET.Types +{ + public class MemoryPool + { + public HandleRef marshaledObject; + } +} diff --git a/src/dotnet/dotnet/Types/Module.cs b/src/dotnet/dotnet/Types/Module.cs new file mode 100755 index 0000000000..1d313c80d9 --- /dev/null +++ b/src/dotnet/dotnet/Types/Module.cs @@ -0,0 +1,59 @@ +/* + * 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 + * + * + * Module.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Marshaling; + +namespace FreeSwitch.NET.Types +{ + public delegate Status ModuleReload(); + public delegate bool ModulePause(); + public delegate bool ModuleResume(); + public delegate bool ModuleStatus(); + public delegate Status ModuleRuntime(); + public delegate bool ModuleShutdown(); + public delegate Status ModuleLoad(ref IntPtr module, string name); + + public delegate void + ApplicationFunction( + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoreSessionMarshaler))] + CoreSession session, + [MarshalAs(UnmanagedType.LPStr)] + string data); + + public delegate Status + ApiFunction( + [MarshalAs(UnmanagedType.LPStr)] + string command, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(StreamHandleMarshaler))] + StreamHandle streamHandle); +} diff --git a/src/dotnet/dotnet/Types/ModuleInterfaces.cs b/src/dotnet/dotnet/Types/ModuleInterfaces.cs new file mode 100755 index 0000000000..5bff3ff0e5 --- /dev/null +++ b/src/dotnet/dotnet/Types/ModuleInterfaces.cs @@ -0,0 +1,69 @@ +/* + * 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 + * + * + * ApplicationInterface.cs -- + * + */ +using System; +using System.Collections; +using System.Runtime.InteropServices; +using System.Text; + +namespace FreeSwitch.NET.Types +{ + /* + public class ApplicationInterface + { + private string interface_name; + private ApplicationFunction application_function; + private string long_desc; + private string short_desc; + private string syntax; + //const struct switch_application_interface *next; + + public string InterfaceName + { + get { return interface_name; } + } + + public ApplicationFunction ApplicationFunction + { + get { return application_function; } + } + + public string LongDesc + { + get { return long_desc; } + } + + public string ShortDesc + { + get { return short_desc; } + } + }*/ +} diff --git a/src/dotnet/dotnet/Types/Status.cs b/src/dotnet/dotnet/Types/Status.cs new file mode 100755 index 0000000000..bc7314b222 --- /dev/null +++ b/src/dotnet/dotnet/Types/Status.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 + * + * + * Status.cs -- + * + */ +using System; + +namespace FreeSwitch.NET.Types +{ + public enum Status + { + Success, + False, + Timeout, + Restart, + Terminate, + NotImplemented, + MemoryError, + NoOp, + Resample, + GeneralError, + InUse, + Break + } +} diff --git a/src/dotnet/dotnet/Types/StreamHandle.cs b/src/dotnet/dotnet/Types/StreamHandle.cs new file mode 100755 index 0000000000..2c7ed33baf --- /dev/null +++ b/src/dotnet/dotnet/Types/StreamHandle.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 + * + * + * StreamHandle.cs -- + * + */ +using System; +using System.Runtime.InteropServices; +using FreeSwitch.NET.Marshaling.Types; + +namespace FreeSwitch.NET.Types +{ + 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)); + + writeFunction(this, data); + } + } +} diff --git a/src/dotnet/dotnet/Types/TextChannel.cs b/src/dotnet/dotnet/Types/TextChannel.cs new file mode 100755 index 0000000000..2e45fc1636 --- /dev/null +++ b/src/dotnet/dotnet/Types/TextChannel.cs @@ -0,0 +1,42 @@ +/* + * 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 + * + * + * TextChannel.cs -- + * + */ +using System; + +namespace FreeSwitch.NET.Types +{ + public enum TextChannel + { + ChannelIdConsole, + ChannelIdConsoleClean, + ChannelIdEvent + } +} diff --git a/src/dotnet/dotnet/public.snk b/src/dotnet/dotnet/public.snk new file mode 100644 index 0000000000..60ac3d5855 Binary files /dev/null and b/src/dotnet/dotnet/public.snk differ